如何解决使用公钥和唯一值生成 Litecoin 和 Zcash Multisig 地址
以下是我用于为比特币创建多重签名地址的输入,我需要一些帮助我需要对以下代码进行哪些必要的更改才能获得莱特币、比特币现金和 Zcash 的多重签名,因为它们都是比特币或比特币现金
公钥:
- 0352d50656796dd79e3e3385c29636d849b8705c9c6d9b86a1717adc38e4a567c7
- 02f39d0b69c3b8e06030ef9dc295cf8c848f51e398fe85414e33509afdc7f01fb3
- 027072ba2319ead2b0b387d69d36508f57b397da8d4ac76ea64676ee8a1356dae0
唯一值 - 8e254ac1
输出 - Multisug 地址
从下面的链接我们可以获得 reddemscript 和唯一值,但这仅适用于已花费的地址 https://blockstream.info/tx/137b9caa21d69151cf9a62976944197453bfad17d63e50badc93983b4fc78bed?expand&input:0
下面是使用的 go lang 代码,它工作正常。任何人都可以帮忙为 Litecoin、Bitcoincash、Zcash 生成多签名地址
package main
import (
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/txscript"
"fmt"
"encoding/hex"
)
func main(){
// create redeem script for 2 of 3 multi-sig
builder := txscript.NewScriptBuilder()
// add the minimum number of needed signatures
builder.AddOp(txscript.OP_2) //OP_PUSHNUM_2
// add the 3 public key
pubkey1,err1 := hex.DecodeString("0352d50656796dd79e3e3385c29636d849b8705c9c6d9b86a1717adc38e4a567c7")
pubkey2,err2 := hex.DecodeString("02f39d0b69c3b8e06030ef9dc295cf8c848f51e398fe85414e33509afdc7f01fb3")
pubkey3,err3 := hex.DecodeString("027072ba2319ead2b0b387d69d36508f57b397da8d4ac76ea64676ee8a1356dae0")
fmt.Println("Bytes of pubklic key")
fmt.Println(pubkey1)
fmt.Println(pubkey2)
fmt.Println(pubkey3)
if err1 != nil {
panic(err1)
}
if err2 != nil {
panic(err2)
}
if err3 != nil {
panic(err3)
}
builder.AddData(pubkey1).AddData(pubkey2).AddData(pubkey3)
// add the total number of public keys in the multi-sig screipt
builder.AddOp(txscript.OP_3)
// add the check-multi-sig op-code
builder.AddOp(txscript.OP_CHECKMULTISIGVERIFY)
specialValue,err4 := hex.DecodeString("8e254ac1")
if err4 != nil {
panic(err4)
}
builder.AddOp(txscript.OP_PUSHDATA4)
builder.AddData(specialValue)
builder.AddOp(txscript.OP_DROP)
builder.AddOp(txscript.OP_DEPTH)
builder.AddOp(txscript.OP_0)
builder.AddOp(txscript.OP_EQUAL)
// redeem script is the script program in the format of []byte
redeemScript,err := builder.Script()
if err != nil {
fmt.Println(err)
}
// calculate the hash160 of the redeem script
redeemHash := btcutil.Hash160(redeemScript)
fmt.Println(redeemHash)
// if using Bitcoin main net then pass &chaincfg.MainNetParams as second argument
addr,err := btcutil.NewAddressScriptHashFromHash(redeemHash,&chaincfg.MainNetParams)
if err != nil {
fmt.Println(err)
}
fmt.Println(addr.EncodeAddress(),nil)
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。