Skip to content

Commit d4c40bf

Browse files
committed
fix multisig script
1 parent 3459117 commit d4c40bf

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

x/lending/types/taproot.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,24 @@ func GetTaprootAddress(script []byte) (*btcutil.AddressTaproot, error) {
2727
// Branch 1: multisig signature script
2828
func createMultisigScript(pubKeys []string) ([]byte, error) {
2929
builder := txscript.NewScriptBuilder()
30-
builder.AddInt64(int64(len(pubKeys))) // Threshold: 2 signatures required
31-
for _, pubKeyHex := range pubKeys {
30+
for i, pubKeyHex := range pubKeys {
3231
pubKey, err := hex.DecodeString(pubKeyHex)
3332
if err != nil {
3433
return nil, err
3534
}
35+
3636
builder.AddData(pubKey)
37+
38+
if i == 0 {
39+
builder.AddOp(txscript.OP_CHECKSIG)
40+
} else {
41+
builder.AddOp(txscript.OP_CHECKSIGADD)
42+
}
3743
}
38-
builder.AddInt64(int64(len(pubKeys))) // Total keys
39-
builder.AddOp(txscript.OP_CHECKMULTISIG)
44+
45+
builder.AddInt64(int64(len(pubKeys)))
46+
builder.AddOp(txscript.OP_NUMEQUAL)
47+
4048
return builder.Script()
4149
}
4250

0 commit comments

Comments
 (0)