20 #include <ripple/app/tx/impl/Escrow.h>
22 #include <ripple/app/misc/HashRouter.h>
23 #include <ripple/basics/Log.h>
24 #include <ripple/basics/XRPAmount.h>
25 #include <ripple/basics/chrono.h>
26 #include <ripple/basics/safe_cast.h>
27 #include <ripple/conditions/Condition.h>
28 #include <ripple/conditions/Fulfillment.h>
29 #include <ripple/ledger/ApplyView.h>
30 #include <ripple/ledger/View.h>
31 #include <ripple/protocol/Feature.h>
32 #include <ripple/protocol/Indexes.h>
33 #include <ripple/protocol/TxFlags.h>
34 #include <ripple/protocol/digest.h>
35 #include <ripple/protocol/st.h>
40 #define SF_CF_INVALID SF_PRIVATE5
41 #define SF_CF_VALID SF_PRIVATE6
140 auto condition = Condition::deserialize(*cb, ec);
144 <<
"Malformed condition during escrow creation: "
151 if (condition->type != Type::preimageSha256 &&
183 if (closeTime.time_since_epoch().count() >= cancelAfter)
191 if (closeTime.time_since_epoch().count() >= finishAfter)
207 if (balance < reserve)
233 Keylet const escrowKeylet =
235 auto const slep = std::make_shared<SLE>(escrowKeylet);
283 auto condition = Condition::deserialize(c, ec);
287 auto fulfillment = Fulfillment::deserialize(f, ec);
291 return validate(*fulfillment, *condition);
308 if (
static_cast<bool>(cb) !=
static_cast<bool>(fb))
324 auto const flags = router.getFlags(
id);
329 if (!(flags & (SF_CF_INVALID | SF_CF_VALID)))
332 router.setFlags(
id, SF_CF_VALID);
334 router.setFlags(
id, SF_CF_INVALID);
348 extraFee +=
view.
fees().
base * (32 + (fb->size() / 16));
402 if (cb && !(flags & (SF_CF_INVALID | SF_CF_VALID)))
412 flags = SF_CF_INVALID;
419 if (flags & SF_CF_INVALID)
435 if (cond && (cond != cb))
470 JLOG(
j_.
fatal()) <<
"Unable to delete Escrow from owner.";
481 JLOG(
j_.
fatal()) <<
"Unable to delete Escrow from recipient.";
552 JLOG(
j_.
fatal()) <<
"Unable to delete Escrow from owner.";
566 JLOG(
j_.
fatal()) <<
"Unable to delete Escrow from recipient.";
virtual LedgerInfo const & info() const =0
Returns information about the ledger.
const SF_UINT32 sfOfferSequence
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)
int getFlags(uint256 const &key)
An immutable linear range of bytes.
static TxConsequences makeTxConsequences(PreflightContext const &ctx)
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.
const uint256 featureDepositAuth
static NotTEC preflight(PreflightContext const &ctx)
virtual void update(std::shared_ptr< SLE > const &sle)=0
Indicate changes to a peeked SLE.
const beast::Journal journal
SeqProxy getSeqProxy() const
NotTEC preflight1(PreflightContext const &ctx)
Performs early sanity checks on the account and fee fields.
bool dirRemove(Keylet const &directory, std::uint64_t page, uint256 const &key, bool keepRoot)
Remove an entry from a directory.
T time_since_epoch(T... args)
Keylet escrow(AccountID const &src, std::uint32_t seq) noexcept
An escrow entry.
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 XRPAmount calculateBaseFee(ReadView const &view, STTx const &tx)
Keylet account(AccountID const &id) noexcept
AccountID root.
const SF_UINT64 sfDestinationNode
std::uint32_t getFlags() const
bool isXRP(AccountID const &c)
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
static bool checkCondition(Slice f, Slice c)
bool validate(Fulfillment const &f, Condition const &c, Slice m)
Verify if the given message satisfies the fulfillment.
uint256 getTransactionID() const
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.
const uint256 featureCryptoConditionsSuite
static NotTEC preflight(PreflightContext const &ctx)
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
@ tecINSUFFICIENT_RESERVE
const SF_UINT32 sfCancelAfter
static NotTEC preflight(PreflightContext const &ctx)
static bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
const SF_UINT32 sfFinishAfter
const SF_ACCOUNT sfAccount
static XRPAmount calculateBaseFee(ReadView const &view, STTx const &tx)
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...
const SF_VL sfFulfillment
virtual HashRouter & getHashRouter()=0
bool setFlags(uint256 const &key, int flags)
Set the flags on a hash.
TERSubset< CanCvtToNotTEC > NotTEC
@ tecCRYPTOCONDITION_ERROR
NetClock::time_point parentCloseTime