swan-bitcoin / xpub-tool Goto Github PK
View Code? Open in Web Editor NEWA JavaScript library to derive bitcoin addresses from extended public keys. Includes a web tool and CLI.
License: MIT License
A JavaScript library to derive bitcoin addresses from extended public keys. Includes a web tool and CLI.
License: MIT License
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:
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"
Do you think it is possible to extend functionality of you libary and support arbitrary coin types like https://iancoleman.io/bip39/ does?
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:
So Gigi, please fix it, that's what we do on SCWUR - motivate programmers.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.