20 #include <ripple/app/tx/impl/PayChan.h>
21 #include <ripple/basics/chrono.h>
22 #include <ripple/basics/Log.h>
23 #include <ripple/basics/XRPAmount.h>
24 #include <ripple/ledger/ApplyView.h>
25 #include <ripple/ledger/View.h>
26 #include <ripple/protocol/digest.h>
27 #include <ripple/protocol/Feature.h>
28 #include <ripple/protocol/Indexes.h>
29 #include <ripple/protocol/PayChan.h>
30 #include <ripple/protocol/PublicKey.h>
31 #include <ripple/protocol/st.h>
32 #include <ripple/protocol/TxFlags.h>
138 JLOG (j.
fatal()) <<
"Could not remove paychan from src owner directory";
150 JLOG (j.
fatal()) <<
"Could not remove paychan from dst owner directory";
209 if (balance < reserve)
248 auto const slep = std::make_shared<SLE> (
323 auto const closeTime =
325 if ((cancelAfter && closeTime >= *cancelAfter) ||
326 (expiration && closeTime >= *expiration))
331 if (src != txAccount)
340 if (expiration && *expiration < minExpiration)
341 minExpiration = *expiration;
343 if (*extend < minExpiration)
359 if (balance < reserve)
392 if (bal && (!
isXRP (*bal) || *bal <= beast::zero))
396 if (amt && (!
isXRP (*amt) || *amt <= beast::zero))
399 if (bal && amt && *bal > *amt)
421 auto const reqBalance = bal->xrp ();
422 auto const authAmt = amt ? amt->xrp() : reqBalance;
424 if (reqBalance > authAmt)
455 auto const closeTime =
457 if ((cancelAfter && closeTime >= *cancelAfter) ||
458 (curExpiration && closeTime >= *curExpiration))
463 if (txAccount != src && txAccount != dst)
468 auto const chanBalance = slep->getFieldAmount (
sfBalance).xrp ();
469 auto const chanFunds = slep->getFieldAmount (
sfAmount).xrp ();
482 if (reqBalance > chanFunds)
485 if (reqBalance <= chanBalance)
507 if (txAccount != dst)
515 XRPAmount const reqDelta = reqBalance - chanBalance;
516 assert (reqDelta >= beast::zero);
524 if (src != txAccount)
537 auto const settleExpiration =
541 if (!curExpiration || *curExpiration > settleExpiration)
virtual LedgerInfo const & info() const =0
Returns information about the ledger.
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.
Keylet payChan(AccountID const &source, AccountID const &dst, std::uint32_t seq)
A PaymentChannel.
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.
static const depositPreauth_t depositPreauth
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.
static const account_t account
const SF_U64 sfDestinationNode(access, STI_UINT64, 9, "DestinationNode")
Keylet ownerDir(AccountID const &id)
The root page of an account's directory.
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")
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.
const SF_U32 sfCancelAfter(access, STI_UINT32, 36, "CancelAfter")
static TER preclaim(PreclaimContext const &ctx)
TERSubset< CanCvtToNotTEC > NotTEC
NetClock::time_point parentCloseTime