wallet: Recalculate the wallet's txos after any imports

This commit is contained in:
Ava Chow 2024-02-20 11:50:00 -05:00
parent ae888c38d0
commit 96e7a89c5e
4 changed files with 12 additions and 0 deletions

View File

@ -250,6 +250,7 @@ RPCHelpMan keypoolrefill()
if (pwallet->GetKeyPoolSize() < kpSize) {
throw JSONRPCError(RPC_WALLET_ERROR, "Error refreshing keypool.");
}
pwallet->RefreshAllTXOs();
return UniValue::VNULL;
},

View File

@ -394,6 +394,7 @@ RPCHelpMan importdescriptors()
}
}
pwallet->ConnectScriptPubKeyManNotifiers();
pwallet->RefreshAllTXOs();
}
// Rescan the blockchain using the lowest timestamp

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

View File

@ -525,6 +525,8 @@ public:
/** Cache outputs that belong to the wallet from a single transaction */
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: