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";
207 if (balance < reserve)
249 auto const slep = std::make_shared<SLE>(
340 auto const closeTime =
342 if ((cancelAfter && closeTime >= *cancelAfter) ||
343 (expiration && closeTime >= *expiration))
348 if (src != txAccount)
357 if (expiration && *expiration < minExpiration)
358 minExpiration = *expiration;
360 if (*extend < minExpiration)
376 if (balance < reserve)
409 if (bal && (!
isXRP(*bal) || *bal <= beast::zero))
413 if (amt && (!
isXRP(*amt) || *amt <= beast::zero))
416 if (bal && amt && *bal > *amt)
438 auto const reqBalance = bal->xrp();
439 auto const authAmt = amt ? amt->xrp() : reqBalance;
441 if (reqBalance > authAmt)
473 auto const closeTime =
475 if ((cancelAfter && closeTime >= *cancelAfter) ||
476 (curExpiration && closeTime >= *curExpiration))
481 if (txAccount != src && txAccount != dst)
486 auto const chanBalance = slep->getFieldAmount(
sfBalance).xrp();
487 auto const chanFunds = slep->getFieldAmount(
sfAmount).xrp();
500 if (reqBalance > chanFunds)
503 if (reqBalance <= chanBalance)
525 if (txAccount != dst)
533 XRPAmount const reqDelta = reqBalance - chanBalance;
534 assert(reqDelta >= beast::zero);
542 if (src != txAccount)
555 auto const settleExpiration =
559 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.
const SF_UINT64 sfOwnerNode
boost::optional< KeyType > publicKeyType(Slice const &slice)
Returns the type of public key.
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)
const std::uint32_t tfClose
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
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.
bool verify(PublicKey const &publicKey, Slice const &m, Slice const &sig, bool mustBeFullyCanonical)
Verify a signature on a message.
Integers of any length that is a multiple of 32-bits.
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.
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.
bool enabled(uint256 const &id) const
Returns true if a feature is enabled.
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
const std::uint32_t tfPayChanClaimMask
const SF_HASH256 sfChannel
static NotTEC preflight(PreflightContext const &ctx)
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.
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 std::uint32_t tfRenew
const SF_AMOUNT sfBalance
static TxConsequences makeTxConsequences(PreflightContext const &ctx)
@ tecINSUFFICIENT_RESERVE
const SF_UINT32 sfCancelAfter
const SF_ACCOUNT sfAccount
const std::uint32_t tfUniversalMask
State information when preflighting a tx.
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)
static TER preclaim(PreclaimContext const &ctx)
NetClock::time_point parentCloseTime