Implements un/serialization of MuSig2 PSBT fields and prepares PSBT to be able to sign for MuSig2 inputs.
Split from #29675
When dummy signing for finalizing, use either the specificed sighash, or
SIGHASH_DEFAULT, rather than always SIGHASH_ALL.
For outputs, just use SIGHASH_DEFAULT.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31247.
See the guideline for information on the review process.
Type | Reviewers |
---|---|
ACK | theStack |
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
717@@ -672,6 +718,80 @@ struct PSBTInput
718 UnserializeFromVector(s, m_tap_merkle_root);
719 break;
720 }
721+ case PSBT_IN_MUSIG2_PARTICIPANT_PUBKEYS:
722+ {
723+ if (!key_lookup.emplace(key).second) {
724+ throw std::ios_base::failure("Duplicate Key, input participant pubkeys for an aggregate key already provided");
725+ } else if (key.size() != 34) {
726+ throw std::ios_base::failure("Input musig2 participants pubkeys aggregate key is more than 33 bytes");
error message nit:
0 throw std::ios_base::failure("Input musig2 participants pubkeys aggregate key is not 34 bytes");
(assuming we are refering to the complete size of the key here, including the compact-size type prefix; we seem to do so on other key types like PSBT_IN_TAP_SCRIPT_SIG)
Code-review ACK 8da5ab60b58b808d693d251c8605d53ae54ba617
I’ve prepared a branch for adding the MuSig2 key types to the test framework and adding a functional test that verifies the decodepsbt
results on these, feel free to either pull in or ignore (will just open a separate PR after this one is merged then): https://github.com/theStack/bitcoin/tree/202411-test-add_musig2_decodepsbt_test