• Welcome to forex.pm forex forum binary options trade. Please login or sign up.
 

NBitcoin: Get address out of raw block stream

Started by Bitcoin, Mar 25, 2022, 06:27 am

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bitcoin

NBitcoin: Get address out of raw block stream

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), 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


Source: NBitcoin: Get address out of raw block stream