Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To obtain a BTC address from a public key in Node.js, you can use the bitcoinjs-lib library. Here is an example code snippet:

const bitcoin = require('bitcoinjs-lib');

const publicKey = Buffer.from('PUBLIC_KEY', 'hex');

const address = bitcoin.payments.p2pkh({ pubkey: publicKey }).address;

console.log('BTC Address:', address);

Replace PUBLIC_KEY with your actual public key in hex format. The above code will output the BTC address corresponding to the provided public key.