Skip to content

Commit

Permalink
fix multisig script
Browse files Browse the repository at this point in the history
  • Loading branch information
keithsue committed Jan 12, 2025
1 parent 3459117 commit d4c40bf
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions x/lending/types/taproot.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,24 @@ func GetTaprootAddress(script []byte) (*btcutil.AddressTaproot, error) {
// Branch 1: multisig signature script
func createMultisigScript(pubKeys []string) ([]byte, error) {
builder := txscript.NewScriptBuilder()
builder.AddInt64(int64(len(pubKeys))) // Threshold: 2 signatures required
for _, pubKeyHex := range pubKeys {
for i, pubKeyHex := range pubKeys {
pubKey, err := hex.DecodeString(pubKeyHex)
if err != nil {
return nil, err
}

builder.AddData(pubKey)

if i == 0 {
builder.AddOp(txscript.OP_CHECKSIG)
} else {
builder.AddOp(txscript.OP_CHECKSIGADD)
}
}
builder.AddInt64(int64(len(pubKeys))) // Total keys
builder.AddOp(txscript.OP_CHECKMULTISIG)

builder.AddInt64(int64(len(pubKeys)))
builder.AddOp(txscript.OP_NUMEQUAL)

return builder.Script()
}

Expand Down

0 comments on commit d4c40bf

Please # to comment.