Fix bug where rescan doesn't do a full rescan #5774

pull RHavar wants to merge 1 commits into bitcoin:master from RHavar:master changing 4 files +15 −10
  1. RHavar commented at 11:13 PM on February 8, 2015: contributor

    No description provided.

  2. Fix bug where rescan doesn't do a full rescan 425473c056
  3. gmaxwell commented at 11:20 PM on February 8, 2015: contributor

    I don't understand the motivation here. Rescan should not pointlessly scan blocks prior to key creation times. If there is some reason that creation times are being set incorrectly that must be fixed, not papered over with a bypass in rescan.

    If you update the patch, please make sure the commit message explains the motivation for the change.

  4. RHavar commented at 11:36 PM on February 8, 2015: contributor

    I guess there's two issues: the first being I think when someone starts bitcoin with -rescan it should scan every block, as that is the safest behaviour and the one of least surprise.

    The second issue, which I guess is not addressed by this pull request is someone does: bitcoin-cli importprivkey $PRIV_KEY "" false

    and then restarts bitcoind (with or without -rescan) it will only start scanning at the earliest key creation time, which may very well be after the key was used. Bitcoin should probably persist something into the wallet letting it know it needs to rescan from block 0, but I'm not familiar enough with the code to do this.

  5. laanwj added the label Wallet on Feb 9, 2015
  6. laanwj commented at 10:12 AM on February 9, 2015: member

    As with many wallet behaviors, it is not documented (nor tested) what the behavior should be, so people give their own interpretation what it should be and try to fix it according to that. Not sure how to go forward here as there is clear disagreement.

    I don't think it makes sense to assume the user wants to rescan from block 0 on next restarts, eg people import keys that are newly generated and don't need rescans at all.

  7. RHavar commented at 2:36 PM on February 9, 2015: contributor

    I guess two things to support my interpretation:

    • If I want to do a full scan (bad address seen date, importing without scanning), right now I'm forced to go bitcoin-cli importprivkey $RANDOMPRIVKEY to force the wallet to do a full scan. But bitcoind -rescan doesn't work. Strange, no?
    • When running bitcoind -rescan the logs even say that it's scanning from the genesis block: https://github.com/bitcoin/bitcoin/blob/425473c056424574f73935add3f110fbce770273/src/init.cpp#L1229 which to me would indicate, that the intention of rescan is to actually rescan everything.
    • I believe I might have already lost some coins due to bitcoind's behaviour. My usage pattern has been this: bitcoin-cli importprivkey $PRIVKEY1 "" false bitcoin-cli importprivkey $PRIVKEY2 "" false ...for all dozens of private keys I have..

    and then finally:

    bitcoind -rescan

    The only reason I caught it this time, was because I knew i was missing a sizable amount of coins.

    I don't think it makes sense to assume the user wants to rescan from block 0 on next restarts eg people import keys that are newly generated and don't need rescans at all.

    Those people don't run with bitcoind -rescan

  8. gmaxwell commented at 3:31 PM on February 9, 2015: contributor

    The -rescan option really shouldn't exist at all. It mostly only remains as historical inertia. The ability to run it has a marginal disk cost of 30+GBytes. Keeping it around has (apparently!) allowed serious birthdate tracking bugs to persist.

    In any case, the interface is never obligated to perform some behavior which should be indistinguishable from the perspective of the user. I think the behavior you're looking for would be one to wipe out the birthdays, not a change in rescan behavior.

  9. laanwj commented at 12:18 PM on February 18, 2015: member

    Agree with @gmaxwell.

    • If you need behavior that clears the birthdays, add an option to clear the birthdays.
    • If you need importprivkey to be able to set the birthday for your imported key, add an argument to importprivkey with the birthdate. This makes it possible to distinguish importing a new key and an old key, and tells the client from when to rescan

    We're not trying to deny that there is an issue here. Right now importprivkey is ambiguous. We just don't agree on this fix.

  10. laanwj closed this on Feb 26, 2015

  11. MarcoFalke locked this on Sep 8, 2021
Labels

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: 2026-04-13 15:15 UTC

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