20 #include <ripple/app/tx/impl/SetAccount.h>
21 #include <ripple/basics/Log.h>
22 #include <ripple/core/Config.h>
23 #include <ripple/ledger/View.h>
24 #include <ripple/protocol/Feature.h>
25 #include <ripple/protocol/Indexes.h>
26 #include <ripple/protocol/PublicKey.h>
27 #include <ripple/protocol/Quality.h>
28 #include <ripple/protocol/st.h>
37 auto getTxConsequencesCategory = [](
STTx const& tx) {
42 if (
auto const uSetFlag = tx[~
sfSetFlag]; uSetFlag &&
47 if (
auto const uClearFlag = tx[~
sfClearFlag]; uClearFlag &&
71 JLOG(j.trace()) <<
"Malformed transaction: Invalid flags set.";
78 if ((uSetFlag != 0) && (uSetFlag == uClearFlag))
80 JLOG(j.trace()) <<
"Malformed transaction: Set and clear same flag.";
87 bool bSetRequireAuth =
89 bool bClearRequireAuth =
92 if (bSetRequireAuth && bClearRequireAuth)
94 JLOG(j.trace()) <<
"Malformed transaction: Contradictory flags set.";
101 bool bSetRequireDest =
103 bool bClearRequireDest =
106 if (bSetRequireDest && bClearRequireDest)
108 JLOG(j.trace()) <<
"Malformed transaction: Contradictory flags set.";
115 bool bSetDisallowXRP =
117 bool bClearDisallowXRP =
120 if (bSetDisallowXRP && bClearDisallowXRP)
122 JLOG(j.trace()) <<
"Malformed transaction: Contradictory flags set.";
131 if (uRate && (uRate < QUALITY_ONE))
134 <<
"Malformed transaction: Transfer rate too small.";
138 if (uRate > 2 * QUALITY_ONE)
141 <<
"Malformed transaction: Transfer rate too large.";
151 ((uTickSize < Quality::minTickSize) ||
152 (uTickSize > Quality::maxTickSize)))
154 JLOG(j.trace()) <<
"Malformed transaction: Bad tick size.";
163 JLOG(j.trace()) <<
"Invalid message key specified.";
168 if (
auto const domain = tx[~
sfDomain];
171 JLOG(j.trace()) <<
"domain too long";
206 bool bSetRequireAuth =
216 JLOG(ctx.
j.
trace()) <<
"Retry: Owner directory not empty.";
230 JLOG(ctx.
j.
trace()) <<
"Can't set Clawback if NoFreeze is set";
236 JLOG(ctx.
j.
trace()) <<
"Owner directory not empty.";
246 <<
"Can't set NoFreeze if clawback is enabled";
271 bool const bSetRequireDest{
273 bool const bClearRequireDest{
275 bool const bSetRequireAuth{
277 bool const bClearRequireAuth{
279 bool const bSetDisallowXRP{
281 bool const bClearDisallowXRP{
284 bool const sigWithMaster{[&tx, &acct =
account_]() {
285 auto const spk = tx.getSigningPubKey();
302 JLOG(
j_.
trace()) <<
"Set RequireAuth.";
308 JLOG(
j_.
trace()) <<
"Clear RequireAuth.";
317 JLOG(
j_.
trace()) <<
"Set lsfRequireDestTag.";
323 JLOG(
j_.
trace()) <<
"Clear lsfRequireDestTag.";
332 JLOG(
j_.
trace()) <<
"Set lsfDisallowXRP.";
338 JLOG(
j_.
trace()) <<
"Clear lsfDisallowXRP.";
349 JLOG(
j_.
trace()) <<
"Must use master key to disable master key.";
360 JLOG(
j_.
trace()) <<
"Set lsfDisableMaster.";
366 JLOG(
j_.
trace()) <<
"Clear lsfDisableMaster.";
375 JLOG(
j_.
trace()) <<
"Set lsfDefaultRipple.";
380 JLOG(
j_.
trace()) <<
"Clear lsfDefaultRipple.";
391 JLOG(
j_.
trace()) <<
"Must use master key to set NoFreeze.";
395 JLOG(
j_.
trace()) <<
"Set NoFreeze flag";
402 JLOG(
j_.
trace()) <<
"Set GlobalFreeze flag";
412 JLOG(
j_.
trace()) <<
"Clear GlobalFreeze flag";
421 JLOG(
j_.
trace()) <<
"Set AccountTxnID.";
427 JLOG(
j_.
trace()) <<
"Clear AccountTxnID.";
438 JLOG(
j_.
trace()) <<
"Set lsfDepositAuth.";
443 JLOG(
j_.
trace()) <<
"Clear lsfDepositAuth.";
457 JLOG(
j_.
trace()) <<
"unset email hash";
462 JLOG(
j_.
trace()) <<
"set email hash";
476 JLOG(
j_.
trace()) <<
"unset wallet locator";
481 JLOG(
j_.
trace()) <<
"set wallet locator";
493 if (messageKey.
empty())
495 JLOG(
j_.
debug()) <<
"set message key";
500 JLOG(
j_.
debug()) <<
"set message key";
514 JLOG(
j_.
trace()) <<
"unset domain";
519 JLOG(
j_.
trace()) <<
"set domain";
531 if (uRate == 0 || uRate == QUALITY_ONE)
533 JLOG(
j_.
trace()) <<
"unset transfer rate";
538 JLOG(
j_.
trace()) <<
"set transfer rate";
549 if ((uTickSize == 0) || (uTickSize == Quality::maxTickSize))
551 JLOG(
j_.
trace()) <<
"unset tick size";
556 JLOG(
j_.
trace()) <<
"set tick size";
600 JLOG(
j_.
trace()) <<
"set allow clawback";
604 if (uFlagsIn != uFlagsOut)
605 sle->setFieldU32(
sfFlags, uFlagsOut);
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.
std::enable_if_t< std::is_same< T, char >::value||std::is_same< T, unsigned char >::value, Slice > makeSlice(std::array< T, N > const &a)
constexpr std::uint32_t asfDisallowXRP
constexpr std::uint32_t asfDepositAuth
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
Stream trace() const
Severity stream access functions.
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
const uint256 featureClawback
constexpr std::uint32_t tfDisallowXRP
const SF_ACCOUNT sfRegularKey
constexpr std::uint32_t asfNoFreeze
const uint256 featureDepositAuth
constexpr std::uint32_t tfAllowXRP
const SF_UINT32 sfSetFlag
constexpr std::uint32_t asfDisallowIncomingPayChan
@ lsfAllowTrustLineClawback
NotTEC preflight1(PreflightContext const &ctx)
Performs early sanity checks on the account and fee fields.
constexpr std::uint32_t asfDisallowIncomingTrustline
constexpr std::uint32_t tfAccountSetMask
constexpr std::uint32_t asfDisallowIncomingCheck
std::optional< KeyType > publicKeyType(Slice const &slice)
Returns the type of public key.
Integers of any length that is a multiple of 32-bits.
constexpr std::uint32_t asfDisableMaster
Keylet account(AccountID const &id) noexcept
AccountID root.
const uint256 featureDisallowIncoming
const SF_ACCOUNT sfNFTokenMinter
@ lsfDisallowIncomingPayChan
@ blocker
Affects the ability of subsequent transactions to claim a fee.
AccountID calcAccountID(PublicKey const &pk)
const SF_UINT256 sfAccountTxnID
std::uint32_t getFlags() const
const SF_UINT32 sfTransferRate
const SF_UINT8 sfTickSize
const SF_UINT32 sfClearFlag
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
constexpr std::uint32_t tfOptionalAuth
constexpr std::uint32_t tfRequireAuth
static TxConsequences makeTxConsequences(PreflightContext const &ctx)
State information when determining if a tx is likely to claim a fee.
const SF_UINT128 sfEmailHash
bool dirIsEmpty(ReadView const &view, Keylet const &k)
Returns true if the directory is empty.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
const uint256 featureNonFungibleTokensV1
const SF_UINT256 sfWalletLocator
@ lsfDisallowIncomingNFTokenOffer
virtual Rules const & rules() const =0
Returns the tx processing rules.
constexpr std::uint32_t asfRequireAuth
static NotTEC preflight(PreflightContext const &ctx)
constexpr std::uint32_t asfDefaultRipple
@ lsfDisallowIncomingTrustline
constexpr std::uint32_t asfRequireDest
@ lsfDisallowIncomingCheck
constexpr std::uint32_t asfGlobalFreeze
const SF_ACCOUNT sfAccount
@ normal
Moves currency around, creates offers, etc.
constexpr std::uint32_t tfRequireDestTag
std::uint32_t getFieldU32(SField const &field) const
State information when preflighting a tx.
constexpr std::uint32_t asfAllowTrustLineClawback
constexpr std::uint32_t tfOptionalDestTag
static Keylet signers(AccountID const &account, std::uint32_t page) noexcept
Class describing the consequences to the account of applying a transaction if the transaction consume...
constexpr std::uint32_t asfAccountTxnID
constexpr std::uint32_t asfDisallowIncomingNFTokenOffer
constexpr std::size_t maxDomainLength
The maximum length of a domain.
static TER preclaim(PreclaimContext const &ctx)
constexpr std::uint32_t asfAuthorizedNFTokenMinter