Skip to content

psbt: add MuSig2 fields#784

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

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

Conversation

@Sjors

@Sjors Sjors commented Jun 3, 2025

Copy link
Copy Markdown
Member

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

Sjors commented Jun 3, 2025

Copy link
Copy Markdown
Member Author

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

Sjors commented Jun 4, 2025

Copy link
Copy Markdown
Member Author

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

Sjors commented Jul 21, 2025

Copy link
Copy Markdown
Member Author

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

Sjors commented Jul 21, 2025

Copy link
Copy Markdown
Member Author

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

Sjors commented Jul 30, 2025

Copy link
Copy Markdown
Member Author

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

Sjors commented Jul 30, 2025

Copy link
Copy Markdown
Member Author

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

Sjors commented Sep 4, 2025

Copy link
Copy Markdown
Member Author

Rebased after #795 landed.

Comment thread 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
Copy Markdown
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
Copy Markdown
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

achow101 commented Feb 3, 2026

Copy link
Copy Markdown
Member

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