Git Product home page Git Product logo

xpub-tool's Introduction

Swan's Address Derivation Tool

code style: prettier

A small JavaScript library and accompanying tool that derives bitcoin addresses from extended public keys. Built upon unchained-bitcoin and bitcoinjs-lib.

For more details refer to the individual packages:

  • xpub-lib - address derivation and validation library
  • xpub-cli - command-line interface

Relevant BIPs and Educational Resources

  • BIP 32 - Hierarchical Deterministic Wallets
  • BIP 44 - Multi-Account Hierarchy for Deterministic Wallets
  • BIP 49 - Derivation scheme for P2WPKH-nested-in-P2SH based accounts
  • BIP 84 - Derivation scheme for P2WPKH based accounts

Samourai Wallet wrote a short summary on the differences between BIP 44, BIP 49, BIP 84 and XPUB's, YPUB's, ZPUB's. For a detailed explanation on derivation paths refer to learn me a bitcoin.

License: MIT

xpub-tool's People

Contributors

dependabot[bot] avatar dergigi avatar joernroeder avatar pablof7z avatar rene78 avatar zanepocock avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xpub-tool's Issues

accountNumber passed to partialpath where change should be used

In xpub-lib/src/derivation.js the accountNumber passed in by the user is being used to derive addresses from the change segment of the derivation path. See here:

const partialPath = partialKeyDerivationPath({ accountNumber, keyIndex })

In practice, this might just be a semantics issue, but for clarity's sake it should probably take change (0 or 1) as an input parameter.

It follows that the returned path when passing in an accountNumber of 1 (e.g. path: "m/84'/0'/1'/0/0") would appear to be incorrect. Really we are returning the address at path: "m/84'/0'/1'/1/0"

If you use both -n and -i parameters in xpub cli, the -i parameter will not be taken into account

I was on the stream with master philosopher @dergigi and tried deriving 3 addresses from xpub:

> xpub derive xpub6CQtk4bkfG1d4UTWNBwmWGP95gjvTvEKZhm74CxLfbd4XqXY5wkyaUvLoWyy6Le24VxCqg2nASLu2xhNaDh5FhFDf8ndUUgbm8q1VDqCipy -v -n 3
{
  path: "m/84'/0'/0'/0/0",
  address: 'bc1qcksx27qlksr2cy3pnwdw0mnm94c5cm0vz3jh6e'
}
{
  path: "m/84'/0'/0'/0/1",
  address: 'bc1qw0c77zue3xduyh4jef3r3jhfpx30jxc7s5z7lv'
}
{
  path: "m/84'/0'/0'/0/2",
  address: 'bc1ql4l5m2wnlcwl28rsu0k8k5rx7yjg9fkr2vld8p'
}

But when I tried using -i parameter as well to skip first 2 keys, I got the same output:

> xpub derive xpub6CQtk4bkfG1d4UTWNBwmWGP95gjvTvEKZhm74CxLfbd4XqXY5wkyaUvLoWyy6Le24VxCqg2nASLu2xhNaDh5FhFDf8ndUUgbm8q1VDqCipy -v -n 3 -i 2
{
  path: "m/84'/0'/0'/0/0",
  address: 'bc1qcksx27qlksr2cy3pnwdw0mnm94c5cm0vz3jh6e'
}
{
  path: "m/84'/0'/0'/0/1",
  address: 'bc1qw0c77zue3xduyh4jef3r3jhfpx30jxc7s5z7lv'
}
{
  path: "m/84'/0'/0'/0/2",
  address: 'bc1ql4l5m2wnlcwl28rsu0k8k5rx7yjg9fkr2vld8p'
}

@dergigi is trying to say this is a feature, but it's not... look, it's even in docs:
image

So Gigi, please fix it, that's what we do on SCWUR - motivate programmers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.