20 #include <ripple/app/ledger/Ledger.h>
21 #include <ripple/app/tx/impl/CreateCheck.h>
22 #include <ripple/basics/Log.h>
23 #include <ripple/protocol/Feature.h>
24 #include <ripple/protocol/Indexes.h>
25 #include <ripple/protocol/STAccount.h>
26 #include <ripple/protocol/TER.h>
27 #include <ripple/protocol/TxFlags.h>
44 JLOG(ctx.
j.
warn()) <<
"Malformed transaction: Invalid flags set.";
50 JLOG(ctx.
j.
warn()) <<
"Malformed transaction: Check to self.";
56 if (!
isLegalNet(sendMax) || sendMax.signum() <= 0)
58 JLOG(ctx.
j.
warn()) <<
"Malformed transaction: bad sendMax amount: "
59 << sendMax.getFullText();
65 JLOG(ctx.
j.
warn()) <<
"Malformed transaction: Bad currency.";
74 JLOG(ctx.
j.
warn()) <<
"Malformed transaction: bad expiration";
89 JLOG(ctx.
j.
warn()) <<
"Destination account does not exist.";
98 JLOG(ctx.
j.
warn()) <<
"Malformed transaction: DestinationTag required.";
104 if (!sendMax.native())
107 AccountID const& issuerId{sendMax.getIssuer()};
110 JLOG(ctx.
j.
warn()) <<
"Creating a check for frozen asset";
119 if (issuerId != srcId)
122 auto const sleTrust = ctx.
view.
read(
129 <<
"Creating a check for frozen trustline.";
133 if (issuerId != dstId)
136 auto const sleTrust = ctx.
view.
read(
143 <<
"Creating a check for destination frozen trustline.";
161 JLOG(ctx.
j.
warn()) <<
"Creating a check that has already expired.";
169 CreateCheck::doApply()
171 auto const sle = view().peek(keylet::account(account_));
180 view().fees().accountReserve(sle->getFieldU32(
sfOwnerCount) + 1)};
182 if (mPriorBalance < reserve)
189 Keylet const checkKeylet = keylet::check(account_, seq);
190 auto sleCheck = std::make_shared<SLE>(checkKeylet);
192 sleCheck->setAccountID(
sfAccount, account_);
206 view().insert(sleCheck);
208 auto viewJ = ctx_.app.journal(
"View");
211 if (dstAccountId != account_)
213 auto const page = view().dirInsert(
214 keylet::ownerDir(dstAccountId),
218 JLOG(j_.
trace()) <<
"Adding Check to destination directory "
219 << to_string(checkKeylet.
key) <<
": "
220 << (page ?
"success" :
"failure");
229 auto const page = view().dirInsert(
230 keylet::ownerDir(account_),
234 JLOG(j_.
trace()) <<
"Adding Check to owner directory "
235 << to_string(checkKeylet.
key) <<
": "
236 << (page ?
"success" :
"failure");
Currency const & badCurrency()
We deliberately disallow the currency that looks like "XRP" because too many people were using it ins...
const SF_UINT32 sfOwnerCount
NotTEC preflight2(PreflightContext const &ctx)
Checks whether the signature appears valid.
const SF_UINT32 sfSourceTag
A pair of SHAMap key and LedgerEntryType.
const SF_AMOUNT sfSendMax
const SF_UINT64 sfOwnerNode
Stream trace() const
Severity stream access functions.
const SF_ACCOUNT sfDestination
std::function< void(SLE::ref)> describeOwnerDir(AccountID const &account)
const SF_UINT32 sfSequence
bool isLegalNet(STAmount const &value)
NetClock::time_point parentCloseTime() const
Returns the close time of the previous ledger.
NotTEC preflight1(PreflightContext const &ctx)
Performs early sanity checks on the account and fee fields.
const SF_UINT32 sfExpiration
bool isGlobalFrozen(ReadView const &view, AccountID const &issuer)
static TER preclaim(PreclaimContext const &ctx)
void adjustOwnerCount(ApplyView &view, std::shared_ptr< SLE > const &sle, std::int32_t amount, beast::Journal j)
Adjust the owner count up or down.
Keylet account(AccountID const &id) noexcept
AccountID root.
AccountID getAccountID(SField const &field) const
const SF_UINT64 sfDestinationNode
std::uint32_t getFlags() const
bool enabled(uint256 const &id) const
Returns true if a feature is enabled.
Keylet line(AccountID const &id0, AccountID const &id1, Currency const ¤cy) noexcept
The index of a trust line for a given currency.
const uint256 featureChecks
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
State information when determining if a tx is likely to claim a fee.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
bool isFieldPresent(SField const &field) const
const SF_HASH256 sfInvoiceID
const SF_UINT32 sfDestinationTag
@ tecINSUFFICIENT_RESERVE
const SF_ACCOUNT sfAccount
std::chrono::duration< rep, period > duration
const std::uint32_t tfUniversalMask
State information when preflighting a tx.
static NotTEC preflight(PreflightContext const &ctx)
std::chrono::time_point< NetClock > time_point
STAmount const & getFieldAmount(SField const &field) const
TERSubset< CanCvtToNotTEC > NotTEC