Guard against invalid coercion of int to u32 in FindSpendableInputs

This commit is contained in:
Kris Nuttycombe 2022-03-28 16:38:07 -06:00
parent e07e355e01
commit 44eb07a2bb
1 changed files with 8 additions and 2 deletions

View File

@ -2364,8 +2364,14 @@ SpendableInputs CWallet::FindSpendableInputs(
}
auto mit = mapWallet.find(noteMeta.GetOutPoint().hash);
auto confirmations = mit->second.GetDepthInMainChain();
if (mit != mapWallet.end() && confirmations >= minDepth) {
// We should never get an outpoint from the Orchard wallet where
// the transaction does not exist in the main wallet.
assert(mit != mapWallet.end());
int confirmations = mit->second.GetDepthInMainChain();
if (confirmations < 0) continue;
if (confirmations >= minDepth) {
noteMeta.SetConfirmations(confirmations);
unspent.orchardNoteMetadata.push_back(noteMeta);
}