0
I'm using the following tool to generate a HD wallet: https://iancoleman.io/bip39/
However, it gives quite a few different private keys and I'm not sure which one is used to sign transactions with.
I'm using the bitcoinjs-lib to create an EC pair but I'm not sure how to go from the private keys generated to a hexidecimal string:
https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/ecpair.js#L29
Thanks!
Are you trying to sign with the HD private keys you generated on the site? – James C. – 2019-01-08T10:20:21.170
If so, you will need to extract the private key from the HD private keys (in Extended Key format), which are encoded like this: https://teachbitcoin.io/wallets.html#/9
– James C. – 2019-01-08T10:24:29.970Yes, thanks that's a great resource! I'll look into extracting the private key from the extended key format. Do I extract from the account extended key or the BIP32 one? – timothyylim – 2019-01-08T10:40:09.287
Extended keys are described in BIP32, and which private key u need to sign with depends on the output. In addition to priv/pubkey, extended keys simply contain the chaincode information required to derive further children. There is a master extended key pair from which all children are derived. The account key I presume u mean the parent of all child keys in that acct, such as m/44’/0’/0’/0? – James C. – 2019-01-08T10:50:42.083
"which private key u need to sign with depends on the output" -> I assume it is because you need to sign with the specific private key that generates the address that the input is coming from? – timothyylim – 2019-01-08T11:20:48.980
I'm still not sure how to get to the hexadecimal string as used in: https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/ecpair.js#L29
I managed to find the bip32 site: http://bip32.org
I wrote my question a bit differently here: https://bitcoin.stackexchange.com/questions/83477/deriving-hex-private-key-from-a-hd-wallet
– timothyylim – 2019-01-08T11:45:15.553