mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-05 10:42:13 +02:00
Merge bitcoin/bitcoin#24539: Add a "tx output spender" index
0b96b9c600Minimize mempool lock, sync txo spender index only when and if needed (sstone)3d82ec5bddAdd a "tx output spender" index (sstone) Pull request description: This PR adds a new "tx output spender" index, which allows users to query which tx spent a given outpoint with the `gettxspendingprevout` RPC call that was added by https://github.com/bitcoin/bitcoin/pull/24408. Such an index would be extremely useful for Lightning, and probably for most layer-2 protocols that rely on chains of unpublished transactions. UPDATE: this PR is ready for review and issues have been addressed: - using a watch-only wallet instead would not work if there is a significant number of outpoints to watch (see https://github.com/bitcoin/bitcoin/pull/24539#issuecomment-1276595646) - this PR does not require `-txindex` anymore We use a composite key with 2 parts (suggested by romanz): hash(spent outpoint) and tx position, with an empty value. Average composite key size is 15 bytes. The spending tx can optionally be returned by `gettxspendingprevout` (even it `-txindex is not set`). ACKs for top commit: hodlinator: re-ACK0b96b9c600sedited: Re-ACK0b96b9c600fjahr: ACK0b96b9c600w0xlt: reACK0b96b9c600Tree-SHA512: 95c2c313ef4086e7d5bf1cf1a3c7b91cfe2bb1a0dcb4c9d3aa8a6e5bfde66aaca48d85a1f1251a780523c3e4356ec8a97fe6f5c7145bc6ccb6f820b26716ae01
This commit is contained in:
@@ -55,6 +55,7 @@ Subdirectory | File(s) | Description
|
||||
`blocks/` | `xor.dat` | Rolling XOR pattern for block and undo data files
|
||||
`chainstate/` | LevelDB database | Blockchain state (a compact representation of all currently unspent transaction outputs (UTXOs) and metadata about the transactions they are from)
|
||||
`indexes/txindex/` | LevelDB database | Transaction index; *optional*, used if `-txindex=1`
|
||||
`indexes/txospenderindex/` | LevelDB database | Transaction spender index; *optional*, used if `-txospenderindex=1`
|
||||
`indexes/blockfilter/basic/db/` | LevelDB database | Blockfilter index LevelDB database for the basic filtertype; *optional*, used if `-blockfilterindex=basic`
|
||||
`indexes/blockfilter/basic/` | `fltrNNNNN.dat`<sup>[\[2\]](#note2)</sup> | Blockfilter index filters for the basic filtertype; *optional*, used if `-blockfilterindex=basic`
|
||||
`indexes/coinstatsindex/db/` | LevelDB database | Coinstats index; *optional*, used if `-coinstatsindex=1`
|
||||
|
||||
14
doc/release-notes-24539.md
Normal file
14
doc/release-notes-24539.md
Normal file
@@ -0,0 +1,14 @@
|
||||
New settings
|
||||
------------
|
||||
- `-txospenderindex` enables the creation of a transaction output spender
|
||||
index that, if present, will be scanned by `gettxspendingprevout` if a
|
||||
spending transaction was not found in the mempool.
|
||||
(#24539)
|
||||
|
||||
Updated RPCs
|
||||
------------
|
||||
- `gettxspendingprevout` has 2 new optional arguments: `mempool_only` and `return_spending_tx`.
|
||||
If `mempool_only` is true it will limit scans to the mempool even if `txospenderindex` is available.
|
||||
If `return_spending_tx` is true, the full spending tx will be returned.
|
||||
In addition if `txospenderindex` is available and a confirmed spending transaction is found,
|
||||
its block hash will be returned. (#24539)
|
||||
Reference in New Issue
Block a user