From fa48b5d28eb5c326115af246b12ff644279172c4 Mon Sep 17 00:00:00 2001 From: pablomartin4btc Date: Fri, 7 Aug 2026 01:24:03 -0300 Subject: [PATCH] test: assert listsinceblock "removed" reports current canonical wtxid When a block is detached, listsinceblock "removed" entries reflect the wallet's current CWalletTx rather than a snapshot of the variant that was actually in the detached block. Add assertions to make this behaviour explicit. A future followup could improve listsinceblock to track and report the specific witness variant that was in the disconnected block (requires per-block tracking of which witness variant was included). Co-authored-by: w0xlt <94266259+w0xlt@users.noreply.github.com> --- test/functional/wallet_listtransactions.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/functional/wallet_listtransactions.py b/test/functional/wallet_listtransactions.py index 0391109cc5c..f48f0cfc52f 100755 --- a/test/functional/wallet_listtransactions.py +++ b/test/functional/wallet_listtransactions.py @@ -356,6 +356,16 @@ class ListTransactionsTest(BitcoinTestFramework): assert_equal(wallet.gettransaction(txid)["confirmations"], 0) self.check_tx_variants(wallet, txid, key_path_tx, key_path_wtxid, alternate_wtxids=[script_path_wtxid]) + # listsinceblock "removed" entries reflect the wallet's current CWalletTx, not a + # snapshot of the detached block. The detached block contained the heavier script + # path variant, but "wtxid" reports the current canonical (key path) variant and + # the script path variant appears under "alternate_wtxids". A future improvement + # could track which specific variant was in the detached block and report that. + removed = next(e for e in wallet.listsinceblock(block)["removed"] if e["txid"] == txid) + assert_equal(removed["confirmations"], 0) + assert_equal(removed["wtxid"], key_path_wtxid) + assert_equal(removed["alternate_wtxids"], [script_path_wtxid]) + if __name__ == '__main__': ListTransactionsTest(__file__).main()