What changed, and why it matters
This commit only adds a new unit test for the PSBT finalizer. It checks that when a Bitcoin Taproot multi-signature (multi_a) input has more valid signatures than required, the finalizer picks exactly the required number and leaves the extra signature slot empty. There is no code change to the finalizer itself—only a test was added.
No action needed. This is a test-only commit. If reviewing the related finalizer behavior, verify the production code already handles excess signatures correctly; this test merely documents that behavior.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds TestTaprootMultiAFinalizerIgnoresExcessSignatures in psbt/taproot_multi_a_test.go. It constructs a 2-of-3 OP_CHECKSIG/OP_CHECKSIGADD/OP_NUMEQUAL multi_a script with valid signatures for all three keys, finalizes the PSBT, and asserts the witness contains an empty placeholder for the excess key, plus sigB and sigA in deterministic script order. No library logic is modified.
Changed components
psbt/taproot_multi_a_test.goInspect captured patch +33 / −0
### psbt/taproot_multi_a_test.go
@@ -91,6 +91,39 @@ func TestTaprootMultiAFinalizerAddsPlaceholders(t *testing.T) {
}, finalTx.TxIn[0].Witness)
}
+func TestTaprootMultiAFinalizerIgnoresExcessSignatures(t *testing.T) {
+ keyA := bytes.Repeat([]byte{0x02}, 32)
+ keyB := bytes.Repeat([]byte{0x03}, 32)
+ keyC := bytes.Repeat([]byte{0x04}, 32)
+ sigA := bytes.Repeat([]byte{0xaa}, 64)
+ sigB := bytes.Repeat([]byte{0xbb}, 64)
+ sigC := bytes.Repeat([]byte{0xcc}, 64)
+
+ script, err := txscript.NewScriptBuilder().
+ AddData(keyA).AddOp(txscript.OP_CHECKSIG).
+ AddData(keyB).AddOp(txscript.OP_CHECKSIGADD).
+ AddData(keyC).AddOp(txscript.OP_CHECKSIGADD).
+ AddInt64(2).AddOp(txscript.OP_NUMEQUAL).Script()
+ require.NoError(t, err)
+
+ packet := taprootMultiATestPacket(t, script, []*TaprootScriptSpendSig{
+ {XOnlyPubKey: keyA, Signature: sigA},
+ {XOnlyPubKey: keyB, Signature: sigB},
+ {XOnlyPubKey: keyC, Signature: sigC},
+ })
+
+ require.NoError(t, MaybeFinalizeAll(packet))
+ finalTx, err := Extract(packet)
+ require.NoError(t, err)
+ require.Equal(t, wire.TxWitness{
+ []byte{},
+ sigB,
+ sigA,
+ script,
+ make([]byte, 33),
+ }, finalTx.TxIn[0].Witness)
+}
+
func TestTaprootMultiAFinalizerRejectsInsufficientSignatures(t *testing.T) {
keyA := bytes.Repeat([]byte{0x02}, 32)
keyB := bytes.Repeat([]byte{0x03}, 32)Why this scored 12/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.