Post
Topic
Board Development & Technical Discussion
Merits 3 from 3 users
Topic OP
How does dumptxoutset calculate txoutset_hash?
by
piotr_n
on 11/10/2024, 18:01:30 UTC
⭐ Merited by garlonicon (1) ,vjudeu (1) ,ABCbits (1)
I've been struggling to reproduce the hashing procedure used by the RPC command dumptxoutset (for the latest release 28.0).

I was hoping that maybe someone could give me a hint what I am doing wrong.

I am assuming that it is using the HASH_SERIALIZED type (not the mysterious MUHASH)

In which case, is should be just a simple SHA256 of all the "Coin" records, ordered like in the file created by dumptxoutset.

Looking at the source code, I think each record is like this:

Code:
32 bytes of TxID (in the same order as stored in memory)
4 bytes of VOut (little endian)
4 bytes of 2*block_heigh+coinbase  (little endian)
8 bytes of Amount (little endian)
the spending script (variable length)

So all he records go one-after-another and at the end I do another SHA256 on the result.

Unfortunately, this does not work, because I don't get the value from the "txoutset_hash" filed returned by dumptxoutset.

I wonder whether there is some kind of script_length filed between the Amount and the script itself?