From 386ecdc3506b87f78bde23ecbd2bfc6b5b737efa Mon Sep 17 00:00:00 2001 From: alvroble <50918598+alvroble@users.noreply.github.com> Date: Tue, 9 Dec 2025 20:17:18 +0100 Subject: [PATCH] Fix multisig tests --- tests/test_psbt_parser.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/tests/test_psbt_parser.py b/tests/test_psbt_parser.py index a24c1f57..a3c1ab91 100644 --- a/tests/test_psbt_parser.py +++ b/tests/test_psbt_parser.py @@ -154,7 +154,7 @@ class TestPSBTParser: PSBTParser should correctly handle PSBTs with missing fingerprints (created from XPUB-only imports, without derivation path) by matching public keys against the seed and filling in correct fingerprints. """ - for input in PSBTTestData.SINGLE_SIG_INPUTS: + for input in PSBTTestData.ALL_INPUTS: psbt = PSBT.parse(a2b_base64(input)) # Set fingerprints to zero to simulate XPUB-only import (missing fingerprint) @@ -189,15 +189,31 @@ class TestPSBTParser: for inp in parser.psbt.inputs: for pub, derivation in inp.bip32_derivations.items(): - # Must match the signing seed's fingerprint from binascii import hexlify - assert hexlify(derivation.fingerprint).decode() == seed_fingerprint + fingerprint_hex = hexlify(derivation.fingerprint).decode() + + # Check if this public key derives from the current seed + derived_key = parser.root.derive(derivation.derivation) + if derived_key.key.sec() == pub.sec(): + # This pubkey derives from current seed, should have current seed's fingerprint + assert fingerprint_hex == seed_fingerprint, f"Expected {seed_fingerprint}, got {fingerprint_hex} for pubkey that derives from current seed" + else: + # This pubkey doesn't derive from current seed, should remain 00000000 + assert fingerprint_hex == "00000000" # Also check Taproot derivations for pub, (leaf_hashes, derivation) in inp.taproot_bip32_derivations.items(): - # Must match the signing seed's fingerprint from binascii import hexlify - assert hexlify(derivation.fingerprint).decode() == seed_fingerprint + fingerprint_hex = hexlify(derivation.fingerprint).decode() + + # Check if this public key derives from the current seed + derived_key = parser.root.derive(derivation.derivation) + if derived_key.key.sec() == pub.sec(): + # This pubkey derives from current seed, should have current seed's fingerprint + assert fingerprint_hex == seed_fingerprint, f"Expected {seed_fingerprint}, got {fingerprint_hex} for taproot pubkey that derives from current seed" + else: + # This pubkey doesn't derive from current seed, should remain 00000000 + assert fingerprint_hex == "00000000" def test_trim_and_sig_count(self):