rippled
Loading...
Searching...
No Matches
View.h
1#pragma once
2
3#include <xrpl/beast/utility/Journal.h>
4#include <xrpl/ledger/ApplyView.h>
5#include <xrpl/ledger/OpenView.h>
6#include <xrpl/ledger/ReadView.h>
7#include <xrpl/protocol/Asset.h>
8#include <xrpl/protocol/Indexes.h>
9#include <xrpl/protocol/MPTIssue.h>
10#include <xrpl/protocol/Protocol.h>
11#include <xrpl/protocol/Rate.h>
12#include <xrpl/protocol/STLedgerEntry.h>
13#include <xrpl/protocol/STObject.h>
14#include <xrpl/protocol/Serializer.h>
15#include <xrpl/protocol/TER.h>
16
17#include <functional>
18#include <initializer_list>
19#include <map>
20#include <utility>
21
22namespace xrpl {
23
24enum class WaiveTransferFee : bool { No = false, Yes };
25enum class SkipEntry : bool { No = false, Yes };
26
27//------------------------------------------------------------------------------
28//
29// Observers
30//
31//------------------------------------------------------------------------------
32
54[[nodiscard]] bool
55hasExpired(ReadView const& view, std::optional<std::uint32_t> const& exp);
56
59
62
65
66[[nodiscard]] bool
67isGlobalFrozen(ReadView const& view, AccountID const& issuer);
68
69[[nodiscard]] bool
70isGlobalFrozen(ReadView const& view, MPTIssue const& mptIssue);
71
72[[nodiscard]] bool
73isGlobalFrozen(ReadView const& view, Asset const& asset);
74
75// Note, depth parameter is used to limit the recursion depth
76[[nodiscard]] bool
77isVaultPseudoAccountFrozen(ReadView const& view, AccountID const& account, MPTIssue const& mptShare, int depth);
78
79[[nodiscard]] bool
80isIndividualFrozen(ReadView const& view, AccountID const& account, Currency const& currency, AccountID const& issuer);
81
82[[nodiscard]] inline bool
83isIndividualFrozen(ReadView const& view, AccountID const& account, Issue const& issue)
84{
85 return isIndividualFrozen(view, account, issue.currency, issue.account);
86}
87
88[[nodiscard]] bool
89isIndividualFrozen(ReadView const& view, AccountID const& account, MPTIssue const& mptIssue);
90
91[[nodiscard]] inline bool
92isIndividualFrozen(ReadView const& view, AccountID const& account, Asset const& asset)
93{
94 return std::visit([&](auto const& issue) { return isIndividualFrozen(view, account, issue); }, asset.value());
95}
96
97[[nodiscard]] bool
98isFrozen(ReadView const& view, AccountID const& account, Currency const& currency, AccountID const& issuer);
99
100[[nodiscard]] inline bool
101isFrozen(ReadView const& view, AccountID const& account, Issue const& issue, int = 0 /*ignored*/)
102{
103 return isFrozen(view, account, issue.currency, issue.account);
104}
105
106[[nodiscard]] bool
107isFrozen(ReadView const& view, AccountID const& account, MPTIssue const& mptIssue, int depth = 0);
108
114[[nodiscard]] inline bool
115isFrozen(ReadView const& view, AccountID const& account, Asset const& asset, int depth = 0)
116{
117 return std::visit([&](auto const& issue) { return isFrozen(view, account, issue, depth); }, asset.value());
118}
119
120[[nodiscard]] inline TER
121checkFrozen(ReadView const& view, AccountID const& account, Issue const& issue)
122{
123 return isFrozen(view, account, issue) ? (TER)tecFROZEN : (TER)tesSUCCESS;
124}
125
126[[nodiscard]] inline TER
127checkFrozen(ReadView const& view, AccountID const& account, MPTIssue const& mptIssue)
128{
129 return isFrozen(view, account, mptIssue) ? (TER)tecLOCKED : (TER)tesSUCCESS;
130}
131
132[[nodiscard]] inline TER
133checkFrozen(ReadView const& view, AccountID const& account, Asset const& asset)
134{
135 return std::visit([&](auto const& issue) { return checkFrozen(view, account, issue); }, asset.value());
136}
137
138[[nodiscard]] bool
140 ReadView const& view,
141 std::initializer_list<AccountID> const& accounts,
142 MPTIssue const& mptIssue,
143 int depth = 0);
144
145[[nodiscard]] inline bool
146isAnyFrozen(ReadView const& view, std::initializer_list<AccountID> const& accounts, Issue const& issue)
147{
148 for (auto const& account : accounts)
149 {
150 if (isFrozen(view, account, issue.currency, issue.account))
151 return true;
152 }
153 return false;
154}
155
156[[nodiscard]] inline bool
157isAnyFrozen(ReadView const& view, std::initializer_list<AccountID> const& accounts, Asset const& asset, int depth = 0)
158{
159 return std::visit(
160 [&]<ValidIssueType TIss>(TIss const& issue) {
161 if constexpr (std::is_same_v<TIss, Issue>)
162 return isAnyFrozen(view, accounts, issue);
163 else
164 return isAnyFrozen(view, accounts, issue, depth);
165 },
166 asset.value());
167}
168
169[[nodiscard]] bool
170isDeepFrozen(ReadView const& view, AccountID const& account, Currency const& currency, AccountID const& issuer);
171
172[[nodiscard]] inline bool
173isDeepFrozen(ReadView const& view, AccountID const& account, Issue const& issue, int = 0 /*ignored*/)
174{
175 return isDeepFrozen(view, account, issue.currency, issue.account);
176}
177
178[[nodiscard]] inline bool
179isDeepFrozen(ReadView const& view, AccountID const& account, MPTIssue const& mptIssue, int depth = 0)
180{
181 // Unlike IOUs, frozen / locked MPTs are not allowed to send or receive
182 // funds, so checking "deep frozen" is the same as checking "frozen".
183 return isFrozen(view, account, mptIssue, depth);
184}
185
191[[nodiscard]] inline bool
192isDeepFrozen(ReadView const& view, AccountID const& account, Asset const& asset, int depth = 0)
193{
194 return std::visit([&](auto const& issue) { return isDeepFrozen(view, account, issue, depth); }, asset.value());
195}
196
197[[nodiscard]] inline TER
198checkDeepFrozen(ReadView const& view, AccountID const& account, Issue const& issue)
199{
200 return isDeepFrozen(view, account, issue) ? (TER)tecFROZEN : (TER)tesSUCCESS;
201}
202
203[[nodiscard]] inline TER
204checkDeepFrozen(ReadView const& view, AccountID const& account, MPTIssue const& mptIssue)
205{
206 return isDeepFrozen(view, account, mptIssue) ? (TER)tecLOCKED : (TER)tesSUCCESS;
207}
208
209[[nodiscard]] inline TER
210checkDeepFrozen(ReadView const& view, AccountID const& account, Asset const& asset)
211{
212 return std::visit([&](auto const& issue) { return checkDeepFrozen(view, account, issue); }, asset.value());
213}
214
215[[nodiscard]] bool
216isLPTokenFrozen(ReadView const& view, AccountID const& account, Issue const& asset, Issue const& asset2);
217
218// Returns the amount an account can spend.
219//
220// If shSIMPLE_BALANCE is specified, this is the amount the account can spend
221// without going into debt.
222//
223// If shFULL_BALANCE is specified, this is the amount the account can spend
224// total. Specifically:
225// * The account can go into debt if using a trust line, and the other side has
226// a non-zero limit.
227// * If the account is the asset issuer the limit is defined by the asset /
228// issuance.
229//
230// <-- saAmount: amount of currency held by account. May be negative.
231[[nodiscard]] STAmount
233 ReadView const& view,
234 AccountID const& account,
235 Currency const& currency,
236 AccountID const& issuer,
237 FreezeHandling zeroIfFrozen,
239 SpendableHandling includeFullBalance = shSIMPLE_BALANCE);
240
241[[nodiscard]] STAmount
243 ReadView const& view,
244 AccountID const& account,
245 Issue const& issue,
246 FreezeHandling zeroIfFrozen,
248 SpendableHandling includeFullBalance = shSIMPLE_BALANCE);
249
250[[nodiscard]] STAmount
252 ReadView const& view,
253 AccountID const& account,
254 MPTIssue const& mptIssue,
255 FreezeHandling zeroIfFrozen,
256 AuthHandling zeroIfUnauthorized,
258 SpendableHandling includeFullBalance = shSIMPLE_BALANCE);
259
260[[nodiscard]] STAmount
262 ReadView const& view,
263 AccountID const& account,
264 Asset const& asset,
265 FreezeHandling zeroIfFrozen,
266 AuthHandling zeroIfUnauthorized,
268 SpendableHandling includeFullBalance = shSIMPLE_BALANCE);
269
270// Returns the amount an account can spend of the currency type saDefault, or
271// returns saDefault if this account is the issuer of the currency in
272// question. Should be used in favor of accountHolds when questioning how much
273// an account can spend while also allowing currency issuers to spend
274// unlimited amounts of their own currency (since they can always issue more).
275[[nodiscard]] STAmount
277 ReadView const& view,
278 AccountID const& id,
279 STAmount const& saDefault,
280 FreezeHandling freezeHandling,
282
283// Return the account's liquid (not reserved) XRP. Generally prefer
284// calling accountHolds() over this interface. However, this interface
285// allows the caller to temporarily adjust the owner count should that be
286// necessary.
287//
288// @param ownerCountAdj positive to add to count, negative to reduce count.
289[[nodiscard]] XRPAmount
290xrpLiquid(ReadView const& view, AccountID const& id, std::int32_t ownerCountAdj, beast::Journal j);
291
293void
294forEachItem(ReadView const& view, Keylet const& root, std::function<void(std::shared_ptr<SLE const> const&)> const& f);
295
302bool
304 ReadView const& view,
305 Keylet const& root,
306 uint256 const& after,
307 std::uint64_t const hint,
308 unsigned int limit,
309 std::function<bool(std::shared_ptr<SLE const> const&)> const& f);
310
312inline void
313forEachItem(ReadView const& view, AccountID const& id, std::function<void(std::shared_ptr<SLE const> const&)> const& f)
314{
315 return forEachItem(view, keylet::ownerDir(id), f);
316}
317
324inline bool
326 ReadView const& view,
327 AccountID const& id,
328 uint256 const& after,
329 std::uint64_t const hint,
330 unsigned int limit,
331 std::function<bool(std::shared_ptr<SLE const> const&)> const& f)
332{
333 return forEachItemAfter(view, keylet::ownerDir(id), after, hint, limit, f);
334}
335
341[[nodiscard]] Rate
342transferRate(ReadView const& view, AccountID const& issuer);
343
349[[nodiscard]] Rate
350transferRate(ReadView const& view, MPTID const& issuanceID);
351
356[[nodiscard]] Rate
357transferRate(ReadView const& view, STAmount const& amount);
358
362[[nodiscard]] bool
363dirIsEmpty(ReadView const& view, Keylet const& k);
364
365// Return the list of enabled amendments
366[[nodiscard]] std::set<uint256>
367getEnabledAmendments(ReadView const& view);
368
369// Return a map of amendments that have achieved majority
371[[nodiscard]] majorityAmendments_t
373
383[[nodiscard]] std::optional<uint256>
384hashOfSeq(ReadView const& ledger, LedgerIndex seq, beast::Journal journal);
385
398inline LedgerIndex
400{
401 return (requested + 255) & (~255);
402}
403
409[[nodiscard]] bool
410areCompatible(ReadView const& validLedger, ReadView const& testLedger, beast::Journal::Stream& s, char const* reason);
411
412[[nodiscard]] bool
414 uint256 const& validHash,
415 LedgerIndex validIndex,
416 ReadView const& testLedger,
418 char const* reason);
419
420//------------------------------------------------------------------------------
421//
422// Modifiers
423//
424//------------------------------------------------------------------------------
425
427void
428adjustOwnerCount(ApplyView& view, std::shared_ptr<SLE> const& sle, std::int32_t amount, beast::Journal j);
429
445bool
447 ReadView const& view,
448 uint256 const& root,
450 unsigned int& index,
451 uint256& entry);
452
453bool
454dirFirst(ApplyView& view, uint256 const& root, std::shared_ptr<SLE>& page, unsigned int& index, uint256& entry);
472bool
474 ReadView const& view,
475 uint256 const& root,
477 unsigned int& index,
478 uint256& entry);
479
480bool
481dirNext(ApplyView& view, uint256 const& root, std::shared_ptr<SLE>& page, unsigned int& index, uint256& entry);
484[[nodiscard]] std::function<void(SLE::ref)>
485describeOwnerDir(AccountID const& account);
486
487[[nodiscard]] TER
488dirLink(ApplyView& view, AccountID const& owner, std::shared_ptr<SLE>& object, SF_UINT64 const& node = sfOwnerNode);
489
491pseudoAccountAddress(ReadView const& view, uint256 const& pseudoOwnerKey);
492
501[[nodiscard]] Expected<std::shared_ptr<SLE>, TER>
502createPseudoAccount(ApplyView& view, uint256 const& pseudoOwnerKey, SField const& ownerField);
503
504// Returns true if and only if sleAcct is a pseudo-account or specific
505// pseudo-accounts in pseudoFieldFilter.
506//
507// Returns false if sleAcct is
508// * NOT a pseudo-account OR
509// * NOT a ltACCOUNT_ROOT OR
510// * null pointer
511[[nodiscard]] bool
512isPseudoAccount(std::shared_ptr<SLE const> sleAcct, std::set<SField const*> const& pseudoFieldFilter = {});
513
514// Returns the list of fields that define an ACCOUNT_ROOT as a pseudo-account if
515// set
516// Pseudo-account designator fields MUST be maintained by including the
517// SField::sMD_PseudoAccount flag in the SField definition. (Don't forget to
518// "| SField::sMD_Default"!) The fields do NOT need to be amendment-gated,
519// since a non-active amendment will not set any field, by definition.
520// Specific properties of a pseudo-account are NOT checked here, that's what
521// InvariantCheck is for.
522[[nodiscard]] std::vector<SField const*> const&
524
525[[nodiscard]] inline bool
526isPseudoAccount(ReadView const& view, AccountID const& accountId, std::set<SField const*> const& pseudoFieldFilter = {})
527{
528 return isPseudoAccount(view.read(keylet::account(accountId)), pseudoFieldFilter);
529}
530
531[[nodiscard]] TER
532canAddHolding(ReadView const& view, Asset const& asset);
533
539[[nodiscard]] TER
540checkDestinationAndTag(SLE::const_ref toSle, bool hasDestinationTag);
541
556[[nodiscard]] TER
558 ReadView const& view,
559 AccountID const& from,
560 AccountID const& to,
561 SLE::const_ref toSle,
562 STAmount const& amount,
563 bool hasDestinationTag);
564
579[[nodiscard]] TER
581 ReadView const& view,
582 AccountID const& from,
583 AccountID const& to,
584 STAmount const& amount,
585 bool hasDestinationTag);
586
601[[nodiscard]] TER
602canWithdraw(ReadView const& view, STTx const& tx);
603
604[[nodiscard]] TER
606 ApplyView& view,
607 STTx const& tx,
608 AccountID const& senderAcct,
609 AccountID const& dstAcct,
610 AccountID const& sourceAcct,
611 XRPAmount priorBalance,
612 STAmount const& amount,
614
617[[nodiscard]] TER
619 ApplyView& view,
620 AccountID const& accountID,
621 XRPAmount priorBalance,
622 Issue const& issue,
623 beast::Journal journal);
624
625[[nodiscard]] TER
627 ApplyView& view,
628 AccountID const& accountID,
629 XRPAmount priorBalance,
630 MPTIssue const& mptIssue,
631 beast::Journal journal);
632
633[[nodiscard]] inline TER
635 ApplyView& view,
636 AccountID const& accountID,
637 XRPAmount priorBalance,
638 Asset const& asset,
639 beast::Journal journal)
640{
641 return std::visit(
642 [&]<ValidIssueType TIss>(TIss const& issue) -> TER {
643 return addEmptyHolding(view, accountID, priorBalance, issue, journal);
644 },
645 asset.value());
646}
647
648[[nodiscard]] TER
650 ApplyView& view,
651 XRPAmount const& priorBalance,
652 MPTID const& mptIssuanceID,
653 AccountID const& account,
654 beast::Journal journal,
655 std::uint32_t flags = 0,
657
658// VFALCO NOTE Both STAmount parameters should just
659// be "Amount", a unit-less number.
660//
665[[nodiscard]] TER
667 ApplyView& view,
668 bool const bSrcHigh,
669 AccountID const& uSrcAccountID,
670 AccountID const& uDstAccountID,
671 uint256 const& uIndex, // --> ripple state entry
672 SLE::ref sleAccount, // --> the account being set.
673 bool const bAuth, // --> authorize account.
674 bool const bNoRipple, // --> others cannot ripple through
675 bool const bFreeze, // --> funds cannot leave
676 bool bDeepFreeze, // --> can neither receive nor send funds
677 STAmount const& saBalance, // --> balance of account being set.
678 // Issuer should be noAccount()
679 STAmount const& saLimit, // --> limit for account being set.
680 // Issuer should be the account being set.
681 std::uint32_t uSrcQualityIn,
682 std::uint32_t uSrcQualityOut,
684
685[[nodiscard]] TER
686removeEmptyHolding(ApplyView& view, AccountID const& accountID, Issue const& issue, beast::Journal journal);
687
688[[nodiscard]] TER
689removeEmptyHolding(ApplyView& view, AccountID const& accountID, MPTIssue const& mptIssue, beast::Journal journal);
690
691[[nodiscard]] inline TER
692removeEmptyHolding(ApplyView& view, AccountID const& accountID, Asset const& asset, beast::Journal journal)
693{
694 return std::visit(
695 [&]<ValidIssueType TIss>(TIss const& issue) -> TER {
696 return removeEmptyHolding(view, accountID, issue, journal);
697 },
698 asset.value());
699}
700
701[[nodiscard]] TER
703 ApplyView& view,
704 std::shared_ptr<SLE> const& sleRippleState,
705 AccountID const& uLowAccountID,
706 AccountID const& uHighAccountID,
708
715// [[nodiscard]] // nodiscard commented out so Flow, BookTip and others compile.
716TER
717offerDelete(ApplyView& view, std::shared_ptr<SLE> const& sle, beast::Journal j);
718
719//------------------------------------------------------------------------------
720
721//
722// Money Transfers
723//
724
725// Direct send w/o fees:
726// - Redeeming IOUs and/or sending sender's own IOUs.
727// - Create trust line of needed.
728// --> bCheckIssuer : normally require issuer to be involved.
729// [[nodiscard]] // nodiscard commented out so DirectStep.cpp compiles.
730
734TER
736 ApplyView& view,
737 AccountID const& uSenderID,
738 AccountID const& uReceiverID,
739 STAmount const& saAmount,
740 bool bCheckIssuer,
742
743TER
744rippleLockEscrowMPT(ApplyView& view, AccountID const& uGrantorID, STAmount const& saAmount, beast::Journal j);
745
746TER
748 ApplyView& view,
749 AccountID const& uGrantorID,
750 AccountID const& uGranteeID,
751 STAmount const& netAmount,
752 STAmount const& grossAmount,
754
758[[nodiscard]] TER
760 ApplyView& view,
761 AccountID const& from,
762 AccountID const& to,
763 STAmount const& saAmount,
766
774[[nodiscard]] TER
776 ApplyView& view,
777 AccountID const& senderID,
778 Asset const& asset,
779 MultiplePaymentDestinations const& receivers,
782
783[[nodiscard]] TER
784issueIOU(ApplyView& view, AccountID const& account, STAmount const& amount, Issue const& issue, beast::Journal j);
785
786[[nodiscard]] TER
787redeemIOU(ApplyView& view, AccountID const& account, STAmount const& amount, Issue const& issue, beast::Journal j);
788
789[[nodiscard]] TER
790transferXRP(ApplyView& view, AccountID const& from, AccountID const& to, STAmount const& amount, beast::Journal j);
791
792/* Check if MPToken (for MPT) or trust line (for IOU) exists:
793 * - StrongAuth - before checking if authorization is required
794 * - WeakAuth
795 * for MPT - after checking lsfMPTRequireAuth flag
796 * for IOU - do not check if trust line exists
797 * - Legacy
798 * for MPT - before checking lsfMPTRequireAuth flag i.e. same as StrongAuth
799 * for IOU - do not check if trust line exists i.e. same as WeakAuth
800 */
802
820[[nodiscard]] TER
821requireAuth(ReadView const& view, Issue const& issue, AccountID const& account, AuthType authType = AuthType::Legacy);
822
846[[nodiscard]] TER
848 ReadView const& view,
849 MPTIssue const& mptIssue,
850 AccountID const& account,
851 AuthType authType = AuthType::Legacy,
852 int depth = 0);
853
854[[nodiscard]] TER inline requireAuth(
855 ReadView const& view,
856 Asset const& asset,
857 AccountID const& account,
858 AuthType authType = AuthType::Legacy)
859{
860 return std::visit(
861 [&]<ValidIssueType TIss>(TIss const& issue_) { return requireAuth(view, issue_, account, authType); },
862 asset.value());
863}
864
888[[nodiscard]] TER
890 ApplyView& view,
891 MPTID const& mptIssuanceID,
892 AccountID const& account,
893 XRPAmount const& priorBalance,
895
900[[nodiscard]] TER
901canTransfer(ReadView const& view, MPTIssue const& mptIssue, AccountID const& from, AccountID const& to);
902
903[[nodiscard]] TER
904canTransfer(ReadView const& view, Issue const& issue, AccountID const& from, AccountID const& to);
905
906[[nodiscard]] TER inline canTransfer(
907 ReadView const& view,
908 Asset const& asset,
909 AccountID const& from,
910 AccountID const& to)
911{
912 return std::visit(
913 [&]<ValidIssueType TIss>(TIss const& issue) -> TER { return canTransfer(view, issue, from, to); },
914 asset.value());
915}
916
929[[nodiscard]] TER
931 ApplyView& view,
932 Keylet const& ownerDirKeylet,
933 EntryDeleter const& deleter,
935 std::optional<std::uint16_t> maxNodesToDelete = std::nullopt);
936
941[[nodiscard]] TER
943 ApplyView& view,
944 std::shared_ptr<SLE> sleState,
945 std::optional<AccountID> const& ammAccountID,
947
948// From the perspective of a vault, return the number of shares to give the
949// depositor when they deposit a fixed amount of assets. Since shares are MPT
950// this number is integral and always truncated in this calculation.
951[[nodiscard]] std::optional<STAmount>
953 std::shared_ptr<SLE const> const& vault,
954 std::shared_ptr<SLE const> const& issuance,
955 STAmount const& assets);
956
957// From the perspective of a vault, return the number of assets to take from
958// depositor when they receive a fixed amount of shares. Note, since shares are
959// MPT, they are always an integral number.
960[[nodiscard]] std::optional<STAmount>
962 std::shared_ptr<SLE const> const& vault,
963 std::shared_ptr<SLE const> const& issuance,
964 STAmount const& shares);
965
966enum class TruncateShares : bool { no = false, yes = true };
967
968// From the perspective of a vault, return the number of shares to demand from
969// the depositor when they ask to withdraw a fixed amount of assets. Since
970// shares are MPT this number is integral, and it will be rounded to nearest
971// unless explicitly requested to be truncated instead.
972[[nodiscard]] std::optional<STAmount>
974 std::shared_ptr<SLE const> const& vault,
975 std::shared_ptr<SLE const> const& issuance,
976 STAmount const& assets,
978
979// From the perspective of a vault, return the number of assets to give the
980// depositor when they redeem a fixed amount of shares. Note, since shares are
981// MPT, they are always an integral number.
982[[nodiscard]] std::optional<STAmount>
984 std::shared_ptr<SLE const> const& vault,
985 std::shared_ptr<SLE const> const& issuance,
986 STAmount const& shares);
987
994bool
996
997} // namespace xrpl
Provide a light-weight way to check active() before string formatting.
Definition Journal.h:180
A generic endpoint for log messages.
Definition Journal.h:40
Writeable view to a ledger, for applying a transaction.
Definition ApplyView.h:114
constexpr value_type const & value() const
Definition Asset.h:154
A currency issued by an account.
Definition Issue.h:13
Currency currency
Definition Issue.h:15
AccountID account
Definition Issue.h:16
std::chrono::time_point< NetClock > time_point
Definition chrono.h:45
A view into a ledger.
Definition ReadView.h:31
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
std::shared_ptr< STLedgerEntry > const & ref
std::shared_ptr< STLedgerEntry const > const & const_ref
T is_same_v
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Definition Indexes.cpp:325
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition Indexes.cpp:160
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
TypedField< STInteger< std::uint64_t > > SF_UINT64
Definition SField.h:333
TER trustCreate(ApplyView &view, bool const bSrcHigh, AccountID const &uSrcAccountID, AccountID const &uDstAccountID, uint256 const &uIndex, SLE::ref sleAccount, bool const bAuth, bool const bNoRipple, bool const bFreeze, bool bDeepFreeze, STAmount const &saBalance, STAmount const &saLimit, std::uint32_t uSrcQualityIn, std::uint32_t uSrcQualityOut, beast::Journal j)
Create a trust line.
Definition View.cpp:1440
std::optional< STAmount > sharesToAssetsDeposit(std::shared_ptr< SLE const > const &vault, std::shared_ptr< SLE const > const &issuance, STAmount const &shares)
Definition View.cpp:3128
TER checkDeepFrozen(ReadView const &view, AccountID const &account, Issue const &issue)
Definition View.h:198
base_uint< 160, detail::CurrencyTag > Currency
Currency is a hash representing a specific currency.
Definition UintTypes.h:36
std::vector< SField const * > const & getPseudoAccountFields()
Definition View.cpp:994
XRPAmount xrpLiquid(ReadView const &view, AccountID const &id, std::int32_t ownerCountAdj, beast::Journal j)
Definition View.cpp:571
TER addEmptyHolding(ApplyView &view, AccountID const &accountID, XRPAmount priorBalance, Issue const &issue, beast::Journal journal)
Any transactors that call addEmptyHolding() in doApply must call canAddHolding() in preflight with th...
Definition View.cpp:1250
FreezeHandling
Controls the treatment of frozen account balances.
Definition View.h:58
@ fhZERO_IF_FROZEN
Definition View.h:58
@ fhIGNORE_FREEZE
Definition View.h:58
bool dirFirst(ApplyView &view, uint256 const &root, std::shared_ptr< SLE > &page, unsigned int &index, uint256 &entry)
Definition View.cpp:89
AccountID pseudoAccountAddress(ReadView const &view, uint256 const &pseudoOwnerKey)
Definition View.cpp:971
bool dirIsEmpty(ReadView const &view, Keylet const &k)
Returns true if the directory is empty.
Definition View.cpp:825
SpendableHandling
Controls whether to include the account's full spendable balance.
Definition View.h:64
@ shSIMPLE_BALANCE
Definition View.h:64
@ shFULL_BALANCE
Definition View.h:64
TER canAddHolding(ReadView const &view, Asset const &asset)
Definition View.cpp:1101
std::set< uint256 > getEnabledAmendments(ReadView const &view)
Definition View.cpp:839
TER issueIOU(ApplyView &view, AccountID const &account, STAmount const &amount, Issue const &issue, beast::Journal j)
Definition View.cpp:2535
TER removeEmptyHolding(ApplyView &view, AccountID const &accountID, Issue const &issue, beast::Journal journal)
Definition View.cpp:1554
bool isVaultPseudoAccountFrozen(ReadView const &view, AccountID const &account, MPTIssue const &mptShare, int depth)
Definition View.cpp:240
TER rippleUnlockEscrowMPT(ApplyView &view, AccountID const &uGrantorID, AccountID const &uGranteeID, STAmount const &netAmount, STAmount const &grossAmount, beast::Journal j)
Definition View.cpp:3280
TER doWithdraw(ApplyView &view, STTx const &tx, AccountID const &senderAcct, AccountID const &dstAcct, AccountID const &sourceAcct, XRPAmount priorBalance, STAmount const &amount, beast::Journal j)
Definition View.cpp:1209
bool hasExpired(ReadView const &view, std::optional< std::uint32_t > const &exp)
Determines whether the given expiration time has passed.
Definition View.cpp:129
TER checkFrozen(ReadView const &view, AccountID const &account, Issue const &issue)
Definition View.h:121
SkipEntry
Definition View.h:25
void forEachItem(ReadView const &view, Keylet const &root, std::function< void(std::shared_ptr< SLE const > const &)> const &f)
Iterate all items in the given directory.
Definition View.cpp:598
bool isAnyFrozen(ReadView const &view, std::initializer_list< AccountID > const &accounts, MPTIssue const &mptIssue, int depth=0)
Definition View.cpp:219
STAmount accountHolds(ReadView const &view, AccountID const &account, Currency const &currency, AccountID const &issuer, FreezeHandling zeroIfFrozen, beast::Journal j, SpendableHandling includeFullBalance=shSIMPLE_BALANCE)
Definition View.cpp:392
WaiveTransferFee
Definition View.h:24
Number root(Number f, unsigned d)
Definition Number.cpp:938
bool cdirNext(ReadView const &view, uint256 const &root, std::shared_ptr< SLE const > &page, unsigned int &index, uint256 &entry)
Returns the next entry in the directory, advancing the index.
Definition View.cpp:112
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:28
TER authorizeMPToken(ApplyView &view, XRPAmount const &priorBalance, MPTID const &mptIssuanceID, AccountID const &account, beast::Journal journal, std::uint32_t flags=0, std::optional< AccountID > holderID=std::nullopt)
Definition View.cpp:1326
TER deleteAMMTrustLine(ApplyView &view, std::shared_ptr< SLE > sleState, std::optional< AccountID > const &ammAccountID, beast::Journal j)
Delete trustline to AMM.
Definition View.cpp:3036
bool isDeepFrozen(ReadView const &view, AccountID const &account, Currency const &currency, AccountID const &issuer)
Definition View.cpp:277
bool cdirFirst(ReadView const &view, uint256 const &root, std::shared_ptr< SLE const > &page, unsigned int &index, uint256 &entry)
Returns the first entry in the directory, advancing the index.
Definition View.cpp:101
bool areCompatible(ReadView const &validLedger, ReadView const &testLedger, beast::Journal::Stream &s, char const *reason)
Return false if the test ledger is provably incompatible with the valid ledger, that is,...
Definition View.cpp:735
base_uint< 256 > uint256
Definition base_uint.h:526
LedgerIndex getCandidateLedger(LedgerIndex requested)
Find a ledger index from which we could easily get the requested ledger.
Definition View.h:399
bool isPseudoAccount(std::shared_ptr< SLE const > sleAcct, std::set< SField const * > const &pseudoFieldFilter={})
Definition View.cpp:1020
TruncateShares
Definition View.h:966
TER accountSend(ApplyView &view, AccountID const &from, AccountID const &to, STAmount const &saAmount, beast::Journal j, WaiveTransferFee waiveFee=WaiveTransferFee::No)
Calls static accountSendIOU if saAmount represents Issue.
Definition View.cpp:2446
std::optional< STAmount > assetsToSharesDeposit(std::shared_ptr< SLE const > const &vault, std::shared_ptr< SLE const > const &issuance, STAmount const &assets)
Definition View.cpp:3107
STAmount accountFunds(ReadView const &view, AccountID const &id, STAmount const &saDefault, FreezeHandling freezeHandling, beast::Journal j)
Definition View.cpp:515
bool isGlobalFrozen(ReadView const &view, AccountID const &issuer)
Definition View.cpp:138
std::optional< uint256 > hashOfSeq(ReadView const &ledger, LedgerIndex seq, beast::Journal journal)
Return the hash of a ledger by sequence.
Definition View.cpp:878
std::optional< STAmount > assetsToSharesWithdraw(std::shared_ptr< SLE const > const &vault, std::shared_ptr< SLE const > const &issuance, STAmount const &assets, TruncateShares truncate=TruncateShares::no)
Definition View.cpp:3149
TERSubset< CanCvtToTER > TER
Definition TER.h:620
void adjustOwnerCount(ApplyView &view, std::shared_ptr< SLE > const &sle, std::int32_t amount, beast::Journal j)
Adjust the owner count up or down.
Definition View.cpp:941
std::uint32_t LedgerIndex
A ledger index.
Definition Protocol.h:254
base_uint< 192 > MPTID
MPTID is a 192-bit value representing MPT Issuance ID, which is a concatenation of a 32-bit sequence ...
Definition UintTypes.h:44
AuthHandling
Controls the treatment of unauthorized MPT balances.
Definition View.h:61
@ ahIGNORE_AUTH
Definition View.h:61
@ ahZERO_IF_UNAUTHORIZED
Definition View.h:61
Rate transferRate(ReadView const &view, AccountID const &issuer)
Returns IOU issuer transfer fee as Rate.
Definition View.cpp:699
majorityAmendments_t getMajorityAmendments(ReadView const &view)
Definition View.cpp:856
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Definition View.cpp:3436
AuthType
Definition View.h:801
TER requireAuth(ReadView const &view, Issue const &issue, AccountID const &account, AuthType authType=AuthType::Legacy)
Check if the account lacks required authorization.
Definition View.cpp:2710
TER canTransfer(ReadView const &view, MPTIssue const &mptIssue, AccountID const &from, AccountID const &to)
Check if the destination account is allowed to receive MPT.
Definition View.cpp:2914
bool isFrozen(ReadView const &view, AccountID const &account, Currency const &currency, AccountID const &issuer)
Definition View.cpp:194
TER transferXRP(ApplyView &view, AccountID const &from, AccountID const &to, STAmount const &amount, beast::Journal j)
Definition View.cpp:2675
std::function< void(SLE::ref)> describeOwnerDir(AccountID const &account)
Definition View.cpp:955
TER dirLink(ApplyView &view, AccountID const &owner, std::shared_ptr< SLE > &object, SF_UINT64 const &node=sfOwnerNode)
Definition View.cpp:961
bool isIndividualFrozen(ReadView const &view, AccountID const &account, Currency const &currency, AccountID const &issuer)
Definition View.cpp:169
TER offerDelete(ApplyView &view, std::shared_ptr< SLE > const &sle, beast::Journal j)
Delete an offer.
Definition View.cpp:1672
TER redeemIOU(ApplyView &view, AccountID const &account, STAmount const &amount, Issue const &issue, beast::Journal j)
Definition View.cpp:2616
std::optional< STAmount > sharesToAssetsWithdraw(std::shared_ptr< SLE const > const &vault, std::shared_ptr< SLE const > const &issuance, STAmount const &shares)
Definition View.cpp:3174
TER rippleLockEscrowMPT(ApplyView &view, AccountID const &uGrantorID, STAmount const &saAmount, beast::Journal j)
Definition View.cpp:3195
LedgerEntryType
Identifiers for on-ledger objects.
@ tecLOCKED
Definition TER.h:339
@ tecFROZEN
Definition TER.h:284
bool forEachItemAfter(ReadView const &view, Keylet const &root, uint256 const &after, std::uint64_t const hint, unsigned int limit, std::function< bool(std::shared_ptr< SLE const > const &)> const &f)
Iterate all items after an item in the given directory.
Definition View.cpp:622
TER enforceMPTokenAuthorization(ApplyView &view, MPTID const &mptIssuanceID, AccountID const &account, XRPAmount const &priorBalance, beast::Journal j)
Enforce account has MPToken to match its authorization.
Definition View.cpp:2819
TER canWithdraw(ReadView const &view, AccountID const &from, AccountID const &to, SLE::const_ref toSle, STAmount const &amount, bool hasDestinationTag)
Checks that can withdraw funds from an object to itself or a destination.
Definition View.cpp:1163
Expected< std::shared_ptr< SLE >, TER > createPseudoAccount(ApplyView &view, uint256 const &pseudoOwnerKey, SField const &ownerField)
Create pseudo-account, storing pseudoOwnerKey into ownerField.
Definition View.cpp:1033
TER checkDestinationAndTag(SLE::const_ref toSle, bool hasDestinationTag)
Validates that the destination SLE and tag are valid.
Definition View.cpp:1108
TER accountSendMulti(ApplyView &view, AccountID const &senderID, Asset const &asset, MultiplePaymentDestinations const &receivers, beast::Journal j, WaiveTransferFee waiveFee=WaiveTransferFee::No)
Like accountSend, except one account is sending multiple payments (with the same asset!...
Definition View.cpp:2465
@ no
Definition Steps.h:25
@ yes
Definition Steps.h:25
TER trustDelete(ApplyView &view, std::shared_ptr< SLE > const &sleRippleState, AccountID const &uLowAccountID, AccountID const &uHighAccountID, beast::Journal j)
Definition View.cpp:1640
bool isLPTokenFrozen(ReadView const &view, AccountID const &account, Issue const &asset, Issue const &asset2)
Definition View.cpp:299
@ tesSUCCESS
Definition TER.h:225
bool dirNext(ApplyView &view, uint256 const &root, std::shared_ptr< SLE > &page, unsigned int &index, uint256 &entry)
Definition View.cpp:95
TER cleanupOnAccountDelete(ApplyView &view, Keylet const &ownerDirKeylet, EntryDeleter const &deleter, beast::Journal j, std::optional< std::uint16_t > maxNodesToDelete=std::nullopt)
Cleanup owner directory entries on account delete.
TER rippleCredit(ApplyView &view, AccountID const &uSenderID, AccountID const &uReceiverID, STAmount const &saAmount, bool bCheckIssuer, beast::Journal j)
Calls static rippleCreditIOU if saAmount represents Issue.
Definition View.cpp:3083
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:19
T visit(T... args)