Fix a couple of issues with -rescan#3796
Conversation
…er than we expected
|
Can you add a screenshot for c93b18d? |
|
@PastaPastaPasta sure, done. EDIT: this PR does not change any rpc, it's gui+cmd-line only (from user perspective). Dropped RPC label. |
|
You wouldn't call fa06123 RPC related? I guess it technically isn't... |
|
Hmmm... It's true that |
| bool res = GetPubKey(keyid, vchPubKey); | ||
| assert(res); // this should never fail |
There was a problem hiding this comment.
You don't use res really, would it be better to make this one line?
There was a problem hiding this comment.
We still need to call GetPubKey to get vchPubKey even when asserts are disabled. Technically, it shouldn't be possible to compile it that way (with -DNDEBUG) because of https://github.com/dashpay/dash/blob/master/src/validation.cpp#L61 but imo it's better to avoid introducing potential issues anyway.
| while (pindexRescan && walletInstance->nTimeFirstKey && (pindexRescan->GetBlockTime() < (walletInstance->nTimeFirstKey - TIMESTAMP_WINDOW))) { | ||
| pindexRescan = chainActive.Next(pindexRescan); | ||
| // unless a full rescan was requested | ||
| if (gArgs.GetArg("-rescan", 0) != 2) { |
There was a problem hiding this comment.
Say someone puts in -rescan=3 should this still be true?
It appears that |
oh, right 🙈 added RPC label back |
xdustinface
left a comment
There was a problem hiding this comment.
how about 4a0adc2?
Looks good to me, utACK
|
Ooops, deleted the wrong one 🙈 pls see #3828 |
When a wallet is created we set
nTimeFirstKey = GetTime()which allows-rescanto save time by fast-forwarding to a block around this time and ignoring all the older blocks. This works fine for non-HD wallets with random keys but HD wallets are special - because of their deterministic nature they might have keys which were used in txes before the wallet file was even created. This PR fixes it by updating key metadata when a key which appears to be used earlier than we expected is found db8b129 and by letting users to rescan from genesis block via-rescan=2fa06123. For qt users there is a new corresponding repair option on Repair tab c93b18d. I also tweakedCreateWalletFromFilelogs andgetwalletinforpc to make it easier to tracknTimeFirstKeychanges 2d2fb11.