firmware: append partial sigs to support multisig#165
firmware: append partial sigs to support multisig#165benma merged 1 commit intoBitBoxSwiss:masterfrom
Conversation
api/firmware/psbt.go
Outdated
| case ourKey.segwit != nil: | ||
| psbtInput.PartialSigs = []*psbt.PartialSig{ | ||
| { | ||
| psbtInput.PartialSigs = append( |
There was a problem hiding this comment.
Should we to check if the pubkey is already present in the list?
https://github.com/btcsuite/btcd/blob/c47cb8aae0105f0fcb86e39eece00e6e5c8c9772/btcutil/psbt/updater.go#L84 does it too
There was a problem hiding this comment.
Sure, I can add a check. But what would we do in that case? Replace the signature or error out? Would the BitBox even sign an input again if there's already a partial signature present for it (didn't check the firmware code).
There was a problem hiding this comment.
The firmware does not receive the PSBT in the raw PSBT format, and it it will sign when asked.
I was going to say that overwriting makes sense, but the btcd function linked above returns ErrDuplicateKey 🤔 I guess I don't have a strong opinion, but ending up with duplicate keys would be invalid, so that should be avoided.
There was a problem hiding this comment.
Okay, I went with the replace approach and documented the behavior in the Godocs.
Currently, even if the BitBox is the last of multiple devices to sign a multisig PSBT, the API just overwrites the partial sigs.
Appending the signature instead makes this work for P2WSH based multisig use cases.