escrow bug fixes, escrow create/finish/cancel working

This commit is contained in:
Richard Holland
2022-04-08 13:25:58 +00:00
parent 9b85d891ca
commit ff6cc9ee8c
2 changed files with 19 additions and 20 deletions

View File

@@ -632,7 +632,7 @@ EscrowFinish::doApply()
<< "EscrowFinish::doApply trustTransferLockedBalance (wet) result="
<< result;
if (isTesSuccess(result))
if (!isTesSuccess(result))
return result;
}

View File

@@ -531,13 +531,13 @@ trustAdjustLockedBalance(
}
/** Check if movement of a particular token between 1 or more accounts
/** Check if a set of accounts can freely exchange the specified token.
Read only, does not change any ledger object.
May be called with ApplyView or ReadView.
(including unlocking) is forbidden by any flag or condition.
If parties contains 1 entry then noRipple is not a bar to xfer.
If parties contains more than 1 entry then any party with noRipple on issuer
side is a bar to xfer.
If parties contains more than 1 entry then any party with noRipple
on issuer side is a bar to xfer.
*/
template<class V>
[[nodiscard]]TER
@@ -775,31 +775,30 @@ trustTransferLockedBalance(
return tecUNFUNDED_PAYMENT;
}
STAmount lockedBalance = sleSrcLine->getFieldAmount(sfLockedBalance);
// check they have sufficient funds
if (amount > lockedBalance)
{
JLOG(j.trace())
<< "trustTransferLockedBalance amount > lockedBalance: "
<< "amount=" << amount << " lockedBalance=" << lockedBalance;
return tecUNFUNDED_PAYMENT;
}
// decrement source balance
{
STAmount priorBalance =
srcHigh ? -((*sleSrcLine)[sfBalance]) : (*sleSrcLine)[sfBalance];
// ensure the currency/issuer in the locked balance matches the xfer amount
if (priorBalance.getIssuer() != issuerAccID || priorBalance.getCurrency() != currency)
return tecNO_PERMISSION;
STAmount finalBalance = priorBalance - amount;
STAmount priorLockedBalance =
srcHigh ? -((*sleSrcLine)[sfLockedBalance]) : (*sleSrcLine)[sfLockedBalance];
AccountID srcIssuerAccID =
sleSrcLine->getFieldAmount(srcHigh ? sfLowLimit : sfHighLimit).getIssuer();
// check they have sufficient funds
if (amount > priorLockedBalance)
{
JLOG(j.trace())
<< "trustTransferLockedBalance amount > lockedBalance: "
<< "amount=" << amount << " lockedBalance="
<< priorLockedBalance;
return tecUNFUNDED_PAYMENT;
}
STAmount finalBalance = priorBalance - amount;
STAmount finalLockedBalance = priorLockedBalance - amount;
// this should never happen but defensively check it here before updating sle