1#include <xrpl/basics/chrono.h>
2#include <xrpl/ledger/ApplyView.h>
3#include <xrpl/ledger/View.h>
4#include <xrpl/ledger/helpers/AccountRootHelpers.h>
5#include <xrpl/ledger/helpers/DirectoryHelpers.h>
6#include <xrpl/protocol/Feature.h>
7#include <xrpl/protocol/Indexes.h>
8#include <xrpl/protocol/PublicKey.h>
9#include <xrpl/protocol/XRPAmount.h>
10#include <xrpl/tx/transactors/payment_channel/PaymentChannelCreate.h>
45 if (!
isXRP(ctx.
tx[sfAmount]) || (ctx.
tx[sfAmount] <= beast::zero))
48 if (ctx.
tx[sfAccount] == ctx.
tx[sfDestination])
60 auto const account = ctx.
tx[sfAccount];
67 auto const balance = (*sle)[sfBalance];
70 if (balance < reserve)
73 if (balance < reserve + ctx.
tx[sfAmount])
77 auto const dst = ctx.
tx[sfDestination];
85 auto const flags = sled->getFlags();
88 if ((flags & lsfDisallowIncomingPayChan) != 0u)
91 if (((flags & lsfRequireDestTag) != 0u) && !ctx.
tx[~sfDestinationTag])
110 auto const account =
ctx_.
tx[sfAccount];
122 auto const dst =
ctx_.
tx[sfDestination];
132 (*slep)[sfAmount] =
ctx_.
tx[sfAmount];
134 (*slep)[sfBalance] =
ctx_.
tx[sfAmount].zeroed();
135 (*slep)[sfAccount] = account;
136 (*slep)[sfDestination] = dst;
137 (*slep)[sfSettleDelay] =
ctx_.
tx[sfSettleDelay];
138 (*slep)[sfPublicKey] =
ctx_.
tx[sfPublicKey];
139 (*slep)[~sfCancelAfter] =
ctx_.
tx[~sfCancelAfter];
140 (*slep)[~sfSourceTag] =
ctx_.
tx[~sfSourceTag];
141 (*slep)[~sfDestinationTag] =
ctx_.
tx[~sfDestinationTag];
155 (*slep)[sfOwnerNode] = *page;
164 (*slep)[sfDestinationNode] = *page;
168 (*sle)[sfBalance] = (*sle)[sfBalance] -
ctx_.
tx[sfAmount];
beast::Journal const journal
virtual void update(std::shared_ptr< SLE > const &sle)=0
Indicate changes to a peeked SLE.
virtual void insert(std::shared_ptr< SLE > const &sle)=0
Insert a new state SLE.
std::optional< std::uint64_t > dirInsert(Keylet const &directory, uint256 const &key, std::function< void(std::shared_ptr< SLE > const &)> const &describe)
Insert an entry to a directory.
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
static TER preclaim(PreclaimContext const &ctx)
static NotTEC preflight(PreflightContext const &ctx)
static TxConsequences makeTxConsequences(PreflightContext const &ctx)
virtual Rules const & rules() const =0
Returns the tx processing rules.
virtual Fees const & fees() const =0
Returns the fees for the base ledger.
virtual LedgerHeader const & header() const =0
Returns information about the ledger.
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
std::uint32_t getSeqValue() const
Returns the first non-zero value of (Sequence, TicketSequence).
Class describing the consequences to the account of applying a transaction if the transaction consume...
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Keylet payChan(AccountID const &src, AccountID const &dst, std::uint32_t seq) noexcept
A PaymentChannel.
Keylet account(AccountID const &id) noexcept
AccountID root.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
bool isXRP(AccountID const &c)
std::optional< KeyType > publicKeyType(Slice const &slice)
Returns the type of public key.
bool isPseudoAccount(std::shared_ptr< SLE const > sleAcct, std::set< SField const * > const &pseudoFieldFilter={})
Returns true if and only if sleAcct is a pseudo-account or specific pseudo-accounts in pseudoFieldFil...
void adjustOwnerCount(ApplyView &view, std::shared_ptr< SLE > const &sle, std::int32_t amount, beast::Journal j)
Adjust the owner count up or down.
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
std::function< void(SLE::ref)> describeOwnerDir(AccountID const &account)
Returns a function that sets the owner on a directory SLE.
@ tecINSUFFICIENT_RESERVE
XRPAmount accountReserve(std::size_t ownerCount) const
Returns the account reserve given the owner count, in drops.
A pair of SHAMap key and LedgerEntryType.
State information when determining if a tx is likely to claim a fee.
State information when preflighting a tx.