-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need library/tool to convert WIF to base58 #15
Comments
Somewhere in here is code that does it: |
Playground is using a copy of this lib from ~3 years ago (not current): https://github.com/bitpay/bitcore-message |
Here's what I'm using right now: https://gist.github.com/3d2c8dcc8fbfc279014baa40d06ef269#file-create-bitcoin-wif-js const bitcoin = require('bitcoinjs-lib')
const NETWORKS = bitcoin.networks
// enter private key and network here
const privateKey = ''
const network = NETWORKS.testnet
const KEY = Buffer.from(privateKey, 'hex')
const keyPair = bitcoin.ECPair.fromPrivateKey(KEY, {
compressed: false,
network: network
})
let { address } = bitcoin.payments.p2pkh({ pubkey: keyPair.publicKey, network: network })
console.log("Public Key: ", keyPair.publicKey.toString('hex'))
console.log("Address: ", address)
console.log("WIF: ", keyPair.toWIF()); Go here https://repl.it/languages/nodejs and just add As I understand it, the WIF is the base58 encoding of a private key, but if that's incorrect let me know. |
I'm getting no luck actually using the above for signing with vs-js-cli demo though. Probably doing something wrong, either above or hacking it into the demo. |
@AnthonyRonning you may want to compare the encoding techniques with what's here: https://github.com/digitalbazaar/secp256k1-key-pair/blob/master/lib/index.js#L52 I believe the bitcoinjs-lib also uses the same |
The text was updated successfully, but these errors were encountered: