Skip to content

Feature request: pruned chain and getrawtransaction #10609

Closed

Description

@BlackFoxController

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

  1. RHavar commented on Jun 16, 2017

    @RHavar
    Contributor

    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.

  2. BlackFoxController commented on Jun 17, 2017

    @BlackFoxController
    Author

    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.

  3. maflcko commented on Jun 18, 2017

    @maflcko
    Member

    Related: #3220

  4. BlackFoxController commented on Jun 19, 2017

    @BlackFoxController
    Author

    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! 👍 )

  5. Sjors commented on Dec 28, 2017

    @Sjors
    Member

    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 getrawtransaction can 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 - getrawtransaction would take a since argument, required for pruned nodes, and throw an error if since is lower than the prune depth.

    This suggestion is separate from the issue that -txindex=1 currently doesn't work with pruned nodes.

  6. jonasschnelli commented on Jan 4, 2018

    @jonasschnelli
    Contributor

    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 call searchrawtransaction would be more appropriate.

    Current master (next 0.16 release) will allow to fetch a transaction with getrawtransaction from a specific block : #10275.

  7. maflcko commented on Apr 28, 2020

    @maflcko
    Member

    Current master (next 0.16 release) will allow to fetch a transaction with getrawtransaction from a specific block : #10275.

    Ok, closing for now.

    Let me know if there are any remaining issues that need to be solved.

  8. locked as resolved and limited conversation to collaborators on Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions