Skip to content

Instantly share code, notes, and snippets.

@shesek
Last active January 5, 2024 00:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shesek/6409c5f9fe3b62214955311aa921dab4 to your computer and use it in GitHub Desktop.
Save shesek/6409c5f9fe3b62214955311aa921dab4 to your computer and use it in GitHub Desktop.
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