Skip to content

Instantly share code, notes, and snippets.

@amingilani
Created September 18, 2015 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amingilani/cacb0f7cc867fa167145 to your computer and use it in GitHub Desktop.
Save amingilani/cacb0f7cc867fa167145 to your computer and use it in GitHub Desktop.
Make pub keys using copay!
/*
If you have a shared copay wallet and would like to create HD multisig address on the fly
Export the backup of your wallet, decrypt it and find the extended public keys for the
co-signers in the publicKeyRing property, and run it through this.
*/
var bitcore = require('bitcore');
// which iteration of the addresses do you want to generate
var walletNumb = 5;
// the extended public keys of the cosigners
var publicKeyRing = [
"xpub661MyMwAqRbcGp97p3hhnARfeddABNRSmmXdzDNzS2dTBJ2WAE6GUNPtAzKmmVaj7KmCDEkhNbwspGkVp28CVKmAZ8GXpFaCkwb5dNTrRyA",
"xpub661MyMwAqRbcGa8jqcUYYvcwXoV4TMc2MQGTUgXS5JHaZHFrAPVg1yEJEdJL9pGdaPPvvTMEZqp9EAtfxycmd5Mq97NRgZHo2ruVGr61iAK",
"xpub661MyMwAqRbcH26YTFSozCCSac5ZYXhsyunEgojy24cAgsCC6TG4Do4RRmrCzghPxfwQwqBLZ4VBBsG9AsZtC9b23ydLX4DEiRoCpYBRpML"
];
// the derived public keys for that iteration
var publicKeys = publicKeyRing.map(function(xPubKey) {
var parent = new bitcore.HDPublicKey(xPubKey);
var index = "m/2147483647/0/" + walletNumb;
var childKey = parent.derive(index).publicKey;
return childKey;
});
// the multisig wallet address
var p2shAddress = new bitcore.Address(publicKeys, 3);
// log out the address
console.log(p2shAddress);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment