Skip to content

Commit b8185ae

Browse files
committed
[Wallet] Add a check on zPIV spend to avoid a segfault
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.
1 parent f226de0 commit b8185ae

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/wallet.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4677,7 +4677,13 @@ bool CWallet::CreateZerocoinSpendTransaction(CAmount nValue, int nSecurityLevel,
46774677
CScript scriptZerocoinSpend;
46784678
CScript scriptChange;
46794679
CAmount nChange = nValueSelected - nValue;
4680-
if (nChange && !address) {
4680+
4681+
if (nChange < 0) {
4682+
receipt.SetStatus(_("Selected coins value is less than payment target"), nStatus);
4683+
return false;
4684+
}
4685+
4686+
if (nChange > 0 && !address) {
46814687
receipt.SetStatus(_("Need address because change is not exact"), nStatus);
46824688
return false;
46834689
}

0 commit comments

Comments
 (0)