Skip to content

Instantly share code, notes, and snippets.

Last active December 4, 2019 03:40
What would you like to do?
Bitcoin address to electrum scripthash with nodejs
$ npm install bitcoinjs-lib
$ node -p 'b=require("bitcoinjs-lib");s=b.address.toOutputScript("2MwEUm842QN4YoetosKc1YbeFpHDjsZ6scS", b.networks.regtest);Buffer.from(b.crypto.sha256(s).reverse()).toString("hex")'

Note the b.networks.regtest, change if the address is on a different network.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment