mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-02 17:56:16 +00:00
Adds an outpoint -> txid index, which can be used to find which transactions spent a given output. We use a composite key with 2 parts (suggested by @romanz): hash(spent outpoint) and tx position, with an empty value. To find the spending tx for a given outpoint, we do a prefix search (prefix being the hash of the provided outpoint), and for all keys that match this prefix we load the tx at the position specified in the key and return it, along with the block hash, if does spend the provided outpoint. To handle reorgs we just erase the keys computed from the removed block. This index is extremely useful for Lightning and more generally for layer-2 protocols that rely on chains of unpublished transactions. If enabled, this index will be used by `gettxspendingprevout` when it does not find a spending transaction in the mempool.
676 B
676 B
New settings
-txospenderindexenables the creation of a transaction output spender index that, if present, will be scanned bygettxspendingprevoutif a spending transaction was not found in the mempool. (#24539)
Updated RPCs
gettxspendingprevouthas 2 new optional arguments:mempool_onlyandreturn_spending_tx. Ifmempool_onlyis true it will limit scans to the mempool even iftxospenderindexis available. Ifreturn_spending_txis true, the full spending tx will be returned. In addition iftxospenderindexis available and a confirmed spending transaction is found, its block hash will be returned. (#24539)