change check from xrp to native + error handle

This commit is contained in:
dangell7
2023-01-01 22:45:46 -05:00
parent cbee151d2d
commit 2bad9bde04

View File

@@ -229,7 +229,7 @@ PayChanCreate::preflight(PreflightContext const& ctx)
return ret;
STAmount const amount {ctx.tx[sfAmount]};
if (!isXRP(amount))
if (!amount.native())
{
if (!ctx.rules.enabled(featurePaychanAndEscrowForTokens))
return temDISABLED;
@@ -280,11 +280,11 @@ PayChanCreate::preclaim(PreclaimContext const& ctx)
auto const dst = ctx.tx[sfDestination];
// Check reserve and funds availability
if (isXRP(amount) && balance < reserve + amount)
if (amount.native() && balance < reserve + amount)
{
return tecUNFUNDED;
}
else if (!isXRP(amount)) {
else if (!amount.native()) {
if (!ctx.view.rules().enabled(featurePaychanAndEscrowForTokens))
return temDISABLED;
@@ -403,7 +403,7 @@ PayChanCreate::doApply()
}
// Deduct owner's balance, increment owner count
if (isXRP(amount))
if (amount.native())
(*sle)[sfBalance] = (*sle)[sfBalance] - amount;
else
{
@@ -414,7 +414,7 @@ PayChanCreate::doApply()
ctx_.view().peek(keylet::line(account, amount.getIssuer(), amount.getCurrency()));
if (!sleLine)
return tecUNFUNDED_PAYMENT;
return tecNO_LINE;
TER result =
trustAdjustLockedBalance(