20#include <xrpld/app/tx/detail/DelegateSet.h>
21#include <xrpld/ledger/View.h>
23#include <xrpl/basics/Log.h>
24#include <xrpl/protocol/Feature.h>
25#include <xrpl/protocol/Indexes.h>
26#include <xrpl/protocol/TxFlags.h>
27#include <xrpl/protocol/st.h>
45 if (ctx.
tx[sfAccount] == ctx.
tx[sfAuthorize])
50 for (
auto const& permission : permissions)
52 if (!permissionSet.
insert(permission[sfPermissionValue]).second)
69 for (
auto const& permission : permissions)
71 auto const permissionValue = permission[sfPermissionValue];
86 auto const& authAccount =
ctx_.
tx[sfAuthorize];
93 if (permissions.empty())
97 sle->setFieldArray(sfPermissions, permissions);
103 sleOwner->getFieldU32(sfOwnerCount) + 1)};
109 if (!permissions.empty())
112 sle->setAccountID(sfAccount,
account_);
113 sle->setAccountID(sfAuthorize, authAccount);
115 sle->setFieldArray(sfPermissions, permissions);
124 (*sle)[sfOwnerNode] = *page;
146 JLOG(j.
fatal()) <<
"Unable to delete Delegate from owner.";
A generic endpoint for log messages.
beast::Journal const journal
Writeable view to a ledger, for applying a transaction.
virtual void update(std::shared_ptr< SLE > const &sle)=0
Indicate changes to a peeked SLE.
bool dirRemove(Keylet const &directory, std::uint64_t page, uint256 const &key, bool keepRoot)
Remove an entry from a directory.
virtual void insert(std::shared_ptr< SLE > const &sle)=0
Insert a new state SLE.
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.
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
virtual void erase(std::shared_ptr< SLE > const &sle)=0
Remove a peeked SLE.
static TER preclaim(PreclaimContext const &ctx)
static NotTEC preflight(PreflightContext const &ctx)
static TER deleteDelegate(ApplyView &view, std::shared_ptr< SLE > const &sle, AccountID const &account, beast::Journal j)
bool isDelegatable(std::uint32_t const &permissionValue) const
static Permission const & getInstance()
virtual Fees const & fees() const =0
Returns the fees for the base ledger.
virtual bool exists(Keylet const &k) const =0
Determine if a state item exists.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
STArray const & getFieldArray(SField const &field) const
Keylet delegate(AccountID const &account, AccountID const &authorizedAccount) noexcept
A keylet for Delegate object.
Keylet account(AccountID const &id) noexcept
AccountID root.
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::size_t constexpr permissionMaxSize
The maximum number of delegate permissions an account can grant.
std::function< void(SLE::ref)> describeOwnerDir(AccountID const &account)
NotTEC preflight1(PreflightContext const &ctx)
Performs early sanity checks on the account and fee fields.
static bool adjustOwnerCount(ApplyContext &ctx, int count)
NotTEC preflight2(PreflightContext const &ctx)
Checks whether the signature appears valid.
@ tecINSUFFICIENT_RESERVE
bool isTesSuccess(TER x) noexcept
TERSubset< CanCvtToNotTEC > NotTEC
XRPAmount accountReserve(std::size_t ownerCount) const
Returns the account reserve given the owner count, in drops.
State information when determining if a tx is likely to claim a fee.
State information when preflighting a tx.