Author

Topic: How does dumptxoutset calculate txoutset_hash? (Read 58 times)

legendary
Activity: 2053
Merit: 1356
aka tonikt
October 11, 2024, 03:34:48 PM
#2
Never mind, already figured it out.

There is a variable length filed between the amount and the script.

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)
var_len byte length of the following script
the spending script (uncompressed, variable length, as stored in memory)
legendary
Activity: 2053
Merit: 1356
aka tonikt
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 written to the hasher 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 (uncompressed, variable length, as stored in memory)

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?
Jump to: