Electrumx protocol

by melaxon   Last Updated August 01, 2020 01:27 AM - source

The description states:

A script hash is the hash of the binary bytes of the locking script (ScriptPubKey), expressed as a hexadecimal string. The hash function to use is given by the “hash_function” member of server.features() (currently sha256() only). Like for block and transaction hashes, when converting the big-endian binary hash to a hexadecimal string the least-significant byte appears first, and the most-significant byte last.

For example, the legacy Bitcoin address from the genesis block:

has P2PKH script:

with SHA256 hash:

which is sent to the server reversed as:

By subscribing to this hash you can find P2PKH payments to that address.

Can anybody explain what these numbers are:



and how to get them?

Tags : electrum

Answers 1

Using the bx command line tool, the Satoshi address:


looks like this decoded (using bx)

$ bx base58-decode 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa



The first 2 digits (00) is the version number, the last 8 digits (c29b7d93) is the checksum. Leaving 62e907b15cbf27d5425399ebf6f0fb50ebb88f18 as your payload (pubkey in this instance).

Now if I were to make a basic P2PKH locking script with the above pubkey it would look like this:

dup hash160 [62e907b15cbf27d5425399ebf6f0fb50ebb88f18] equalverify checksig

and now encode it in base16:

bx script-encode "dup hash160 [62e907b15cbf27d5425399ebf6f0fb50ebb88f18] equalverify checksig"



sha256 this:

bx sha256 76a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac

result is your number:


The second number,


is serialized in the little-endian (least-significant-byte-first) order. As stated in the link:

When transactions are transmitted over the network or exchanged between applications, they are serialized. Serialization is the process of converting the internal representation of a data structure into a format that can be transmitted one byte at a time, also known as a byte stream. Serialization is most commonly used for encoding data structures for transmission over a network or for storage in a file.

so they're the same number, except byte by byte backwards (I exploded the last 3 bytes of the first to make it apparent).

6191c3b590bfcfa0475e877c302da1e323497acf3b42c08d8fa28e364e df 01 8b
8b 01 df ...
October 29, 2019 18:16 PM

Related Questions

Bitcoin Core internal Electrum Server

Updated July 01, 2020 15:27 PM

Script to import multiple priv keys in Electrum

Updated April 13, 2019 13:27 PM

electrum wallet console - how to get help on a command

Updated September 15, 2017 19:27 PM