test: fix tap tree absence check in rpc_psbt.py
What changed, and why it matters
This commit fixes a test in Bitcoin Core that was checking the wrong thing. The test was meant to verify that a simple Taproot output (one without a script tree) does not include an unnecessary 'tap tree' field in a PSBT. However, the original test accidentally sent funds to a regular non-Taproot address, so the absence of a tap tree was meaningless. The fix sends to a proper Taproot (bech32m) address and checks the processed wallet PSBT instead of the raw one, making the test meaningful. There is no change to production code and no security vulnerability is being patched.
No security action required. This is a test-only correction. Reviewers may optionally verify the test now exercises the intended Taproot key-path output behavior.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change is confined to test/functional/rpc_psbt.py. It corrects a functional test that intended to assert PSBT_OUT_TAP_TREE is absent for key-path-only Taproot outputs. Previously the test created a PSBT spending to a default (non-Taproot) address, then inspected the raw createpsbt result, so the tap tree absence was trivially true. The patch changes the destination to a bech32m address, uses walletprocesspsbt’s signed PSBT, asserts PSBT_OUT_TAP_INTERNAL_KEY is present, and asserts PSBT_OUT_TAP_TREE and decodepsbt’s taproot_tree are absent. It also updates the combinepsbt assertion to use the signed PSBT. No consensus, wallet, or P2P code is modified.
Changed components
test/functional/rpc_psbt.pyInspect captured patch +11 / −6
### test/functional/rpc_psbt.py
@@ -48,6 +48,7 @@
PSBT_IN_FINAL_SCRIPTWITNESS,
PSBT_OUT_MUSIG2_PARTICIPANT_PUBKEYS,
PSBT_OUT_PROPRIETARY,
+ PSBT_OUT_TAP_INTERNAL_KEY,
PSBT_OUT_TAP_TREE,
PSBT_OUT_SCRIPT,
)
@@ -1695,19 +1696,23 @@ def global_xpub_key(extended_pubkey):
self.log.info("Test that walletprocesspsbt both updates and signs a non-updated psbt containing Taproot inputs")
addr = self.nodes[0].getnewaddress("", "bech32m")
utxo = self.create_outpoints(self.nodes[0], outputs=[{addr: 1}])[0]
- psbt = self.nodes[0].createpsbt([utxo], [{self.nodes[0].getnewaddress(): 0.9999}])
+ psbt = self.nodes[0].createpsbt([utxo], [{self.nodes[0].getnewaddress("", "bech32m"): 0.9999}])
signed = self.nodes[0].walletprocesspsbt(psbt)
rawtx = signed["hex"]
self.nodes[0].sendrawtransaction(rawtx)
self.generate(self.nodes[0], 1)
- # Make sure tap tree is not in psbt
- parsed_psbt = PSBT.from_base64(psbt)
+ # Make sure tap tree is not in psbt for a key-path-only taproot output
+ signed_psbt = signed["psbt"]
+ parsed_psbt = PSBT.from_base64(signed_psbt)
+ assert PSBT_OUT_TAP_INTERNAL_KEY in parsed_psbt.o[0].map
assert PSBT_OUT_TAP_TREE not in parsed_psbt.o[0].map
- assert "taproot_tree" not in self.nodes[0].decodepsbt(psbt)["outputs"][0]
+ decoded_output = self.nodes[0].decodepsbt(signed_psbt)["outputs"][0]
+ assert "taproot_internal_key" in decoded_output
+ assert "taproot_tree" not in decoded_output
parsed_psbt.make_blank()
- comb_psbt = self.nodes[0].combinepsbt([psbt, parsed_psbt.to_base64()])
- assert_equal(comb_psbt, psbt)
+ comb_psbt = self.nodes[0].combinepsbt([signed_psbt, parsed_psbt.to_base64()])
+ assert_equal(comb_psbt, signed_psbt)
self.log.info("Test walletprocesspsbt raises if an invalid sighashtype is passed")
assert_raises_rpc_error(-8, "'all' is not a valid sighash parameter.", self.nodes[0].walletprocesspsbt, psbt=psbt, sighashtype="all")Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.