Pages:
Author

Topic: "Easy way" to extract the UTXO from Bitcoin Core? - page 2. (Read 3844 times)

donator
Activity: 1218
Merit: 1080
Gerald Davis
I am not sure about this specific implementation, but normally UTXO database is just a database: keys => records

Keys are usually txid+vout, while records contain at least value+pk_script, though usually also things like block_height, etc.

In case of Bitcon Core, it should be the same, so I'd say: use any LevelDB engine to load the DB and browse through it - that should be exactly what you need.
The format of the records should not be hard to figure out.

My post above was posted while you were typing but that makes a lot of sense.  It is very likely the UXTO reported is just the key (hash & index) that would coincide with the reported size.  So the question becomes which file is the UXTO index stored in?

On edit:
Quote
chainstate subdirectory
[v0.8 and above] A LevelDB database with a compact representation of all currently unspent transaction outputs and some metadata about the transactions they are from. The data here is necessary for validating new incoming blocks and transactions. It can theoretically be rebuilt from the block data (see the -reindex command line option), but this takes a rather long time. Without it, you could still theoretically do validation indeed, but it would mean a full scan through the blocks (7 GB as of may 2013) for every output being spent.

Ok so here is where to start.  Lets see if I can decode it.  Thanks.   Would be nice if the format structure was reported somewhere other than just in the code.
donator
Activity: 1218
Merit: 1080
Gerald Davis
On a related note what is the "bytes serialized" representing.  393434666 / 11337577 = ~35 bytes per output.   The tx hash (32 bytes) and output index (1-2 bytes) would be 33 to 34 bytes right there.  Is it just referring to the index? Or is it just referring the raw output data (value & script) not the lookup values?  It can't be the full set as that would be closer to

To validate an the input of an arbitrary tx isn't the following needed?
tx_out_hash (32 bytes)
tx_out_index (4 bytes)
value (8 bytes)
script_len (variant - usually 1 byte)
script (variable - 25 bytes for P2PKH outputs which make up 90%+ of UXTO)
That is 70 bytes minimum, so for 11,337,577 outputs the UXTO would be a minimum of 794MB right?  What am I missing?
legendary
Activity: 2058
Merit: 1416
aka tonikt
I am not sure about this specific implementation, but normally UTXO database is just a database: keys => records

Keys are usually txid+vout, while records contain at least value+pk_script, though usually also things like block_height, etc.

In case of Bitcon Core, it should be the same, so I'd say: use any LevelDB engine to load the DB and browse through it - that should be exactly what you need.
The format of the records should not be hard to figure out.
donator
Activity: 1218
Merit: 1080
Gerald Davis
Is there a relatively easy way to extract the UTXO from Bitcoin Core?

Code:
{
"height" : 305134,
"bestblock" : "00000000000000003f0bb243b026fa904946f262eebf0684614ebb2622e4e554",
"transactions" : 3304525,
"txouts" : 11337577,
"bytes_serialized" : 393434666,
"hash_serialized" : "4132c6a9bdb7f2492348ba9cf8ca1c1fb954f619805de0c3cd01847f969ece65",
"total_amount" : 12878214.79102854
}

I would like the set of these 11,337,577 outputs so they can be parsed and dumped into a database for analysis.  Any links to information or relevant code on how Bitcoin-Core stores the UTXO?  I understand I could use a blockchain parser to build the UTXO and that is probably happening next (as I want to see how it has changed over time) but a dump would be a good start.  Even just a dump of the index (tx_out_hash & tx_out_index) would be great.
Pages:
Jump to: