Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
P2SH-wrapped P2PKH address
const bitcoin = require('bitcoinjs-lib');
// Step 1
const address = "1CciesT23BNionJeXrbxmjc7ywfiyM4oLW";
console.log(`Address we use now: ${address}`);
// Step 2
const lockingScript = bitcoin.address.toOutputScript(address);
console.log(`Output Script: ${bitcoin.script.toASM(lockingScript)}`);
const hash160ed = bitcoin.crypto.hash160(lockingScript);
console.log(`Hashed Output Script: ${hash160ed.toString('hex')}`);
// Step 3
const p2sh = bitcoin.address.toBase58Check(hash160ed, 5);
console.log(`Final P2SH: ${p2sh}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.