20 #include <ripple/app/tx/impl/CreateCheck.h>
21 #include <ripple/app/ledger/Ledger.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_));
179 STAmount const reserve {view().fees().accountReserve (
182 if (mPriorBalance < reserve)
191 sleCheck->setAccountID (
sfAccount, account_);
204 view().insert (sleCheck);
206 auto viewJ = ctx_.app.journal (
"View");
209 if (dstAccountId != account_)
211 auto const page =
dirAdd (view(), keylet::ownerDir (dstAccountId),
215 <<
"Adding Check to destination directory "
216 << to_string (sleCheck->key())
217 <<
": " << (page ?
"success" :
"failure");
226 auto const page =
dirAdd (view(), keylet::ownerDir (account_),
230 <<
"Adding Check to owner directory "
231 << to_string (sleCheck->key())
232 <<
": " << (page ?
"success" :
"failure");
Currency const & badCurrency()
We deliberately disallow the currency that looks like "XRP" because too many people were using it ins...
NotTEC preflight2(PreflightContext const &ctx)
Checks whether the signature appears valid.
Stream trace() const
Severity stream access functions.
std::function< void(SLE::ref)> describeOwnerDir(AccountID const &account)
const SF_U32 sfSequence(access, STI_UINT32, 4, "Sequence")
const SF_Account sfAccount(access, STI_ACCOUNT, 1, "Account")
bool isLegalNet(STAmount const &value)
const SF_U64 sfOwnerNode(access, STI_UINT64, 4, "OwnerNode")
NetClock::time_point parentCloseTime() const
Returns the close time of the previous ledger.
const SF_U32 sfOwnerCount(access, STI_UINT32, 13, "OwnerCount")
NotTEC preflight1(PreflightContext const &ctx)
Performs early sanity checks on the account and fee fields.
const SF_U32 sfDestinationTag(access, STI_UINT32, 14, "DestinationTag")
uint256 getCheckIndex(AccountID const &account, std::uint32_t uSequence)
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.
static const account_t account
const SF_Amount sfSendMax(access, STI_AMOUNT, 9, "SendMax")
AccountID getAccountID(SField const &field) const
const SF_U64 sfDestinationNode(access, STI_UINT64, 9, "DestinationNode")
std::uint32_t getFlags() const
bool enabled(uint256 const &id) const
Returns true if a feature is enabled.
const uint256 featureChecks
const SF_U32 sfSourceTag(access, STI_UINT32, 3, "SourceTag")
const SF_U32 sfExpiration(access, STI_UINT32, 10, "Expiration")
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
boost::optional< std::uint64_t > dirAdd(ApplyView &view, Keylet const &dir, uint256 const &uLedgerIndex, bool strictOrder, std::function< void(SLE::ref)> fDescriber, beast::Journal j)
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
@ tecINSUFFICIENT_RESERVE
const SF_Account sfDestination(access, STI_ACCOUNT, 3, "Destination")
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
const SF_U256 sfInvoiceID(access, STI_HASH256, 17, "InvoiceID")
TERSubset< CanCvtToNotTEC > NotTEC