Skip to content

How do I derive new Accounts from xPub? #1006

@vzelenko

Description

@vzelenko

I am trying to derive a new address based on xPub key on Testnet.

const rootKey = bitcoin.HDNode.fromBase58(WALLET_XPUB_KEY, bitcoin.networks.testnet).neutered();
const key = { accountNumber: 20, lastAddressNumber: 10 };
const txtPath = `m/49'/1'/${key.accountNumber}'/0/${key.lastAddressNumber}`;
const child = rootKey.derivePath(txtPath);
return child.getAddress();

It fails on derivePath with message Error: Not a master node - what is the correct way of getting N'th account addresses?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions