Skip to content

How can i get the derive path #139

@zhengjunxiang

Description

@zhengjunxiang

Hello, I want to generate the address from the xpub,but I don't know how to get derive path.
This my codes:

     const bitcoin = require('bitcoinjs-lib');

      const zpub = 'zpub6r1Di2DqG9hrkk3EYQgjxVSr2QJTvtBaLswyknjwPc3eFiBipPWUE8RAhiCKDJxPiYHUpavEFueEuA4NsD82mhPMdPws6LonuuNGhDVyv4Q';

      const path = "m/0/1";

      const network = bitcoin.networks.bitcoin;


      const hdNode = bitcoin.bip32.fromBase58(zpub, network);

      const childNode = hdNode.derivePath(path);

      const address = bitcoin.payments.p2wpkh({ pubkey: childNode.publicKey, network }).address;

My purpose is to verify that an address is generated by this wallet,thx

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