Public key to address

0

I am working in js and I need a library that helps me get an address with a public key stored in a buffer.

sanemiliano

Posted 2019-02-21T18:34:53.657

Reputation: 1

Question was closed 2019-02-22T04:58:01.830

Answers

1

Try bitcoinjs-lib

The following will generate a P2SH(P2WPKH) address

const bitcoin = require('bitcoinjs-lib')
let pubkey = Buffer.from('027a2c8c567a5bb7777580d31d1fd8d9910d4b1bb398570e3a36e81d7522cf828a', 'hex')
let address = bitcoin.payments.p2sh({redeem: bitcoin.payments.p2wpkh({ pubkey })}).address
console.log('address: ', address)

address:  3F1JMjuxgNFuK4kBxv4JXMEdQ2yvjuz939

JBaczuk

Posted 2019-02-21T18:34:53.657

Reputation: 6 172