-
Notifications
You must be signed in to change notification settings - Fork 37.7k
wallet: Track no-longer-spendable TXOs separately #27865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/27865. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
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. |
6925928
to
7a50755
Compare
8c4b04a
to
9730ec0
Compare
3c56e99
to
edaf52d
Compare
edaf52d
to
1784af7
Compare
c05ed69
to
c41741e
Compare
Perform the transaction reorder upgrade immediately after loading txs instead of waiting for the end of loading.
m_from_me is used to track whether a transaction is "from me", i.e. has any inputs which belong to the wallet.
Instead of looking at the cached amounts or searching every input of a transaction each time we want to determine whether it is "from me", use m_from_me which stores this value for us.
Since we need to know whether the transaction that creates a WalletTXO is "from me", we should store this state in the WalletTXO too, copied from its parent CWalletTx.
WalletTXOs need to know their parent tx's timestamp for AvailableCoins to work.
When the state of a CWalletTx changes, we need to change the state in the WalletTXOs too.
A min_conf parameter is added to IsSpent so that it can set a confirmation threshold for whether something is considered spent.
When a block is disconnected, we need to process the transactions in reverse order so that the wallet's TXO set is updated in the correct order.
CWallet::Create will properly connect the wallet to the chain, so we should be doing that rather than ad-hoc chain connection.
Definitely unusable TXOs are those that are spent by a confirmed transaction or were produced by a now conflicted transaction. However, we still need them for GetDebit, so we store them in a separate m_unusable_txos container. MarkConflicted, AbandonTransaction, and loading (via PruneSpentTXOs) will ensure that these unusable TXOs are properly moved.
c41741e
to
64c2c8a
Compare
In #27286, the wallet keeps track of all of its transaction outputs, even if they are already spent or are otherwise unspendable. This TXO set is iterated for balance checking and coin selection preparation, which can still be slow for wallets that have had a lot of activity. This PR aims to improve the performance of such wallets by moving UTXOs that are definitely no longer spendable to a different map in the wallet so that far fewer TXOs need to be iterated for the aforementioned functions.
Unspendable TXOs (not to be confused with Unspent TXOs) are those which have a spending transaction that has been confirmed, or are no longer valid due to reorgs. TXOs that are spent in unconfirmed transactions remain in the primary TXO set, and are filtered out of balance and coin selection as before.
Depends on #27286