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

Bitcoin generate addresses from xpub #284

@dominator-1

Description

@dominator-1

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions