update error handling & fix xrp issue

This commit is contained in:
dangell7
2022-12-27 19:45:24 -05:00
parent 6dfbf39c99
commit 24c51a51a6
3 changed files with 22 additions and 20 deletions

View File

@@ -124,7 +124,7 @@ EscrowCreate::preflight(PreflightContext const& ctx)
{
JLOG(ctx.j.trace())
<< "Malformed transaction: Cannot escrow own tokens to self.";
return temDST_IS_SRC;
return temBAD_SRC_ACCOUNT;
}
}
@@ -216,7 +216,7 @@ EscrowCreate::doApply()
auto const account = ctx_.tx[sfAccount];
auto const sle = ctx_.view().peek(keylet::account(account));
if (!sle)
return tefINTERNAL;
return temDISABLED;
STAmount const amount {ctx_.tx[sfAmount]};
@@ -241,7 +241,7 @@ EscrowCreate::doApply()
// preflight will prevent this ever firing, included
// defensively for completeness
if (!ctx_.view().rules().enabled(featurePaychanAndEscrowForTokens))
return tefINTERNAL;
return temDISABLED;
// check if the escrow is capable of being
// finished before we allow it to be created
@@ -342,7 +342,7 @@ EscrowCreate::doApply()
else
{
if (!ctx_.view().rules().enabled(featurePaychanAndEscrowForTokens) || !sleLine)
return tefINTERNAL;
return temDISABLED;
// do the lock-up for real now
TER result =
@@ -565,7 +565,7 @@ EscrowFinish::doApply()
if (!isXRP(amount))
{
if (!ctx_.view().rules().enabled(featurePaychanAndEscrowForTokens))
return tefINTERNAL;
return temDISABLED;
// perform a dry run of the transfer before we
// change anything on-ledger
@@ -704,7 +704,7 @@ EscrowCancel::doApply()
if (!isXRP(amount))
{
if (!ctx_.view().rules().enabled(featurePaychanAndEscrowForTokens))
return tefINTERNAL;
return temDISABLED;
sleLine =
ctx_.view().peek(
@@ -754,7 +754,7 @@ EscrowCancel::doApply()
else
{
if (!ctx_.view().rules().enabled(featurePaychanAndEscrowForTokens))
return tefINTERNAL;
return temDISABLED;
// unlock previously locked tokens from source line
TER result =

View File

@@ -127,7 +127,7 @@ closeChannel(
if (!isXRP(amount))
{
if (!view.rules().enabled(featurePaychanAndEscrowForTokens))
return tefINTERNAL;
return temDISABLED;
sleLine =
view.peek(keylet::line(src, amount.getIssuer(), amount.getCurrency()));
@@ -244,7 +244,7 @@ PayChanCreate::preflight(PreflightContext const& ctx)
{
JLOG(ctx.j.trace())
<< "Malformed transaction: Cannot paychan own tokens to self.";
return temDST_IS_SRC;
return temBAD_SRC_ACCOUNT;
}
}
@@ -280,9 +280,11 @@ PayChanCreate::preclaim(PreclaimContext const& ctx)
auto const dst = ctx.tx[sfDestination];
// Check reserve and funds availability
if (isXRP(amount) && balance < reserve + ctx.tx[sfAmount])
if (isXRP(amount) && balance < reserve + amount)
{
return tecUNFUNDED;
else
}
else if (!isXRP(amount)) {
{
if (!ctx.view.rules().enabled(featurePaychanAndEscrowForTokens))
return tecINTERNAL;
@@ -407,7 +409,7 @@ PayChanCreate::doApply()
else
{
if (!ctx_.view().rules().enabled(featurePaychanAndEscrowForTokens))
return tefINTERNAL;
return temDISABLED;
auto sleLine =
ctx_.view().peek(keylet::line(account, amount.getIssuer(), amount.getCurrency()));
@@ -471,8 +473,8 @@ PayChanFund::preflight(PreflightContext const& ctx)
if (ctx.tx[sfAccount] == amount.getIssuer())
{
JLOG(ctx.j.trace())
<< "Malformed transaction: Cannot escrow own tokens to self.";
return temDST_IS_SRC;
<< "Malformed transaction: Cannot paychan own tokens to self.";
return temBAD_SRC_ACCOUNT;
}
}
@@ -584,7 +586,7 @@ PayChanFund::doApply()
else
{
if (!ctx_.view().rules().enabled(featurePaychanAndEscrowForTokens))
return tefINTERNAL;
return temDISABLED;
TER result =
@@ -772,7 +774,7 @@ PayChanClaim::doApply()
// RH NOTE: there's no ledger modification before this point so
// no reason to do a dry run first
if (!ctx_.view().rules().enabled(featurePaychanAndEscrowForTokens))
return tefINTERNAL;
return temDISABLED;
auto sleSrcAcc = ctx_.view().peek(keylet::account(src));
TER result =

View File

@@ -492,10 +492,10 @@ trustAdjustLockedBalance(
static_assert(!(std::is_same<V, ReadView const>::value && !dryRun));
if (!view.rules().enabled(featurePaychanAndEscrowForTokens))
return tefINTERNAL;
return temDISABLED;
if (!sleLine)
return tecINTERNAL;
return tecNO_LINE;
auto const currency = deltaAmt.getCurrency();
auto const issuer = deltaAmt.getIssuer();
@@ -583,7 +583,7 @@ trustAdjustLockedBalance(
if ((deltaLockCount > 0 && priorLockCount > finalLockCount) ||
(deltaLockCount < 0 && priorLockCount < finalLockCount) ||
(deltaLockCount == 0 && priorLockCount != finalLockCount))
return tecINTERNAL;
return tecOVERSIZE;
// we won't update any SLEs if it is a dry run
if (dryRun)
@@ -894,7 +894,7 @@ trustTransferLockedBalance(
if ((deltaLockCount > 0 && priorLockCount > finalLockCount) ||
(deltaLockCount < 0 && priorLockCount < finalLockCount) ||
(deltaLockCount == 0 && priorLockCount != finalLockCount))
return tecINTERNAL;
return tecOVERSIZE;
// this should never happen but defensively check it here before updating sle
if (finalBalance < beast::zero || finalLockedBalance < beast::zero)