Skip to content

Commit 31c0df0

Browse files
furszyfjahr
authored andcommitted
wallet: migration, write best locator before unloading wallet
1 parent 7e3dbe4 commit 31c0df0

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/wallet/wallet.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4398,6 +4398,11 @@ util::Result<MigrationResult> MigrateLegacyToDescriptor(const std::string& walle
43984398
return util::Error{_("Error: This wallet is already a descriptor wallet")};
43994399
}
44004400

4401+
// Flush chain state before unloading wallet
4402+
CBlockLocator locator;
4403+
WITH_LOCK(wallet->cs_wallet, context.chain->findBlock(wallet->GetLastBlockHash(), FoundBlock().locator(locator)));
4404+
if (!locator.IsNull()) wallet->chainStateFlushed(ChainstateRole::NORMAL, locator);
4405+
44014406
if (!RemoveWallet(context, wallet, /*load_on_start=*/std::nullopt, warnings)) {
44024407
return util::Error{_("Unable to unload the wallet before migrating")};
44034408
}

0 commit comments

Comments
 (0)