使用公钥和唯一值生成 Litecoin 和 Zcash Multisig 地址

问题描述

以下是我用于为比特币创建多重签名地址的输入,我需要一些帮助我需要对以下代码进行哪些必要的更改才能获得莱特币、比特币现金和 Zcash 的多重签名,因为它们都是比特币或比特币现金

公钥:

  1. 0352d50656796dd79e3e3385c29636d849b8705c9c6d9b86a1717adc38e4a567c7
  2. 02f39d0b69c3b8e06030ef9dc295cf8c848f51e398fe85414e33509afdc7f01fb3
  3. 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 (将#修改为@)