From 17d453cb3a6fdbb0ebc8538c228c89712c989499 Mon Sep 17 00:00:00 2001 From: Ava Chow Date: Tue, 20 Feb 2024 11:50:11 -0500 Subject: [PATCH] wallet: Recompute wallet TXOs after descriptor migration When a legacy wallet has been migrated to contain descriptors, but before the transactions have been updated to match, we need to recompute the wallet TXOs so that the transaction update will work correctly. --- src/wallet/wallet.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 7d2e9eec766..373daed0916 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3901,6 +3901,10 @@ util::Result CWallet::ApplyMigrationData(WalletBatch& local_wallet_batch, return util::Error{_("Error: Unable to read wallet's best block locator record")}; } + // Update m_txos to match the descriptors remaining in this wallet + m_txos.clear(); + RefreshAllTXOs(); + // Check if the transactions in the wallet are still ours. Either they belong here, or they belong in the watchonly wallet. // We need to go through these in the tx insertion order so that lookups to spends works. std::vector txids_to_delete;