mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-24 23:50:22 +00:00
migrate transactors
This commit is contained in:
@@ -817,8 +817,7 @@ Transactor::ticketDelete(
|
||||
if (!sleTicket)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j.fatal()) << "Ticket disappeared from ledger.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Ticket disappeared from ledger."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -826,8 +825,7 @@ Transactor::ticketDelete(
|
||||
if (!view.dirRemove(keylet::ownerDir(account), page, ticketIndex, true))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j.fatal()) << "Unable to delete Ticket from owner.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Unable to delete Ticket from owner."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -837,8 +835,7 @@ Transactor::ticketDelete(
|
||||
if (!sleAccount)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j.fatal()) << "Could not find Ticket owner account root.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Could not find Ticket owner account root."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -856,8 +853,7 @@ Transactor::ticketDelete(
|
||||
else
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j.fatal()) << "TicketCount field missing from account root.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "TicketCount field missing from account root."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
|
||||
@@ -198,14 +198,12 @@ AccountSet::preclaim(PreclaimContext const& ctx)
|
||||
{
|
||||
if (sle->isFlag(lsfNoFreeze))
|
||||
{
|
||||
JLOG(ctx.j.trace()) << "Can't set Clawback if NoFreeze is set";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "Can't set Clawback if NoFreeze is set"};
|
||||
}
|
||||
|
||||
if (!dirIsEmpty(ctx.view, keylet::ownerDir(id)))
|
||||
{
|
||||
JLOG(ctx.j.trace()) << "Owner directory not empty.";
|
||||
return tecOWNERS;
|
||||
return {tecOWNERS, "Owner directory not empty."};
|
||||
}
|
||||
}
|
||||
else if (uSetFlag == asfNoFreeze)
|
||||
@@ -213,8 +211,7 @@ AccountSet::preclaim(PreclaimContext const& ctx)
|
||||
// Cannot set NoFreeze if clawback is enabled
|
||||
if (sle->isFlag(lsfAllowTrustLineClawback))
|
||||
{
|
||||
JLOG(ctx.j.trace()) << "Can't set NoFreeze if clawback is enabled";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "Can't set NoFreeze if clawback is enabled"};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,8 +305,7 @@ AccountSet::doApply()
|
||||
{
|
||||
if (!sigWithMaster)
|
||||
{
|
||||
JLOG(j_.trace()) << "Must use master key to disable master key.";
|
||||
return tecNEED_MASTER_KEY;
|
||||
return {tecNEED_MASTER_KEY, "Must use master key to disable master key."};
|
||||
}
|
||||
|
||||
if ((!sle->isFieldPresent(sfRegularKey)) && (!view().peek(keylet::signerList(accountID_))))
|
||||
@@ -349,8 +345,7 @@ AccountSet::doApply()
|
||||
{
|
||||
if (!sigWithMaster && !sle->isFlag(lsfDisableMaster))
|
||||
{
|
||||
JLOG(j_.trace()) << "Must use master key to set NoFreeze.";
|
||||
return tecNEED_MASTER_KEY;
|
||||
return {tecNEED_MASTER_KEY, "Must use master key to set NoFreeze."};
|
||||
}
|
||||
|
||||
JLOG(j_.trace()) << "Set NoFreeze flag";
|
||||
|
||||
@@ -208,8 +208,7 @@ removeSignersFromLedger(
|
||||
if (!view.dirRemove(ownerDirKeylet, hint, signerListKeylet.key, false))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j.fatal()) << "Unable to delete SignerList from owner.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Unable to delete SignerList from owner."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
|
||||
@@ -133,9 +133,9 @@ checkAttestationPublicKey(
|
||||
// master key
|
||||
if (sleAttestationSigningAccount->isFlag(lsfDisableMaster))
|
||||
{
|
||||
JLOG(j.trace()) << "Attempt to add an attestation with "
|
||||
"disabled master key.";
|
||||
return tecXCHAIN_BAD_PUBLIC_KEY_ACCOUNT_PAIR;
|
||||
return {
|
||||
tecXCHAIN_BAD_PUBLIC_KEY_ACCOUNT_PAIR,
|
||||
"Attempt to add an attestation with disabled master key."};
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -165,9 +165,10 @@ checkAttestationPublicKey(
|
||||
// account does not exist.
|
||||
if (calcAccountID(pk) != attestationSignerAccount)
|
||||
{
|
||||
JLOG(j.trace()) << "Attempt to add an attestation with non-existant account "
|
||||
"and mismatched pk/account pair.";
|
||||
return tecXCHAIN_BAD_PUBLIC_KEY_ACCOUNT_PAIR;
|
||||
return {
|
||||
tecXCHAIN_BAD_PUBLIC_KEY_ACCOUNT_PAIR,
|
||||
"Attempt to add an attestation with non-existant account and mismatched pk/account "
|
||||
"pair."};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -465,8 +466,7 @@ transferHelper(
|
||||
}
|
||||
if (amt < psb.fees().reserve)
|
||||
{
|
||||
JLOG(j.trace()) << "Insufficient payment to create account.";
|
||||
return tecNO_DST_INSUF_XRP;
|
||||
return {tecNO_DST_INSUF_XRP, "Insufficient payment to create account."};
|
||||
}
|
||||
|
||||
// Create the account.
|
||||
|
||||
@@ -33,8 +33,7 @@ CheckCancel::preclaim(PreclaimContext const& ctx)
|
||||
auto const sleCheck = ctx.view.read(keylet::check(ctx.tx[sfCheckID]));
|
||||
if (!sleCheck)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Check does not exist.";
|
||||
return tecNO_ENTRY;
|
||||
return {tecNO_ENTRY, "Check does not exist."};
|
||||
}
|
||||
|
||||
// Expiration is defined in terms of the close time of the parent
|
||||
@@ -48,9 +47,9 @@ CheckCancel::preclaim(PreclaimContext const& ctx)
|
||||
AccountID const acctId{ctx.tx[sfAccount]};
|
||||
if (acctId != (*sleCheck)[sfAccount] && acctId != (*sleCheck)[sfDestination])
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Check is not expired and canceler is "
|
||||
"neither check source nor destination.";
|
||||
return tecNO_PERMISSION;
|
||||
return {
|
||||
tecNO_PERMISSION,
|
||||
"Check is not expired and canceler is neither check source nor destination."};
|
||||
}
|
||||
}
|
||||
return tesSUCCESS;
|
||||
@@ -63,8 +62,7 @@ CheckCancel::doApply()
|
||||
if (!sleCheck)
|
||||
{
|
||||
// Error should have been caught in preclaim.
|
||||
JLOG(j_.warn()) << "Check does not exist.";
|
||||
return tecNO_ENTRY;
|
||||
return {tecNO_ENTRY, "Check does not exist."};
|
||||
}
|
||||
|
||||
AccountID const srcId{sleCheck->getAccountID(sfAccount)};
|
||||
@@ -79,8 +77,7 @@ CheckCancel::doApply()
|
||||
if (!view().dirRemove(keylet::ownerDir(dstId), page, sleCheck->key(), true))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.fatal()) << "Unable to delete check from destination.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Unable to delete check from destination."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
}
|
||||
@@ -89,8 +86,7 @@ CheckCancel::doApply()
|
||||
if (!view().dirRemove(keylet::ownerDir(srcId), page, sleCheck->key(), true))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.fatal()) << "Unable to delete check from owner.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Unable to delete check from owner."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,16 +89,14 @@ CheckCash::preclaim(PreclaimContext const& ctx)
|
||||
auto const sleCheck = ctx.view.read(keylet::check(ctx.tx[sfCheckID]));
|
||||
if (!sleCheck)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Check does not exist.";
|
||||
return tecNO_ENTRY;
|
||||
return {tecNO_ENTRY, "Check does not exist."};
|
||||
}
|
||||
|
||||
// Only cash a check with this account as the destination.
|
||||
AccountID const dstId = sleCheck->at(sfDestination);
|
||||
if (ctx.tx[sfAccount] != dstId)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Cashing a check with wrong Destination.";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "Cashing a check with wrong Destination."};
|
||||
}
|
||||
AccountID const srcId = sleCheck->at(sfAccount);
|
||||
if (srcId == dstId)
|
||||
@@ -106,8 +104,7 @@ CheckCash::preclaim(PreclaimContext const& ctx)
|
||||
// They wrote a check to themselves. This should be caught when
|
||||
// the check is created, but better late than never.
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx.j.error()) << "Malformed transaction: Cashing check to self.";
|
||||
return tecINTERNAL;
|
||||
return {tecINTERNAL, "Malformed transaction: Cashing check to self."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
{
|
||||
@@ -116,23 +113,20 @@ CheckCash::preclaim(PreclaimContext const& ctx)
|
||||
if (!sleSrc || !sleDst)
|
||||
{
|
||||
// If the check exists this should never occur.
|
||||
JLOG(ctx.j.warn()) << "Malformed transaction: source or destination not in ledger";
|
||||
return tecNO_ENTRY;
|
||||
return {tecNO_ENTRY, "Malformed transaction: source or destination not in ledger"};
|
||||
}
|
||||
|
||||
if (sleDst->isFlag(lsfRequireDestTag) && !sleCheck->isFieldPresent(sfDestinationTag))
|
||||
{
|
||||
// The tag is basically account-specific information we don't
|
||||
// understand, but we can require someone to fill it in.
|
||||
JLOG(ctx.j.warn()) << "Malformed transaction: DestinationTag required in check.";
|
||||
return tecDST_TAG_NEEDED;
|
||||
return {tecDST_TAG_NEEDED, "Malformed transaction: DestinationTag required in check."};
|
||||
}
|
||||
}
|
||||
|
||||
if (hasExpired(ctx.view, sleCheck->at(~sfExpiration)))
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Cashing a check that has already expired.";
|
||||
return tecEXPIRED;
|
||||
return {tecEXPIRED, "Cashing a check that has already expired."};
|
||||
}
|
||||
|
||||
{
|
||||
@@ -162,8 +156,7 @@ CheckCash::preclaim(PreclaimContext const& ctx)
|
||||
}
|
||||
if (value > sendMax)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Check cashed for more than check sendMax.";
|
||||
return tecPATH_PARTIAL;
|
||||
return {tecPATH_PARTIAL, "Check cashed for more than check sendMax."};
|
||||
}
|
||||
|
||||
// Make sure the check owner holds at least value. If they have
|
||||
@@ -186,8 +179,7 @@ CheckCash::preclaim(PreclaimContext const& ctx)
|
||||
|
||||
if (value > availableFunds)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Check cashed for more than owner's balance.";
|
||||
return tecPATH_PARTIAL;
|
||||
return {tecPATH_PARTIAL, "Check cashed for more than owner's balance."};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,9 +222,7 @@ CheckCash::preclaim(PreclaimContext const& ctx)
|
||||
|
||||
if (!isAuthorized)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Can't receive IOUs from "
|
||||
"issuer without auth.";
|
||||
return tecNO_AUTH;
|
||||
return {tecNO_AUTH, "Can't receive IOUs from issuer without auth."};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,8 +235,7 @@ CheckCash::preclaim(PreclaimContext const& ctx)
|
||||
// not be frozen.
|
||||
if (isFrozen(ctx.view, dstId, currency, issuerId))
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Cashing a check to a frozen trustline.";
|
||||
return tecFROZEN;
|
||||
return {tecFROZEN, "Cashing a check to a frozen trustline."};
|
||||
}
|
||||
|
||||
return tesSUCCESS;
|
||||
@@ -270,8 +259,7 @@ CheckCash::preclaim(PreclaimContext const& ctx)
|
||||
|
||||
if (isFrozen(ctx.view, dstId, issue))
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Cashing a check to a frozen MPT.";
|
||||
return tecLOCKED;
|
||||
return {tecLOCKED, "Cashing a check to a frozen MPT."};
|
||||
}
|
||||
|
||||
if (auto const err = canTransfer(ctx.view, issue, srcId, dstId);
|
||||
@@ -299,8 +287,7 @@ CheckCash::doApply()
|
||||
if (!sleCheck)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.fatal()) << "Precheck did not verify check's existence.";
|
||||
return tecFAILED_PROCESSING;
|
||||
return {tecFAILED_PROCESSING, "Precheck did not verify check's existence."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -308,8 +295,7 @@ CheckCash::doApply()
|
||||
if (!psb.exists(keylet::account(srcId)) || !psb.exists(keylet::account(accountID_)))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx_.journal.fatal()) << "Precheck did not verify source or destination's existence.";
|
||||
return tecFAILED_PROCESSING;
|
||||
return {tecFAILED_PROCESSING, "Precheck did not verify source or destination's existence."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -566,8 +552,7 @@ CheckCash::doApply()
|
||||
{
|
||||
if (result.actualAmountOut < *optDeliverMin)
|
||||
{
|
||||
JLOG(ctx_.journal.warn()) << "flow did not produce DeliverMin.";
|
||||
return tecPATH_PARTIAL;
|
||||
return {tecPATH_PARTIAL, "flow did not produce DeliverMin."};
|
||||
}
|
||||
ctx_.deliver(result.actualAmountOut);
|
||||
}
|
||||
@@ -587,8 +572,7 @@ CheckCash::doApply()
|
||||
keylet::ownerDir(accountID_), sleCheck->at(sfDestinationNode), sleCheck->key(), true))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.fatal()) << "Unable to delete check from destination.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Unable to delete check from destination."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -596,8 +580,7 @@ CheckCash::doApply()
|
||||
if (!psb.dirRemove(keylet::ownerDir(srcId), sleCheck->at(sfOwnerNode), sleCheck->key(), true))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.fatal()) << "Unable to delete check from owner.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Unable to delete check from owner."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
|
||||
@@ -83,8 +83,7 @@ CheckCreate::preclaim(PreclaimContext const& ctx)
|
||||
auto const sleDst = ctx.view.read(keylet::account(dstId));
|
||||
if (!sleDst)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Destination account does not exist.";
|
||||
return tecNO_DST;
|
||||
return {tecNO_DST, "Destination account does not exist."};
|
||||
}
|
||||
|
||||
// Check if the destination has disallowed incoming checks
|
||||
@@ -102,8 +101,7 @@ CheckCreate::preclaim(PreclaimContext const& ctx)
|
||||
{
|
||||
// The tag is basically account-specific information we don't
|
||||
// understand, but we can require someone to fill it in.
|
||||
JLOG(ctx.j.warn()) << "Malformed transaction: DestinationTag required.";
|
||||
return tecDST_TAG_NEEDED;
|
||||
return {tecDST_TAG_NEEDED, "Malformed transaction: DestinationTag required."};
|
||||
}
|
||||
|
||||
{
|
||||
@@ -114,8 +112,7 @@ CheckCreate::preclaim(PreclaimContext const& ctx)
|
||||
AccountID const& issuerId{sendMax.getIssuer()};
|
||||
if (auto const ter = checkGlobalFrozen(ctx.view, sendMax.asset()); !isTesSuccess(ter))
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Creating a check for frozen or locked asset";
|
||||
return ter;
|
||||
return {ter, "Creating a check for frozen or locked asset"};
|
||||
}
|
||||
auto const err = sendMax.asset().visit(
|
||||
[&](Issue const& issue) -> std::optional<TER> {
|
||||
@@ -132,8 +129,7 @@ CheckCreate::preclaim(PreclaimContext const& ctx)
|
||||
if (sleTrust &&
|
||||
sleTrust->isFlag((issuerId > srcId) ? lsfHighFreeze : lsfLowFreeze))
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Creating a check for frozen trustline.";
|
||||
return tecFROZEN;
|
||||
return TER{tecFROZEN, "Creating a check for frozen trustline."};
|
||||
}
|
||||
}
|
||||
if (issuerId != dstId)
|
||||
@@ -144,9 +140,8 @@ CheckCreate::preclaim(PreclaimContext const& ctx)
|
||||
if (sleTrust &&
|
||||
sleTrust->isFlag((dstId > issuerId) ? lsfHighFreeze : lsfLowFreeze))
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Creating a check for "
|
||||
"destination frozen trustline.";
|
||||
return tecFROZEN;
|
||||
return TER{
|
||||
tecFROZEN, "Creating a check for destination frozen trustline."};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,19 +150,16 @@ CheckCreate::preclaim(PreclaimContext const& ctx)
|
||||
[&](MPTIssue const& issue) -> std::optional<TER> {
|
||||
if (srcId != issuerId && isFrozen(ctx.view, srcId, issue))
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Creating a check for locked MPT.";
|
||||
return tecLOCKED;
|
||||
return TER{tecLOCKED, "Creating a check for locked MPT."};
|
||||
}
|
||||
if (dstId != issuerId && isFrozen(ctx.view, dstId, issue))
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Creating a check for locked MPT.";
|
||||
return tecLOCKED;
|
||||
return TER{tecLOCKED, "Creating a check for locked MPT."};
|
||||
}
|
||||
if (auto const ter = canTransfer(ctx.view, issue, srcId, dstId);
|
||||
!isTesSuccess(ter))
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "MPT transfer is disabled.";
|
||||
return ter;
|
||||
return TER{ter, "MPT transfer is disabled."};
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
@@ -178,8 +170,7 @@ CheckCreate::preclaim(PreclaimContext const& ctx)
|
||||
}
|
||||
if (hasExpired(ctx.view, ctx.tx[~sfExpiration]))
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Creating a check that has already expired.";
|
||||
return tecEXPIRED;
|
||||
return {tecEXPIRED, "Creating a check that has already expired."};
|
||||
}
|
||||
|
||||
return tesSUCCESS;
|
||||
|
||||
@@ -86,14 +86,12 @@ CredentialCreate::preclaim(PreclaimContext const& ctx)
|
||||
|
||||
if (!ctx.view.exists(keylet::account(subject)))
|
||||
{
|
||||
JLOG(ctx.j.trace()) << "Subject doesn't exist.";
|
||||
return tecNO_TARGET;
|
||||
return {tecNO_TARGET, "Subject doesn't exist."};
|
||||
}
|
||||
|
||||
if (ctx.view.exists(keylet::credential(subject, ctx.tx[sfAccount], credType)))
|
||||
{
|
||||
JLOG(ctx.j.trace()) << "Credential already exists.";
|
||||
return tecDUPLICATE;
|
||||
return {tecDUPLICATE, "Credential already exists."};
|
||||
}
|
||||
|
||||
return tesSUCCESS;
|
||||
@@ -118,9 +116,7 @@ CredentialCreate::doApply()
|
||||
|
||||
if (closeTime > *optExp)
|
||||
{
|
||||
JLOG(j_.trace()) << "Malformed transaction: "
|
||||
"Expiration time is in the past.";
|
||||
return tecEXPIRED;
|
||||
return {tecEXPIRED, "Malformed transaction: Expiration time is in the past."};
|
||||
}
|
||||
|
||||
sleCred->setFieldU32(sfExpiration, *optExp);
|
||||
|
||||
@@ -87,8 +87,7 @@ CredentialDelete::doApply()
|
||||
if ((subject != accountID_) && (issuer != accountID_) &&
|
||||
!checkExpired(*sleCred, ctx_.view().header().parentCloseTime))
|
||||
{
|
||||
JLOG(j_.trace()) << "Can't delete non-expired credential.";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "Can't delete non-expired credential."};
|
||||
}
|
||||
|
||||
return deleteSLE(view(), sleCred, j_);
|
||||
|
||||
@@ -152,8 +152,7 @@ DelegateSet::deleteDelegate(ApplyView& view, SLE::ref sle, beast::Journal j)
|
||||
if (!view.dirRemove(keylet::ownerDir(delegator), (*sle)[sfOwnerNode], sle->key(), false))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j.fatal()) << "Unable to delete Delegate from owner.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Unable to delete Delegate from owner."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -163,8 +162,7 @@ DelegateSet::deleteDelegate(ApplyView& view, SLE::ref sle, beast::Journal j)
|
||||
if (!view.dirRemove(keylet::ownerDir(delegatee), *optPage, sle->key(), false))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j.fatal()) << "Unable to delete Delegate from authorized account.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Unable to delete Delegate from authorized account."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,8 +107,7 @@ AMMBid::preclaim(PreclaimContext const& ctx)
|
||||
auto const ammSle = ctx.view.read(keylet::amm(ctx.tx[sfAsset], ctx.tx[sfAsset2]));
|
||||
if (!ammSle)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "AMM Bid: Invalid asset pair.";
|
||||
return terNO_AMM;
|
||||
return {terNO_AMM, "AMM Bid: Invalid asset pair."};
|
||||
}
|
||||
|
||||
auto const lpTokensBalance = (*ammSle)[sfLPTokenBalance];
|
||||
@@ -121,8 +120,7 @@ AMMBid::preclaim(PreclaimContext const& ctx)
|
||||
{
|
||||
if (!ctx.view.read(keylet::account(account[sfAccount])))
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "AMM Bid: Invalid Account.";
|
||||
return terNO_ACCOUNT;
|
||||
return {terNO_ACCOUNT, "AMM Bid: Invalid Account."};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,8 +129,7 @@ AMMBid::preclaim(PreclaimContext const& ctx)
|
||||
// Not LP
|
||||
if (lpTokens == beast::kZero)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "AMM Bid: account is not LP.";
|
||||
return tecAMM_INVALID_TOKENS;
|
||||
return {tecAMM_INVALID_TOKENS, "AMM Bid: account is not LP."};
|
||||
}
|
||||
|
||||
auto const bidMin = ctx.tx[~sfBidMin];
|
||||
@@ -146,8 +143,7 @@ AMMBid::preclaim(PreclaimContext const& ctx)
|
||||
}
|
||||
if (*bidMin > lpTokens || *bidMin >= lpTokensBalance)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "AMM Bid: Invalid Tokens.";
|
||||
return tecAMM_INVALID_TOKENS;
|
||||
return {tecAMM_INVALID_TOKENS, "AMM Bid: Invalid Tokens."};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,15 +157,13 @@ AMMBid::preclaim(PreclaimContext const& ctx)
|
||||
}
|
||||
if (*bidMax > lpTokens || *bidMax >= lpTokensBalance)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "AMM Bid: Invalid Tokens.";
|
||||
return tecAMM_INVALID_TOKENS;
|
||||
return {tecAMM_INVALID_TOKENS, "AMM Bid: Invalid Tokens."};
|
||||
}
|
||||
}
|
||||
|
||||
if (bidMin && bidMax && bidMin > bidMax)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "AMM Bid: Invalid Max/MinSlotPrice.";
|
||||
return tecAMM_INVALID_TOKENS;
|
||||
return {tecAMM_INVALID_TOKENS, "AMM Bid: Invalid Max/MinSlotPrice."};
|
||||
}
|
||||
|
||||
return tesSUCCESS;
|
||||
|
||||
@@ -112,8 +112,7 @@ AMMClawback::preclaim(PreclaimContext const& ctx)
|
||||
auto const ammSle = ctx.view.read(keylet::amm(asset, asset2));
|
||||
if (!ammSle)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "AMM Clawback: Invalid asset pair.";
|
||||
return terNO_AMM;
|
||||
return {terNO_AMM, "AMM Clawback: Invalid asset pair."};
|
||||
}
|
||||
|
||||
if (!ctx.view.rules().enabled(featureMPTokensV2))
|
||||
|
||||
@@ -102,8 +102,7 @@ AMMCreate::preclaim(PreclaimContext const& ctx)
|
||||
if (auto const ammKeylet = keylet::amm(amount.asset(), amount2.asset());
|
||||
ctx.view.read(ammKeylet))
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "AMM Instance: ltAMM already exists.";
|
||||
return tecDUPLICATE;
|
||||
return {tecDUPLICATE, "AMM Instance: ltAMM already exists."};
|
||||
}
|
||||
|
||||
if (auto const ter = requireAuth(ctx.view, amount.asset(), accountID); !isTesSuccess(ter))
|
||||
@@ -122,13 +121,11 @@ AMMCreate::preclaim(PreclaimContext const& ctx)
|
||||
if (auto const ter = checkFrozen(ctx.view, accountID, amount.asset()); !isTesSuccess(ter))
|
||||
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "AMM Instance: involves frozen or locked asset.";
|
||||
return ter;
|
||||
return {ter, "AMM Instance: involves frozen or locked asset."};
|
||||
}
|
||||
if (auto const ter = checkFrozen(ctx.view, accountID, amount2.asset()); !isTesSuccess(ter))
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "AMM Instance: involves frozen or locked asset.";
|
||||
return ter;
|
||||
return {ter, "AMM Instance: involves frozen or locked asset."};
|
||||
}
|
||||
|
||||
auto noDefaultRipple = [](ReadView const& view, Asset const& asset) {
|
||||
@@ -143,8 +140,7 @@ AMMCreate::preclaim(PreclaimContext const& ctx)
|
||||
|
||||
if (noDefaultRipple(ctx.view, amount.asset()) || noDefaultRipple(ctx.view, amount2.asset()))
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "AMM Instance: DefaultRipple not set";
|
||||
return terNO_RIPPLE;
|
||||
return {terNO_RIPPLE, "AMM Instance: DefaultRipple not set"};
|
||||
}
|
||||
|
||||
// Check the reserve for LPToken trustline
|
||||
@@ -152,8 +148,7 @@ AMMCreate::preclaim(PreclaimContext const& ctx)
|
||||
// Insufficient reserve
|
||||
if (xrpBalance <= beast::kZero)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "AMM Instance: insufficient reserves";
|
||||
return tecINSUF_RESERVE_LINE;
|
||||
return {tecINSUF_RESERVE_LINE, "AMM Instance: insufficient reserves"};
|
||||
}
|
||||
|
||||
auto insufficientBalance = [&](STAmount const& amount) {
|
||||
|
||||
@@ -39,8 +39,7 @@ AMMDelete::preclaim(PreclaimContext const& ctx)
|
||||
auto const ammSle = ctx.view.read(keylet::amm(ctx.tx[sfAsset], ctx.tx[sfAsset2]));
|
||||
if (!ammSle)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "AMM Delete: Invalid asset pair.";
|
||||
return terNO_AMM;
|
||||
return {terNO_AMM, "AMM Delete: Invalid asset pair."};
|
||||
}
|
||||
|
||||
auto const lpTokensBalance = (*ammSle)[sfLPTokenBalance];
|
||||
|
||||
@@ -181,8 +181,7 @@ AMMDeposit::preclaim(PreclaimContext const& ctx)
|
||||
auto const ammSle = ctx.view.read(keylet::amm(ctx.tx[sfAsset], ctx.tx[sfAsset2]));
|
||||
if (!ammSle)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "AMM Deposit: Invalid asset pair.";
|
||||
return terNO_AMM;
|
||||
return {terNO_AMM, "AMM Deposit: Invalid asset pair."};
|
||||
}
|
||||
|
||||
auto const expected = ammHolds(
|
||||
@@ -203,8 +202,7 @@ AMMDeposit::preclaim(PreclaimContext const& ctx)
|
||||
if (amountBalance != beast::kZero || amount2Balance != beast::kZero)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx.j.debug()) << "AMM Deposit: tokens balance is not zero.";
|
||||
return tecINTERNAL;
|
||||
return {tecINTERNAL, "AMM Deposit: tokens balance is not zero."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
}
|
||||
@@ -216,8 +214,7 @@ AMMDeposit::preclaim(PreclaimContext const& ctx)
|
||||
lptAMMBalance < beast::kZero)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx.j.debug()) << "AMM Deposit: reserves or tokens balance is zero.";
|
||||
return tecINTERNAL;
|
||||
return {tecINTERNAL, "AMM Deposit: reserves or tokens balance is zero."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
}
|
||||
@@ -393,8 +390,7 @@ AMMDeposit::preclaim(PreclaimContext const& ctx)
|
||||
// Insufficient reserve
|
||||
if (xrpBalance <= beast::kZero)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "AMM Instance: insufficient reserves";
|
||||
return tecINSUF_RESERVE_LINE;
|
||||
return {tecINSUF_RESERVE_LINE, "AMM Instance: insufficient reserves"};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,8 +61,7 @@ AMMVote::preclaim(PreclaimContext const& ctx)
|
||||
auto const ammSle = ctx.view.read(keylet::amm(ctx.tx[sfAsset], ctx.tx[sfAsset2]));
|
||||
if (!ammSle)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "AMM Vote: Invalid asset pair.";
|
||||
return terNO_AMM;
|
||||
return {terNO_AMM, "AMM Vote: Invalid asset pair."};
|
||||
}
|
||||
if (ammSle->getFieldAmount(sfLPTokenBalance) == beast::kZero)
|
||||
{
|
||||
@@ -71,8 +70,7 @@ AMMVote::preclaim(PreclaimContext const& ctx)
|
||||
if (auto const lpTokensNew = ammLPHolds(ctx.view, *ammSle, ctx.tx[sfAccount], ctx.j);
|
||||
lpTokensNew == beast::kZero)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "AMM Vote: account is not LP.";
|
||||
return tecAMM_INVALID_TOKENS;
|
||||
return {tecAMM_INVALID_TOKENS, "AMM Vote: account is not LP."};
|
||||
}
|
||||
|
||||
return tesSUCCESS;
|
||||
|
||||
@@ -186,8 +186,7 @@ AMMWithdraw::preclaim(PreclaimContext const& ctx)
|
||||
auto const ammSle = ctx.view.read(keylet::amm(ctx.tx[sfAsset], ctx.tx[sfAsset2]));
|
||||
if (!ammSle)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "AMM Withdraw: Invalid asset pair.";
|
||||
return terNO_AMM;
|
||||
return {terNO_AMM, "AMM Withdraw: Invalid asset pair."};
|
||||
}
|
||||
|
||||
auto const amount = ctx.tx[~sfAmount];
|
||||
@@ -210,8 +209,7 @@ AMMWithdraw::preclaim(PreclaimContext const& ctx)
|
||||
lptAMMBalance < beast::kZero)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx.j.debug()) << "AMM Withdraw: reserves or tokens balance is zero.";
|
||||
return tecINTERNAL;
|
||||
return {tecINTERNAL, "AMM Withdraw: reserves or tokens balance is zero."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -280,8 +278,7 @@ AMMWithdraw::preclaim(PreclaimContext const& ctx)
|
||||
|
||||
if (lpTokens <= beast::kZero)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "AMM Withdraw: tokens balance is zero.";
|
||||
return tecAMM_BALANCE;
|
||||
return {tecAMM_BALANCE, "AMM Withdraw: tokens balance is zero."};
|
||||
}
|
||||
|
||||
if (lpTokensWithdraw && lpTokensWithdraw->asset() != lpTokens.asset())
|
||||
@@ -292,8 +289,7 @@ AMMWithdraw::preclaim(PreclaimContext const& ctx)
|
||||
|
||||
if (lpTokensWithdraw && *lpTokensWithdraw > lpTokens)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "AMM Withdraw: invalid tokens.";
|
||||
return tecAMM_INVALID_TOKENS;
|
||||
return {tecAMM_INVALID_TOKENS, "AMM Withdraw: invalid tokens."};
|
||||
}
|
||||
|
||||
if (auto const ePrice = ctx.tx[~sfEPrice]; ePrice && ePrice->asset() != lpTokens.asset())
|
||||
|
||||
@@ -190,13 +190,11 @@ OfferCreate::preclaim(PreclaimContext const& ctx)
|
||||
|
||||
if (auto const ter = checkGlobalFrozen(ctx.view, saTakerPays.asset()); !isTesSuccess(ter))
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "Offer involves frozen or locked asset";
|
||||
return ter;
|
||||
return {ter, "Offer involves frozen or locked asset"};
|
||||
}
|
||||
if (auto const ter = checkGlobalFrozen(ctx.view, saTakerGets.asset()); !isTesSuccess(ter))
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "Offer involves frozen or locked asset";
|
||||
return ter;
|
||||
return {ter, "Offer involves frozen or locked asset"};
|
||||
}
|
||||
|
||||
// Allow unfunded MPT for issuer (OutstandingAmount >= MaximumAmount)
|
||||
@@ -209,8 +207,7 @@ OfferCreate::preclaim(PreclaimContext const& ctx)
|
||||
AuthHandling::ZeroIfUnauthorized,
|
||||
viewJ) <= beast::kZero)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "delay: Offers must be at least partially funded.";
|
||||
return tecUNFUNDED_OFFER;
|
||||
return {tecUNFUNDED_OFFER, "delay: Offers must be at least partially funded."};
|
||||
}
|
||||
|
||||
// This can probably be simplified to make sure that you cancel sequences
|
||||
@@ -587,8 +584,9 @@ OfferCreate::applyHybrid(
|
||||
|
||||
if (!bookNode)
|
||||
{
|
||||
JLOG(j_.debug()) << "final result: failed to add hybrid offer to open book";
|
||||
return tecDIR_FULL; // LCOV_EXCL_LINE
|
||||
return {
|
||||
tecDIR_FULL,
|
||||
"final result: failed to add hybrid offer to open book"}; // LCOV_EXCL_LINE
|
||||
}
|
||||
|
||||
STArray bookArr(sfAdditionalBooks, 1);
|
||||
|
||||
@@ -41,8 +41,7 @@ DIDDelete::deleteSLE(ApplyView& view, SLE::pointer sle, AccountID const owner, b
|
||||
if (!view.dirRemove(keylet::ownerDir(owner), (*sle)[sfOwnerNode], sle->key(), true))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j.fatal()) << "Unable to delete DID from owner.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Unable to delete DID from owner."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
|
||||
@@ -145,8 +145,7 @@ EscrowCancel::doApply()
|
||||
if (!ctx_.view().dirRemove(keylet::ownerDir(account), page, k.key, true))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.fatal()) << "Unable to delete Escrow from owner.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Unable to delete Escrow from owner."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
}
|
||||
@@ -157,8 +156,7 @@ EscrowCancel::doApply()
|
||||
if (!ctx_.view().dirRemove(keylet::ownerDir((*slep)[sfDestination]), *optPage, k.key, true))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.fatal()) << "Unable to delete Escrow from recipient.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Unable to delete Escrow from recipient."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
}
|
||||
@@ -202,8 +200,7 @@ EscrowCancel::doApply()
|
||||
if (!ctx_.view().dirRemove(keylet::ownerDir(issuer), *optPage, k.key, true))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.fatal()) << "Unable to delete Escrow from recipient.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Unable to delete Escrow from recipient."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,8 +322,7 @@ EscrowFinish::doApply()
|
||||
if (!ctx_.view().dirRemove(keylet::ownerDir(account), page, k.key, true))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.fatal()) << "Unable to delete Escrow from owner.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Unable to delete Escrow from owner."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
}
|
||||
@@ -334,8 +333,7 @@ EscrowFinish::doApply()
|
||||
if (!ctx_.view().dirRemove(keylet::ownerDir(destID), *optPage, k.key, true))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.fatal()) << "Unable to delete Escrow from recipient.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Unable to delete Escrow from recipient."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
}
|
||||
@@ -390,8 +388,7 @@ EscrowFinish::doApply()
|
||||
if (!ctx_.view().dirRemove(keylet::ownerDir(issuer), *optPage, k.key, true))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.fatal()) << "Unable to delete Escrow from recipient.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Unable to delete Escrow from recipient."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,8 +248,7 @@ LoanBrokerCoverClawback::preclaim(PreclaimContext const& ctx)
|
||||
auto const sleBroker = ctx.view.read(keylet::loanBroker(brokerID));
|
||||
if (!sleBroker)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "LoanBroker does not exist.";
|
||||
return tecNO_ENTRY;
|
||||
return {tecNO_ENTRY, "LoanBroker does not exist."};
|
||||
}
|
||||
|
||||
auto const brokerPseudoAccountID = sleBroker->at(sfAccount);
|
||||
@@ -267,16 +266,14 @@ LoanBrokerCoverClawback::preclaim(PreclaimContext const& ctx)
|
||||
|
||||
if (vaultAsset.native())
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Cannot clawback native asset.";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "Cannot clawback native asset."};
|
||||
}
|
||||
|
||||
// Only the issuer of the vault asset can claw it back from the broker's
|
||||
// cover funds.
|
||||
if (vaultAsset.getIssuer() != account)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Account is not the issuer of the vault asset.";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "Account is not the issuer of the vault asset."};
|
||||
}
|
||||
|
||||
if (amount)
|
||||
@@ -287,9 +284,10 @@ LoanBrokerCoverClawback::preclaim(PreclaimContext const& ctx)
|
||||
auto const txAsset = *findAsset;
|
||||
if (txAsset != vaultAsset)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Account is the correct issuer, but trying "
|
||||
"to clawback the wrong asset from LoanBroker";
|
||||
return tecWRONG_ASSET;
|
||||
return {
|
||||
tecWRONG_ASSET,
|
||||
"Account is the correct issuer, but trying to clawback the wrong asset from "
|
||||
"LoanBroker"};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,8 +321,7 @@ LoanBrokerCoverClawback::preclaim(PreclaimContext const& ctx)
|
||||
if (!sleIssuer)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx.j.fatal()) << "Issuer account does not exist.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Issuer account does not exist."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
|
||||
@@ -54,13 +54,11 @@ LoanBrokerCoverDeposit::preclaim(PreclaimContext const& ctx)
|
||||
auto const sleBroker = ctx.view.read(keylet::loanBroker(brokerID));
|
||||
if (!sleBroker)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "LoanBroker does not exist.";
|
||||
return tecNO_ENTRY;
|
||||
return {tecNO_ENTRY, "LoanBroker does not exist."};
|
||||
}
|
||||
if (account != sleBroker->at(sfOwner))
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Account is not the owner of the LoanBroker.";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "Account is not the owner of the LoanBroker."};
|
||||
}
|
||||
auto const vault = ctx.view.read(keylet::vault(sleBroker->at(sfVaultID)));
|
||||
if (!vault)
|
||||
|
||||
@@ -67,19 +67,16 @@ LoanBrokerCoverWithdraw::preclaim(PreclaimContext const& ctx)
|
||||
|
||||
if (isPseudoAccount(ctx.view, dstAcct))
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Trying to withdraw into a pseudo-account.";
|
||||
return tecPSEUDO_ACCOUNT;
|
||||
return {tecPSEUDO_ACCOUNT, "Trying to withdraw into a pseudo-account."};
|
||||
}
|
||||
auto const sleBroker = ctx.view.read(keylet::loanBroker(brokerID));
|
||||
if (!sleBroker)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "LoanBroker does not exist.";
|
||||
return tecNO_ENTRY;
|
||||
return {tecNO_ENTRY, "LoanBroker does not exist."};
|
||||
}
|
||||
if (account != sleBroker->at(sfOwner))
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Account is not the owner of the LoanBroker.";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "Account is not the owner of the LoanBroker."};
|
||||
}
|
||||
auto const vault = ctx.view.read(keylet::vault(sleBroker->at(sfVaultID)));
|
||||
if (!vault)
|
||||
|
||||
@@ -46,16 +46,14 @@ LoanBrokerDelete::preclaim(PreclaimContext const& ctx)
|
||||
auto const sleBroker = ctx.view.read(keylet::loanBroker(brokerID));
|
||||
if (!sleBroker)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "LoanBroker does not exist.";
|
||||
return tecNO_ENTRY;
|
||||
return {tecNO_ENTRY, "LoanBroker does not exist."};
|
||||
}
|
||||
|
||||
auto const brokerOwner = sleBroker->at(sfOwner);
|
||||
|
||||
if (account != brokerOwner)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Account is not the owner of the LoanBroker.";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "Account is not the owner of the LoanBroker."};
|
||||
}
|
||||
if (auto const ownerCount = sleBroker->at(sfOwnerCount); ownerCount != 0)
|
||||
{
|
||||
@@ -170,18 +168,21 @@ LoanBrokerDelete::doApply()
|
||||
// obligations associated with the broker or broker pseudo-account.
|
||||
if (*brokerPseudoSLE->at(sfBalance))
|
||||
{
|
||||
JLOG(j_.warn()) << "LoanBrokerDelete: Pseudo-account has a balance";
|
||||
return tecHAS_OBLIGATIONS; // LCOV_EXCL_LINE
|
||||
return {
|
||||
tecHAS_OBLIGATIONS,
|
||||
"LoanBrokerDelete: Pseudo-account has a balance"}; // LCOV_EXCL_LINE
|
||||
}
|
||||
if (brokerPseudoSLE->at(sfOwnerCount) != 0)
|
||||
{
|
||||
JLOG(j_.warn()) << "LoanBrokerDelete: Pseudo-account still owns objects";
|
||||
return tecHAS_OBLIGATIONS; // LCOV_EXCL_LINE
|
||||
return {
|
||||
tecHAS_OBLIGATIONS,
|
||||
"LoanBrokerDelete: Pseudo-account still owns objects"}; // LCOV_EXCL_LINE
|
||||
}
|
||||
if (auto const directory = keylet::ownerDir(brokerPseudoID); view().read(directory))
|
||||
{
|
||||
JLOG(j_.warn()) << "LoanBrokerDelete: Pseudo-account has a directory";
|
||||
return tecHAS_OBLIGATIONS; // LCOV_EXCL_LINE
|
||||
return {
|
||||
tecHAS_OBLIGATIONS,
|
||||
"LoanBrokerDelete: Pseudo-account has a directory"}; // LCOV_EXCL_LINE
|
||||
}
|
||||
|
||||
view().erase(brokerPseudoSLE);
|
||||
|
||||
@@ -99,15 +99,13 @@ LoanBrokerSet::preclaim(PreclaimContext const& ctx)
|
||||
auto const sleVault = ctx.view.read(keylet::vault(vaultID));
|
||||
if (!sleVault)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Vault does not exist.";
|
||||
return tecNO_ENTRY;
|
||||
return {tecNO_ENTRY, "Vault does not exist."};
|
||||
}
|
||||
Asset const asset = sleVault->at(sfAsset);
|
||||
|
||||
if (account != sleVault->at(sfOwner))
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Account is not the owner of the Vault.";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "Account is not the owner of the Vault."};
|
||||
}
|
||||
|
||||
if (auto const brokerID = tx[~sfLoanBrokerID])
|
||||
@@ -117,18 +115,15 @@ LoanBrokerSet::preclaim(PreclaimContext const& ctx)
|
||||
auto const sleBroker = ctx.view.read(keylet::loanBroker(*brokerID));
|
||||
if (!sleBroker)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "LoanBroker does not exist.";
|
||||
return tecNO_ENTRY;
|
||||
return {tecNO_ENTRY, "LoanBroker does not exist."};
|
||||
}
|
||||
if (vaultID != sleBroker->at(sfVaultID))
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Can not change VaultID on an existing LoanBroker.";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "Can not change VaultID on an existing LoanBroker."};
|
||||
}
|
||||
if (account != sleBroker->at(sfOwner))
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Account is not the owner of the LoanBroker.";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "Account is not the owner of the LoanBroker."};
|
||||
}
|
||||
|
||||
if (auto const debtMax = tx[~sfDebtMaximum])
|
||||
@@ -137,8 +132,7 @@ LoanBrokerSet::preclaim(PreclaimContext const& ctx)
|
||||
auto const currentDebtTotal = sleBroker->at(sfDebtTotal);
|
||||
if (*debtMax != 0 && *debtMax < currentDebtTotal)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Cannot reduce DebtMaximum below current DebtTotal.";
|
||||
return tecLIMIT_EXCEEDED;
|
||||
return {tecLIMIT_EXCEEDED, "Cannot reduce DebtMaximum below current DebtTotal."};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,8 +143,7 @@ LoanBrokerSet::preclaim(PreclaimContext const& ctx)
|
||||
|
||||
if (auto const ter = checkFrozen(ctx.view, sleVault->at(sfAccount), sleVault->at(sfAsset)))
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Vault pseudo-account is frozen.";
|
||||
return ter;
|
||||
return {ter, "Vault pseudo-account is frozen."};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,8 +176,7 @@ LoanBrokerSet::doApply()
|
||||
{
|
||||
// This should be impossible
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.fatal()) << "LoanBroker does not exist.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "LoanBroker does not exist."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -212,8 +204,7 @@ LoanBrokerSet::doApply()
|
||||
{
|
||||
// This should be impossible
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.fatal()) << "Vault does not exist.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Vault does not exist."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
auto const vaultPseudoID = sleVault->at(sfAccount);
|
||||
@@ -225,8 +216,7 @@ LoanBrokerSet::doApply()
|
||||
{
|
||||
// This should be impossible
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.fatal()) << "Account does not exist.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Account does not exist."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
auto broker = std::make_shared<SLE>(keylet::loanBroker(accountID_, sequence));
|
||||
|
||||
@@ -44,13 +44,11 @@ LoanDelete::preclaim(PreclaimContext const& ctx)
|
||||
auto const loanSle = ctx.view.read(keylet::loan(loanID));
|
||||
if (!loanSle)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Loan does not exist.";
|
||||
return tecNO_ENTRY;
|
||||
return {tecNO_ENTRY, "Loan does not exist."};
|
||||
}
|
||||
if (loanSle->at(sfPaymentRemaining) > 0)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Active loan can not be deleted.";
|
||||
return tecHAS_OBLIGATIONS;
|
||||
return {tecHAS_OBLIGATIONS, "Active loan can not be deleted."};
|
||||
}
|
||||
|
||||
auto const loanBrokerID = loanSle->at(sfLoanBrokerID);
|
||||
@@ -62,8 +60,7 @@ LoanDelete::preclaim(PreclaimContext const& ctx)
|
||||
}
|
||||
if (loanBrokerSle->at(sfOwner) != account && loanSle->at(sfBorrower) != account)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Account is not Loan Broker Owner or Loan Borrower.";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "Account is not Loan Broker Owner or Loan Borrower."};
|
||||
}
|
||||
|
||||
return tesSUCCESS;
|
||||
|
||||
@@ -72,8 +72,7 @@ LoanManage::preclaim(PreclaimContext const& ctx)
|
||||
auto const loanSle = ctx.view.read(keylet::loan(loanID));
|
||||
if (!loanSle)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Loan does not exist.";
|
||||
return tecNO_ENTRY;
|
||||
return {tecNO_ENTRY, "Loan does not exist."};
|
||||
}
|
||||
// Impairment only allows certain transitions.
|
||||
// 1. Once it's in default, it can't be changed.
|
||||
@@ -83,31 +82,27 @@ LoanManage::preclaim(PreclaimContext const& ctx)
|
||||
// 4. If it's in a state, it can't be put in that state again.
|
||||
if (loanSle->isFlag(lsfLoanDefault))
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Loan is in default. A defaulted loan can not be modified.";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "Loan is in default. A defaulted loan can not be modified."};
|
||||
}
|
||||
if (loanSle->isFlag(lsfLoanImpaired) && tx.isFlag(tfLoanImpair))
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Loan is impaired. A loan can not be impaired twice.";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "Loan is impaired. A loan can not be impaired twice."};
|
||||
}
|
||||
if (!(loanSle->isFlag(lsfLoanImpaired) || loanSle->isFlag(lsfLoanDefault)) &&
|
||||
(tx.isFlag(tfLoanUnimpair)))
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Loan is unimpaired. Can not be unimpaired again.";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "Loan is unimpaired. Can not be unimpaired again."};
|
||||
}
|
||||
if (loanSle->at(sfPaymentRemaining) == 0)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Loan is fully paid. A loan can not be modified "
|
||||
"after it is fully paid.";
|
||||
return tecNO_PERMISSION;
|
||||
return {
|
||||
tecNO_PERMISSION,
|
||||
"Loan is fully paid. A loan can not be modified after it is fully paid."};
|
||||
}
|
||||
if (tx.isFlag(tfLoanDefault) &&
|
||||
!hasExpired(ctx.view, loanSle->at(sfNextPaymentDueDate) + loanSle->at(sfGracePeriod)))
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "A loan can not be defaulted before the next payment due date.";
|
||||
return tecTOO_SOON;
|
||||
return {tecTOO_SOON, "A loan can not be defaulted before the next payment due date."};
|
||||
}
|
||||
|
||||
auto const loanBrokerID = loanSle->at(sfLoanBrokerID);
|
||||
@@ -119,9 +114,10 @@ LoanManage::preclaim(PreclaimContext const& ctx)
|
||||
}
|
||||
if (loanBrokerSle->at(sfOwner) != account)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "LoanBroker for Loan does not belong to the account. LoanManage "
|
||||
"can only be submitted by the Loan Broker.";
|
||||
return tecNO_PERMISSION;
|
||||
return {
|
||||
tecNO_PERMISSION,
|
||||
"LoanBroker for Loan does not belong to the account. LoanManage can only be submitted "
|
||||
"by the Loan Broker."};
|
||||
}
|
||||
|
||||
return tesSUCCESS;
|
||||
@@ -199,8 +195,7 @@ LoanManage::defaultLoan(
|
||||
if (vaultTotalProxy < vaultDefaultAmount)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j.warn()) << "Vault total assets is less than the vault default amount";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Vault total assets is less than the vault default amount"};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -244,8 +239,7 @@ LoanManage::defaultLoan(
|
||||
if (vaultLossUnrealizedProxy < totalDefaultAmount)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j.warn()) << "Vault unrealized loss is less than the default amount";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Vault unrealized loss is less than the default amount"};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
adjustImpreciseNumber(
|
||||
@@ -264,8 +258,7 @@ LoanManage::defaultLoan(
|
||||
if (coverAvailableProxy < defaultCovered)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j.warn()) << "LoanBroker cover available is less than amount covered";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "LoanBroker cover available is less than amount covered"};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
coverAvailableProxy -= defaultCovered;
|
||||
@@ -318,9 +311,8 @@ LoanManage::impairLoan(
|
||||
{
|
||||
// Having a loss greater than the vault's unavailable assets
|
||||
// will leave the vault in an invalid / inconsistent state.
|
||||
JLOG(j.warn()) << "Vault unrealized loss is too large, and will "
|
||||
"corrupt the vault.";
|
||||
return tecLIMIT_EXCEEDED;
|
||||
return {
|
||||
tecLIMIT_EXCEEDED, "Vault unrealized loss is too large, and will corrupt the vault."};
|
||||
}
|
||||
view.update(vaultSle);
|
||||
|
||||
@@ -357,8 +349,7 @@ LoanManage::unimpairLoan(
|
||||
if (vaultLossUnrealizedProxy < lossReversed)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j.warn()) << "Vault unrealized loss is less than the amount to be cleared";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Vault unrealized loss is less than the amount to be cleared"};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
// Reverse the "paper loss"
|
||||
|
||||
@@ -187,14 +187,12 @@ LoanPay::preclaim(PreclaimContext const& ctx)
|
||||
auto const loanSle = ctx.view.read(keylet::loan(loanID));
|
||||
if (!loanSle)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Loan does not exist.";
|
||||
return tecNO_ENTRY;
|
||||
return {tecNO_ENTRY, "Loan does not exist."};
|
||||
}
|
||||
|
||||
if (loanSle->at(sfBorrower) != account)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Loan does not belong to the account.";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "Loan does not belong to the account."};
|
||||
}
|
||||
|
||||
if (tx.isFlag(tfLoanOverpayment) && !loanSle->isFlag(lsfLoanOverpayment))
|
||||
@@ -208,8 +206,7 @@ LoanPay::preclaim(PreclaimContext const& ctx)
|
||||
|
||||
if (paymentRemaining == 0 || principalOutstanding == 0)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Loan is already paid off.";
|
||||
return tecKILLED;
|
||||
return {tecKILLED, "Loan is already paid off."};
|
||||
}
|
||||
|
||||
auto const loanBrokerID = loanSle->at(sfLoanBrokerID);
|
||||
@@ -218,8 +215,7 @@ LoanPay::preclaim(PreclaimContext const& ctx)
|
||||
{
|
||||
// This should be impossible
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx.j.fatal()) << "LoanBroker does not exist.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "LoanBroker does not exist."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
auto const vaultID = loanBrokerSle->at(sfVaultID);
|
||||
@@ -228,8 +224,7 @@ LoanPay::preclaim(PreclaimContext const& ctx)
|
||||
{
|
||||
// This should be impossible
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx.j.fatal()) << "Vault does not exist.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Vault does not exist."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
auto const asset = vaultSle->at(sfAsset);
|
||||
@@ -237,8 +232,7 @@ LoanPay::preclaim(PreclaimContext const& ctx)
|
||||
|
||||
if (amount.asset() != asset)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Loan amount does not match the Vault asset.";
|
||||
return tecWRONG_ASSET;
|
||||
return {tecWRONG_ASSET, "Loan amount does not match the Vault asset."};
|
||||
}
|
||||
|
||||
if (auto const ret = checkFrozen(ctx.view, account, asset))
|
||||
@@ -415,8 +409,7 @@ LoanPay::doApply()
|
||||
paymentParts->feePaid < 0)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.fatal()) << "Loan payment computation returned invalid values.";
|
||||
return tecLIMIT_EXCEEDED;
|
||||
return {tecLIMIT_EXCEEDED, "Loan payment computation returned invalid values."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
|
||||
@@ -246,29 +246,27 @@ LoanSet::preclaim(PreclaimContext const& ctx)
|
||||
// mostly so that unit tests can test that specific case.
|
||||
if (grace > timeAvailable)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Grace period exceeds protocol time limit.";
|
||||
return tecKILLED;
|
||||
return {tecKILLED, "Grace period exceeds protocol time limit."};
|
||||
}
|
||||
|
||||
if (interval > timeAvailable)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Payment interval exceeds protocol time limit.";
|
||||
return tecKILLED;
|
||||
return {tecKILLED, "Payment interval exceeds protocol time limit."};
|
||||
}
|
||||
|
||||
if (total > timeAvailable)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Payment total exceeds protocol time limit.";
|
||||
return tecKILLED;
|
||||
return {tecKILLED, "Payment total exceeds protocol time limit."};
|
||||
}
|
||||
|
||||
auto const timeLastPayment = timeAvailable - grace;
|
||||
|
||||
if (timeLastPayment / interval < total)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Last payment due date, or grace period for "
|
||||
"last payment exceeds protocol time limit.";
|
||||
return tecKILLED;
|
||||
return {
|
||||
tecKILLED,
|
||||
"Last payment due date, or grace period for last payment exceeds protocol time "
|
||||
"limit."};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,16 +278,14 @@ LoanSet::preclaim(PreclaimContext const& ctx)
|
||||
{
|
||||
// This can only be hit if there's a counterparty specified, otherwise
|
||||
// it'll fail in the signature check
|
||||
JLOG(ctx.j.warn()) << "LoanBroker does not exist.";
|
||||
return tecNO_ENTRY;
|
||||
return {tecNO_ENTRY, "LoanBroker does not exist."};
|
||||
}
|
||||
auto const brokerOwner = brokerSle->at(sfOwner);
|
||||
auto const counterparty = tx[~sfCounterparty].value_or(brokerOwner);
|
||||
if (account != brokerOwner && counterparty != brokerOwner)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Neither Account nor Counterparty are the owner "
|
||||
"of the LoanBroker.";
|
||||
return tecNO_PERMISSION;
|
||||
return {
|
||||
tecNO_PERMISSION, "Neither Account nor Counterparty are the owner of the LoanBroker."};
|
||||
}
|
||||
auto const brokerPseudo = brokerSle->at(sfAccount);
|
||||
|
||||
@@ -298,8 +294,7 @@ LoanSet::preclaim(PreclaimContext const& ctx)
|
||||
{
|
||||
// It may not be possible to hit this case, because it'll fail the
|
||||
// signature check with terNO_ACCOUNT.
|
||||
JLOG(ctx.j.warn()) << "Borrower does not exist.";
|
||||
return terNO_ACCOUNT;
|
||||
return {terNO_ACCOUNT, "Borrower does not exist."};
|
||||
}
|
||||
|
||||
auto const vault = ctx.view.read(keylet::vault(brokerSle->at(sfVaultID)));
|
||||
@@ -311,8 +306,7 @@ LoanSet::preclaim(PreclaimContext const& ctx)
|
||||
|
||||
if (vault->at(sfAssetsMaximum) != 0 && vault->at(sfAssetsTotal) >= vault->at(sfAssetsMaximum))
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Vault at maximum assets limit. Can't add another loan.";
|
||||
return tecLIMIT_EXCEEDED;
|
||||
return {tecLIMIT_EXCEEDED, "Vault at maximum assets limit. Can't add another loan."};
|
||||
}
|
||||
|
||||
Asset const asset = vault->at(sfAsset);
|
||||
@@ -415,8 +409,8 @@ LoanSet::doApply()
|
||||
auto const vaultScale = getAssetsTotalScale(vaultSle);
|
||||
if (vaultAvailableProxy < principalRequested)
|
||||
{
|
||||
JLOG(j_.warn()) << "Insufficient assets available in the Vault to fund the loan.";
|
||||
return tecINSUFFICIENT_FUNDS;
|
||||
return {
|
||||
tecINSUFFICIENT_FUNDS, "Insufficient assets available in the Vault to fund the loan."};
|
||||
}
|
||||
|
||||
TenthBips32 const interestRate{tx[~sfInterestRate].value_or(0)};
|
||||
@@ -446,8 +440,7 @@ LoanSet::doApply()
|
||||
"Vault is below maximum limit");
|
||||
if (vaultMaximum != 0 && state.interestDue > vaultMaximum - vaultTotalProxy)
|
||||
{
|
||||
JLOG(j_.warn()) << "Loan would exceed the maximum assets of the vault";
|
||||
return tecLIMIT_EXCEEDED;
|
||||
return {tecLIMIT_EXCEEDED, "Loan would exceed the maximum assets of the vault"};
|
||||
}
|
||||
// Check that relevant values won't lose precision. This is mostly only
|
||||
// relevant for IOU assets.
|
||||
@@ -495,8 +488,7 @@ LoanSet::doApply()
|
||||
if (auto const debtMaximum = brokerSle->at(sfDebtMaximum);
|
||||
debtMaximum != 0 && debtMaximum < newDebtTotal)
|
||||
{
|
||||
JLOG(j_.warn()) << "Loan would exceed the maximum debt limit of the LoanBroker.";
|
||||
return tecLIMIT_EXCEEDED;
|
||||
return {tecLIMIT_EXCEEDED, "Loan would exceed the maximum debt limit of the LoanBroker."};
|
||||
}
|
||||
TenthBips32 const coverRateMinimum{brokerSle->at(sfCoverRateMinimum)};
|
||||
{
|
||||
@@ -514,8 +506,7 @@ LoanSet::doApply()
|
||||
}();
|
||||
if (brokerSle->at(sfCoverAvailable) < minCover)
|
||||
{
|
||||
JLOG(j_.warn()) << "Insufficient first-loss capital to cover the loan.";
|
||||
return tecINSUFFICIENT_FUNDS;
|
||||
return {tecINSUFFICIENT_FUNDS, "Insufficient first-loss capital to cover the loan."};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,16 +34,14 @@ OracleDelete::preclaim(PreclaimContext const& ctx)
|
||||
ctx.view.read(keylet::oracle(ctx.tx.getAccountID(sfAccount), ctx.tx[sfOracleDocumentID]));
|
||||
if (!sle)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "Oracle Delete: Oracle does not exist.";
|
||||
return tecNO_ENTRY;
|
||||
return {tecNO_ENTRY, "Oracle Delete: Oracle does not exist."};
|
||||
}
|
||||
|
||||
if (ctx.tx.getAccountID(sfAccount) != sle->getAccountID(sfOwner))
|
||||
{
|
||||
// this can't happen because of the above check
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx.j.debug()) << "Oracle Delete: invalid account.";
|
||||
return tecINTERNAL;
|
||||
return {tecINTERNAL, "Oracle Delete: invalid account."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
return tesSUCCESS;
|
||||
@@ -62,8 +60,7 @@ OracleDelete::deleteOracle(
|
||||
if (!view.dirRemove(keylet::ownerDir(account), (*sle)[sfOwnerNode], sle->key(), true))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j.fatal()) << "Unable to delete Oracle from owner.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Unable to delete Oracle from owner."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
|
||||
@@ -267,8 +267,7 @@ DepositPreauth::removeFromLedger(ApplyView& view, uint256 const& preauthIndex, b
|
||||
auto const slePreauth{view.peek(keylet::depositPreauth(preauthIndex))};
|
||||
if (!slePreauth)
|
||||
{
|
||||
JLOG(j.warn()) << "Selected DepositPreauth does not exist.";
|
||||
return tecNO_ENTRY;
|
||||
return {tecNO_ENTRY, "Selected DepositPreauth does not exist."};
|
||||
}
|
||||
|
||||
AccountID const account{(*slePreauth)[sfAccount]};
|
||||
@@ -276,8 +275,7 @@ DepositPreauth::removeFromLedger(ApplyView& view, uint256 const& preauthIndex, b
|
||||
if (!view.dirRemove(keylet::ownerDir(account), page, preauthIndex, false))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j.fatal()) << "Unable to delete DepositPreauth from owner.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Unable to delete DepositPreauth from owner."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
|
||||
@@ -429,9 +429,7 @@ Payment::preclaim(PreclaimContext const& ctx)
|
||||
|
||||
// We didn't make this test for a newly-formed account because there's
|
||||
// no way for this field to be set.
|
||||
JLOG(ctx.j.trace()) << "Malformed transaction: DestinationTag required.";
|
||||
|
||||
return tecDST_TAG_NEEDED;
|
||||
return {tecDST_TAG_NEEDED, "Malformed transaction: DestinationTag required."};
|
||||
}
|
||||
|
||||
// Payment with at least one intermediate step and uses transitive balances.
|
||||
|
||||
@@ -58,8 +58,7 @@ PermissionedDomainDelete::doApply()
|
||||
if (!view().dirRemove(keylet::ownerDir(accountID_), page, slePd->key(), true))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.fatal()) << "Unable to delete permissioned domain directory entry.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Unable to delete permissioned domain directory entry."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
|
||||
@@ -182,15 +182,13 @@ deleteSponsorship(ApplyView& view, SLE::ref sle, beast::Journal j)
|
||||
if (!view.dirRemove(keylet::ownerDir(sponsorID), (*sle)[sfOwnerNode], sle->key(), false))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j.fatal()) << "Unable to delete Sponsorship from sponsor.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Unable to delete Sponsorship from sponsor."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
if (!view.dirRemove(keylet::ownerDir(sponseeID), (*sle)[sfSponseeNode], sle->key(), false))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j.fatal()) << "Unable to delete Sponsorship from sponsee.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "Unable to delete Sponsorship from sponsee."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
|
||||
@@ -287,8 +287,7 @@ Change::applyFee()
|
||||
|
||||
view().update(feeObject);
|
||||
|
||||
JLOG(j_.warn()) << "Fees have been changed";
|
||||
return tesSUCCESS;
|
||||
return {tesSUCCESS, "Fees have been changed"};
|
||||
}
|
||||
|
||||
TER
|
||||
@@ -304,8 +303,7 @@ Change::applyUNLModify()
|
||||
ctx_.tx.getFieldU8(sfUNLModifyDisabling) > 1 || !ctx_.tx.isFieldPresent(sfLedgerSequence) ||
|
||||
!ctx_.tx.isFieldPresent(sfUNLModifyValidator))
|
||||
{
|
||||
JLOG(j_.warn()) << "N-UNL: applyUNLModify, wrong Tx format.";
|
||||
return tefFAILURE;
|
||||
return {tefFAILURE, "N-UNL: applyUNLModify, wrong Tx format."};
|
||||
}
|
||||
|
||||
bool const disabling = ctx_.tx.getFieldU8(sfUNLModifyDisabling) != 0u;
|
||||
@@ -319,8 +317,7 @@ Change::applyUNLModify()
|
||||
Blob const validator = ctx_.tx.getFieldVL(sfUNLModifyValidator);
|
||||
if (!publicKeyType(makeSlice(validator)))
|
||||
{
|
||||
JLOG(j_.warn()) << "N-UNL: applyUNLModify, bad validator key";
|
||||
return tefFAILURE;
|
||||
return {tefFAILURE, "N-UNL: applyUNLModify, bad validator key"};
|
||||
}
|
||||
|
||||
JLOG(j_.info()) << "N-UNL: applyUNLModify, " << (disabling ? "ToDisable" : "ToReEnable")
|
||||
@@ -352,8 +349,7 @@ Change::applyUNLModify()
|
||||
// cannot have more than one toDisable
|
||||
if (negUnlObject->isFieldPresent(sfValidatorToDisable))
|
||||
{
|
||||
JLOG(j_.warn()) << "N-UNL: applyUNLModify, already has ToDisable";
|
||||
return tefFAILURE;
|
||||
return {tefFAILURE, "N-UNL: applyUNLModify, already has ToDisable"};
|
||||
}
|
||||
|
||||
// cannot be the same as toReEnable
|
||||
@@ -361,16 +357,14 @@ Change::applyUNLModify()
|
||||
{
|
||||
if (negUnlObject->getFieldVL(sfValidatorToReEnable) == validator)
|
||||
{
|
||||
JLOG(j_.warn()) << "N-UNL: applyUNLModify, ToDisable is same as ToReEnable";
|
||||
return tefFAILURE;
|
||||
return {tefFAILURE, "N-UNL: applyUNLModify, ToDisable is same as ToReEnable"};
|
||||
}
|
||||
}
|
||||
|
||||
// cannot be in negative UNL already
|
||||
if (found)
|
||||
{
|
||||
JLOG(j_.warn()) << "N-UNL: applyUNLModify, ToDisable already in negative UNL";
|
||||
return tefFAILURE;
|
||||
return {tefFAILURE, "N-UNL: applyUNLModify, ToDisable already in negative UNL"};
|
||||
}
|
||||
|
||||
negUnlObject->setFieldVL(sfValidatorToDisable, validator);
|
||||
@@ -380,8 +374,7 @@ Change::applyUNLModify()
|
||||
// cannot have more than one toReEnable
|
||||
if (negUnlObject->isFieldPresent(sfValidatorToReEnable))
|
||||
{
|
||||
JLOG(j_.warn()) << "N-UNL: applyUNLModify, already has ToReEnable";
|
||||
return tefFAILURE;
|
||||
return {tefFAILURE, "N-UNL: applyUNLModify, already has ToReEnable"};
|
||||
}
|
||||
|
||||
// cannot be the same as toDisable
|
||||
@@ -389,16 +382,14 @@ Change::applyUNLModify()
|
||||
{
|
||||
if (negUnlObject->getFieldVL(sfValidatorToDisable) == validator)
|
||||
{
|
||||
JLOG(j_.warn()) << "N-UNL: applyUNLModify, ToReEnable is same as ToDisable";
|
||||
return tefFAILURE;
|
||||
return {tefFAILURE, "N-UNL: applyUNLModify, ToReEnable is same as ToDisable"};
|
||||
}
|
||||
}
|
||||
|
||||
// must be in negative UNL
|
||||
if (!found)
|
||||
{
|
||||
JLOG(j_.warn()) << "N-UNL: applyUNLModify, ToReEnable is not in negative UNL";
|
||||
return tefFAILURE;
|
||||
return {tefFAILURE, "N-UNL: applyUNLModify, ToReEnable is not in negative UNL"};
|
||||
}
|
||||
|
||||
negUnlObject->setFieldVL(sfValidatorToReEnable, validator);
|
||||
|
||||
@@ -245,9 +245,8 @@ ConfidentialMPTConvert::doApply()
|
||||
if (!sum)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx_.journal.error())
|
||||
<< "ConfidentialMPTConvert failed homomorphic add for holder inbox.";
|
||||
return tecINTERNAL;
|
||||
return {
|
||||
tecINTERNAL, "ConfidentialMPTConvert failed homomorphic add for holder inbox."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -260,9 +259,9 @@ ConfidentialMPTConvert::doApply()
|
||||
if (!sum)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx_.journal.error())
|
||||
<< "ConfidentialMPTConvert failed homomorphic add for issuer balance.";
|
||||
return tecINTERNAL;
|
||||
return {
|
||||
tecINTERNAL,
|
||||
"ConfidentialMPTConvert failed homomorphic add for issuer balance."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -279,9 +278,9 @@ ConfidentialMPTConvert::doApply()
|
||||
if (!sum)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx_.journal.error())
|
||||
<< "ConfidentialMPTConvert failed homomorphic add for auditor balance.";
|
||||
return tecINTERNAL;
|
||||
return {
|
||||
tecINTERNAL,
|
||||
"ConfidentialMPTConvert failed homomorphic add for auditor balance."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
|
||||
@@ -244,10 +244,10 @@ ConfidentialMPTConvertBack::doApply()
|
||||
if (!res)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx_.journal.error())
|
||||
<< "ConfidentialMPTConvertBack failed homomorphic subtract for holder spending "
|
||||
"balance.";
|
||||
return tecINTERNAL;
|
||||
return {
|
||||
tecINTERNAL,
|
||||
"ConfidentialMPTConvertBack failed homomorphic subtract for holder spending "
|
||||
"balance."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -261,9 +261,9 @@ ConfidentialMPTConvertBack::doApply()
|
||||
if (!res)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx_.journal.error())
|
||||
<< "ConfidentialMPTConvertBack failed homomorphic subtract for issuer balance.";
|
||||
return tecINTERNAL;
|
||||
return {
|
||||
tecINTERNAL,
|
||||
"ConfidentialMPTConvertBack failed homomorphic subtract for issuer balance."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -277,9 +277,9 @@ ConfidentialMPTConvertBack::doApply()
|
||||
if (!res)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx_.journal.error())
|
||||
<< "ConfidentialMPTConvertBack failed homomorphic subtract for auditor balance.";
|
||||
return tecINTERNAL;
|
||||
return {
|
||||
tecINTERNAL,
|
||||
"ConfidentialMPTConvertBack failed homomorphic subtract for auditor balance."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
|
||||
@@ -100,9 +100,7 @@ ConfidentialMPTMergeInbox::doApply()
|
||||
if (!sum)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx_.journal.error())
|
||||
<< "ConfidentialMPTMergeInbox failed homomorphic add for inbox merge.";
|
||||
return tecINTERNAL;
|
||||
return {tecINTERNAL, "ConfidentialMPTMergeInbox failed homomorphic add for inbox merge."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
|
||||
@@ -306,9 +306,9 @@ ConfidentialMPTSend::doApply()
|
||||
if (!newSpending)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx_.journal.error())
|
||||
<< "ConfidentialMPTSend failed homomorphic subtract for sender spending balance.";
|
||||
return tecINTERNAL;
|
||||
return {
|
||||
tecINTERNAL,
|
||||
"ConfidentialMPTSend failed homomorphic subtract for sender spending balance."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -322,9 +322,9 @@ ConfidentialMPTSend::doApply()
|
||||
if (!newIssuerEnc)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx_.journal.error())
|
||||
<< "ConfidentialMPTSend failed homomorphic subtract for sender issuer balance.";
|
||||
return tecINTERNAL;
|
||||
return {
|
||||
tecINTERNAL,
|
||||
"ConfidentialMPTSend failed homomorphic subtract for sender issuer balance."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -339,9 +339,9 @@ ConfidentialMPTSend::doApply()
|
||||
if (!newAuditorEnc)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx_.journal.error())
|
||||
<< "ConfidentialMPTSend failed homomorphic subtract for sender auditor balance.";
|
||||
return tecINTERNAL;
|
||||
return {
|
||||
tecINTERNAL,
|
||||
"ConfidentialMPTSend failed homomorphic subtract for sender auditor balance."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -360,9 +360,8 @@ ConfidentialMPTSend::doApply()
|
||||
if (!newInbox)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx_.journal.error())
|
||||
<< "ConfidentialMPTSend failed homomorphic add for destination inbox.";
|
||||
return tecINTERNAL;
|
||||
return {
|
||||
tecINTERNAL, "ConfidentialMPTSend failed homomorphic add for destination inbox."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -381,9 +380,9 @@ ConfidentialMPTSend::doApply()
|
||||
if (!newIssuerEnc)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx_.journal.error())
|
||||
<< "ConfidentialMPTSend failed homomorphic add for destination issuer balance.";
|
||||
return tecINTERNAL;
|
||||
return {
|
||||
tecINTERNAL,
|
||||
"ConfidentialMPTSend failed homomorphic add for destination issuer balance."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -403,9 +402,9 @@ ConfidentialMPTSend::doApply()
|
||||
if (!newAuditorEnc)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx_.journal.error())
|
||||
<< "ConfidentialMPTSend failed homomorphic add for destination auditor balance.";
|
||||
return tecINTERNAL;
|
||||
return {
|
||||
tecINTERNAL,
|
||||
"ConfidentialMPTSend failed homomorphic add for destination auditor balance."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
|
||||
@@ -165,8 +165,7 @@ TrustSet::preclaim(PreclaimContext const& ctx)
|
||||
|
||||
if (bSetAuth && !sle->isFlag(lsfRequireAuth))
|
||||
{
|
||||
JLOG(ctx.j.trace()) << "Retry: Auth not required.";
|
||||
return tefNO_AUTH_REQUIRED;
|
||||
return {tefNO_AUTH_REQUIRED, "Retry: Auth not required."};
|
||||
}
|
||||
|
||||
auto const saLimitAmount = ctx.tx[sfLimitAmount];
|
||||
@@ -354,8 +353,7 @@ TrustSet::doApply()
|
||||
|
||||
if (!sleDst)
|
||||
{
|
||||
JLOG(j_.trace()) << "Delay transaction: Destination account does not exist.";
|
||||
return tecNO_DST;
|
||||
return {tecNO_DST, "Delay transaction: Destination account does not exist."};
|
||||
}
|
||||
|
||||
STAmount saLimitAllow = saLimitAmount;
|
||||
@@ -683,8 +681,7 @@ TrustSet::doApply()
|
||||
// setting default quality out.
|
||||
(!bSetAuth))
|
||||
{
|
||||
JLOG(j_.trace()) << "Redundant: Setting non-existent ripple line to defaults.";
|
||||
return tecNO_LINE_REDUNDANT;
|
||||
return {tecNO_LINE_REDUNDANT, "Redundant: Setting non-existent ripple line to defaults."};
|
||||
}
|
||||
// reserve is not scaled by load
|
||||
else if (!view().rules().enabled(featureSponsor) && preFeeBalance_ < reserveCreate)
|
||||
|
||||
@@ -90,8 +90,7 @@ VaultClawback::preclaim(PreclaimContext const& ctx)
|
||||
if (!sleShareIssuance)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx.j.error()) << "VaultClawback: missing issuance of vault shares.";
|
||||
return tefINTERNAL;
|
||||
return {tefINTERNAL, "VaultClawback: missing issuance of vault shares."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -100,8 +99,7 @@ VaultClawback::preclaim(PreclaimContext const& ctx)
|
||||
// Ambiguous case: If Issuer is Owner they must specify the asset
|
||||
if (!maybeAmount && !vaultAsset.native() && vaultAsset.getIssuer() == vault->at(sfOwner))
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "VaultClawback: must specify amount when issuer is owner.";
|
||||
return tecWRONG_ASSET;
|
||||
return {tecWRONG_ASSET, "VaultClawback: must specify amount when issuer is owner."};
|
||||
}
|
||||
|
||||
auto const amount = clawbackAmount(vault, maybeAmount, account);
|
||||
@@ -115,8 +113,7 @@ VaultClawback::preclaim(PreclaimContext const& ctx)
|
||||
// Only the Vault Owner may clawback shares
|
||||
if (account != vault->at(sfOwner))
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "VaultClawback: only vault owner can clawback shares.";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "VaultClawback: only vault owner can clawback shares."};
|
||||
}
|
||||
|
||||
auto const assetsTotal = vault->at(sfAssetsTotal);
|
||||
@@ -126,9 +123,9 @@ VaultClawback::preclaim(PreclaimContext const& ctx)
|
||||
// Owner can clawback funds when the vault has shares but no assets
|
||||
if (sharesTotal == 0 || (assetsTotal != 0 || assetsAvailable != 0))
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "VaultClawback: vault owner can clawback shares only"
|
||||
" when vault has no assets.";
|
||||
return tecNO_PERMISSION;
|
||||
return {
|
||||
tecNO_PERMISSION,
|
||||
"VaultClawback: vault owner can clawback shares only when vault has no assets."};
|
||||
}
|
||||
|
||||
// If amount is non-zero, the VaultOwner must burn all shares
|
||||
@@ -145,9 +142,7 @@ VaultClawback::preclaim(PreclaimContext const& ctx)
|
||||
// The VaultOwner must burn all shares
|
||||
if (amount != sharesHeld)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "VaultClawback: vault owner must clawback all "
|
||||
"shares.";
|
||||
return tecLIMIT_EXCEEDED;
|
||||
return {tecLIMIT_EXCEEDED, "VaultClawback: vault owner must clawback all shares."};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,22 +155,19 @@ VaultClawback::preclaim(PreclaimContext const& ctx)
|
||||
// XRP cannot be clawed back
|
||||
if (vaultAsset.native())
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "VaultClawback: cannot clawback XRP.";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "VaultClawback: cannot clawback XRP."};
|
||||
}
|
||||
|
||||
// Only the Asset Issuer may clawback the asset
|
||||
if (account != vaultAsset.getIssuer())
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "VaultClawback: only asset issuer can clawback asset.";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "VaultClawback: only asset issuer can clawback asset."};
|
||||
}
|
||||
|
||||
// The issuer cannot clawback from itself
|
||||
if (account == holder)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "VaultClawback: issuer cannot be the holder.";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "VaultClawback: issuer cannot be the holder."};
|
||||
}
|
||||
|
||||
return vaultAsset.visit(
|
||||
@@ -186,9 +178,7 @@ VaultClawback::preclaim(PreclaimContext const& ctx)
|
||||
|
||||
if (!mptIssue->isFlag(lsfMPTCanClawback))
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "VaultClawback: cannot clawback "
|
||||
"MPT vault asset.";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "VaultClawback: cannot clawback MPT vault asset."};
|
||||
}
|
||||
|
||||
return tesSUCCESS;
|
||||
@@ -198,16 +188,13 @@ VaultClawback::preclaim(PreclaimContext const& ctx)
|
||||
if (!issuerSle)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx.j.error()) << "VaultClawback: missing submitter account.";
|
||||
return tefINTERNAL;
|
||||
return {tefINTERNAL, "VaultClawback: missing submitter account."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
if (!issuerSle->isFlag(lsfAllowTrustLineClawback) || issuerSle->isFlag(lsfNoFreeze))
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "VaultClawback: cannot clawback "
|
||||
"IOU vault asset.";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "VaultClawback: cannot clawback IOU vault asset."};
|
||||
}
|
||||
|
||||
return tesSUCCESS;
|
||||
@@ -341,8 +328,7 @@ VaultClawback::doApply()
|
||||
if (!sleIssuance)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.error()) << "VaultClawback: missing issuance of vault shares.";
|
||||
return tefINTERNAL;
|
||||
return {tefINTERNAL, "VaultClawback: missing issuance of vault shares."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
MPTIssue const share{mptIssuanceID};
|
||||
@@ -440,8 +426,7 @@ VaultClawback::doApply()
|
||||
j_) < beast::kZero)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.error()) << "VaultClawback: negative balance of vault assets.";
|
||||
return tefINTERNAL;
|
||||
return {tefINTERNAL, "VaultClawback: negative balance of vault assets."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,20 +48,17 @@ VaultDelete::preclaim(PreclaimContext const& ctx)
|
||||
|
||||
if (vault->at(sfOwner) != ctx.tx[sfAccount])
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "VaultDelete: account is not an owner.";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "VaultDelete: account is not an owner."};
|
||||
}
|
||||
|
||||
if (vault->at(sfAssetsAvailable) != 0)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "VaultDelete: nonzero assets available.";
|
||||
return tecHAS_OBLIGATIONS;
|
||||
return {tecHAS_OBLIGATIONS, "VaultDelete: nonzero assets available."};
|
||||
}
|
||||
|
||||
if (vault->at(sfAssetsTotal) != 0)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "VaultDelete: nonzero assets total.";
|
||||
return tecHAS_OBLIGATIONS;
|
||||
return {tecHAS_OBLIGATIONS, "VaultDelete: nonzero assets total."};
|
||||
}
|
||||
|
||||
// Verify we can destroy MPTokenIssuance
|
||||
@@ -70,23 +67,20 @@ VaultDelete::preclaim(PreclaimContext const& ctx)
|
||||
if (!sleMPT)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx.j.error()) << "VaultDelete: missing issuance of vault shares.";
|
||||
return tecOBJECT_NOT_FOUND;
|
||||
return {tecOBJECT_NOT_FOUND, "VaultDelete: missing issuance of vault shares."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
if (sleMPT->at(sfIssuer) != vault->getAccountID(sfAccount))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx.j.error()) << "VaultDelete: invalid owner of vault shares.";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "VaultDelete: invalid owner of vault shares."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
if (sleMPT->at(sfOutstandingAmount) != 0)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "VaultDelete: nonzero outstanding shares.";
|
||||
return tecHAS_OBLIGATIONS;
|
||||
return {tecHAS_OBLIGATIONS, "VaultDelete: nonzero outstanding shares."};
|
||||
}
|
||||
|
||||
return tesSUCCESS;
|
||||
@@ -112,8 +106,7 @@ VaultDelete::doApply()
|
||||
if (!pseudoAcct)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.error()) << "VaultDelete: missing vault pseudo-account.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "VaultDelete: missing vault pseudo-account."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -124,8 +117,7 @@ VaultDelete::doApply()
|
||||
if (!mpt)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.error()) << "VaultDelete: missing issuance of vault shares.";
|
||||
return tefINTERNAL;
|
||||
return {tefINTERNAL, "VaultDelete: missing issuance of vault shares."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -150,8 +142,7 @@ VaultDelete::doApply()
|
||||
if (!view().dirRemove(keylet::ownerDir(pseudoID), (*mpt)[sfOwnerNode], mpt->key(), false))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.error()) << "VaultDelete: failed to delete issuance object.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "VaultDelete: failed to delete issuance object."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
decreaseOwnerCountForObject(view(), pseudoAcct, mpt, 1, j_);
|
||||
@@ -172,22 +163,19 @@ VaultDelete::doApply()
|
||||
if (*vaultPseudoSLE->at(sfBalance))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.error()) << "VaultDelete: pseudo-account has a balance";
|
||||
return tecHAS_OBLIGATIONS;
|
||||
return {tecHAS_OBLIGATIONS, "VaultDelete: pseudo-account has a balance"};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
if (vaultPseudoSLE->at(sfOwnerCount) != 0)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.error()) << "VaultDelete: pseudo-account still owns objects";
|
||||
return tecHAS_OBLIGATIONS;
|
||||
return {tecHAS_OBLIGATIONS, "VaultDelete: pseudo-account still owns objects"};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
if (view().exists(keylet::ownerDir(pseudoID)))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.error()) << "VaultDelete: pseudo-account has a directory";
|
||||
return tecHAS_OBLIGATIONS;
|
||||
return {tecHAS_OBLIGATIONS, "VaultDelete: pseudo-account has a directory"};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -198,8 +186,7 @@ VaultDelete::doApply()
|
||||
if (!view().dirRemove(keylet::ownerDir(ownerID), vault->at(sfOwnerNode), vault->key(), false))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.error()) << "VaultDelete: failed to delete vault object.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "VaultDelete: failed to delete vault object."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -207,8 +194,7 @@ VaultDelete::doApply()
|
||||
if (!owner)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.error()) << "VaultDelete: missing vault owner account.";
|
||||
return tefBAD_LEDGER;
|
||||
return {tefBAD_LEDGER, "VaultDelete: missing vault owner account."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
|
||||
@@ -80,8 +80,7 @@ VaultDeposit::preclaim(PreclaimContext const& ctx)
|
||||
auto const& vaultAccount = vault->at(sfAccount);
|
||||
if (auto ter = canTransfer(ctx.view, vaultAsset, account, vaultAccount); !isTesSuccess(ter))
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "VaultDeposit: vault assets are non-transferable.";
|
||||
return ter;
|
||||
return {ter, "VaultDeposit: vault assets are non-transferable."};
|
||||
}
|
||||
|
||||
auto const mptIssuanceID = vault->at(sfShareMPTID);
|
||||
@@ -89,8 +88,7 @@ VaultDeposit::preclaim(PreclaimContext const& ctx)
|
||||
if (vaultShare == amount.asset())
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx.j.error()) << "VaultDeposit: vault shares and assets cannot be same.";
|
||||
return tefINTERNAL;
|
||||
return {tefINTERNAL, "VaultDeposit: vault shares and assets cannot be same."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -98,16 +96,14 @@ VaultDeposit::preclaim(PreclaimContext const& ctx)
|
||||
if (!sleIssuance)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx.j.error()) << "VaultDeposit: missing issuance of vault shares.";
|
||||
return tefINTERNAL;
|
||||
return {tefINTERNAL, "VaultDeposit: missing issuance of vault shares."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
if (sleIssuance->isFlag(lsfMPTLocked))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx.j.error()) << "VaultDeposit: issuance of vault shares is locked.";
|
||||
return tefINTERNAL;
|
||||
return {tefINTERNAL, "VaultDeposit: issuance of vault shares is locked."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -222,8 +218,7 @@ VaultDeposit::doApply()
|
||||
if (!sleIssuance)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.error()) << "VaultDeposit: missing issuance of vault shares.";
|
||||
return tefINTERNAL;
|
||||
return {tefINTERNAL, "VaultDeposit: missing issuance of vault shares."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -292,8 +287,7 @@ VaultDeposit::doApply()
|
||||
if (*maybeAssets > amount)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.error()) << "VaultDeposit: would take more than offered.";
|
||||
return tecINTERNAL;
|
||||
return {tecINTERNAL, "VaultDeposit: would take more than offered."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
assetsDeposited = *maybeAssets;
|
||||
@@ -346,8 +340,7 @@ VaultDeposit::doApply()
|
||||
AuthHandling::IgnoreAuth,
|
||||
j_) < beast::kZero)
|
||||
{
|
||||
JLOG(j_.error()) << "VaultDeposit: negative balance of account assets.";
|
||||
return tefINTERNAL;
|
||||
return {tefINTERNAL, "VaultDeposit: negative balance of account assets."};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,8 +70,7 @@ VaultSet::preclaim(PreclaimContext const& ctx)
|
||||
// Assert that submitter is the Owner.
|
||||
if (ctx.tx[sfAccount] != vault->at(sfOwner))
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "VaultSet: account is not an owner.";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "VaultSet: account is not an owner."};
|
||||
}
|
||||
|
||||
auto const mptIssuanceID = (*vault)[sfShareMPTID];
|
||||
@@ -79,8 +78,7 @@ VaultSet::preclaim(PreclaimContext const& ctx)
|
||||
if (!sleIssuance)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx.j.error()) << "VaultSet: missing issuance of vault shares.";
|
||||
return tefINTERNAL;
|
||||
return {tefINTERNAL, "VaultSet: missing issuance of vault shares."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -89,8 +87,7 @@ VaultSet::preclaim(PreclaimContext const& ctx)
|
||||
// We can only set domain if private flag was originally set
|
||||
if (!vault->isFlag(lsfVaultPrivate))
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "VaultSet: vault is not private";
|
||||
return tecNO_PERMISSION;
|
||||
return {tecNO_PERMISSION, "VaultSet: vault is not private"};
|
||||
}
|
||||
|
||||
if (*domain != beast::kZero)
|
||||
@@ -104,8 +101,7 @@ VaultSet::preclaim(PreclaimContext const& ctx)
|
||||
if (!sleIssuance->isFlag(lsfMPTRequireAuth))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx.j.error()) << "VaultSet: issuance of vault shares is not private.";
|
||||
return tefINTERNAL;
|
||||
return {tefINTERNAL, "VaultSet: issuance of vault shares is not private."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
}
|
||||
@@ -134,8 +130,7 @@ VaultSet::doApply()
|
||||
if (!sleIssuance)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.error()) << "VaultSet: missing issuance of vault shares.";
|
||||
return tefINTERNAL;
|
||||
return {tefINTERNAL, "VaultSet: missing issuance of vault shares."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
|
||||
@@ -90,16 +90,14 @@ VaultWithdraw::preclaim(PreclaimContext const& ctx)
|
||||
if (auto ter = canTransfer(ctx.view, vaultAsset, vaultAccount, dstAcct, waive);
|
||||
!isTesSuccess(ter))
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "VaultWithdraw: vault assets are non-transferable.";
|
||||
return ter;
|
||||
return {ter, "VaultWithdraw: vault assets are non-transferable."};
|
||||
}
|
||||
|
||||
// Enforce valid withdrawal policy
|
||||
if (vault->at(sfWithdrawalPolicy) != kVaultStrategyFirstComeFirstServe)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx.j.error()) << "VaultWithdraw: invalid withdrawal policy.";
|
||||
return tefINTERNAL;
|
||||
return {tefINTERNAL, "VaultWithdraw: invalid withdrawal policy."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -113,8 +111,7 @@ VaultWithdraw::preclaim(PreclaimContext const& ctx)
|
||||
if (!sleIssuance)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx.j.error()) << "VaultWithdraw: missing issuance of vault shares.";
|
||||
return tefINTERNAL;
|
||||
return {tefINTERNAL, "VaultWithdraw: missing issuance of vault shares."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -203,8 +200,7 @@ VaultWithdraw::doApply()
|
||||
if (!sleIssuance)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j_.error()) << "VaultWithdraw: missing issuance of vault shares.";
|
||||
return tefINTERNAL;
|
||||
return {tefINTERNAL, "VaultWithdraw: missing issuance of vault shares."};
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -283,8 +279,7 @@ VaultWithdraw::doApply()
|
||||
if (accountHolds(view(), accountID_, share, freezeHandling, AuthHandling::IgnoreAuth, j_) <
|
||||
sharesRedeemed)
|
||||
{
|
||||
JLOG(j_.debug()) << "VaultWithdraw: account doesn't hold enough shares";
|
||||
return tecINSUFFICIENT_FUNDS;
|
||||
return {tecINSUFFICIENT_FUNDS, "VaultWithdraw: account doesn't hold enough shares"};
|
||||
}
|
||||
|
||||
auto assetsAvailable = vault->at(sfAssetsAvailable);
|
||||
@@ -297,8 +292,7 @@ VaultWithdraw::doApply()
|
||||
// The vault must have enough assets on hand.
|
||||
if (*assetsAvailable < assetsWithdrawn)
|
||||
{
|
||||
JLOG(j_.debug()) << "VaultWithdraw: vault doesn't hold enough assets";
|
||||
return tecINSUFFICIENT_FUNDS;
|
||||
return {tecINSUFFICIENT_FUNDS, "VaultWithdraw: vault doesn't hold enough assets"};
|
||||
}
|
||||
|
||||
// Post-fixCleanup3_2_0 "final withdrawal" rule:
|
||||
|
||||
Reference in New Issue
Block a user