1#include <xrpl/ledger/ApplyView.h>
2#include <xrpl/ledger/View.h>
3#include <xrpl/protocol/Indexes.h>
4#include <xrpl/tx/transactors/payment_channel/PaymentChannelFund.h>
6#include <libxrpl/tx/transactors/payment_channel/PaymentChannelHelpers.h>
19 if (!
isXRP(ctx.
tx[sfAmount]) || (ctx.
tx[sfAmount] <= beast::zero))
34 auto const txAccount =
ctx_.
tx[sfAccount];
35 auto const expiration = (*slep)[~sfExpiration];
38 auto const cancelAfter = (*slep)[~sfCancelAfter];
40 if ((cancelAfter && closeTime >= *cancelAfter) || (expiration && closeTime >= *expiration))
50 if (
auto extend =
ctx_.
tx[~sfExpiration])
53 (*slep)[sfSettleDelay];
54 if (expiration && *expiration < minExpiration)
55 minExpiration = *expiration;
57 if (*extend < minExpiration)
59 (*slep)[~sfExpiration] = *extend;
69 auto const balance = (*sle)[sfBalance];
72 if (balance < reserve)
75 if (balance < reserve +
ctx_.
tx[sfAmount])
85 (*slep)[sfAmount] = (*slep)[sfAmount] +
ctx_.
tx[sfAmount];
88 (*sle)[sfBalance] = (*sle)[sfBalance] -
ctx_.
tx[sfAmount];
std::reference_wrapper< ServiceRegistry > registry
virtual void update(std::shared_ptr< SLE > const &sle)=0
Indicate changes to a peeked SLE.
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
static TxConsequences makeTxConsequences(PreflightContext const &ctx)
static NotTEC preflight(PreflightContext const &ctx)
virtual Fees const & fees() const =0
Returns the fees for the base ledger.
virtual LedgerHeader const & header() const =0
Returns information about the ledger.
Class describing the consequences to the account of applying a transaction if the transaction consume...
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)
TER closeChannel(std::shared_ptr< SLE > const &slep, ApplyView &view, uint256 const &key, beast::Journal j)
@ 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 preflighting a tx.
T time_since_epoch(T... args)