<p>Your address <code>32feVAD9Haq1CtfT6JCLTt4L5qef3UnVpY</code> is a P2SH mainnet address, with a <code>05</code> address prefix and represents the base58 encoding of the following data:</p>

<ul>
<li><code>[05][20-byte hash][4-byte checksum]</code></li>
</ul>

<p>So, the <code>[05]</code> prefix tells your wallet that your address represents a P2SH embedded script presage (20B). </p>

<p>On the other hand, a <code>[00]</code> prefix tells your wallet that the 20B digest represents a Public-Key-Hash, and that funds should be sent to a P2PKH (Pay-2-Public-Key-Hash) output.</p>

<p>The version number therefore gives your wallet the necessary information to produce the correct output type when sending funds, so that the recipient has the private keys (P2PKH) or presage (P2SH) to spend them. </p>

<p>The <code>05</code> prefix translates to a <code>3</code> in base58 encoding, which is why your addresses begin with 3. I cannot comment on what the embedded script type is though, since the P2SH has is simply the 20B hash-digest thereof. Perhaps a P2SH(P2WPKH) script type.</p>

<p><strong>Amended Answer:</strong></p>

<p>To determine the address version appropriate for a specific output from a transaction, simply look at the output script in question.</p>

<ul>
<li>P2PKH: <code>"hash160 [20B] equal"</code> -> version 5</li>
<li>P2SH: <code>"dup hash160 [20B] equalverify checksig"</code> -> version 0</li>
<li>P2WPKH: <code>"[00] [20B]"</code> -> bech32 address</li>
</ul>

CC BY-SA 4.0
2019-01-14T09:47:54.240Z
Thank you for response. Bx explorer returns address_hash as shown above, but my problem is how to correct determine version from bx response. Other blockexplorers like blockchain.info or bitpay insight shows right address, so there is a way to determine the right version. Miss I anything?
Ramirez
CC BY-SA 4.0
2019-01-14T09:50:31.097Z
You mean how to decode the version from an address, such as 32feVAD9Haq1CtfT6JCLTt4L5qef3UnVpY? Try bx address-decode 32feVAD9Haq1CtfT6JCLTt4L5qef3UnVpY
James C.
CC BY-SA 4.0
2019-01-14T09:55:16.370Z
No. I want to use bx fetch-tx result to generate address. It returns address_hash and bx base58check-encode returns address. But only with right version choosen it leads to the right address. My problem is to determine the right version.
Ramirez
CC BY-SA 4.0
2019-01-14T10:12:09.983Z
I see. You have to examine the output scripts when you fetch the tx. The output script pattern (P2SH or P2PKH etc.) will tell you what version is required (05 or 00 etc.). BX doesn't recognise script patterns for you. Libbitcoin-System has internal methods which check for standard output script patterns, if you want to look into the Libbitcoin C++ library.
James C.
CC BY-SA 4.0
2019-01-14T19:05:13.847Z
If this answer helped u, your up/downvote/check would be appreciated either way. Thank you.
James C.
CC BY-SA 4.0
2019-01-14T09:26:26.787Z
2019-01-14T10:26:37.337Z
2019-01-14T10:26:37.337Z
James C.
<p>I'm using private libbitcoin server and libbitcoin explorer.
When I use bx fetxh-transaction, it returns something like: </p>

<p><a href="https://i.sstatic.net/Zmafk.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Zmafk.png" alt="enter image description here"></a></p>

<p>I'm trying to figure out, how to get right address from address_hash.
When I use bx base58check-encode for input address_hash without version (or -v 0) it returns:</p>

<p><a href="https://i.sstatic.net/9X4EO.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/9X4EO.png" alt="enter image description here"></a></p>

<p>When I use bx base58check-encode -v 5 it returns:</p>

<p><a href="https://i.sstatic.net/gsMQo.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/gsMQo.png" alt="enter image description here"></a></p>

