Skip to content

Commit

Permalink
[Wallet] Add a check on zPIV spend to avoid a segfault
Browse files Browse the repository at this point in the history
When zPIV coins are selected and their total value is less than the
target value of the payment, there was nothing to see it before
commiting the transaction. At which point the function would crap out
with an exception which QT would fail to handle, leading to a
segmentation fault. This new check avoids this situation.
  • Loading branch information
Warrows committed Mar 15, 2018
1 parent f226de0 commit b8185ae
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4677,7 +4677,13 @@ bool CWallet::CreateZerocoinSpendTransaction(CAmount nValue, int nSecurityLevel,
CScript scriptZerocoinSpend;
CScript scriptChange;
CAmount nChange = nValueSelected - nValue;
if (nChange && !address) {

if (nChange < 0) {
receipt.SetStatus(_("Selected coins value is less than payment target"), nStatus);
return false;
}

if (nChange > 0 && !address) {
receipt.SetStatus(_("Need address because change is not exact"), nStatus);
return false;
}
Expand Down

0 comments on commit b8185ae

Please sign in to comment.