1#include <xrpl/tx/invariants/FreezeInvariant.h>
3#include <xrpl/basics/Log.h>
4#include <xrpl/beast/utility/instrumentation.h>
5#include <xrpl/protocol/Feature.h>
6#include <xrpl/protocol/TxFormats.h>
7#include <xrpl/tx/invariants/InvariantCheckPrivilege.h>
33 if (balanceChange.signum() == 0)
65 [[maybe_unused]]
bool const enforce = view.
rules().
enabled(featureDeepFreeze);
69 auto const issuerSle =
findIssuer(issue.account, view);
78 "xrpl::TransfersNotFrozen::finalize : enforce "
102 XRPL_ASSERT(
after,
"xrpl::TransfersNotFrozen::isValidEntry : valid after.");
108 if (
after->getType() == ltACCOUNT_ROOT)
120 return after->getType() == ltRIPPLE_STATE && (!before || before->getType() == ltRIPPLE_STATE);
129 auto const getBalance = [](
auto const& line,
auto const& other,
bool zero) {
130 STAmount const amt = line ? line->at(sfBalance) : other->at(sfBalance).zeroed();
131 return zero ? amt.
zeroed() : amt;
139 auto const balanceBefore = getBalance(before,
after,
false);
146 auto const balanceAfter = getBalance(
after, before, isDelete);
148 return balanceAfter - balanceBefore;
156 "xrpl::TransfersNotFrozen::recordBalance : valid trustline "
161 changes.senders.emplace_back(std::move(change));
165 changes.receivers.emplace_back(std::move(change));
174 auto const balanceChangeSign = balanceChange.
signum();
175 auto const currency =
after->at(sfBalance).getCurrency();
208 bool const globalFreeze = issuer->isFlag(lsfGlobalFreeze);
223 for (
auto const& change : actors)
225 bool const high = change.line->at(sfLowLimit).getIssuer() == issuer->at(sfAccount);
247 bool const deepFreeze = change.
line->isFlag(high ? lsfLowDeepFreeze : lsfHighDeepFreeze);
248 bool const frozen = globalFreeze || deepFreeze || freeze;
250 bool const isAMMLine = change.
line->isFlag(lsfAMMNode);
260 JLOG(j.
debug()) <<
"Invariant check allowing funds to be moved "
266 JLOG(j.
fatal()) <<
"Invariant failed: Attempting to move frozen funds for "
271 "xrpl::TransfersNotFrozen::validateFrozenState : enforce "
A generic endpoint for log messages.
A currency issued by an account.
virtual Rules const & rules() const =0
Returns the tx processing rules.
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.
int signum() const noexcept
STAmount zeroed() const
Returns a zero value with the same issuer and currency.
uint256 getTransactionID() const
std::shared_ptr< SLE const > findIssuer(AccountID const &issuerID, ReadView const &view)
void recordBalance(Issue const &issue, BalanceChange change)
bool isValidEntry(std::shared_ptr< SLE const > const &before, std::shared_ptr< SLE const > const &after)
static bool validateIssuerChanges(std::shared_ptr< SLE const > const &issuer, IssuerChanges const &changes, STTx const &tx, beast::Journal const &j, bool enforce)
std::map< AccountID, std::shared_ptr< SLE const > const > possibleIssuers_
static STAmount calculateBalanceChange(std::shared_ptr< SLE const > const &before, std::shared_ptr< SLE const > const &after, bool isDelete)
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &)
static bool validateFrozenState(BalanceChange const &change, bool high, STTx const &tx, beast::Journal const &j, bool enforce, bool globalFreeze)
void visitEntry(bool, std::shared_ptr< SLE const > const &, std::shared_ptr< SLE const > const &)
void recordBalanceChanges(std::shared_ptr< SLE const > const &after, STAmount const &balanceChange)
Keylet account(AccountID const &id) noexcept
AccountID root.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
bool hasPrivilege(STTx const &tx, Privilege priv)
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
int const balanceChangeSign
std::shared_ptr< SLE const > const line
std::vector< BalanceChange > senders
std::vector< BalanceChange > receivers