New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calculate Electrum scripthash from address #990
Comments
Not a problem!
I think let script = bitcoin.address.toOutputScript(address)
let hash = bitcoin.crypto.sha256(script)
console.log(address, ' maps to ', hash.toString('hex')) |
Thanks a lot let script = bitcoin.address.toOutputScript(address)
let hash = bitcoin.crypto.sha256(script)
let reversedHash = new Buffer(hash.reverse())
console.log(address, ' maps to ', reversedHash.toString('hex')) No idea why Electrum uses the reverse of the hash and not the hash itself |
endianness and Bitcoin ftw |
And how can you do that in reverse order? I mean by converting from scripthash to public address? Assuming we got scripthash from this
I tried following script but somehow it doesnt work:
Did I something wrong? |
@YanDevDe |
How can i get the scripthash from the address ? as in the following example :
Sorry to bother you with opening an issue here as a question
The original question in stackexchange : ScriptHash from bitcoin address with BitcoinJS
The text was updated successfully, but these errors were encountered: