cryptocoinjs / hdkey

JavaScript component for Bitcoin hierarchical deterministic keys (BIP32)
MIT License
201 stars 74 forks source link

Including options for exporting public and private key for toJson() function #16

Closed prahaladbelavadi closed 4 years ago

prahaladbelavadi commented 6 years ago

https://github.com/cryptocoinjs/hdkey/blob/548a71ee171955a3e823b9300189c21bcc3e65be/lib/hdkey.js#L163

I was trying to export both public and private keys using toJSON() function. is knowledge of seed necessary for exporting to json ?

can we have parameters where we can fill in both xpriv and xpub to be exported ? I can fill in either xpriv or xpub right now, but not both

Ref

RyanZim commented 4 years ago

In your example code, you're creating an HDKey with an xpub, which doesn't contain the private data. If you create one with an xpriv, you'd be able to export both private and public keys.