Bitcoinjs-lib: version 4.0.1, Derive addresses from xpubkey

Created on 4 Sep 2018  路  1Comment  路  Source: bitcoinjs/bitcoinjs-lib

Hello guys, help much appreciated.

I use to be able to derive addresses from xpub keys like this (version 3.x.x) (note that the xpubkey I'm using is not segwit)

bjs.HDNode.fromBase58(xpub, network).neutered()
    .derive(0)
    .derive(0)
    .getAddress()

I've upgraded to 4.0.1 and it does not work anymore. I've tried

bjs.bip32.fromBase58(xpub, network)
    .derive(0)
    .derive(0)
    .getAddress()

but I get _bitcoinjsLib.bip32.fromBase58(...).derive(...).derive(...).getAddress is not a function"

also tried

const pubkey = bjs.bip32.fromBase58(xpub, network)
    .derive(0)
    .derive(0)
    .getPublicKeyBuffer()

const { address } = bjs.payments.p2sh({
  redeem: bjs.payments.p2wpk({
    pubkey: pubKey
  })
})

but I get _bitcoinjsLib.bip32.fromBase58(...).derive(...).derive(...).getPublicKeyBuffer is not a function

Anyone care to explain ? thank you very much

how to / question / docs

Most helpful comment

ok I've firgured it out:

const pubkey = bip32.fromBase58(xpub, network)
        .derive(0)
        .derive(0)

      return bjs.payments.p2pkh({ pubkey: pubkey.publicKey, network }).address

>All comments

ok I've firgured it out:

const pubkey = bip32.fromBase58(xpub, network)
        .derive(0)
        .derive(0)

      return bjs.payments.p2pkh({ pubkey: pubkey.publicKey, network }).address
Was this page helpful?
0 / 5 - 0 ratings

Related issues

coingeek picture coingeek  路  4Comments

yakitorifoodie picture yakitorifoodie  路  3Comments

askucher picture askucher  路  3Comments

zhaozhiming picture zhaozhiming  路  3Comments

dcousens picture dcousens  路  3Comments