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";
201 if (balance < reserve)
240 auto const slep = std::make_shared<SLE>(
325 auto const closeTime =
327 if ((cancelAfter && closeTime >= *cancelAfter) ||
328 (expiration && closeTime >= *expiration))
333 if (src != txAccount)
342 if (expiration && *expiration < minExpiration)
343 minExpiration = *expiration;
345 if (*extend < minExpiration)
361 if (balance < reserve)
394 if (bal && (!
isXRP(*bal) || *bal <= beast::zero))
398 if (amt && (!
isXRP(*amt) || *amt <= beast::zero))
401 if (bal && amt && *bal > *amt)
423 auto const reqBalance = bal->xrp();
424 auto const authAmt = amt ? amt->xrp() : reqBalance;
426 if (reqBalance > authAmt)
457 auto const closeTime =
459 if ((cancelAfter && closeTime >= *cancelAfter) ||
460 (curExpiration && closeTime >= *curExpiration))
465 if (txAccount != src && txAccount != dst)
470 auto const chanBalance = slep->getFieldAmount(
sfBalance).xrp();
471 auto const chanFunds = slep->getFieldAmount(
sfAmount).xrp();
484 if (reqBalance > chanFunds)
487 if (reqBalance <= chanBalance)
509 if (txAccount != dst)
517 XRPAmount const reqDelta = reqBalance - chanBalance;
518 assert(reqDelta >= beast::zero);
526 if (src != txAccount)
539 auto const settleExpiration =
543 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.
NotTEC preflight2(PreflightContext const &ctx)
Checks whether the signature appears valid.
A pair of SHAMap key and LedgerEntryType.
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.
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.
const SF_U32 sfSequence(access, STI_UINT32, 4, "Sequence")
virtual Fees const & fees() const =0
Returns the fees for the base ledger.
static NotTEC preflight(PreflightContext const &ctx)
const SF_Account sfAccount(access, STI_ACCOUNT, 1, "Account")
const SF_U32 sfFlags(access, STI_UINT32, 2, "Flags")
const uint256 featureDepositAuth
virtual void update(std::shared_ptr< SLE > const &sle)=0
Indicate changes to a peeked SLE.
const beast::Journal journal
const SF_U64 sfOwnerNode(access, STI_UINT64, 4, "OwnerNode")
const SF_U256 sfPayChannel(access, STI_HASH256, 22, "Channel")
void serializePayChanAuthorization(Serializer &msg, uint256 const &key, XRPAmount const &amt)
const SF_Amount sfAmount(access, STI_AMOUNT, 1, "Amount")
const SF_U32 sfOwnerCount(access, STI_UINT32, 13, "OwnerCount")
const SF_Blob sfSignature(access, STI_VL, 6, "Signature", SField::sMD_Default, SField::notSigning)
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_U32 sfDestinationTag(access, STI_UINT32, 14, "DestinationTag")
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.
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.
Keylet account(AccountID const &id) noexcept
AccountID root.
const SF_U64 sfDestinationNode(access, STI_UINT64, 9, "DestinationNode")
TERSubset< CanCvtToTER > TER
Slice slice() const noexcept
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.
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.
const std::uint32_t tfPayChanClaimMask
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.
const SF_Blob sfPublicKey(access, STI_VL, 1, "PublicKey")
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
const SF_Amount sfBalance(access, STI_AMOUNT, 2, "Balance")
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 std::uint32_t tfRenew
const SF_U32 sfSettleDelay(access, STI_UINT32, 39, "SettleDelay")
@ tecINSUFFICIENT_RESERVE
const SF_Account sfDestination(access, STI_ACCOUNT, 3, "Destination")
const std::uint32_t tfUniversalMask
State information when preflighting a tx.
Keylet depositPreauth(AccountID const &owner, AccountID const &preauthorized) noexcept
A DepositPreauth.
const SF_U32 sfCancelAfter(access, STI_UINT32, 36, "CancelAfter")
static TER preclaim(PreclaimContext const &ctx)
TERSubset< CanCvtToNotTEC > NotTEC
NetClock::time_point parentCloseTime