Dumplings icon indicating copy to clipboard operation
Dumplings copied to clipboard

Use `dumptxoutset` instead of `gettxout`?

Open kristapsk opened this issue 11 months ago • 0 comments

Currently Dumplings is doing a lot of gettxout calls to Bitcoin Core / Knots to check each TXO individually. It would probably be a lot faster to use dumptxoutset instead, then load it in memory and then query that data instead. But it would require bitcoind and Dumplings running on the same machine, which is probably ok tradeoff.

It was implemented in https://github.com/bitcoin/bitcoin/pull/16899.

$ bitcoin-cli help dumptxoutset
dumptxoutset "path" ( format show_header "separator" )

Write the UTXO set to disk.

Arguments:
1. path                   (string, required) Path to the output file. If relative, will be prefixed by datadir.
2. format                 (json array, optional, default=compact serialized format) If no argument is provided, a compact binary serialized format is used; otherwise only requested items available below are written in ASCII format (if an empty array is provided, all items are written in ASCII).
     [
       "txid",            (string) Info to write for a given UTXO
       "vout",            (string) Info to write for a given UTXO
       "value",           (string) Info to write for a given UTXO
       "coinbase",        (string) Info to write for a given UTXO
       "height",          (string) Info to write for a given UTXO
       "scriptPubKey",    (string) Info to write for a given UTXO
       ...
     ]
3. show_header            (boolean, optional, default=true) Whether to include the header line in non-serialized (ASCII) mode
4. separator              (string, optional, default=",") Field separator to use in non-serialized (ASCII) mode

Result:
{                             (json object)
  "coins_written" : n,        (numeric) the number of coins written in the snapshot
  "base_hash" : "hex",        (string) the hash of the base of the snapshot
  "base_height" : n,          (numeric) the height of the base of the snapshot
  "path" : "str",             (string) the absolute path that the snapshot was written to
  "txoutset_hash" : "hex",    (string) the hash of the UTXO set contents
  "nchaintx" : n              (numeric) the number of transactions in the chain up to and including the base block
}

Examples:
> bitcoin-cli dumptxoutset utxo.dat
> bitcoin-cli dumptxoutset utxo.dat '[]'
> bitcoin-cli dumptxoutset utxo.dat '["txid", "vout"]' false ':'

kristapsk avatar Sep 08 '23 14:09 kristapsk