multi sig address
random9brat opened this issue · comments
Hi everyone,
Any chance of someone giving me an example of creating a multisig within buidljs ?
Thanks 🥇
There are only two multisig functions in buidljs to CREATE multisig addresses. NOTE there are no functions in buidljs to spend from multisig.
multisig(pubkey1,pubkey2,pubkey3) - 3 parameters (string, string, string). This function will take 3 public keys and creates a 2 of 3 multisig address.
multisigRandom(m,n) - 2 parameters (integer, integer). M must be less than N. Generates random private keys based on the m-of-n provided and outputs the multisig address, redeemscript and private keys needed to sign.
Any chance writing this in a code/line as an example? Thanks
EDIT: found a solution for a second one with m and n...but still cant understand who first one works
Create a random 2-3 multisig
var newkey = buidl.multisigRandom(2,3)
console.log("Address: "+newkey.addr)
console.log("WIF Keys: "+newkey.privateKeys)
console.log("RedeemScript: "+newkey.redeemScript)
Or if you want to provide public keys to create a multisig:
//generate the keypairs
var keypair1 = buidl.getNewAddress()
var keypair2 = buidl.getNewAddress()
var keypair3 = buidl.getNewAddress()
//obtain the public key for each
var pubkey1 = buidl.getDetails(keypair1.pk).publicKey
var pubkey2 = buidl.getDetails(keypair2.pk).publicKey
var pubkey3 = buidl.getDetails(keypair3.pk).publicKey
//create a 2 of 3 multisig with public keys
var wallet = buidl.multisig(pubkey1,pubkey2,pubkey3)
console.log("Address: "+wallet.addr)
console.log("RedeemScript: "+wallet.redeemScript)