Merge bitcoin/bitcoin#26282: wallet: have prune error take precedence over assumedvalid

1c36bafc5f wallet: have prune error take precedence over assumedvalid (James O'Beirne)

Pull request description:

  Fixes https://github.com/bitcoin/bitcoin/pull/23997#discussion_r891412739.

  From Russ Yanofsky:

  > Agree with all of Marco's points here and think this should be updated
  >
  > If havePrune and hasAssumedValidChain are both true, better to show havePrune error message.  Assumed-valid error message is vague and not very actionable.  Would suggest "Error loading wallet. Wallet requires blocks to be downloaded, and software does not currently support loading wallets while blocks are being downloaded out of order though assumeutxo snapshots. Wallet should be able to load successfully after node sync reaches height {block_height}"

ACKs for top commit:
  MarcoFalke:
    ACK 1c36bafc5f
  aureleoules:
    ACK 1c36bafc5f

Tree-SHA512: bfb0024bb962525cbbd392ade3c0331a8b0525e7f2f2ab52b2dbb9b6dd6311070d85ecb762a7689db84a30991971865698ab6fec187206e6a92133790c5a91dc
This commit is contained in:
fanquake 2022-10-10 16:52:06 +08:00
commit 869342f7fa
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1

View file

@ -3111,12 +3111,14 @@ bool CWallet::AttachChain(const std::shared_ptr<CWallet>& walletInstance, interf
// If a block is pruned after this check, we will load the wallet,
// but fail the rescan with a generic error.
error = chain.hasAssumedValidChain() ?
_(
"Assumed-valid: last wallet synchronisation goes beyond "
"available block data. You need to wait for the background "
"validation chain to download more blocks.") :
_("Prune: last wallet synchronisation goes beyond pruned data. You need to -reindex (download the whole blockchain again in case of pruned node)");
error = chain.havePruned() ?
_("Prune: last wallet synchronisation goes beyond pruned data. You need to -reindex (download the whole blockchain again in case of pruned node)") :
strprintf(_(
"Error loading wallet. Wallet requires blocks to be downloaded, "
"and software does not currently support loading wallets while "
"blocks are being downloaded out of order when using assumeutxo "
"snapshots. Wallet should be able to load successfully after "
"node sync reaches height %s"), block_height);
return false;
}
}