mirror of
https://github.com/XRPLF/rippled.git
synced 2026-09-26 23:19:07 +00:00
Revert isPositive -> isNonPositive rename
isNonPositiveXRPAmount(amount) = !isXRP(amount) || amount <= 0, which reads misleadingly (returns true for non-XRP amounts entirely, not just non-positive XRP ones). Restore isPositiveXRPAmount/ isPositiveAmount and the negation at call sites.
This commit is contained in:
@@ -41,18 +41,18 @@ isZeroId(T const& id)
|
||||
return id == beast::kZero;
|
||||
}
|
||||
|
||||
// Checks whether an amount is not a strictly positive XRP amount.
|
||||
// Checks whether an amount is a strictly positive XRP amount.
|
||||
inline bool
|
||||
isNonPositiveXRPAmount(STAmount const& amount)
|
||||
isPositiveXRPAmount(STAmount const& amount)
|
||||
{
|
||||
return !isXRP(amount) || amount <= beast::kZero;
|
||||
return isXRP(amount) && amount > beast::kZero;
|
||||
}
|
||||
|
||||
// Checks whether an amount (of any asset type) is not strictly positive.
|
||||
// Checks whether an amount (of any asset type) is strictly positive.
|
||||
inline bool
|
||||
isNonPositiveAmount(STAmount const& amount)
|
||||
isPositiveAmount(STAmount const& amount)
|
||||
{
|
||||
return amount <= beast::kZero;
|
||||
return amount > beast::kZero;
|
||||
}
|
||||
|
||||
// Checks whether a currency code is the reserved "bad"/XRP currency code,
|
||||
|
||||
@@ -101,7 +101,7 @@ NotTEC
|
||||
escrowCreatePreflightHelper<Issue>(PreflightContext const& ctx)
|
||||
{
|
||||
STAmount const amount = ctx.tx[sfAmount];
|
||||
if (amount.native() || isNonPositiveAmount(amount))
|
||||
if (amount.native() || !isPositiveAmount(amount))
|
||||
return temBAD_AMOUNT;
|
||||
|
||||
if (isBadCurrency(amount.get<Issue>().currency))
|
||||
@@ -118,8 +118,7 @@ escrowCreatePreflightHelper<MPTIssue>(PreflightContext const& ctx)
|
||||
return temDISABLED;
|
||||
|
||||
auto const amount = ctx.tx[sfAmount];
|
||||
if (amount.native() || amount.mpt() > MPTAmount{kMaxMpTokenAmount} ||
|
||||
isNonPositiveAmount(amount))
|
||||
if (amount.native() || amount.mpt() > MPTAmount{kMaxMpTokenAmount} || !isPositiveAmount(amount))
|
||||
return temBAD_AMOUNT;
|
||||
|
||||
return tesSUCCESS;
|
||||
@@ -142,7 +141,7 @@ EscrowCreate::preflight(PreflightContext const& ctx)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isNonPositiveXRPAmount(amount))
|
||||
if (!isPositiveXRPAmount(amount))
|
||||
return temBAD_AMOUNT;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ LoanBrokerCoverDeposit::preflight(PreflightContext const& ctx)
|
||||
return temINVALID;
|
||||
|
||||
auto const dstAmount = ctx.tx[sfAmount];
|
||||
if (isNonPositiveAmount(dstAmount))
|
||||
if (!isPositiveAmount(dstAmount))
|
||||
return temBAD_AMOUNT;
|
||||
|
||||
if (!isLegalNet(dstAmount))
|
||||
|
||||
@@ -35,7 +35,7 @@ LoanBrokerCoverWithdraw::preflight(PreflightContext const& ctx)
|
||||
return temINVALID;
|
||||
|
||||
auto const dstAmount = ctx.tx[sfAmount];
|
||||
if (isNonPositiveAmount(dstAmount))
|
||||
if (!isPositiveAmount(dstAmount))
|
||||
return temBAD_AMOUNT;
|
||||
|
||||
if (!isLegalNet(dstAmount))
|
||||
|
||||
@@ -52,7 +52,7 @@ LoanPay::preflight(PreflightContext const& ctx)
|
||||
if (isZeroId(ctx.tx[sfLoanID]))
|
||||
return temINVALID;
|
||||
|
||||
if (isNonPositiveAmount(ctx.tx[sfAmount]))
|
||||
if (!isPositiveAmount(ctx.tx[sfAmount]))
|
||||
return temBAD_AMOUNT;
|
||||
|
||||
// The loan payment flags are all mutually exclusive. If more than one is
|
||||
|
||||
@@ -184,13 +184,13 @@ Payment::preflight(PreflightContext const& ctx)
|
||||
<< "Payment destination account not specified.";
|
||||
return temDST_NEEDED;
|
||||
}
|
||||
if (hasMax && isNonPositiveAmount(maxSourceAmount))
|
||||
if (hasMax && !isPositiveAmount(maxSourceAmount))
|
||||
{
|
||||
JLOG(j.trace()) << "Malformed transaction: bad max amount: "
|
||||
<< maxSourceAmount.getFullText();
|
||||
return temBAD_AMOUNT;
|
||||
}
|
||||
if (isNonPositiveAmount(dstAmount))
|
||||
if (!isPositiveAmount(dstAmount))
|
||||
{
|
||||
JLOG(j.trace()) << "Malformed transaction: bad dst amount: " << dstAmount.getFullText();
|
||||
return temBAD_AMOUNT;
|
||||
|
||||
@@ -47,11 +47,11 @@ PaymentChannelClaim::preflight(PreflightContext const& ctx)
|
||||
return temMALFORMED;
|
||||
|
||||
auto const bal = ctx.tx[~sfBalance];
|
||||
if (bal && isNonPositiveXRPAmount(*bal))
|
||||
if (bal && !isPositiveXRPAmount(*bal))
|
||||
return temBAD_AMOUNT;
|
||||
|
||||
auto const amt = ctx.tx[~sfAmount];
|
||||
if (amt && isNonPositiveXRPAmount(*amt))
|
||||
if (amt && !isPositiveXRPAmount(*amt))
|
||||
return temBAD_AMOUNT;
|
||||
|
||||
if (bal && amt && *bal > *amt)
|
||||
|
||||
@@ -57,7 +57,7 @@ PaymentChannelCreate::makeTxConsequences(PreflightContext const& ctx)
|
||||
NotTEC
|
||||
PaymentChannelCreate::preflight(PreflightContext const& ctx)
|
||||
{
|
||||
if (isNonPositiveXRPAmount(ctx.tx[sfAmount]))
|
||||
if (!isPositiveXRPAmount(ctx.tx[sfAmount]))
|
||||
return temBAD_AMOUNT;
|
||||
|
||||
if (ctx.tx[sfAccount] == ctx.tx[sfDestination])
|
||||
|
||||
@@ -34,7 +34,7 @@ PaymentChannelFund::preflight(PreflightContext const& ctx)
|
||||
if (ctx.rules.enabled(fixCleanup3_2_0) && isZeroId(ctx.tx[sfChannel]))
|
||||
return temMALFORMED;
|
||||
|
||||
if (isNonPositiveXRPAmount(ctx.tx[sfAmount]))
|
||||
if (!isPositiveXRPAmount(ctx.tx[sfAmount]))
|
||||
return temBAD_AMOUNT;
|
||||
|
||||
return tesSUCCESS;
|
||||
|
||||
@@ -45,7 +45,7 @@ preflightHelper<Issue>(PreflightContext const& ctx)
|
||||
// The issuer field is used for the token holder instead
|
||||
AccountID const& holder = clawAmount.getIssuer();
|
||||
|
||||
if (issuer == holder || isXRP(clawAmount) || isNonPositiveAmount(clawAmount))
|
||||
if (issuer == holder || isXRP(clawAmount) || !isPositiveAmount(clawAmount))
|
||||
return temBAD_AMOUNT;
|
||||
|
||||
return tesSUCCESS;
|
||||
@@ -68,7 +68,7 @@ preflightHelper<MPTIssue>(PreflightContext const& ctx)
|
||||
if (ctx.tx[sfAccount] == *mptHolder)
|
||||
return temMALFORMED;
|
||||
|
||||
if (clawAmount.mpt() > MPTAmount{kMaxMpTokenAmount} || isNonPositiveAmount(clawAmount))
|
||||
if (clawAmount.mpt() > MPTAmount{kMaxMpTokenAmount} || !isPositiveAmount(clawAmount))
|
||||
return temBAD_AMOUNT;
|
||||
|
||||
return tesSUCCESS;
|
||||
|
||||
@@ -49,7 +49,7 @@ VaultWithdraw::preflight(PreflightContext const& ctx)
|
||||
return temMALFORMED;
|
||||
}
|
||||
|
||||
if (isNonPositiveAmount(ctx.tx[sfAmount]))
|
||||
if (!isPositiveAmount(ctx.tx[sfAmount]))
|
||||
return temBAD_AMOUNT;
|
||||
|
||||
if (auto const destination = ctx.tx[~sfDestination])
|
||||
|
||||
Reference in New Issue
Block a user