20 #include <ripple/app/tx/impl/PayChan.h>
21 #include <ripple/basics/Log.h>
22 #include <ripple/basics/XRPAmount.h>
23 #include <ripple/basics/chrono.h>
24 #include <ripple/ledger/ApplyView.h>
25 #include <ripple/ledger/View.h>
26 #include <ripple/protocol/Feature.h>
27 #include <ripple/protocol/Indexes.h>
28 #include <ripple/protocol/PayChan.h>
29 #include <ripple/protocol/PublicKey.h>
30 #include <ripple/protocol/TxFlags.h>
31 #include <ripple/protocol/digest.h>
32 #include <ripple/protocol/st.h>
129 <<
"Could not remove paychan from src owner directory";
142 <<
"Could not remove paychan from dst owner directory";
206 if (balance < reserve)
221 auto const flags = sled->getFlags();
255 Keylet const payChanKeylet =
257 auto const slep = std::make_shared<SLE>(payChanKeylet);
339 auto const closeTime =
341 if ((cancelAfter && closeTime >= *cancelAfter) ||
342 (expiration && closeTime >= *expiration))
347 if (src != txAccount)
356 if (expiration && *expiration < minExpiration)
357 minExpiration = *expiration;
359 if (*extend < minExpiration)
375 if (balance < reserve)
407 if (bal && (!
isXRP(*bal) || *bal <= beast::zero))
411 if (amt && (!
isXRP(*amt) || *amt <= beast::zero))
414 if (bal && amt && *bal > *amt)
436 auto const reqBalance = bal->xrp();
437 auto const authAmt = amt ? amt->xrp() : reqBalance;
439 if (reqBalance > authAmt)
471 auto const closeTime =
473 if ((cancelAfter && closeTime >= *cancelAfter) ||
474 (curExpiration && closeTime >= *curExpiration))
479 if (txAccount != src && txAccount != dst)
484 auto const chanBalance = slep->getFieldAmount(
sfBalance).xrp();
485 auto const chanFunds = slep->getFieldAmount(
sfAmount).xrp();
498 if (reqBalance > chanFunds)
501 if (reqBalance <= chanBalance)
523 if (txAccount != dst)
531 XRPAmount const reqDelta = reqBalance - chanBalance;
532 assert(reqDelta >= beast::zero);
540 if (src != txAccount)
553 auto const settleExpiration =
557 if (!curExpiration || *curExpiration > settleExpiration)
virtual LedgerInfo const & info() const =0
Returns information about the ledger.
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
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.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
const SF_UINT64 sfOwnerNode
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
const SF_ACCOUNT sfDestination
std::function< void(SLE::ref)> describeOwnerDir(AccountID const &account)
static TER closeChannel(std::shared_ptr< SLE > const &slep, ApplyView &view, uint256 const &key, beast::Journal j)
bool verify(PublicKey const &publicKey, Slice const &m, Slice const &sig, bool mustBeFullyCanonical) noexcept
Verify a signature on a message.
virtual void erase(std::shared_ptr< SLE > const &sle)=0
Remove a peeked SLE.
virtual Fees const & fees() const =0
Returns the fees for the base ledger.
static NotTEC preflight(PreflightContext const &ctx)
const uint256 featureDepositAuth
constexpr std::uint32_t tfClose
virtual void update(std::shared_ptr< SLE > const &sle)=0
Indicate changes to a peeked SLE.
const beast::Journal journal
SeqProxy getSeqProxy() const
void serializePayChanAuthorization(Serializer &msg, uint256 const &key, XRPAmount const &amt)
NotTEC preflight1(PreflightContext const &ctx)
Performs early sanity checks on the account and fee fields.
Writeable view to a ledger, for applying a transaction.
const SF_UINT32 sfExpiration
bool dirRemove(Keylet const &directory, std::uint64_t page, uint256 const &key, bool keepRoot)
Remove an entry from a directory.
std::optional< KeyType > publicKeyType(Slice const &slice)
Returns the type of public key.
T time_since_epoch(T... args)
void adjustOwnerCount(ApplyView &view, std::shared_ptr< SLE > const &sle, std::int32_t amount, beast::Journal j)
Adjust the owner count up or down.
const SF_UINT32 sfSettleDelay
Keylet account(AccountID const &id) noexcept
AccountID root.
const uint256 featureDisallowIncoming
@ lsfDisallowIncomingPayChan
TERSubset< CanCvtToTER > TER
Slice slice() const noexcept
const SF_UINT64 sfDestinationNode
const uint256 fixPayChanRecipientOwnerDir
std::uint32_t getFlags() const
bool isXRP(AccountID const &c)
static NotTEC preflight(PreflightContext const &ctx)
A generic endpoint for log messages.
constexpr std::uint32_t tfPayChanClaimMask
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
constexpr std::uint32_t tfRenew
static NotTEC preflight(PreflightContext const &ctx)
State information when determining if a tx is likely to claim a fee.
constexpr std::uint32_t value() const
virtual void insert(std::shared_ptr< SLE > const &sle)=0
Insert a new state SLE.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
virtual beast::Journal journal(std::string const &name)=0
Keylet payChan(AccountID const &src, AccountID const &dst, std::uint32_t seq) noexcept
A PaymentChannel.
XRPAmount accountReserve(std::size_t ownerCount) const
Returns the account reserve given the owner count, in drops.
virtual Rules const & rules() const =0
Returns the tx processing rules.
const SF_UINT32 sfDestinationTag
const SF_AMOUNT sfBalance
static TxConsequences makeTxConsequences(PreflightContext const &ctx)
@ tecINSUFFICIENT_RESERVE
const SF_UINT32 sfCancelAfter
const SF_UINT256 sfChannel
const SF_ACCOUNT sfAccount
State information when preflighting a tx.
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.
constexpr std::uint32_t tfUniversalMask
Keylet depositPreauth(AccountID const &owner, AccountID const &preauthorized) noexcept
A DepositPreauth.
Class describing the consequences to the account of applying a transaction if the transaction consume...
static TxConsequences makeTxConsequences(PreflightContext const &ctx)
@ ltPAYCHAN
A ledger object describing a single unidirectional XRP payment channel.
static TER preclaim(PreclaimContext const &ctx)
NetClock::time_point parentCloseTime