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
141 auto condition = Condition::deserialize(*cb, ec);
145 <<
"Malformed condition during escrow creation: "
152 if (condition->type != Type::preimageSha256 &&
184 if (closeTime.time_since_epoch().count() >= cancelAfter)
192 if (closeTime.time_since_epoch().count() >= finishAfter)
208 if (balance < reserve)
292 auto condition = Condition::deserialize(c, ec);
296 auto fulfillment = Fulfillment::deserialize(f, ec);
300 return validate(*fulfillment, *condition);
320 if (
static_cast<bool>(cb) !=
static_cast<bool>(fb))
336 auto const flags = router.getFlags(
id);
341 if (!(flags & (SF_CF_INVALID | SF_CF_VALID)))
344 router.setFlags(
id, SF_CF_VALID);
346 router.setFlags(
id, SF_CF_INVALID);
361 safe_cast<FeeUnit64>(
view.
fees().
units) * (32 + (fb->size() / 16));
415 if (cb && !(flags & (SF_CF_INVALID | SF_CF_VALID)))
425 flags = SF_CF_INVALID;
432 if (flags & SF_CF_INVALID)
448 if (cond && (cond != cb))
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.
static FeeUnit64 calculateBaseFee(ReadView const &view, STTx const &tx)
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)
int getFlags(uint256 const &key)
An immutable linear range of bytes.
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.
const SF_Account sfAccount(access, STI_ACCOUNT, 1, "Account")
const SF_U32 sfFlags(access, STI_UINT32, 2, "Flags")
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
const SF_U64 sfOwnerNode(access, STI_UINT64, 4, "OwnerNode")
const SF_Amount sfAmount(access, STI_AMOUNT, 1, "Amount")
const SF_U32 sfOwnerCount(access, STI_UINT32, 13, "OwnerCount")
const SF_U32 sfFinishAfter(access, STI_UINT32, 37, "FinishAfter")
NotTEC preflight1(PreflightContext const &ctx)
Performs early sanity checks on the account and fee fields.
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.
const SF_Blob sfFulfillment(access, STI_VL, 16, "Fulfillment")
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.
const SF_Account sfOwner(access, STI_ACCOUNT, 2, "Owner")
static XRPAmount calculateMaxSpend(STTx const &tx)
Keylet account(AccountID const &id) noexcept
AccountID root.
const SF_U64 sfDestinationNode(access, STI_UINT64, 9, "DestinationNode")
std::uint32_t getFlags() const
static FeeUnit64 calculateBaseFee(ReadView const &view, STTx const &tx)
bool isXRP(AccountID const &c)
bool enabled(uint256 const &id) const
Returns true if a feature is enabled.
const SF_U32 sfSourceTag(access, STI_UINT32, 3, "SourceTag")
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
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)
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 uint256 featureCryptoConditionsSuite
static NotTEC preflight(PreflightContext const &ctx)
const SF_Amount sfBalance(access, STI_AMOUNT, 2, "Balance")
const SF_U32 sfOfferSequence(access, STI_UINT32, 25, "OfferSequence")
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_Blob sfCondition(access, STI_VL, 17, "Condition")
@ tecINSUFFICIENT_RESERVE
static NotTEC preflight(PreflightContext const &ctx)
const SF_Account sfDestination(access, STI_ACCOUNT, 3, "Destination")
static bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
const std::uint32_t tfUniversalMask
State information when preflighting a tx.
Keylet depositPreauth(AccountID const &owner, AccountID const &preauthorized) noexcept
A DepositPreauth.
virtual HashRouter & getHashRouter()=0
bool setFlags(uint256 const &key, int flags)
Set the flags on a hash.
const SF_U32 sfCancelAfter(access, STI_UINT32, 36, "CancelAfter")
TERSubset< CanCvtToNotTEC > NotTEC
@ tecCRYPTOCONDITION_ERROR
NetClock::time_point parentCloseTime