fix(coinjoin): CreateDenominated crash (#4838)

We overshoot (intentionally) and nBalanceToDenominate can become negative because of that. It was fine with raw loops but irange throws an exception here.
This commit is contained in:
UdjinM6 2022-05-12 23:32:23 +03:00 committed by GitHub
parent e95655cd9f
commit b582524939
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1697,6 +1697,7 @@ bool CCoinJoinClientSession::CreateDenominated(CAmount nBalanceToDenominate, con
// Go big to small // Go big to small
for (auto nDenomValue : denoms) { for (auto nDenomValue : denoms) {
if (nBalanceToDenominate <= 0) break;
int nOutputs = 0; int nOutputs = 0;
// Number of denoms we can create given our denom and the amount of funds we have left // Number of denoms we can create given our denom and the amount of funds we have left