From cb99864c91c9def07f75872df533a5bd7a3c649b Mon Sep 17 00:00:00 2001 From: Ava Chow Date: Mon, 27 Apr 2026 13:19:32 -0700 Subject: [PATCH] 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. --- src/wallet/transaction.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/wallet/transaction.h b/src/wallet/transaction.h index 1fb14c4059a..23f990425cd 100644 --- a/src/wallet/transaction.h +++ b/src/wallet/transaction.h @@ -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(value); else if (key == "timesmart") nTimeSmart = LocaleIndependentAtoi(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");