Skip to content

derive bip44 hardened addresses from xpub key #914

@stefanhuber

Description

@stefanhuber

It got my issues with deriving addresses from xpub keys answered very well: #584

Unfortunately, I run into problems when deriving addresses from xpub keys with hardened indexes. I checked the unit tests (https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/bip32.js#L50) which work great, however not with only a xpub as an input.

This triggers error: TypeError: Could not derive hardened child key

bitcoin.HDNode.fromBase58('xpub...').derivePath("m/44'/0'/0/0").getAddress();

This works without problems

bitcoin.HDNode.fromBase58('xpub...').derivePath("m/0/0").getAddress();

Strangely with testnet it doesn't work, first line triggers the error: Error: Not a master node, second line works correctly

bitcoin.HDNode.fromBase58('tpub...', [bitcoin.networks.testnet]).derivePath("m/0/0").getAddress()
bitcoin.HDNode.fromBase58('tpub...', [bitcoin.networks.testnet]).derive(0).derive(0).getAddress()

My goal is to derive addresses from xpub keys exported from bip44 wallets. Testnet should also be supported. Can somebody give me an answer how this can be done? Referring to issue #584, is it only possible for non-hardened indexes?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions