wallet: Recalculate the wallet's txos after any imports

This commit is contained in:
Ava Chow committed 2025-06-25 14:08:49 -07:00
1 parent ae888c38d0
commit 96e7a89c5e
4 files changed
+12

No files matched your search

+1
View File
@@ -250,6 +250,7 @@ RPCHelpMan keypoolrefill()
if (pwallet->GetKeyPoolSize() < kpSize) { if (pwallet->GetKeyPoolSize() < kpSize) {
throw JSONRPCError(RPC_WALLET_ERROR, "Error refreshing keypool."); throw JSONRPCError(RPC_WALLET_ERROR, "Error refreshing keypool.");
} }
pwallet->RefreshAllTXOs();
return UniValue::VNULL; return UniValue::VNULL;
}, },
+1
View File
@@ -394,6 +394,7 @@ RPCHelpMan importdescriptors()
} }
} }
pwallet->ConnectScriptPubKeyManNotifiers(); pwallet->ConnectScriptPubKeyManNotifiers();
pwallet->RefreshAllTXOs();
} }
// Rescan the blockchain using the lowest timestamp // Rescan the blockchain using the lowest timestamp
+8
View File
@@ -4451,4 +4451,12 @@ void CWallet::RefreshTXOsFromTx(const CWalletTx& wtx)
} }
} }
} }
void CWallet::RefreshAllTXOs()
{
AssertLockHeld(cs_wallet);
for (const auto& [_, wtx] : mapWallet) {
RefreshTXOsFromTx(wtx);
}
}
} // namespace wallet } // namespace wallet
+2
View File
@@ -525,6 +525,8 @@ public:
/** Cache outputs that belong to the wallet from a single transaction */ /** Cache outputs that belong to the wallet from a single transaction */
void RefreshTXOsFromTx(const CWalletTx& wtx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); void RefreshTXOsFromTx(const CWalletTx& wtx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
/** Cache outputs that belong to the wallet for all transactions in the wallet */
void RefreshAllTXOs() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
/** /**
* Return depth of transaction in blockchain: * Return depth of transaction in blockchain: