swan-bitcoin / xpub-tool

A JavaScript library to derive bitcoin addresses from extended public keys. Includes a web tool and CLI.
MIT License
47 stars 21 forks source link

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

Open rockstardev opened 3 years ago

rockstardev commented 3 years ago

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.