diff --git a/src/script/sign.cpp b/src/script/sign.cpp index c4d59de46d5..efee5a35fe0 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -318,14 +318,15 @@ static bool SignMuSig2(const BaseSignatureCreator& creator, SignatureData& sigda } // Get the BIP32 derivation tweaks CExtPubKey extpub = CreateMuSig2SyntheticXpub(agg_pub); - for (const int i : agg_info.path) { + for (const uint32_t i : agg_info.path) { + if (i >> 31) return false; // Hardened derivation is not possible from a public key auto& [t, xonly] = tweaks.emplace_back(); xonly = false; if (!extpub.Derive(extpub, i, &t)) { return false; } } - Assert(XOnlyPubKey(extpub.pubkey) == script_pubkey); + if (XOnlyPubKey(extpub.pubkey) != script_pubkey) continue; plain_pub = extpub.pubkey; } diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py index 364a9334511..bab3d92f39a 100755 --- a/test/functional/rpc_psbt.py +++ b/test/functional/rpc_psbt.py @@ -57,7 +57,6 @@ from test_framework.util import ( assert_equal, assert_greater_than, assert_greater_than_or_equal, - assert_raises, assert_raises_rpc_error, find_vout_for_address, wallet_importprivkey, @@ -320,10 +319,8 @@ class PSBTTest(BitcoinTestFramework): PSBT_IN_TAP_INTERNAL_KEY: script_pubkey, bytes([PSBT_IN_MUSIG2_PARTICIPANT_PUBKEYS]) + aggregate_pubkey: [participant_pubkey], }).to_base64() - assert_raises(Exception, node.analyzepsbt, psbt) # TODO: Unexpected derivation metadata should not abort the node - self.start_node(0) - assert_raises(Exception, node.finalizepsbt, psbt) # TODO: Unexpected derivation metadata should not abort the node - self.start_node(0) + assert_equal(node.analyzepsbt(psbt)["inputs"][0]["is_final"], False) + assert_equal(node.finalizepsbt(psbt)["complete"], False) def test_combinepsbt_preserves_proprietary_fields(self): self.log.info("Test that combining PSBTs preserves proprietary fields")