<blockquote>
  <p>my test transaction has a Base160 encoding, so according to my understanding it was sent to an address</p>
</blockquote>

<p>I guess you mean ripemd160 or base 16 (hexadecimal) rather than Base160. Ripemd160 is just a hashing algorithm so the output is just bytes, probably encoded in hex (base 16). You can guess it is a ripemd hash based on its length, but not based on its encoding, because the entire transaction is usually displayed in hex.</p>

<p>But to convert from a pubkey hash to an address, you also have to add the checksum onto the end, rather than just the version byte (the <code>0x00</code>). That is most likely why you are getting a different result, because you have no created a checksum before encoding it with base58.</p>

<p>See the steps outlined here for more info: <a href="https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses#How_to_create_Bitcoin_Address" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses#How_to_create_Bitcoin_Address</a></p>

CC BY-SA 3.0
2017-12-24T03:43:01.327Z
2017-12-24T03:43:01.327Z
meshcollider
<p>OK, I am sure that this is a really dumb, rookie question, so sorry in advance...
I am trying to read through the blockchain and display the receiving address(es) for all transactions in the chain. (Just like Blockchain-Explorer would do.) My library is NBitCoin in C#, so I am not really working through the raw data here. My starting point is the the Hash that is in the output transaction part (TxOut.ScriptPubKey.PaymentScript.Hash). I read in another post that in order to convert that Base160 encoded hash to a BitCoin address I would have to add 00 in front and then do a Base58 encode of the resulting array. So I did that:</p>

<p>Base58Encoding.Encode(ArrayHelpers.ConcatArrays(DoubleZero,TO.ScriptPubKey.PaymentScript.Hash.ToBytes()))</p>

<p>Then I took a sample and compared it with the output blockexplorer.com had for the same transaction, and unfortunately it didn't match. (And yes, I checked the comment made in this question (<a href="https://bitcoin.stackexchange.com/questions/14151/deriving-the-bitcoin-address-from-the-raw-block-script">Deriving the Bitcoin address from the raw block script</a>), my test transaction has a Base160 encoding, so according to my understanding it was sent to an address.
The hash is: caf74d35ff967c946f99588cb03b774350d83331
My generated output is: 13q1EyUVtUfvpixnYkDRoZUsi5ZVi
Blockexplorer.com shows: 16va6NxJrMGe5d2LP6wUzuVnzBBoKQZKom </p>

<p>Just for the sake of it I tried using all the other hashes in that ScriptPubKey block as well, but none yielded the result blockexplorer.com had. 
What am I missing here?
thx</p>

CC BY-SA 3.0
2017-10-15T09:09:58.020Z
I am not familiar with c#, but this looks to me as if you are not working on the hex representation of data. I usually check here: http://gobittest.appspot.com/Address, and when I enter in step9 your result, it shows the hash. Cleaning and re-entering the hash in step 3 results into a different address. I had a similiar problem with the shell scripts, look at the reply from Dave here: https://bitcoin.stackexchange.com/questions/46455/verifying-a-bitcoin-trx-on-the-unix-cmd-line-with-openssl
pebwindkraft
<address><raw-transaction><output>
NBitcoin: Get address out of raw block stream
AmbitiousScriptKiddy
# NBitcoin: Get address out of raw block stream

(Asked by: username_0 on 2017-10-14)

OK, I am sure that this is a really dumb, rookie question, so sorry in advance...
I am trying to read through the blockchain and display the receiving address(es) for all transactions in the chain. (Just like Blockchain-Explorer would do.) My library is NBitCoin in C#, so I am not really working through the raw data here. My starting point is the the Hash that is in the output transaction part (TxOut.ScriptPubKey.PaymentScript.Hash). I read in another post that in order to convert that Base160 encoded hash to a BitCoin address I would have to add 00 in front and then do a Base58 encode of the resulting array. So I did that:

Base58Encoding.Encode(ArrayHelpers.ConcatArrays(DoubleZero,TO.ScriptPubKey.PaymentScript.Hash.ToBytes()))

Then I took a sample and compared it with the output blockexplorer.com had for the same transaction, and unfortunately it didn't match. (And yes, I checked the comment made in this question ([Deriving the Bitcoin address from the raw block script](https://bitcoin.stackexchange.com/questions/14151/deriving-the-bitcoin-address-from-the-raw-block-script)), my test transaction has a Base160 encoding, so according to my understanding it was sent to an address.
The hash is: caf74d35ff967c946f99588cb03b774350d83331
My generated output is: 13q1EyUVtUfvpixnYkDRoZUsi5ZVi
Blockexplorer.com shows: 16va6NxJrMGe5d2LP6wUzuVnzBBoKQZKom

Just for the sake of it I tried using all the other hashes in that ScriptPubKey block as well, but none yielded the result blockexplorer.com had.
What am I missing here?
thx

**Tags:** address, raw-transaction, output

> **Comments:**
> **username_1**: I am not familiar with c#, but this looks to me as if you are not working on the hex representation of data. I usually check here: http://gobittest.appspot.com/Address, and when I enter in step9 your result, it shows the hash. Cleaning and re-entering the hash in step 3 results into a different address. I had a similiar problem with the shell scripts, look at the reply from Dave here: https://bitcoin.stackexchange.com/questions/46455/verifying-a-bitcoin-trx-on-the-unix-cmd-line-with-openssl  

---

## 1 answers

### Answer by username_2 on 2017-12-24. Score: 1

> my test transaction has a Base160 encoding, so according to my understanding it was sent to an address

I guess you mean ripemd160 or base 16 (hexadecimal) rather than Base160. Ripemd160 is just a hashing algorithm so the output is just bytes, probably encoded in hex (base 16). You can guess it is a ripemd hash based on its length, but not based on its encoding, because the entire transaction is usually displayed in hex.

But to convert from a pubkey hash to an address, you also have to add the checksum onto the end, rather than just the version byte (the `0x00`). That is most likely why you are getting a different result, because you have no created a checksum before encoding it with base58.

See the steps outlined here for more info: <https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses#How_to_create_Bitcoin_Address>


---