<p>Check by <a href="https://blockexplorer.com/tx/51cc10772f9370a9fcab6f4b4f99cd8df8164f5c9f39ac81171c4453e491fbe0" rel="nofollow noreferrer">blockexplorer</a> shows the second way is right.
My question is: How to determine base58check-encode version to generate right address?</p>

<p>Thank you.</p>

<transactions><address><hash><libbitcoin>
How to determine right address from address hash
Ramirez
# How to determine right address from address hash

(Asked by: username_0 on 2019-01-14)

I'm using private libbitcoin server and libbitcoin explorer.
When I use bx fetxh-transaction, it returns something like:

[![enter image description here](https://i.sstatic.net/Zmafk.png)](https://i.sstatic.net/Zmafk.png)

I'm trying to figure out, how to get right address from address\_hash.
When I use bx base58check-encode for input address\_hash without version (or -v 0) it returns:

[![enter image description here](https://i.sstatic.net/9X4EO.png)](https://i.sstatic.net/9X4EO.png)

When I use bx base58check-encode -v 5 it returns:

[![enter image description here](https://i.sstatic.net/gsMQo.png)](https://i.sstatic.net/gsMQo.png)

Check by [blockexplorer](https://blockexplorer.com/tx/51cc10772f9370a9fcab6f4b4f99cd8df8164f5c9f39ac81171c4453e491fbe0) shows the second way is right.
My question is: How to determine base58check-encode version to generate right address?

Thank you.

**Tags:** transactions, address, hash, libbitcoin


---

## 1 answers

### Answer by username_1 on 2019-01-14. Score: 2 | Accepted answer

Your address `32feVAD9Haq1CtfT6JCLTt4L5qef3UnVpY` is a P2SH mainnet address, with a `05` address prefix and represents the base58 encoding of the following data:

* `[05][20-byte hash][4-byte checksum]`

So, the `[05]` prefix tells your wallet that your address represents a P2SH embedded script presage (20B).

On the other hand, a `[00]` prefix tells your wallet that the 20B digest represents a Public-Key-Hash, and that funds should be sent to a P2PKH (Pay-2-Public-Key-Hash) output.

The version number therefore gives your wallet the necessary information to produce the correct output type when sending funds, so that the recipient has the private keys (P2PKH) or presage (P2SH) to spend them.

The `05` prefix translates to a `3` in base58 encoding, which is why your addresses begin with 3. I cannot comment on what the embedded script type is though, since the P2SH has is simply the 20B hash-digest thereof. Perhaps a P2SH(P2WPKH) script type.

**Amended Answer:**

To determine the address version appropriate for a specific output from a transaction, simply look at the output script in question.

* P2PKH: `"hash160 [20B] equal"` -> version 5
* P2SH: `"dup hash160 [20B] equalverify checksig"` -> version 0
* P2WPKH: `"[00] [20B]"` -> bech32 address

> **Comments:**
> **username_0**: Thank you for response. Bx explorer returns address_hash as shown above, but my problem is how to correct determine version from bx response. Other blockexplorers like blockchain.info or bitpay insight shows right address, so there is a way to determine the right version. Miss I anything?  
> **username_1**: You mean how to decode the version from an address, such as 32feVAD9Haq1CtfT6JCLTt4L5qef3UnVpY? Try bx address-decode 32feVAD9Haq1CtfT6JCLTt4L5qef3UnVpY  
> **username_0**: No. I want to use bx fetch-tx result to generate address. It returns address_hash and bx base58check-encode returns address. But only with right version choosen it leads to the right address. My problem is to determine the right version.  
> **username_1**: I see. You have to examine the output scripts when you fetch the tx. The output script pattern (P2SH or P2PKH etc.) will tell you what version is required (05 or 00 etc.). BX doesn't recognise script patterns for you. Libbitcoin-System has internal methods which check for standard output script patterns, if you want to look into the Libbitcoin C++ library.  
> **username_1**: If this answer helped u, your up/downvote/check would be appreciated either way. Thank you.  

---

