mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 05:32:22 +02:00
wallet: Throw if unknown entry is found in mapValue
We know what entries are expected to be found in mapValue. If we encounter one that is not recognized, then we should throw and refuse to load the wallet in order to avoid losing user data once mapValue is no longer used.
This commit is contained in:
@@ -330,6 +330,8 @@ public:
|
||||
|
||||
m_state = TxStateInterpretSerialized({serialized_block_hash, serializedIndex});
|
||||
|
||||
mapValue.erase("fromaccount");
|
||||
mapValue.erase("spent");
|
||||
for (const auto& [key, value] : mapValue) {
|
||||
if (key == "n") nOrderPos = LocaleIndependentAtoi<int64_t>(value);
|
||||
else if (key == "timesmart") nTimeSmart = LocaleIndependentAtoi<int64_t>(value);
|
||||
@@ -339,10 +341,11 @@ public:
|
||||
else if (key == "to") m_comment_to = value;
|
||||
else if (key == "replaces_txid") m_replaces_txid = Txid::FromHex(value);
|
||||
else if (key == "replaced_by_txid") m_replaced_by_txid = Txid::FromHex(value);
|
||||
else {
|
||||
throw std::runtime_error("Unexpected value in CWalletTx strings value map");
|
||||
}
|
||||
}
|
||||
|
||||
mapValue.erase("fromaccount");
|
||||
mapValue.erase("spent");
|
||||
mapValue.erase("n");
|
||||
mapValue.erase("timesmart");
|
||||
mapValue.erase("from");
|
||||
|
||||
Reference in New Issue
Block a user