<p>Using the <a href="https://github.com/libbitcoin/libbitcoin-explorer" rel="nofollow noreferrer">bx command line tool</a>,
the Satoshi address: </p>

<p><code>1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa</code></p>

<p>looks like this decoded (using bx)</p>

<pre><code>$ bx base58-decode 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa
</code></pre>

<p>outputs:</p>

<pre><code>0062e907b15cbf27d5425399ebf6f0fb50ebb88f18c29b7d93
</code></pre>

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

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

<pre><code>dup hash160 [62e907b15cbf27d5425399ebf6f0fb50ebb88f18] equalverify checksig
</code></pre>

<p>and now encode it in base16:</p>

<pre><code>bx script-encode "dup hash160 [62e907b15cbf27d5425399ebf6f0fb50ebb88f18] equalverify checksig"
</code></pre>

<p>result:</p>

<pre><code>76a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac
</code></pre>

<p>sha256 this:</p>

<pre><code>bx sha256 76a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac
</code></pre>

<p>result is your number:</p>

<pre><code>6191c3b590bfcfa0475e877c302da1e323497acf3b42c08d8fa28e364edf018b
</code></pre>

<p>The second number, </p>

<pre><code>8b01df4e368ea28f8dc0423bcf7a4923e3a12d307c875e47a0cfbf90b5c39161
</code></pre>

<p>is <a href="https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch06.asciidoc#transaction-serializationoutputs" rel="nofollow noreferrer">serialized in the little-endian</a> (least-significant-byte-first) order. As stated in the link:</p>

<blockquote>
  <p>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. </p>
</blockquote>

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

<pre><code>6191c3b590bfcfa0475e877c302da1e323497acf3b42c08d8fa28e364e df 01 8b
8b 01 df ...
</code></pre>

CC BY-SA 4.0
2019-10-30T20:52:45.757Z
Thanks a lot!!!
One more question: we derived this number :
```76a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac```
from P2PKH:
```62e907b15cbf27d5425399ebf6f0fb50ebb88f18```
by adding a prefix ```76a914``` and suffix ```88ac```.
What are these prefix and suffix? Do they depend on currency or something else?
melaxon
CC BY-SA 4.0
2019-10-31T12:40:29.673Z
It's not derived from `62e9..` but its making a locking script using that pubkey, then encoding it. So you're seeing the base16 encoding of the script language. For example, `bx script-encode "[62e907b15cbf27d5425399ebf6f0fb50ebb88f18]"` yields the hash `1462e907b15cbf27d5425399ebf6f0fb50ebb88f18` (14...) and `bx script-encode "dup hash160 equalverify checksig"` yields `76a988ac`. The pubkey is already base16, of course. So there are your numbers.
tgunnoe
CC BY-SA 4.0
2019-10-29T18:16:09.143Z
2019-10-30T01:56:28.620Z
2019-10-30T01:56:28.620Z
tgunnoe
<p>The <a href="https://electrumx.readthedocs.io/en/latest/protocol-basics.html#script-hashes" rel="nofollow noreferrer">description</a> states:</p>

<pre><code>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:

1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa
has P2PKH script:

76a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac
with SHA256 hash:

6191c3b590bfcfa0475e877c302da1e323497acf3b42c08d8fa28e364edf018b
which is sent to the server reversed as:

8b01df4e368ea28f8dc0423bcf7a4923e3a12d307c875e47a0cfbf90b5c39161
By subscribing to this hash you can find P2PKH payments to that address.
</code></pre>

<p>Can anybody explain what these numbers are:</p>

<p><strong>6191c3b590bfcfa0475e877c302da1e323497acf3b42c08d8fa28e364edf018b</strong></p>

<p><strong>8b01df4e368ea28f8dc0423bcf7a4923e3a12d307c875e47a0cfbf90b5c39161</strong></p>

<p>and how to get them?</p>

<electrum>
Electrumx protocol
melaxon
# Electrumx protocol

(Asked by: username_0 on 2019-10-25)

The [description](https://electrumx.readthedocs.io/en/latest/protocol-basics.html#script-hashes) 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:

1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa
has P2PKH script:

76a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac
with SHA256 hash:

6191c3b590bfcfa0475e877c302da1e323497acf3b42c08d8fa28e364edf018b
which is sent to the server reversed as:

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

```

Can anybody explain what these numbers are:

**6191c3b590bfcfa0475e877c302da1e323497acf3b42c08d8fa28e364edf018b**

**8b01df4e368ea28f8dc0423bcf7a4923e3a12d307c875e47a0cfbf90b5c39161**

and how to get them?

**Tags:** electrum


---

## 1 answers

### Answer by username_1 on 2019-10-29. Score: 2

Using the [bx command line tool](https://github.com/libbitcoin/libbitcoin-explorer),
the Satoshi address:

`1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa`

looks like this decoded (using bx)

```
$ bx base58-decode 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa

```

outputs:

```
0062e907b15cbf27d5425399ebf6f0fb50ebb88f18c29b7d93

```

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"

```

result:

```
76a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac

```

sha256 this:

```
bx sha256 76a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac

```

result is your number:

```
6191c3b590bfcfa0475e877c302da1e323497acf3b42c08d8fa28e364edf018b

```

The second number,

```
8b01df4e368ea28f8dc0423bcf7a4923e3a12d307c875e47a0cfbf90b5c39161

```

is [serialized in the little-endian](https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch06.asciidoc#transaction-serializationoutputs) (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 ...

```

> **Comments:**
> **username_0**: Thanks a lot!!! One more question: we derived this number : ```76a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac``` from P2PKH: ```62e907b15cbf27d5425399ebf6f0fb50ebb88f18``` by adding a prefix ```76a914``` and suffix ```88ac```. What are these prefix and suffix? Do they depend on currency or something else?  
> **username_1**: It's not derived from `62e9..` but its making a locking script using that pubkey, then encoding it. So you're seeing the base16 encoding of the script language. For example, `bx script-encode "[62e907b15cbf27d5425399ebf6f0fb50ebb88f18]"` yields the hash `1462e907b15cbf27d5425399ebf6f0fb50ebb88f18` (14...) and `bx script-encode "dup hash160 equalverify checksig"` yields `76a988ac`. The pubkey is already base16, of course. So there are your numbers.  

---

