From b582524939eafaf9ebe5cd9fcbf134b33beac6ef Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Thu, 12 May 2022 23:32:23 +0300 Subject: [PATCH] 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. --- src/coinjoin/client.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/coinjoin/client.cpp b/src/coinjoin/client.cpp index 9ed6170fef..e519e1bfec 100644 --- a/src/coinjoin/client.cpp +++ b/src/coinjoin/client.cpp @@ -1697,6 +1697,7 @@ bool CCoinJoinClientSession::CreateDenominated(CAmount nBalanceToDenominate, con // Go big to small for (auto nDenomValue : denoms) { + if (nBalanceToDenominate <= 0) break; int nOutputs = 0; // Number of denoms we can create given our denom and the amount of funds we have left