HomePhabricator

[Chronik] Add `/script/:type/:payload/utxos` HTTP endpoint

Description

[Chronik] Add /script/:type/:payload/utxos HTTP endpoint

Summary:
Allows to query the UTXOs of a script. This endpoint has no pagination as there's no obvious way to do it.

However, this endpoint is very fast, as it never reads the full tx off the disk, it only reads txid, block_height and is_coinbase, the remaining data is stored in the UTXOs (out_idx and value).

To decrease the size of ScriptUtxo protobuf messages, it doesn't contain the script directly (which would be the same for all UTXOs in the query anyway). Instead, it's in ScriptUtxos, for all UTXOs.

The allocated vector for the resulting UTXOs slightly over-allocates, by the number of DB UTXOs spent in the mempool. This could be fixed by counting the DB UTXOs spent in the mempool, but the added complexity doesn't seem worth it.

Depends on D13760 and D13761.

Test Plan: ninja && ./test/functional/test_runner.py chronik_script_utxos

Reviewers: Fabien, #bitcoin_abc

Reviewed By: Fabien, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D13763

Details

Provenance
tobias_ruckAuthored on Apr 24 2023, 15:38
tobias_ruckPushed on Apr 25 2023, 16:17
Reviewer
Restricted Project
Differential Revision
D13763: [Chronik] Add `/script/:type/:payload/utxos` HTTP endpoint
Parents
rABCe1b5f49026f5: [Chronik] Add `MempoolGroupUtxos` to store mempool UTXOs by group
Branches
Unknown
Tags
Unknown