Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Bitcoin generate addresses from xpub #284

Open
dominator-1 opened this issue Jan 24, 2019 · 0 comments
Open

Bitcoin generate addresses from xpub #284

dominator-1 opened this issue Jan 24, 2019 · 0 comments

Comments

@dominator-1
Copy link

Hello, I'm trying to create a module which generate addresses from my xpub.

Currently I have this code


var bitcore = require('bitcore-lib');
var Address = bitcore.Address;
var PublicKey = bitcore.PublicKey;
var Networks = bitcore.Networks;

var xpub = 'xpub6C5jKCKeVmMNaceEoVRsTy7e8ZBCwmJZBv5gJYEV1h3QubtBB4RUecEdfEWfvCM5aD15DiaaAjJq5zgBZzFX2vYzUZLfSt4NEfVHahZKD2v';
var hdPublickey = new bitcore.HDPublicKey(xpub);
var orderPublickey = hdPublickey.deriveChild("m/49/0/4/1");
var pubkey = new PublicKey(orderPublickey.publicKey);
var address = Address.fromPublicKey(pubkey, Networks.mainnet);

var address2 = Address.fromPublicKey(pubkey);

console.log(address.toString());

This is working for me and generate addresses, but when I send btc to newly created addresses I can't see transaction when checking my xpub on blockchain.info.
Looks like generated addresses not bound to my xpub.

Can someone help me with it?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant