mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
lint
This commit is contained in:
@@ -30,11 +30,10 @@
|
|||||||
#include <ripple/ledger/View.h>
|
#include <ripple/ledger/View.h>
|
||||||
#include <ripple/protocol/Feature.h>
|
#include <ripple/protocol/Feature.h>
|
||||||
#include <ripple/protocol/Indexes.h>
|
#include <ripple/protocol/Indexes.h>
|
||||||
|
#include <ripple/protocol/Rate.h>
|
||||||
#include <ripple/protocol/TxFlags.h>
|
#include <ripple/protocol/TxFlags.h>
|
||||||
#include <ripple/protocol/digest.h>
|
#include <ripple/protocol/digest.h>
|
||||||
#include <ripple/protocol/st.h>
|
#include <ripple/protocol/st.h>
|
||||||
#include <ripple/protocol/Rate.h>
|
|
||||||
|
|
||||||
|
|
||||||
// During an EscrowFinish, the transaction must specify both
|
// During an EscrowFinish, the transaction must specify both
|
||||||
// a condition and a fulfillment. We track whether that
|
// a condition and a fulfillment. We track whether that
|
||||||
@@ -95,8 +94,8 @@ after(NetClock::time_point now, std::uint32_t mark)
|
|||||||
TxConsequences
|
TxConsequences
|
||||||
EscrowCreate::makeTxConsequences(PreflightContext const& ctx)
|
EscrowCreate::makeTxConsequences(PreflightContext const& ctx)
|
||||||
{
|
{
|
||||||
return TxConsequences{ctx.tx,
|
return TxConsequences{
|
||||||
isXRP(ctx.tx[sfAmount]) ? ctx.tx[sfAmount].xrp() : beast::zero};
|
ctx.tx, isXRP(ctx.tx[sfAmount]) ? ctx.tx[sfAmount].xrp() : beast::zero};
|
||||||
}
|
}
|
||||||
|
|
||||||
NotTEC
|
NotTEC
|
||||||
@@ -108,7 +107,7 @@ EscrowCreate::preflight(PreflightContext const& ctx)
|
|||||||
if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
|
if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
STAmount const amount {ctx.tx[sfAmount]};
|
STAmount const amount{ctx.tx[sfAmount]};
|
||||||
if (!isXRP(amount))
|
if (!isXRP(amount))
|
||||||
{
|
{
|
||||||
if (!ctx.rules.enabled(featurePaychanAndEscrowForTokens))
|
if (!ctx.rules.enabled(featurePaychanAndEscrowForTokens))
|
||||||
@@ -218,7 +217,7 @@ EscrowCreate::doApply()
|
|||||||
if (!sle)
|
if (!sle)
|
||||||
return temDISABLED;
|
return temDISABLED;
|
||||||
|
|
||||||
STAmount const amount {ctx_.tx[sfAmount]};
|
STAmount const amount{ctx_.tx[sfAmount]};
|
||||||
|
|
||||||
std::shared_ptr<SLE> sleLine;
|
std::shared_ptr<SLE> sleLine;
|
||||||
|
|
||||||
@@ -246,12 +245,11 @@ EscrowCreate::doApply()
|
|||||||
// check if the escrow is capable of being
|
// check if the escrow is capable of being
|
||||||
// finished before we allow it to be created
|
// finished before we allow it to be created
|
||||||
{
|
{
|
||||||
TER result =
|
TER result = trustTransferAllowed(
|
||||||
trustTransferAllowed(
|
ctx_.view(),
|
||||||
ctx_.view(),
|
{account, ctx_.tx[sfDestination]},
|
||||||
{account, ctx_.tx[sfDestination]},
|
amount.issue(),
|
||||||
amount.issue(),
|
ctx_.journal);
|
||||||
ctx_.journal);
|
|
||||||
|
|
||||||
JLOG(ctx_.journal.trace())
|
JLOG(ctx_.journal.trace())
|
||||||
<< "EscrowCreate::doApply trustTransferAllowed result="
|
<< "EscrowCreate::doApply trustTransferAllowed result="
|
||||||
@@ -263,20 +261,16 @@ EscrowCreate::doApply()
|
|||||||
|
|
||||||
// perform the lock as a dry run before
|
// perform the lock as a dry run before
|
||||||
// we modify anything on-ledger
|
// we modify anything on-ledger
|
||||||
sleLine = ctx_.view().peek(keylet::line(account, amount.getIssuer(), amount.getCurrency()));
|
sleLine = ctx_.view().peek(
|
||||||
|
keylet::line(account, amount.getIssuer(), amount.getCurrency()));
|
||||||
|
|
||||||
{
|
{
|
||||||
TER result =
|
TER result = trustAdjustLockedBalance(
|
||||||
trustAdjustLockedBalance(
|
ctx_.view(), sleLine, amount, 1, ctx_.journal, DryRun);
|
||||||
ctx_.view(),
|
|
||||||
sleLine,
|
|
||||||
amount,
|
|
||||||
1,
|
|
||||||
ctx_.journal,
|
|
||||||
DryRun);
|
|
||||||
|
|
||||||
JLOG(ctx_.journal.trace())
|
JLOG(ctx_.journal.trace())
|
||||||
<< "EscrowCreate::doApply trustAdjustLockedBalance (dry) result="
|
<< "EscrowCreate::doApply trustAdjustLockedBalance (dry) "
|
||||||
|
"result="
|
||||||
<< result;
|
<< result;
|
||||||
|
|
||||||
if (!isTesSuccess(result))
|
if (!isTesSuccess(result))
|
||||||
@@ -296,8 +290,8 @@ EscrowCreate::doApply()
|
|||||||
|
|
||||||
// Obeying the lsfDissalowXRP flag was a bug. Piggyback on
|
// Obeying the lsfDissalowXRP flag was a bug. Piggyback on
|
||||||
// featureDepositAuth to remove the bug.
|
// featureDepositAuth to remove the bug.
|
||||||
if (!ctx_.view().rules().enabled(featureDepositAuth) &&
|
if (!ctx_.view().rules().enabled(featureDepositAuth) && isXRP(amount) &&
|
||||||
isXRP(amount) && ((*sled)[sfFlags] & lsfDisallowXRP))
|
((*sled)[sfFlags] & lsfDisallowXRP))
|
||||||
return tecNO_TARGET;
|
return tecNO_TARGET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -339,21 +333,16 @@ EscrowCreate::doApply()
|
|||||||
// Deduct owner's balance, increment owner count
|
// Deduct owner's balance, increment owner count
|
||||||
if (isXRP(amount))
|
if (isXRP(amount))
|
||||||
(*sle)[sfBalance] = (*sle)[sfBalance] - ctx_.tx[sfAmount];
|
(*sle)[sfBalance] = (*sle)[sfBalance] - ctx_.tx[sfAmount];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!ctx_.view().rules().enabled(featurePaychanAndEscrowForTokens) || !sleLine)
|
if (!ctx_.view().rules().enabled(featurePaychanAndEscrowForTokens) ||
|
||||||
|
!sleLine)
|
||||||
return temDISABLED;
|
return temDISABLED;
|
||||||
|
|
||||||
// do the lock-up for real now
|
// do the lock-up for real now
|
||||||
TER result =
|
TER result = trustAdjustLockedBalance(
|
||||||
trustAdjustLockedBalance(
|
ctx_.view(), sleLine, amount, 1, ctx_.journal, WetRun);
|
||||||
ctx_.view(),
|
|
||||||
sleLine,
|
|
||||||
amount,
|
|
||||||
1,
|
|
||||||
ctx_.journal,
|
|
||||||
WetRun);
|
|
||||||
|
|
||||||
JLOG(ctx_.journal.trace())
|
JLOG(ctx_.journal.trace())
|
||||||
<< "EscrowCreate::doApply trustAdjustLockedBalance (wet) result="
|
<< "EscrowCreate::doApply trustAdjustLockedBalance (wet) result="
|
||||||
<< result;
|
<< result;
|
||||||
@@ -561,25 +550,23 @@ EscrowFinish::doApply()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!isXRP(amount))
|
if (!isXRP(amount))
|
||||||
{
|
{
|
||||||
if (!ctx_.view().rules().enabled(featurePaychanAndEscrowForTokens))
|
if (!ctx_.view().rules().enabled(featurePaychanAndEscrowForTokens))
|
||||||
return temDISABLED;
|
return temDISABLED;
|
||||||
|
|
||||||
// perform a dry run of the transfer before we
|
// perform a dry run of the transfer before we
|
||||||
// change anything on-ledger
|
// change anything on-ledger
|
||||||
TER result =
|
TER result = trustTransferLockedBalance(
|
||||||
trustTransferLockedBalance(
|
ctx_.view(),
|
||||||
ctx_.view(),
|
account_, // txn signing account
|
||||||
account_, // txn signing account
|
sle, // src account
|
||||||
sle, // src account
|
sled, // dst account
|
||||||
sled, // dst account
|
amount, // xfer amount
|
||||||
amount, // xfer amount
|
-1,
|
||||||
-1,
|
j_,
|
||||||
j_,
|
DryRun // dry run
|
||||||
DryRun // dry run
|
);
|
||||||
);
|
|
||||||
|
|
||||||
JLOG(j_.trace())
|
JLOG(j_.trace())
|
||||||
<< "EscrowFinish::doApply trustTransferLockedBalance (dry) result="
|
<< "EscrowFinish::doApply trustTransferLockedBalance (dry) result="
|
||||||
@@ -611,26 +598,23 @@ EscrowFinish::doApply()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (isXRP(amount))
|
if (isXRP(amount))
|
||||||
(*sled)[sfBalance] = (*sled)[sfBalance] + (*slep)[sfAmount];
|
(*sled)[sfBalance] = (*sled)[sfBalance] + (*slep)[sfAmount];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// all the significant complexity of checking the validity of this
|
// all the significant complexity of checking the validity of this
|
||||||
// transfer and ensuring the lines exist etc is hidden away in this
|
// transfer and ensuring the lines exist etc is hidden away in this
|
||||||
// function, all we need to do is call it and return if unsuccessful.
|
// function, all we need to do is call it and return if unsuccessful.
|
||||||
TER result =
|
TER result = trustTransferLockedBalance(
|
||||||
trustTransferLockedBalance(
|
ctx_.view(),
|
||||||
ctx_.view(),
|
account_, // txn signing account
|
||||||
account_, // txn signing account
|
sle, // src account
|
||||||
sle, // src account
|
sled, // dst account
|
||||||
sled, // dst account
|
amount, // xfer amount
|
||||||
amount, // xfer amount
|
-1,
|
||||||
-1,
|
j_,
|
||||||
j_,
|
WetRun // wet run;
|
||||||
WetRun // wet run;
|
);
|
||||||
);
|
|
||||||
|
|
||||||
JLOG(j_.trace())
|
JLOG(j_.trace())
|
||||||
<< "EscrowFinish::doApply trustTransferLockedBalance (wet) result="
|
<< "EscrowFinish::doApply trustTransferLockedBalance (wet) result="
|
||||||
@@ -706,19 +690,12 @@ EscrowCancel::doApply()
|
|||||||
if (!ctx_.view().rules().enabled(featurePaychanAndEscrowForTokens))
|
if (!ctx_.view().rules().enabled(featurePaychanAndEscrowForTokens))
|
||||||
return temDISABLED;
|
return temDISABLED;
|
||||||
|
|
||||||
sleLine =
|
sleLine = ctx_.view().peek(
|
||||||
ctx_.view().peek(
|
keylet::line(account, amount.getIssuer(), amount.getCurrency()));
|
||||||
keylet::line(account, amount.getIssuer(), amount.getCurrency()));
|
|
||||||
|
|
||||||
// dry run before we make any changes to ledger
|
// dry run before we make any changes to ledger
|
||||||
if (TER result =
|
if (TER result = trustAdjustLockedBalance(
|
||||||
trustAdjustLockedBalance(
|
ctx_.view(), sleLine, -amount, -1, ctx_.journal, DryRun);
|
||||||
ctx_.view(),
|
|
||||||
sleLine,
|
|
||||||
-amount,
|
|
||||||
-1,
|
|
||||||
ctx_.journal,
|
|
||||||
DryRun);
|
|
||||||
result != tesSUCCESS)
|
result != tesSUCCESS)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -757,19 +734,13 @@ EscrowCancel::doApply()
|
|||||||
return temDISABLED;
|
return temDISABLED;
|
||||||
|
|
||||||
// unlock previously locked tokens from source line
|
// unlock previously locked tokens from source line
|
||||||
TER result =
|
TER result = trustAdjustLockedBalance(
|
||||||
trustAdjustLockedBalance(
|
ctx_.view(), sleLine, -amount, -1, ctx_.journal, WetRun);
|
||||||
ctx_.view(),
|
|
||||||
sleLine,
|
|
||||||
-amount,
|
|
||||||
-1,
|
|
||||||
ctx_.journal,
|
|
||||||
WetRun);
|
|
||||||
|
|
||||||
JLOG(ctx_.journal.trace())
|
JLOG(ctx_.journal.trace())
|
||||||
<< "EscrowCancel::doApply trustAdjustLockedBalance (wet) result="
|
<< "EscrowCancel::doApply trustAdjustLockedBalance (wet) result="
|
||||||
<< result;
|
<< result;
|
||||||
|
|
||||||
if (!isTesSuccess(result))
|
if (!isTesSuccess(result))
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,22 +129,15 @@ closeChannel(
|
|||||||
if (!view.rules().enabled(featurePaychanAndEscrowForTokens))
|
if (!view.rules().enabled(featurePaychanAndEscrowForTokens))
|
||||||
return temDISABLED;
|
return temDISABLED;
|
||||||
|
|
||||||
sleLine =
|
sleLine = view.peek(
|
||||||
view.peek(keylet::line(src, amount.getIssuer(), amount.getCurrency()));
|
keylet::line(src, amount.getIssuer(), amount.getCurrency()));
|
||||||
|
|
||||||
// dry run
|
|
||||||
TER result =
|
|
||||||
trustAdjustLockedBalance(
|
|
||||||
view,
|
|
||||||
sleLine,
|
|
||||||
-amount,
|
|
||||||
-1,
|
|
||||||
j,
|
|
||||||
DryRun);
|
|
||||||
|
|
||||||
JLOG(j.trace())
|
// dry run
|
||||||
<< "closeChannel: trustAdjustLockedBalance(dry) result="
|
TER result =
|
||||||
<< result;
|
trustAdjustLockedBalance(view, sleLine, -amount, -1, j, DryRun);
|
||||||
|
|
||||||
|
JLOG(j.trace()) << "closeChannel: trustAdjustLockedBalance(dry) result="
|
||||||
|
<< result;
|
||||||
|
|
||||||
if (!isTesSuccess(result))
|
if (!isTesSuccess(result))
|
||||||
return result;
|
return result;
|
||||||
@@ -185,18 +178,11 @@ closeChannel(
|
|||||||
(*sle)[sfBalance] = (*sle)[sfBalance] + amount;
|
(*sle)[sfBalance] = (*sle)[sfBalance] + amount;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TER result =
|
TER result =
|
||||||
trustAdjustLockedBalance(
|
trustAdjustLockedBalance(view, sleLine, -amount, -1, j, WetRun);
|
||||||
view,
|
|
||||||
sleLine,
|
|
||||||
-amount,
|
|
||||||
-1,
|
|
||||||
j,
|
|
||||||
WetRun);
|
|
||||||
|
|
||||||
JLOG(j.trace())
|
JLOG(j.trace()) << "closeChannel: trustAdjustLockedBalance(wet) result="
|
||||||
<< "closeChannel: trustAdjustLockedBalance(wet) result="
|
<< result;
|
||||||
<< result;
|
|
||||||
|
|
||||||
if (!isTesSuccess(result))
|
if (!isTesSuccess(result))
|
||||||
return result;
|
return result;
|
||||||
@@ -214,9 +200,9 @@ closeChannel(
|
|||||||
|
|
||||||
TxConsequences
|
TxConsequences
|
||||||
PayChanCreate::makeTxConsequences(PreflightContext const& ctx)
|
PayChanCreate::makeTxConsequences(PreflightContext const& ctx)
|
||||||
{
|
{
|
||||||
return TxConsequences{ctx.tx,
|
return TxConsequences{
|
||||||
isXRP(ctx.tx[sfAmount]) ? ctx.tx[sfAmount].xrp() : beast::zero};
|
ctx.tx, isXRP(ctx.tx[sfAmount]) ? ctx.tx[sfAmount].xrp() : beast::zero};
|
||||||
}
|
}
|
||||||
|
|
||||||
NotTEC
|
NotTEC
|
||||||
@@ -228,7 +214,7 @@ PayChanCreate::preflight(PreflightContext const& ctx)
|
|||||||
if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
|
if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
STAmount const amount {ctx.tx[sfAmount]};
|
STAmount const amount{ctx.tx[sfAmount]};
|
||||||
if (!isXRP(amount))
|
if (!isXRP(amount))
|
||||||
{
|
{
|
||||||
if (!ctx.rules.enabled(featurePaychanAndEscrowForTokens))
|
if (!ctx.rules.enabled(featurePaychanAndEscrowForTokens))
|
||||||
@@ -268,7 +254,7 @@ PayChanCreate::preclaim(PreclaimContext const& ctx)
|
|||||||
if (!sle)
|
if (!sle)
|
||||||
return terNO_ACCOUNT;
|
return terNO_ACCOUNT;
|
||||||
|
|
||||||
STAmount const amount {ctx.tx[sfAmount]};
|
STAmount const amount{ctx.tx[sfAmount]};
|
||||||
|
|
||||||
auto const balance = (*sle)[sfBalance];
|
auto const balance = (*sle)[sfBalance];
|
||||||
auto const reserve =
|
auto const reserve =
|
||||||
@@ -284,19 +270,16 @@ PayChanCreate::preclaim(PreclaimContext const& ctx)
|
|||||||
{
|
{
|
||||||
return tecUNFUNDED;
|
return tecUNFUNDED;
|
||||||
}
|
}
|
||||||
else if (!isXRP(amount)) {
|
else if (!isXRP(amount))
|
||||||
|
{
|
||||||
if (!ctx.view.rules().enabled(featurePaychanAndEscrowForTokens))
|
if (!ctx.view.rules().enabled(featurePaychanAndEscrowForTokens))
|
||||||
return temDISABLED;
|
return temDISABLED;
|
||||||
|
|
||||||
// check for any possible bars to a channel existing
|
// check for any possible bars to a channel existing
|
||||||
// between these accounts for this asset
|
// between these accounts for this asset
|
||||||
{
|
{
|
||||||
TER result =
|
TER result = trustTransferAllowed(
|
||||||
trustTransferAllowed(
|
ctx.view, {account, dst}, amount.issue(), ctx.j);
|
||||||
ctx.view,
|
|
||||||
{account, dst},
|
|
||||||
amount.issue(),
|
|
||||||
ctx.j);
|
|
||||||
JLOG(ctx.j.trace())
|
JLOG(ctx.j.trace())
|
||||||
<< "PayChanCreate::preclaim trustTransferAllowed result="
|
<< "PayChanCreate::preclaim trustTransferAllowed result="
|
||||||
<< result;
|
<< result;
|
||||||
@@ -307,21 +290,14 @@ PayChanCreate::preclaim(PreclaimContext const& ctx)
|
|||||||
|
|
||||||
// check if the amount can be locked
|
// check if the amount can be locked
|
||||||
{
|
{
|
||||||
auto sleLine =
|
auto sleLine = ctx.view.read(keylet::line(
|
||||||
ctx.view.read(
|
account, amount.getIssuer(), amount.getCurrency()));
|
||||||
keylet::line(account, amount.getIssuer(), amount.getCurrency()));
|
TER result = trustAdjustLockedBalance(
|
||||||
TER result =
|
ctx.view, sleLine, amount, 1, ctx.j, DryRun);
|
||||||
trustAdjustLockedBalance(
|
|
||||||
ctx.view,
|
JLOG(ctx.j.trace()) << "PayChanCreate::preclaim "
|
||||||
sleLine,
|
"trustAdjustLockedBalance(dry) result="
|
||||||
amount,
|
<< result;
|
||||||
1,
|
|
||||||
ctx.j,
|
|
||||||
DryRun);
|
|
||||||
|
|
||||||
JLOG(ctx.j.trace())
|
|
||||||
<< "PayChanCreate::preclaim trustAdjustLockedBalance(dry) result="
|
|
||||||
<< result;
|
|
||||||
|
|
||||||
if (!isTesSuccess(result))
|
if (!isTesSuccess(result))
|
||||||
return result;
|
return result;
|
||||||
@@ -339,8 +315,8 @@ PayChanCreate::preclaim(PreclaimContext const& ctx)
|
|||||||
|
|
||||||
// Obeying the lsfDisallowXRP flag was a bug. Piggyback on
|
// Obeying the lsfDisallowXRP flag was a bug. Piggyback on
|
||||||
// featureDepositAuth to remove the bug.
|
// featureDepositAuth to remove the bug.
|
||||||
if (!ctx.view.rules().enabled(featureDepositAuth) &&
|
if (!ctx.view.rules().enabled(featureDepositAuth) && isXRP(amount) &&
|
||||||
isXRP(amount) && ((*sled)[sfFlags] & lsfDisallowXRP))
|
((*sled)[sfFlags] & lsfDisallowXRP))
|
||||||
return tecNO_TARGET;
|
return tecNO_TARGET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,7 +333,7 @@ PayChanCreate::doApply()
|
|||||||
|
|
||||||
auto const dst = ctx_.tx[sfDestination];
|
auto const dst = ctx_.tx[sfDestination];
|
||||||
|
|
||||||
STAmount const amount {ctx_.tx[sfAmount]};
|
STAmount const amount{ctx_.tx[sfAmount]};
|
||||||
|
|
||||||
// Create PayChan in ledger.
|
// Create PayChan in ledger.
|
||||||
//
|
//
|
||||||
@@ -410,20 +386,14 @@ PayChanCreate::doApply()
|
|||||||
if (!ctx_.view().rules().enabled(featurePaychanAndEscrowForTokens))
|
if (!ctx_.view().rules().enabled(featurePaychanAndEscrowForTokens))
|
||||||
return temDISABLED;
|
return temDISABLED;
|
||||||
|
|
||||||
auto sleLine =
|
auto sleLine = ctx_.view().peek(
|
||||||
ctx_.view().peek(keylet::line(account, amount.getIssuer(), amount.getCurrency()));
|
keylet::line(account, amount.getIssuer(), amount.getCurrency()));
|
||||||
|
|
||||||
if (!sleLine)
|
if (!sleLine)
|
||||||
return tecNO_LINE;
|
return tecNO_LINE;
|
||||||
|
|
||||||
TER result =
|
TER result = trustAdjustLockedBalance(
|
||||||
trustAdjustLockedBalance(
|
ctx_.view(), sleLine, amount, 1, ctx_.journal, WetRun);
|
||||||
ctx_.view(),
|
|
||||||
sleLine,
|
|
||||||
amount,
|
|
||||||
1,
|
|
||||||
ctx_.journal,
|
|
||||||
WetRun);
|
|
||||||
|
|
||||||
JLOG(ctx_.journal.trace())
|
JLOG(ctx_.journal.trace())
|
||||||
<< "PayChanCreate::doApply trustAdjustLockedBalance(wet) result="
|
<< "PayChanCreate::doApply trustAdjustLockedBalance(wet) result="
|
||||||
@@ -432,7 +402,7 @@ PayChanCreate::doApply()
|
|||||||
if (!isTesSuccess(result))
|
if (!isTesSuccess(result))
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
adjustOwnerCount(ctx_.view(), sle, 1, ctx_.journal);
|
adjustOwnerCount(ctx_.view(), sle, 1, ctx_.journal);
|
||||||
ctx_.view().update(sle);
|
ctx_.view().update(sle);
|
||||||
|
|
||||||
@@ -444,8 +414,8 @@ PayChanCreate::doApply()
|
|||||||
TxConsequences
|
TxConsequences
|
||||||
PayChanFund::makeTxConsequences(PreflightContext const& ctx)
|
PayChanFund::makeTxConsequences(PreflightContext const& ctx)
|
||||||
{
|
{
|
||||||
return TxConsequences{ctx.tx,
|
return TxConsequences{
|
||||||
isXRP(ctx.tx[sfAmount]) ? ctx.tx[sfAmount].xrp() : beast::zero};
|
ctx.tx, isXRP(ctx.tx[sfAmount]) ? ctx.tx[sfAmount].xrp() : beast::zero};
|
||||||
}
|
}
|
||||||
|
|
||||||
NotTEC
|
NotTEC
|
||||||
@@ -457,7 +427,7 @@ PayChanFund::preflight(PreflightContext const& ctx)
|
|||||||
if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
|
if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
STAmount const amount {ctx.tx[sfAmount]};
|
STAmount const amount{ctx.tx[sfAmount]};
|
||||||
if (!isXRP(amount))
|
if (!isXRP(amount))
|
||||||
{
|
{
|
||||||
if (!ctx.rules.enabled(featurePaychanAndEscrowForTokens))
|
if (!ctx.rules.enabled(featurePaychanAndEscrowForTokens))
|
||||||
@@ -490,30 +460,21 @@ PayChanFund::doApply()
|
|||||||
auto const slep = ctx_.view().peek(k);
|
auto const slep = ctx_.view().peek(k);
|
||||||
if (!slep)
|
if (!slep)
|
||||||
return tecNO_ENTRY;
|
return tecNO_ENTRY;
|
||||||
|
|
||||||
STAmount const amount {ctx_.tx[sfAmount]};
|
|
||||||
|
|
||||||
std::shared_ptr<SLE> sleLine; // if XRP or featurePaychanAndEscrowForTokens
|
STAmount const amount{ctx_.tx[sfAmount]};
|
||||||
// not enabled this remains null
|
|
||||||
|
std::shared_ptr<SLE> sleLine; // if XRP or featurePaychanAndEscrowForTokens
|
||||||
|
// not enabled this remains null
|
||||||
|
|
||||||
// if this is a Fund operation on an IOU then perform a dry run here
|
// if this is a Fund operation on an IOU then perform a dry run here
|
||||||
if (!isXRP(amount) &&
|
if (!isXRP(amount) &&
|
||||||
ctx_.view().rules().enabled(featurePaychanAndEscrowForTokens))
|
ctx_.view().rules().enabled(featurePaychanAndEscrowForTokens))
|
||||||
{
|
{
|
||||||
sleLine = ctx_.view().peek(
|
sleLine = ctx_.view().peek(keylet::line(
|
||||||
keylet::line(
|
(*slep)[sfAccount], amount.getIssuer(), amount.getCurrency()));
|
||||||
(*slep)[sfAccount],
|
|
||||||
amount.getIssuer(),
|
|
||||||
amount.getCurrency()));
|
|
||||||
|
|
||||||
TER result =
|
TER result = trustAdjustLockedBalance(
|
||||||
trustAdjustLockedBalance(
|
ctx_.view(), sleLine, amount, 1, ctx_.journal, DryRun);
|
||||||
ctx_.view(),
|
|
||||||
sleLine,
|
|
||||||
amount,
|
|
||||||
1,
|
|
||||||
ctx_.journal,
|
|
||||||
DryRun);
|
|
||||||
|
|
||||||
JLOG(ctx_.journal.trace())
|
JLOG(ctx_.journal.trace())
|
||||||
<< "PayChanFund::doApply trustAdjustLockedBalance(dry) result="
|
<< "PayChanFund::doApply trustAdjustLockedBalance(dry) result="
|
||||||
@@ -586,15 +547,9 @@ PayChanFund::doApply()
|
|||||||
if (!ctx_.view().rules().enabled(featurePaychanAndEscrowForTokens))
|
if (!ctx_.view().rules().enabled(featurePaychanAndEscrowForTokens))
|
||||||
return temDISABLED;
|
return temDISABLED;
|
||||||
|
|
||||||
TER result =
|
TER result = trustAdjustLockedBalance(
|
||||||
trustAdjustLockedBalance(
|
ctx_.view(), sleLine, amount, 1, ctx_.journal, WetRun);
|
||||||
ctx_.view(),
|
|
||||||
sleLine,
|
|
||||||
amount,
|
|
||||||
1,
|
|
||||||
ctx_.journal,
|
|
||||||
WetRun);
|
|
||||||
|
|
||||||
JLOG(ctx_.journal.trace())
|
JLOG(ctx_.journal.trace())
|
||||||
<< "PayChanFund::doApply trustAdjustLockedBalance(wet) result="
|
<< "PayChanFund::doApply trustAdjustLockedBalance(wet) result="
|
||||||
<< result;
|
<< result;
|
||||||
@@ -620,7 +575,8 @@ PayChanClaim::preflight(PreflightContext const& ctx)
|
|||||||
auto const bal = ctx.tx[~sfBalance];
|
auto const bal = ctx.tx[~sfBalance];
|
||||||
if (bal)
|
if (bal)
|
||||||
{
|
{
|
||||||
if (!isXRP(*bal) && !ctx.rules.enabled(featurePaychanAndEscrowForTokens))
|
if (!isXRP(*bal) &&
|
||||||
|
!ctx.rules.enabled(featurePaychanAndEscrowForTokens))
|
||||||
return temBAD_AMOUNT;
|
return temBAD_AMOUNT;
|
||||||
|
|
||||||
if (*bal <= beast::zero)
|
if (*bal <= beast::zero)
|
||||||
@@ -631,7 +587,8 @@ PayChanClaim::preflight(PreflightContext const& ctx)
|
|||||||
|
|
||||||
if (amt)
|
if (amt)
|
||||||
{
|
{
|
||||||
if (!isXRP(*amt) && !ctx.rules.enabled(featurePaychanAndEscrowForTokens))
|
if (!isXRP(*amt) &&
|
||||||
|
!ctx.rules.enabled(featurePaychanAndEscrowForTokens))
|
||||||
return temBAD_AMOUNT;
|
return temBAD_AMOUNT;
|
||||||
|
|
||||||
if (*amt <= beast::zero)
|
if (*amt <= beast::zero)
|
||||||
@@ -676,7 +633,12 @@ PayChanClaim::preflight(PreflightContext const& ctx)
|
|||||||
if (isXRP(authAmt))
|
if (isXRP(authAmt))
|
||||||
serializePayChanAuthorization(msg, k.key, authAmt.xrp());
|
serializePayChanAuthorization(msg, k.key, authAmt.xrp());
|
||||||
else
|
else
|
||||||
serializePayChanAuthorization(msg, k.key, authAmt.iou(), authAmt.getCurrency(), authAmt.getIssuer());
|
serializePayChanAuthorization(
|
||||||
|
msg,
|
||||||
|
k.key,
|
||||||
|
authAmt.iou(),
|
||||||
|
authAmt.getCurrency(),
|
||||||
|
authAmt.getIssuer());
|
||||||
|
|
||||||
if (!verify(pk, msg.slice(), *sig, /*canonical*/ true))
|
if (!verify(pk, msg.slice(), *sig, /*canonical*/ true))
|
||||||
return temBAD_SIGNATURE;
|
return temBAD_SIGNATURE;
|
||||||
@@ -741,7 +703,8 @@ PayChanClaim::doApply()
|
|||||||
// Obeying the lsfDisallowXRP flag was a bug. Piggyback on
|
// Obeying the lsfDisallowXRP flag was a bug. Piggyback on
|
||||||
// featureDepositAuth to remove the bug.
|
// featureDepositAuth to remove the bug.
|
||||||
bool const depositAuth{ctx_.view().rules().enabled(featureDepositAuth)};
|
bool const depositAuth{ctx_.view().rules().enabled(featureDepositAuth)};
|
||||||
if (!depositAuth && chanBalance.native() && (txAccount == src && (sled->getFlags() & lsfDisallowXRP)))
|
if (!depositAuth && chanBalance.native() &&
|
||||||
|
(txAccount == src && (sled->getFlags() & lsfDisallowXRP)))
|
||||||
return tecNO_TARGET;
|
return tecNO_TARGET;
|
||||||
|
|
||||||
// Check whether the destination account requires deposit authorization.
|
// Check whether the destination account requires deposit authorization.
|
||||||
@@ -763,7 +726,7 @@ PayChanClaim::doApply()
|
|||||||
assert(reqDelta >= beast::zero);
|
assert(reqDelta >= beast::zero);
|
||||||
if (isXRP(reqDelta))
|
if (isXRP(reqDelta))
|
||||||
(*sled)[sfBalance] = (*sled)[sfBalance] + reqDelta;
|
(*sled)[sfBalance] = (*sled)[sfBalance] + reqDelta;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// xfer locked tokens to satisfy claim
|
// xfer locked tokens to satisfy claim
|
||||||
// RH NOTE: there's no ledger modification before this point so
|
// RH NOTE: there's no ledger modification before this point so
|
||||||
@@ -772,19 +735,19 @@ PayChanClaim::doApply()
|
|||||||
return temDISABLED;
|
return temDISABLED;
|
||||||
|
|
||||||
auto sleSrcAcc = ctx_.view().peek(keylet::account(src));
|
auto sleSrcAcc = ctx_.view().peek(keylet::account(src));
|
||||||
TER result =
|
TER result = trustTransferLockedBalance(
|
||||||
trustTransferLockedBalance(
|
ctx_.view(),
|
||||||
ctx_.view(),
|
txAccount,
|
||||||
txAccount,
|
sleSrcAcc,
|
||||||
sleSrcAcc,
|
sled,
|
||||||
sled,
|
reqDelta,
|
||||||
reqDelta,
|
0,
|
||||||
0,
|
ctx_.journal,
|
||||||
ctx_.journal,
|
WetRun);
|
||||||
WetRun);
|
|
||||||
|
|
||||||
JLOG(ctx_.journal.trace())
|
JLOG(ctx_.journal.trace())
|
||||||
<< "PayChanClaim::doApply trustTransferLockedBalance(wet) result="
|
<< "PayChanClaim::doApply trustTransferLockedBalance(wet) "
|
||||||
|
"result="
|
||||||
<< result;
|
<< result;
|
||||||
|
|
||||||
if (!isTesSuccess(result))
|
if (!isTesSuccess(result))
|
||||||
|
|||||||
Reference in New Issue
Block a user