{"action":"created","issue":{"url":"https://api.github.com/repos/bitcoin/bitcoin/issues/5389","labels_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/5389/labels{/name}","comments_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/5389/comments","events_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/5389/events","html_url":"https://github.com/bitcoin/bitcoin/pull/5389","id":50378921,"number":5389,"title":"[Wallet] Wallet-pruning","user":{"login":"cozz","id":2814559,"avatar_url":"https://avatars.githubusercontent.com/u/2814559?v=3","gravatar_id":"","url":"https://api.github.com/users/cozz","html_url":"https://github.com/cozz","followers_url":"https://api.github.com/users/cozz/followers","following_url":"https://api.github.com/users/cozz/following{/other_user}","gists_url":"https://api.github.com/users/cozz/gists{/gist_id}","starred_url":"https://api.github.com/users/cozz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cozz/subscriptions","organizations_url":"https://api.github.com/users/cozz/orgs","repos_url":"https://api.github.com/users/cozz/repos","events_url":"https://api.github.com/users/cozz/events{/privacy}","received_events_url":"https://api.github.com/users/cozz/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/bitcoin/bitcoin/labels/Wallet","name":"Wallet","color":"02d7e1"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":16,"created_at":"2014-11-28T14:25:02Z","updated_at":"2015-02-18T08:18:29Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/5389","html_url":"https://github.com/bitcoin/bitcoin/pull/5389","diff_url":"https://github.com/bitcoin/bitcoin/pull/5389.diff","patch_url":"https://github.com/bitcoin/bitcoin/pull/5389.patch"},"body":"Wallet pruning can be used to speed up and shrink large wallets.\r\n\r\nTransactions will only be removed, if this for sure does not affect your balance.\r\n\r\nRPC prunewallet(n) removes transactions older than n days (n >= 1). Or adding prunewallet=n to bitcoin.conf prunes on startup. Note that the latter is required to prevent rescan from readding the transactions.\r\n\r\nA transaction is pruned, if the following conditions are met\r\n- at least 100 confirmations\r\n- older than n days according to block-timestamp (n >= 1)\r\n- our outputs must be completely spent and also the spending transaction must\r\n  have at least 100 confirmations\r\n- the inputs we spent are also pruned/prunable transactions, so that they dont require us as a spent-flag anymore\r\n\r\nA new class STXO has been introduced, which loops over the last 100 blocks and builds a temporary recently-spent-outputs index.\r\nIts only used on rescan, if wallet pruning is enabled. This is necessary to answer the question\r\n\"has the spending transaction at least 100 confirmations?\".\r\nBecause if not, a rescan wants to always add the transaction to the wallet, and not skip.\r\nThis is because, when we rescan, we dont have the spending transaction anymore in the wallet, to check how many confirmations it has.\r\nAlso a rescan checks if spent or not in our coins-utxo, because the wallet does not know if spent or not while rescaning.\r\n\r\nNote that the feature is disabled if someone uses the account-feature. I could add support for this, but I am not bothering if our plan is to remove the account-feature. Because pruning as is, would destroy account-balances."},"comment":{"url":"https://api.github.com/repos/bitcoin/bitcoin/issues/comments/74827933","html_url":"https://github.com/bitcoin/bitcoin/pull/5389#issuecomment-74827933","issue_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/5389","id":74827933,"user":{"login":"arnuschky","id":179920,"avatar_url":"https://avatars.githubusercontent.com/u/179920?v=3","gravatar_id":"","url":"https://api.github.com/users/arnuschky","html_url":"https://github.com/arnuschky","followers_url":"https://api.github.com/users/arnuschky/followers","following_url":"https://api.github.com/users/arnuschky/following{/other_user}","gists_url":"https://api.github.com/users/arnuschky/gists{/gist_id}","starred_url":"https://api.github.com/users/arnuschky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arnuschky/subscriptions","organizations_url":"https://api.github.com/users/arnuschky/orgs","repos_url":"https://api.github.com/users/arnuschky/repos","events_url":"https://api.github.com/users/arnuschky/events{/privacy}","received_events_url":"https://api.github.com/users/arnuschky/received_events","type":"User","site_admin":false},"created_at":"2015-02-18T08:18:29Z","updated_at":"2015-02-18T08:18:29Z","body":"@gmaxwell: I don't really get this \"loss of financial information\" argument. All information is contained in the blockchain and can be recovered anytime with a rescan, or am I wrong here?\r\n\r\nOn the other hand, I think it is very reasonable to allow the user to decide to which extend the wallet stores/replicates information on past transactions. Especially as this functionality allows users to use the current wallet implementation for addresses with large amounts of transactions."}}