Skip to content

Commit c9f7364

Browse files
committed
test: fix MiniWallet script-path spend (missing parity bit in leaf version)
This commit fixes a dormant bug in MiniWallet that exists since support for P2TR was initially added in #23371 (see commit 041abfe). In the course of spending the output, the leaf version byte of the control block in the witness stack doesn't set the parity bit, i.e. we were so far just lucky that the used combinations of relevant data (internal pubkey, leaf script / version) didn't result in a tweaked pubkey with odd y-parity. If that was the case, we'd get the following validation error: `mandatory-script-verify-flag-failed (Witness program hash mismatch) (-26)` Since MiniWallets can now optionally be tagged (#29939), resulting in different internal pubkeys, the issue is more prevalent now. Fix it by passing the parity bit, as specified in BIP341.
1 parent 7774c31 commit c9f7364

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

test/functional/test_framework/wallet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def sign_tx(self, tx, fixed_length=True):
198198
leaf_info = list(self._taproot_info.leaves.values())[0]
199199
i.scriptWitness.stack = [
200200
leaf_info.script,
201-
bytes([leaf_info.version]) + self._taproot_info.internal_pubkey,
201+
bytes([leaf_info.version | self._taproot_info.negflag]) + self._taproot_info.internal_pubkey,
202202
]
203203
else:
204204
assert False

0 commit comments

Comments
 (0)