question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Calculate Electrum scripthash from address

See original GitHub issue

How can i get the scripthash from the address ? as in the following example :

{'priv': 'L8g5V8kFFeg2WbecahRSdobARbHz2w2STH9S8ePHVSY4fmia7Rsj',
        'pub': '03e9f948421aaa89415dc5f281a61b60dde12aae3181b3a76cd2d849b164fc6d0b',
        'address': 'bc1qqmpt7u5e9hfznljta5gnvhyvfd2kdd0r90hwue',
        'minikey': False,
        'txin_type': 'p2wpkh',
        'compressed': True,
        'addr_encoding': 'bech32',
        'scripthash': '1929acaaef3a208c715228e9f1ca0318e3a6b9394ab53c8d026137f847ecf97b'}

Sorry to bother you with opening an issue here as a question The original question in stackexchange : ScriptHash from bitcoin address with BitcoinJS

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
youssefghcommented, Jan 18, 2018

Thanks a lot Your example worked with just a small modification:

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 Cheers

3reactions
junderwcommented, Jan 19, 2018

endianness and Bitcoin ftw

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scripthash from bitcoin address with Golang
I broke my head looking for a solution. I want use bitcoin address for electrumx. Take bitcoin address from docs example: ...
Read more >
Protocol Methods - ElectrumX - Read the Docs
A list of confirmed transactions in blockchain order, with the output of blockchain.scripthash.get_mempool() appended to the list.
Read more >
scripthash to address - Bitcoin Talk
[...] It seems that electrumx stores scripthash, but I want to get all the wallet addresses, a lot of BTC explorer How did...
Read more >
Electrum server method: "blockchain.scripthash.subscribe"
According to the docs status is just a hash of all you transactions, ordered in a specific manner. As long as it is...
Read more >
From address - Bitcoin Wiki
Bitcoin addresses are used to receive payments, but not to send them: there is no concept ... 3.5 Recipient can work out the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found