mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
wallet: migration, write best locator before unloading wallet
This commit is contained in:
parent
7e3dbe4180
commit
31c0df0389
1 changed files with 5 additions and 0 deletions
|
@ -4398,6 +4398,11 @@ util::Result<MigrationResult> MigrateLegacyToDescriptor(const std::string& walle
|
|||
return util::Error{_("Error: This wallet is already a descriptor wallet")};
|
||||
}
|
||||
|
||||
// Flush chain state before unloading wallet
|
||||
CBlockLocator locator;
|
||||
WITH_LOCK(wallet->cs_wallet, context.chain->findBlock(wallet->GetLastBlockHash(), FoundBlock().locator(locator)));
|
||||
if (!locator.IsNull()) wallet->chainStateFlushed(ChainstateRole::NORMAL, locator);
|
||||
|
||||
if (!RemoveWallet(context, wallet, /*load_on_start=*/std::nullopt, warnings)) {
|
||||
return util::Error{_("Unable to unload the wallet before migrating")};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue