wallet: Identify transactions spending 0-value outputs, and add tests for anchor outputs in a wallet - #33268
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/33268. 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. |
bae350c to
7d1c3ce
Compare
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
|
Tested ACK 7d1c3ce7f0f0. I have compiled it and ran the script from issue #33265 with no output other than the current UTC date. Works for me. Thanks! |
|
After it gets merged into |
|
@jsarenik technically this issue could happen if miners mine 0-value outputs of any kind, but given that it's now relay-possible, seems like a good idea to backport |
7d1c3ce to
de98ffb
Compare
|
Tested ACK de98ffb |
furszy
left a comment
There was a problem hiding this comment.
q: is IsFromMe() method still relevant? It seems we could directly call IsMine() on the inputs, which is also cached now and should be slightly safer for migration.
Yes, transactions that we make are still treated specially. |
Where?. |
Hmm, I forgot that |
de98ffb to
c33734f
Compare
I've pulled in 2 commits from #27865 which drop
While that's true, moving |
c33734f to
e201a1e
Compare
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
There was a problem hiding this comment.
nit: perhaps it makes review easier.
| wallet = self.nodes[0].get_wallet_rpc("fromme") | |
| fromme_wallet = self.nodes[0].get_wallet_rpc("fromme") |
|
Backported to 29.x in #34268. |
If something is imported into the wallet, it can change the 'from me' status of a transaction. This status is only visible through gettransaction's "fee" field which is only shown for transactions that are 'from me'. Github-Pull: bitcoin#33268 Rebased-From: e76c2f7
Instead of checking whether the total amount of inputs known by the wallet is greater than 0, we should be checking for whether the input is known by the wallet. This enables us to determine whether a transaction spends an of output with an amount of 0, which is necessary for marking 0-value dust outputs as spent. Github-Pull: bitcoin#33268 Rebased-From: 39a7dbd
Github-Pull: bitcoin#33268 Rebased-From: c40dc82
Github-Pull: bitcoin#33268 Rebased-From: 609d265
If something is imported into the wallet, it can change the 'from me' status of a transaction. This status is only visible through gettransaction's "fee" field which is only shown for transactions that are 'from me'. Github-Pull: bitcoin#33268 Rebased-From: e76c2f7
Instead of checking whether the total amount of inputs known by the wallet is greater than 0, we should be checking for whether the input is known by the wallet. This enables us to determine whether a transaction spends an of output with an amount of 0, which is necessary for marking 0-value dust outputs as spent. Github-Pull: bitcoin#33268 Rebased-From: 39a7dbd
Github-Pull: bitcoin#33268 Rebased-From: c40dc82
m_cached_from_me is used to track whether a transaction is "from me", i.e. has any inputs which belong to the wallet. This is held in memory only in the same way that a transaction's balances are. Github-Pull: bitcoin#33268 Rebased-From: 113a422
b834447 [doc] generate manpages 29.3rc1 (glozow) e9c9783 [build] bump version to 29.3rc1 (glozow) e973b61 [doc] update release notes for 29.3rc1 (glozow) f4b78c4 test: Add a test for anchor outputs in the wallet (Ava Chow) c6e7765 wallet: Throw an error in sendall if the tx size cannot be calculated (Ava Chow) bab1ac8 wallet: Determine IsFromMe by checking for TXOs of inputs (Ava Chow) 71633a9 test: Test wallet 'from me' status change (Ava Chow) daef585 guix: Fix `osslsigncode` tests (Hennadii Stepanov) 7a71850 Remove unreliable seed from chainparams.cpp, and the associated README (SatsAndSports) 2e46886 miner: fix `addPackageTxs` unsigned integer overflow (ismaelsadeeq) Pull request description: Backports: - #34227 - #33723 - #33475 - #33268 And final changes for 29.3rc1 ACKs for top commit: achow101: ACK b834447 janb84: ACK b834447 sedited: ACK b834447 Tree-SHA512: 68e02fbde7162f728229f4bfc803bedda6d269e54593ebe40da607f6bd25b2b10bc4297bfa0bc977ce2dc6b558efe6571a7f875090e0f916fc09e5b67432ba30
If something is imported into the wallet, it can change the 'from me' status of a transaction. This status is only visible through gettransaction's "fee" field which is only shown for transactions that are 'from me'. Github-Pull: bitcoin#33268 Rebased-From: afed5f7
Instead of checking whether the total amount of inputs known by the wallet is greater than 0, we should be checking for whether the input is known by the wallet. This enables us to determine whether a transaction spends an of output with an amount of 0, which is necessary for marking 0-value dust outputs as spent. Github-Pull: bitcoin#33268 Rebased-From: aae427c
Github-Pull: bitcoin#33268 Rebased-From: 4212b7c
Github-Pull: bitcoin#33268 Rebased-From: 7b1f54d
m_cached_from_me is used to track whether a transaction is "from me", i.e. has any inputs which belong to the wallet. This is held in memory only in the same way that a transaction's balances are. Github-Pull: bitcoin#33268 Rebased-From: 71136c5
6b222a3 cmake: Install `bitcoin` manpage (Hennadii Stepanov) 6d44e0e net: Do not apply whitelist permission to onion inbounds (Martin Zumsande) 5357c58 test: Add submitblock test in interface_ipc (TheCharlatan) 8247fdd test: Prevent disk space warning during node_init_tests (Ryan Ofsky) 609a121 ci: Enable CI_LIMIT_STACK_SIZE=1 in i686_no_ipc task (MarcoFalke) f492aec test: Fix CLI_MAX_ARG_SIZE issues (MarcoFalke) 393b45d cmake: Fix regression in `secp256k1.cmake` (Hennadii Stepanov) a4874b8 wallet: Add m_cached_from_me to cache "from me" status (Ava Chow) c831d6a test: Add a test for anchor outputs in the wallet (Ava Chow) 0d311f7 wallet: Throw an error in sendall if the tx size cannot be calculated (Ava Chow) bd80dc7 wallet: Determine IsFromMe by checking for TXOs of inputs (Ava Chow) 19da90f test: Test wallet 'from me' status change (Ava Chow) 6b1d3da trace: Workaround GCC bug compiling with old systemtap (Luke Dashjr) b776b2e ci: always use tag for LLVM checkout (fanquake) 7c96632 gui: Avoid pathological QT text/markdown behavior... (David Gumberg) Pull request description: Backports: * bitcoin#33243 * bitcoin#33268 * bitcoin#33310 * bitcoin#33364 * bitcoin#33379 * bitcoin#33380 * bitcoin#33391 * bitcoin#33407 * bitcoin-core/gui#886 ACKs for top commit: darosior: utACK 6b222a3 hebasto: ACK 6b222a3, I applied all backports locally without conflicts and obtained a zero diff with this PR branch. Tree-SHA512: 257cc5bd0423fbf2aff62c72957faea3de8731353d809b11e18d0e5cad174c7023dca9dedd0c73e07497eb804b7c48355a055b4461db260e2f0a5712d2514ff6
If something is imported into the wallet, it can change the 'from me' status of a transaction. This status is only visible through gettransaction's "fee" field which is only shown for transactions that are 'from me'. Github-Pull: bitcoin#33268 Rebased-From: afed5f7
One of the ways that the wallet would determine if a transaction was sent from the wallet was by checking if the total amount being spent by a transaction from outputs known to the wallet was greater than 0. This has worked fine until recently since there was no reason for 0-value outputs to be created. However, with ephemeral dust and P2A, it is possible to create standard 0-value outputs, and the wallet was not correctly identifying the spends of such outputs. This PR updates
IsFromMeto only check whether the wallet knows any of the inputs, rather than checking the debit amount of a transaction.Additionally, a new functional test is added to test for this case, as well as a few other anchor output related scenarios. This also revealed a bug in
sendallwhich would cause an assertion error when trying to spend all of the outputs in a wallet that has anchor outputs.Fixes #33265