Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Converts mnemonic recovery seed
- * into xpub for watch-only services
- *
- * Dependencies:
- * npm install bitcore bitcore-mnemonic
- */
- var bitcore = require('bitcore');
- var bitcoreMnemonic = require('bitcore-mnemonic');
- var mnemonic = '<ENTER 12-word or 24-word mnemonic seed>';
- var seed = new bitcoreMnemonic(mnemonic);
- var hdnode = seed.toHDPrivateKey();
- // BREAD WALLET and others
- // BIP32 (m/0')
- var parent = hdnode.derive("m/0'");
- console.log(parent.xpubkey);
- // TREZOR and others
- // BIP44 (m/44'/0'/0')
- // var parent = hdnode.derive("m/44'/0'/0'");
- // Confirm correct derivation by checking first address
- // compare with first receive address generated by your app
- var first = parent.derive('m/0/0').publicKey;
- console.log(new bitcore.Address(first).toString());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement