Bugfix: if no bestblock record is present, do a -rescan #2603

pull sipa wants to merge 1 commits into bitcoin:master from sipa:nobestblock changing 1 files +4 −0
  1. sipa commented at 5:37 PM on May 1, 2013: member

    It is possible to have a wallet.dat file without any bestblock record at all (if created offline, for example), which - when loaded into a client with a up-to-date chain - does no rescan and shows no transactions.

    Also make sure to write the current best block after a rescan, so it isn't necessary twice.

  2. Bugfix: if no bestblock record is present, do a -rescan
    It is possible to have a wallet.dat file without any bestblock
    record at all (if created offline, for example), which - when
    loaded into a client with a up-to-date chain - does no rescan and
    shows no transactions.
    
    Also make sure to write the current best block after a rescan, so
    it isn't necessary twice.
    2aceeb01a9
  3. BitcoinPullTester commented at 6:11 PM on May 1, 2013: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/2aceeb01a9b0b0c6bfa0d56211453e87bc33d6e4 for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.

  4. gavinandresen commented at 6:40 PM on May 2, 2013: contributor

    ACK.

    Tested by removing the bestblock record from a -testnet wallet.

  5. laanwj commented at 9:03 PM on May 3, 2013: member

    ACK

  6. sipa referenced this in commit aa6b3061ee on May 3, 2013
  7. sipa merged this on May 3, 2013
  8. sipa closed this on May 3, 2013

  9. sipa deleted the branch on May 3, 2013
  10. petertodd commented at 8:07 AM on May 20, 2013: contributor

    Looks like if you delete your wallet after Bitcoin creates the new one it triggers a rescan of every block.

  11. sipa commented at 10:27 PM on May 20, 2013: member

    Indeed, I'll look at this. It's not a regression though, before there was just a chance of missing stuff, as no accurate bestblock was written either.

    The solution is doing an explicit write of the bestblock record at wallet unload/exit time.

  12. gmaxwell commented at 10:35 PM on May 20, 2013: contributor

    If we knew the bestblock at the time we created the wallet (I don't think we've loaded the chain at that point) it would be simple to just have it set the best block to be the current best block when creating it.

  13. gmaxwell commented at 12:56 AM on May 21, 2013: contributor

    Another possible fix is doing the key birthday thing and using the min(birthday) to control the rescan.

  14. sipa commented at 1:08 AM on May 21, 2013: member

    @gmaxwell That'd be a nice improvement, but doesn't change the fact that we need to write updated bestblock records more frequently to avoid spurious rescans.

  15. laudney referenced this in commit b4dfe498ac on Mar 19, 2014
  16. DrahtBot locked this on Sep 8, 2021

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-19 09:15 UTC

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