Skip to content

psbt: add MuSig2 fields#784

Merged
achow101 merged 1 commit intobitcoin-core:masterfrom
Sjors:2025/06/psbt
Feb 3, 2026
Merged

psbt: add MuSig2 fields#784
achow101 merged 1 commit intobitcoin-core:masterfrom
Sjors:2025/06/psbt

Conversation

@Sjors
Copy link
Member

@Sjors Sjors commented Jun 3, 2025

Fixes #783

@Sjors Sjors force-pushed the 2025/06/psbt branch 2 times, most recently from fc57dfb to 46ceff9 Compare June 3, 2025 07:44
@Sjors
Copy link
Member Author

Sjors commented Jun 3, 2025

@Sjors Sjors marked this pull request as ready for review June 4, 2025 09:56
@Sjors
Copy link
Member Author

Sjors commented Jun 4, 2025

I ended copying @bigspider's code. However there's no test coverage.

I also can't manually test it on a device without passing the BIP-388 policy policy and (no BIP?) HMAC, which is a separate issue.

@Sjors
Copy link
Member Author

Sjors commented Jul 21, 2025

Fixed a few bugs.

I wanted to test this using #792 and taking some code from MooSig, but the latter changed the sign_psbt signature to return List[Tuple[int, SignPsbtYieldedObject]] instead of List[Tuple[int, bytes, bytes]].

@Sjors
Copy link
Member Author

Sjors commented Jul 21, 2025

I think I get the gist of the sign_psbt change, so I made a standalone change in #793 use the SignPsbtYieldedObject (only PartialSignature, leaving out the MuSig2 specific MusigPubNonce and MusigPartialSignature).

@Sjors Sjors mentioned this pull request Jul 21, 2025
1 task
@Sjors
Copy link
Member Author

Sjors commented Jul 30, 2025

I've been testing this with various wallets and I'm pretty sure it works now.

Rebasing on #795 to make sure CI passes.

@Sjors Sjors force-pushed the 2025/06/psbt branch 2 times, most recently from f35fe9f to 337fd14 Compare July 30, 2025 12:05
@Sjors
Copy link
Member Author

Sjors commented Jul 30, 2025

Fixed linter E226 missing whitespace around arithmetic operator

Looks like I accidentally dropped PSBT_IN_TAP_INTERNAL_KEY deserialization code bit, brought it back.

I also added the new test vectors, copied from Bitcoin Core.

@Sjors
Copy link
Member Author

Sjors commented Sep 4, 2025

Rebased after #795 landed.

hwilib/psbt.py Outdated
r += ser_string(b''.join(pubkeys))

for (pk, aggpk, hash), pubnonce in self.musig2_pub_nonces.items():
key_value = pk + aggpk + (hash or b'')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hash is the name of a builtin function in python, we should avoid naming variables hash.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed and rebased.

Co-Authored-By: Salvatore Ingala <6681844+bigspider@users.noreply.github.com>
@achow101
Copy link
Member

achow101 commented Feb 3, 2026

ACK 351b3e4

@achow101 achow101 merged commit 8e72d66 into bitcoin-core:master Feb 3, 2026
233 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add MuSig2 PSBT fields

2 participants