From c66803370988f9806c0ded24c404edb58f60498f Mon Sep 17 00:00:00 2001 From: Ava Chow Date: Tue, 17 Jun 2025 14:15:19 -0700 Subject: [PATCH 1/2] wallet: Remove unused fTimeReceivedIsTxTime fTimeReceivedIsTxTime has been unused unused since 0.3.24 --- src/wallet/transaction.h | 12 ++++++------ src/wallet/wallet.cpp | 2 -- src/wallet/walletdb.cpp | 23 +---------------------- 3 files changed, 7 insertions(+), 30 deletions(-) diff --git a/src/wallet/transaction.h b/src/wallet/transaction.h index e1ebcbe71e1..1ec62b992b6 100644 --- a/src/wallet/transaction.h +++ b/src/wallet/transaction.h @@ -203,7 +203,6 @@ public: */ mapValue_t mapValue; std::vector > vOrderForm; - unsigned int fTimeReceivedIsTxTime; unsigned int nTimeReceived; //!< time received by this node /** * Stable timestamp that never changes, and reflects the order a transaction @@ -240,7 +239,6 @@ public: { mapValue.clear(); vOrderForm.clear(); - fTimeReceivedIsTxTime = false; nTimeReceived = 0; nTimeSmart = 0; fChangeCached = false; @@ -274,10 +272,11 @@ public: std::vector dummy_vector1; //!< Used to be vMerkleBranch std::vector dummy_vector2; //!< Used to be vtxPrev - bool dummy_bool = false; //!< Used to be fFromMe and fSpent + bool dummy_bool = false; //!< Used to be fFromMe, and fSpent + uint32_t dummy_int = 0; // Used to be fTimeReceivedIsTxTime uint256 serializedHash = TxStateSerializedBlockHash(m_state); int serializedIndex = TxStateSerializedIndex(m_state); - s << TX_WITH_WITNESS(tx) << serializedHash << dummy_vector1 << serializedIndex << dummy_vector2 << mapValueCopy << vOrderForm << fTimeReceivedIsTxTime << nTimeReceived << dummy_bool << dummy_bool; + s << TX_WITH_WITNESS(tx) << serializedHash << dummy_vector1 << serializedIndex << dummy_vector2 << mapValueCopy << vOrderForm << dummy_int << nTimeReceived << dummy_bool << dummy_bool; } template @@ -287,10 +286,11 @@ public: std::vector dummy_vector1; //!< Used to be vMerkleBranch std::vector dummy_vector2; //!< Used to be vtxPrev - bool dummy_bool; //! Used to be fFromMe and fSpent + bool dummy_bool; //! Used to be fFromMe, and fSpent + uint32_t dummy_int; // Used to be fTimeReceivedIsTxTime uint256 serialized_block_hash; int serializedIndex; - s >> TX_WITH_WITNESS(tx) >> serialized_block_hash >> dummy_vector1 >> serializedIndex >> dummy_vector2 >> mapValue >> vOrderForm >> fTimeReceivedIsTxTime >> nTimeReceived >> dummy_bool >> dummy_bool; + s >> TX_WITH_WITNESS(tx) >> serialized_block_hash >> dummy_vector1 >> serializedIndex >> dummy_vector2 >> mapValue >> vOrderForm >> dummy_int >> nTimeReceived >> dummy_bool >> dummy_bool; m_state = TxStateInterpretSerialized({serialized_block_hash, serializedIndex}); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 20f0aae2e3f..b110b133431 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -726,7 +726,6 @@ void CWallet::SyncMetaData(std::pair ran if (!copyFrom->IsEquivalentTo(*copyTo)) continue; copyTo->mapValue = copyFrom->mapValue; copyTo->vOrderForm = copyFrom->vOrderForm; - // fTimeReceivedIsTxTime not copied on purpose // nTimeReceived not copied on purpose copyTo->nTimeSmart = copyFrom->nTimeSmart; // nOrderPos not copied on purpose @@ -2227,7 +2226,6 @@ void CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::ve CHECK_NONFATAL(wtx.vOrderForm.empty()); wtx.mapValue = std::move(mapValue); wtx.vOrderForm = std::move(orderForm); - wtx.fTimeReceivedIsTxTime = true; return true; }); diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index a3fcb0584ea..ef26f685f22 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -1013,7 +1013,7 @@ static DBErrors LoadTxRecords(CWallet* pwallet, DatabaseBatch& batch, std::vecto // Load tx record any_unordered = false; LoadResult tx_res = LoadRecords(pwallet, batch, DBKeys::TX, - [&any_unordered, &upgraded_txs] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& err) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) { + [&any_unordered] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& err) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) { DBErrors result = DBErrors::LOAD_OK; Txid hash; key >> hash; @@ -1030,27 +1030,6 @@ static DBErrors LoadTxRecords(CWallet* pwallet, DatabaseBatch& batch, std::vecto if (wtx.GetHash() != hash) return false; - // Undo serialize changes in 31600 - if (31404 <= wtx.fTimeReceivedIsTxTime && wtx.fTimeReceivedIsTxTime <= 31703) - { - if (!value.empty()) - { - uint8_t fTmp; - uint8_t fUnused; - std::string unused_string; - value >> fTmp >> fUnused >> unused_string; - pwallet->WalletLogPrintf("LoadWallet() upgrading tx ver=%d %d %s\n", - wtx.fTimeReceivedIsTxTime, fTmp, hash.ToString()); - wtx.fTimeReceivedIsTxTime = fTmp; - } - else - { - pwallet->WalletLogPrintf("LoadWallet() repairing tx ver=%d %s\n", wtx.fTimeReceivedIsTxTime, hash.ToString()); - wtx.fTimeReceivedIsTxTime = 0; - } - upgraded_txs.push_back(hash); - } - if (wtx.nOrderPos == -1) any_unordered = true; From 9eb2c82e7c911a066781d67e6846cf6bbbaba6e9 Mon Sep 17 00:00:00 2001 From: Ava Chow Date: Tue, 17 Jun 2025 14:16:33 -0700 Subject: [PATCH 2/2] walletdb: Remove unused upgraded_txs --- src/wallet/walletdb.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index ef26f685f22..6f552076633 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -1005,7 +1005,7 @@ static DBErrors LoadAddressBookRecords(CWallet* pwallet, DatabaseBatch& batch) E return result; } -static DBErrors LoadTxRecords(CWallet* pwallet, DatabaseBatch& batch, std::vector& upgraded_txs, bool& any_unordered) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) +static DBErrors LoadTxRecords(CWallet* pwallet, DatabaseBatch& batch, bool& any_unordered) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) { AssertLockHeld(pwallet->cs_wallet); DBErrors result = DBErrors::LOAD_OK; @@ -1128,7 +1128,6 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet) { DBErrors result = DBErrors::LOAD_OK; bool any_unordered = false; - std::vector upgraded_txs; LOCK(pwallet->cs_wallet); @@ -1165,7 +1164,7 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet) result = std::max(LoadAddressBookRecords(pwallet, *m_batch), result); // Load tx records - result = std::max(LoadTxRecords(pwallet, *m_batch, upgraded_txs, any_unordered), result); + result = std::max(LoadTxRecords(pwallet, *m_batch, any_unordered), result); // Load SPKMs result = std::max(LoadActiveSPKMs(pwallet, *m_batch), result); @@ -1189,9 +1188,6 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet) if (result != DBErrors::LOAD_OK) return result; - for (const Txid& hash : upgraded_txs) - WriteTx(pwallet->mapWallet.at(hash)); - if (!has_last_client || last_client != CLIENT_VERSION) // Update m_batch->Write(DBKeys::VERSION, CLIENT_VERSION);