20#include <xrpld/app/tx/detail/VaultSet.h>
22#include <xrpl/ledger/View.h>
23#include <xrpl/protocol/Asset.h>
24#include <xrpl/protocol/Feature.h>
25#include <xrpl/protocol/Indexes.h>
26#include <xrpl/protocol/SField.h>
27#include <xrpl/protocol/STNumber.h>
28#include <xrpl/protocol/TER.h>
29#include <xrpl/protocol/TxFlags.h>
46 if (ctx.
tx[sfVaultID] == beast::zero)
48 JLOG(ctx.
j.
debug()) <<
"VaultSet: zero/empty vault ID.";
55 if (
auto const data = ctx.
tx[~sfData])
59 JLOG(ctx.
j.
debug()) <<
"VaultSet: invalid data payload size.";
64 if (
auto const assetMax = ctx.
tx[~sfAssetsMaximum])
66 if (*assetMax < beast::zero)
68 JLOG(ctx.
j.
debug()) <<
"VaultSet: invalid max assets.";
77 JLOG(ctx.
j.
debug()) <<
"VaultSet: nothing is being updated.";
92 if (ctx.
tx[sfAccount] != vault->at(sfOwner))
94 JLOG(ctx.
j.
debug()) <<
"VaultSet: account is not an owner.";
98 auto const mptIssuanceID = (*vault)[sfShareMPTID];
103 JLOG(ctx.
j.
error()) <<
"VaultSet: missing issuance of vault shares.";
108 if (
auto const domain = ctx.
tx[~sfDomainID])
113 JLOG(ctx.
j.
debug()) <<
"VaultSet: vault is not private";
117 if (*domain != beast::zero)
119 auto const sleDomain =
130 <<
"VaultSet: issuance of vault shares is not private.";
153 auto const mptIssuanceID = (*vault)[sfShareMPTID];
158 JLOG(
j_.
error()) <<
"VaultSet: missing issuance of vault shares.";
164 if (tx.isFieldPresent(sfData))
165 vault->at(sfData) = tx[sfData];
166 if (tx.isFieldPresent(sfAssetsMaximum))
168 if (tx[sfAssetsMaximum] != 0 &&
169 tx[sfAssetsMaximum] < *vault->at(sfAssetsTotal))
171 vault->at(sfAssetsMaximum) = tx[sfAssetsMaximum];
174 if (
auto const domainId = tx[~sfDomainID]; domainId)
176 if (*domainId != beast::zero)
183 sleIssuance->setFieldH256(sfDomainID, *domainId);
185 else if (sleIssuance->isFieldPresent(sfDomainID))
187 sleIssuance->makeFieldAbsent(sfDomainID);
virtual void update(std::shared_ptr< SLE > const &sle)=0
Indicate changes to a peeked SLE.
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
bool isFieldPresent(SField const &field) const
std::uint32_t getFlags() const
static TER preclaim(PreclaimContext const &ctx)
static NotTEC preflight(PreflightContext const &ctx)
Keylet permissionedDomain(AccountID const &account, std::uint32_t seq) noexcept
Keylet mptIssuance(std::uint32_t seq, AccountID const &issuer) noexcept
Keylet vault(AccountID const &owner, std::uint32_t seq) noexcept
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::size_t constexpr maxDataPayloadLength
The maximum length of Data payload.
NotTEC preflight1(PreflightContext const &ctx)
Performs early sanity checks on the account and fee fields.
NotTEC preflight2(PreflightContext const &ctx)
Checks whether the signature appears valid.
constexpr std::uint32_t tfUniversalMask
TERSubset< CanCvtToNotTEC > NotTEC
State information when determining if a tx is likely to claim a fee.
State information when preflighting a tx.