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.
Asked: 2023-06-12 06:27:24 +0000
Seen: 14 times
Last updated: Jun 12 '23