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