Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can i get the derive path #139

Open
zhengjunxiang opened this issue Oct 29, 2023 · 0 comments
Open

How can i get the derive path #139

zhengjunxiang opened this issue Oct 29, 2023 · 0 comments

Comments

@zhengjunxiang
Copy link

zhengjunxiang commented Oct 29, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant