CWalletTx::fTimeReceivedIsTxTime is no longer used and can be removed. This additionally allows the removal of the upgraded_txs loop in LoadWallet.
wallet: Remove `CWalletTx::fTimeReceivedIsTxTime` #32768
pull achow101 wants to merge 2 commits into bitcoin:master from achow101:rm-timereceivedistxtime changing 3 files +9 −36-
achow101 commented at 9:28 PM on June 17, 2025: member
-
DrahtBot commented at 9:28 PM on June 17, 2025: contributor
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--006a51241073e994b41acfe9ec718e94-->
Code Coverage & Benchmarks
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32768.
<!--021abf342d371248e50ceaed478a90ca-->
Reviews
See the guideline for information on the review process.
Type Reviewers ACK maflcko, rkrux, Eunovo, davidgumberg, w0xlt, PeterWrighten If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
<!--174a7506f384e20aa4161008e828411d-->
Conflicts
Reviewers, this pull request conflicts with the following ones:
- #32763 (wallet: Replace CWalletTx::mapValue and vOrderForm with explicit class members by achow101)
- #32685 (wallet: Allow read-only database access for info and dump commands by PeterWrighten)
- #27865 (wallet: Track no-longer-spendable TXOs separately by achow101)
- #27286 (wallet: Keep track of the wallet's own transaction outputs in memory by achow101)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
<!--5faf32d7da4f0f540f40219e4f7537a3-->
- DrahtBot added the label Wallet on Jun 17, 2025
- DrahtBot added the label CI failed on Jun 17, 2025
- achow101 force-pushed on Jun 18, 2025
-
c668033709
wallet: Remove unused fTimeReceivedIsTxTime
fTimeReceivedIsTxTime has been unused unused since 0.3.24
-
walletdb: Remove unused upgraded_txs 9eb2c82e7c
- achow101 force-pushed on Jun 18, 2025
- DrahtBot removed the label CI failed on Jun 18, 2025
-
maflcko commented at 7:39 AM on June 20, 2025: member
lgtm ACK 9eb2c82e7c911a066781d67e6846cf6bbbaba6e9
-
in src/wallet/wallet.cpp:2230 in c668033709 outdated
2225 | @@ -2227,7 +2226,6 @@ void CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::ve 2226 | CHECK_NONFATAL(wtx.vOrderForm.empty()); 2227 | wtx.mapValue = std::move(mapValue); 2228 | wtx.vOrderForm = std::move(orderForm); 2229 | - wtx.fTimeReceivedIsTxTime = true;
rkrux commented at 10:52 AM on June 20, 2025:I find it slightly weird that boolean was used to set an unsigned int.
in src/wallet/transaction.h:279 in c668033709 outdated
276 | + bool dummy_bool = false; //!< Used to be fFromMe, and fSpent 277 | + uint32_t dummy_int = 0; // Used to be fTimeReceivedIsTxTime 278 | uint256 serializedHash = TxStateSerializedBlockHash(m_state); 279 | int serializedIndex = TxStateSerializedIndex(m_state); 280 | - s << TX_WITH_WITNESS(tx) << serializedHash << dummy_vector1 << serializedIndex << dummy_vector2 << mapValueCopy << vOrderForm << fTimeReceivedIsTxTime << nTimeReceived << dummy_bool << dummy_bool; 281 | + s << TX_WITH_WITNESS(tx) << serializedHash << dummy_vector1 << serializedIndex << dummy_vector2 << mapValueCopy << vOrderForm << dummy_int << nTimeReceived << dummy_bool << dummy_bool;
rkrux commented at 10:53 AM on June 20, 2025:Is there a possibility that sometime in the future we stop serialising and unserialising dummy values?
achow101 commented at 7:31 PM on June 20, 2025:Not with the way that stuff is serialized into the wallet.
davidgumberg commented at 8:51 PM on June 20, 2025:I think if we ever started using the SQLite database as a relational database instead of as a key-value store as @achow101 has suggestd in the past, adding and removing fields will be neater.
in src/wallet/walletdb.cpp:1033 in c668033709 outdated
1029 | @@ -1030,27 +1030,6 @@ static DBErrors LoadTxRecords(CWallet* pwallet, DatabaseBatch& batch, std::vecto 1030 | if (wtx.GetHash() != hash) 1031 | return false; 1032 | 1033 | - // Undo serialize changes in 31600
rkrux commented at 10:58 AM on June 20, 2025:Interesting that
v0.3.16is not present in the tags, might have been buggy for which this undoing was needed.in src/wallet/walletdb.cpp:1194 in 9eb2c82e7c
1187 | @@ -1189,9 +1188,6 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet) 1188 | if (result != DBErrors::LOAD_OK) 1189 | return result; 1190 | 1191 | - for (const Txid& hash : upgraded_txs) 1192 | - WriteTx(pwallet->mapWallet.at(hash)); 1193 | -
rkrux commented at 10:59 AM on June 20, 2025:Looks fine to me to remove because
fTimeReceivedIsTxTimeis not really used in the wallet codebase at present, so I see no point in writing this upgraded transaction back.rkrux commented at 10:59 AM on June 20, 2025: contributorACK 9eb2c82e7c911a066781d67e6846cf6bbbaba6e9
Eunovo commented at 4:20 PM on June 20, 2025: contributorACK https://github.com/bitcoin/bitcoin/pull/32768/commits/9eb2c82e7c911a066781d67e6846cf6bbbaba6e9
fTimeReceivedIsTxTimehas had no functional impact since it was removed in https://github.com/bitcoin/bitcoin/commit/471426fb3b2c2fa37640c03819c4f7be69ba8301#diff-286fedc8ff8f47bca92c7024d2c75272aa5bcfd733379eac1555e6036528d6b1davidgumberg commented at 10:20 PM on June 20, 2025: contributorACK https://github.com/bitcoin/bitcoin/commit/9eb2c82e7c911a066781d67e6846cf6bbbaba6e9
The
fTimeReceivedIsTxTimeonce indicated whether a transactions "time" was the time the wallet heard about the transaction, or the time that the transaction was included in a block.It was set to true for transactions created by the wallet, where presumably we care more about what time we made the transaction then what time we heard about it in a block, but for other transaction's the time that we "receive" the transaction may be much later (e.g. IBD) than the time it was included in a block, so we don't want the transaction's "time" to be
nTimeReceived.:https://github.com/bitcoin/bitcoin/blob/4405b78d6059e536c36974088a8ed4d9f0f29898/main.cpp#L263-L279 [^1]
This field was mistakenly an
unsigned intrather than achar/bool:https://github.com/bitcoin/bitcoin/blob/4405b78d6059e536c36974088a8ed4d9f0f29898/main.h#L678
A later commit (e4ff4e6898d378b1a3e83791034a7af455fde3ab), that AFAICT predates the practice of using dummy types for deprecated fields in serialization, attempted to "fix" this inefficiency of using 4 bytes to represent a bool. Since the commit was adding an
nVersionfield to the serialized transaction data anyways, andnVersionis 4 bytes, it reused thefTimeReceivedIsTxTimefield as thenVersionfield, and changedfTimeReceivedIsTxTimeto a bool and moved it to the end of tx serialization:diff --git a/main.h b/main.h index 7d1145b5ff..dda5f730c7 100644 - READWRITE(fTimeReceivedIsTxTime); + READWRITE(nVersion); + if (fRead && nVersion < 100) + const_cast<CWalletTx*>(this)->fTimeReceivedIsTxTime = nVersion; READWRITE(nTimeReceived); READWRITE(fFromMe); READWRITE(fSpent); + if (nVersion >= 31404) + { + READWRITE(fTimeReceivedIsTxTime); + READWRITE(fUnused); + READWRITE(strFromAccount); + } )This broke transaction times for wallets that were upgraded and then loaded into an older bitcoin client, since these wallets would have giant version numbers like
31404in thefTimeReceivedIsTxTimefor every transaction, andfTimeReceivedIsTxTimewould always be true.A later commit (https://github.com/bitcoin/bitcoin/commit/865c3a23832e36d50cb873d38c976032b027b5d3) reverted the above change to fix this upgrade-then-downgrade bug, but it had to include a special case for fixing transactions that had very large
fTimeReceivedIsTxTimethat matched the version numbers that were affected by this bugAnd Bitcoin Core retains this special-case handling today, even though, for a long time, even before the introduction of smart time in #1393,
GetTxTime()has not usedfTimeReceivedIsTxTime(471426fb3b2c2fa37640c0381):[^1]: This snippet is from the initial git commit: 4405b78d6059e536c36
w0xlt commented at 10:26 PM on June 20, 2025: contributorPeterWrighten commented at 2:38 AM on June 22, 2025: nonePeterWrighten commented at 2:40 AM on June 22, 2025: noneglozow merged this on Jun 25, 2025glozow closed this on Jun 25, 2025
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-15 09:12 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me