Pruned wallet support #9409

issue gmaxwell openend this issue on December 22, 2016
  1. gmaxwell commented at 9:13 pm on December 22, 2016: contributor

    This describes a proposed enhancement.

    With the ability to import keys without full rescan or load an old wallet without a rescan (e.g. with pruning), the user of a wallet is exposed to the possiblity that there will be wallet txn that they don’t know about.

    Even if the user intentionally put the wallet in this state, they may forget months later (esp. if managing multiple wallets).

    Failure to know about this can result funds loss (thinking keys don’t have funds when they do), and even if there is a UTXO scan, issues may remain: The user may falsely think they didn’t pay someone and then pay again, the user may falsely think they weren’t paid and falsely demand payment. The user might screw up their taxes or business records and get themselves in trouble. In short: “the wallet gives you a complete history of your transactions, except when it doesn’t” is a somewhat dangerous interface.

    I believe we can avoid these issues by establishing clear behavior.

    To do this we define a pruned wallet: A pruned wallet knows every wallet transaction up to height X, and before that only knows about coins.

    In the transaction list there would be a top most entry that says something like “Prior history not shown due to pruning” and perhaps a correcting ledger entry that showed the amount of coins available at the point of pruning. RPC would provide the pruning state via getwalletinfo and potentially a correcting ledger entry at the earliest point in listtransactions.

    Any wallet could be pruned to any height at any time. Any pruned wallet could be unpruned with a rescan.

    If you import keys in the UI or load a old wallet the GUI could prompt the user to allow rescan or prune– or if the age is beyond their blockchain prune depth, allow them to prune or abort.

    (or even rescan by fetching blocks … wee!)

    (Potentially a wallet could have an unknown pruned state where a notice is displayed that says it doesn’t know if its pruned or not, allowing the current behavior.)

    This would also be attractive to large commercial parties who have ended up with wallets that are hundreds of megs in size. (most of that is transaction data that would be eliminated by pruning)

    Some thought might be given to preserving labels for pruned transactions. They don’t take much space, and might just be worth preserving.

  2. fanquake added the label Wallet on Dec 23, 2016
  3. rebroad commented at 12:42 pm on December 23, 2016: contributor
    I like this idea… I’m also wondering if perhaps some of the code from the SPV-hybrid PR I saw recently could be used to optionally allow the user to fill in the blind spots either as SPV (open to abuse) or from a trusted/whitelisted node (e.g. I run a pruned node and a full-node, and I suspect I may not alone with this setup).
  4. da2ce7 commented at 2:43 pm on December 26, 2016: none

    From my issue (made in error without noticing this issue). I think that this is a very useful idea.

    (an proposed api):

    (in brackets optional arguments)

    Prune Wallet:

    • [integer: start block height] - Start Range (inclusive)
    • [integer: end block height] - End Range - (exclusive)
    • (boolean: test run, default: true) - Return transactions that would be removed, but don’t execute.
    • (boolean: keep unspent, default: true) - If transaction has unspent output, exclude from removal.
    • (list of txid: excluded transactions) - List of transactions that should be not removed.
    • (boolean: error if excluded txid not found, default: true) - If excluded txid not found, don’t continue.
  5. praxeology-guy commented at 1:48 pm on April 24, 2017: none

    Here is a proposed data structure that can handle working on utxo set data and works well with ryanofsky’s hybrid full/spv mode: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2017-April/014230.html

    To keep the historical data pruned, prune ranges would need to be stored in the wallet meta data as da2ce7 proposed.

  6. frankforte commented at 1:09 pm on December 15, 2017: none
    After a rescan, is the wallet meta data updated with the last scanned block? This way the next time that same wallet is imported, it can continue the scan from that block, rather than from the beginning? Sorry if I am misunderstanding how scans work.
  7. ryanofsky commented at 1:39 pm on December 15, 2017: contributor

    After a rescan, is the wallet meta data updated with the last scanned block?

    Yes, wallet saves the location of the last block it has data from (see https://github.com/bitcoin/bitcoin/blob/df7181952436a90a7f300f2b673321e2ac92ef56/src/wallet/walletdb.cpp#L116).

    When the wallet is running it will continually receive blocks from the network, and scan them for thansactions and update the last block. If it gets shut down and restarted it will automatically rescan starting from the last block.

  8. achow101 closed this on Dec 16, 2022

  9. bitcoin locked this on Dec 16, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-17 12:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me