Bitcoinjs-lib: How to convert bitcoind private key to ECPair?

Created on 5 Oct 2016  路  7Comments  路  Source: bitcoinjs/bitcoinjs-lib

I have a private key from bitcoind, and I want to convert it to ECPair.

Is there some simple tool for this, either in this library or elsewhere on npm? I cannot find anything usable.

how to / question / docs

Most helpful comment

Yes. I put in wrong network (main instead of testnet) and it confused me. :)

All 7 comments

I am not 100% sure what exactly is coming from bitcoind (when using dumpprivkey), but it seems like base58. But I try to use bs58 and base58check to decode, and it doesn't work really

oh nevermind, it's already WIF, I just put in wrong network. Closing.

dumprivkey provides your key in WIF format which happens to be base58 check encoded.

See this as an example:

https://github.com/bitcoinjs/bitcoinjs-lib/blob/4ae06003c4b38aa2335a152e12a003d8f4dee889/test/integration/basic.js#L44

Yes. I put in wrong network (main instead of testnet) and it confused me. :)

ECPair.fromWIF, with the right network provided :smiley:

What is the command in node using bitcoin js to dumprivkey? I have the private key and need to generate the wif, to be use to generate ECPair.

dumpprivkey is a bitcoind CLI/RPC command. It has nothing to do with NodeJS.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rbndg picture rbndg  路  3Comments

ghost picture ghost  路  3Comments

ishwarchandratiwari picture ishwarchandratiwari  路  3Comments

askucher picture askucher  路  3Comments

panpan2 picture panpan2  路  3Comments