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:
Ava Chow
2026-04-27 13:19:32 -07:00
parent 98d5cdae66
commit cb99864c91

View File

@@ -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");