Description
I'd very much appreciate the (RPC) command getrawtransaction to work on a pruned node. When I browse the rawmempool or the last X blocks, I'd love to be able to find out about what's gone on in these blocks.
I have not tried pruning my node to test getrawtransaction but I've read that the txindex (needed for getrawtransaction) is incompatible with getrawtransaction. Why?
Logically speaking I'd think I could browse and decode the X blocks (and transactions) that I do have stored. And if the block or transaction is not in my local database, could it not tell me something like: "this block does either not exist or it is not in your pruned version of the database"
Maybe there can be a prunedtxindex option or perhaps txindex can be made compatible with the pruned option.
Please tell me if this is technically possible or if it is not (if say old blocks need to be queried to decode a raw transaction)
Activity
RHavar commentedon Jun 16, 2017
getrawtransaction currently works with pruned nodes as long as the transaction has at least one unspent output. I believe this functionality is deprecated though.
The point of pruning is to throw away transactions that are no longer needed, and the point of txindex is to be able to search for old transactions by their transaction id. I'm not entirely sure these concepts are very compatible.
I guess it would be theoretically possible to have a txindex for all transactions that aren't pruned, but this seems a little weird.
BlackFoxController commentedon Jun 17, 2017
I'm currently reindexing and will have a look at the getrawtransaction method on a few recent transactions and see what it gets me.
I just want to be able to read recent (confirmed and unconfirmed) transactions without relying on a public blockchain API and without running a full node (150+GB is a big chain for me to store).
Is there any way to do this currently? In very essence, I want to create say, a webwallet that relies on a pruned local node and doesn't use it for a wallet.
maflcko commentedon Jun 18, 2017
Related: #3220
BlackFoxController commentedon Jun 19, 2017
With some testing I can confirm that any unspent recent tx (in my pruned database) are indeed visible, as mentioned in 3220.
Any spent tx seems to be unreadable.
Not sure about the rawmempool, but I assume it acts the same (spent unreadable, unspent readable).
Ideally getrawtransaction would also show me spent transactions but either way this is good enough for my use case.
But I do not think it's intended behaviour though as the documents say txindex and getrawtransaction should be incompatible. (keep it though! 👍 )
Sjors commentedon Dec 28, 2017
A pruned node currently has no way of knowing if a transaction hash doesn't exist or did exist but got pruned.
Maybe a pruned node can use some bloom-filter like data structure to hold on to the full set of pruned transaction ids? That way
getrawtransactioncan return a clear error message and state with confidence that a given transaction doesn't exist (false positives don't really matter in this scenario).Alternatively - easier -
getrawtransactionwould take asinceargument, required for pruned nodes, and throw an error ifsinceis lower than the prune depth.This suggestion is separate from the issue that
-txindex=1currently doesn't work with pruned nodes.jonasschnelli commentedon Jan 4, 2018
IMO
getrawtransaction, in disabled txindex mode, should not brows the blocks your have store locally because that could consume a serious amount of resources (assume you have pruned to 100GB). For that, a callsearchrawtransactionwould be more appropriate.Current master (next 0.16 release) will allow to fetch a transaction with
getrawtransactionfrom a specific block : #10275.maflcko commentedon Apr 28, 2020
Ok, closing for now.
Let me know if there are any remaining issues that need to be solved.