I suspect there is no good way to do it.
However is there any sub-optimal way to find the transaction that spends a transaction output (knowing the txid
and index
) with Bitcoin RPC?
Assuming txindex=1
and prune=0
.
This was the more general question. In my case:
- When I receive the TXO, it's actually an UTXO.
- I am only interested in confirmed transactions.
The only way I can come up with to answer both questions is iterating through all the transactions of all the blocks from the TXO's block to the last received block and the mempool. Or in my case, I don't mind the mempool.
Nevertheless this is cumbersome and likely I'd be better off with some kind of indexer. Is there better way to do it with RPC?
getrawtransaction
in my sub-optimal solution. It doesn't tell you which tx spends the txos of the transaction, but it tells you which block contains the transaction. – nopara73 Nov 02 '17 at 12:02txid
-index
pair. My point is, if I have a transaction, then based on thevin[]
one can track all transaction down backwards all the way to the coinbase, sincevin[]
has previous outputs (txid
-index
pairs). While the reverse does not work: from thevout[]
I cannot go forward, sincevout[]
isamount
-scriptPubKey
pairs.spending_outpoints.tx_index
onhttps://blockchain.info/tx/$tx_index_or_txid?format=json
– Ciro Santilli OurBigBook.com Mar 25 '24 at 20:46