rippled
Loading...
Searching...
No Matches
View.h
1#ifndef XRPL_LEDGER_VIEW_H_INCLUDED
2#define XRPL_LEDGER_VIEW_H_INCLUDED
3
4#include <xrpl/beast/utility/Journal.h>
5#include <xrpl/ledger/ApplyView.h>
6#include <xrpl/ledger/OpenView.h>
7#include <xrpl/ledger/ReadView.h>
8#include <xrpl/protocol/Asset.h>
9#include <xrpl/protocol/Indexes.h>
10#include <xrpl/protocol/MPTIssue.h>
11#include <xrpl/protocol/Protocol.h>
12#include <xrpl/protocol/Rate.h>
13#include <xrpl/protocol/STLedgerEntry.h>
14#include <xrpl/protocol/STObject.h>
15#include <xrpl/protocol/Serializer.h>
16#include <xrpl/protocol/TER.h>
17
18#include <functional>
19#include <initializer_list>
20#include <map>
21#include <utility>
22
23namespace xrpl {
24
25enum class WaiveTransferFee : bool { No = false, Yes };
26enum class SkipEntry : bool { No = false, Yes };
27
28//------------------------------------------------------------------------------
29//
30// Observers
31//
32//------------------------------------------------------------------------------
33
55[[nodiscard]] bool
56hasExpired(ReadView const& view, std::optional<std::uint32_t> const& exp);
57
60
63
66
67[[nodiscard]] bool
68isGlobalFrozen(ReadView const& view, AccountID const& issuer);
69
70[[nodiscard]] bool
71isGlobalFrozen(ReadView const& view, MPTIssue const& mptIssue);
72
73[[nodiscard]] bool
74isGlobalFrozen(ReadView const& view, Asset const& asset);
75
76// Note, depth parameter is used to limit the recursion depth
77[[nodiscard]] bool
79 ReadView const& view,
80 AccountID const& account,
81 MPTIssue const& mptShare,
82 int depth);
83
84[[nodiscard]] bool
86 ReadView const& view,
87 AccountID const& account,
88 Currency const& currency,
89 AccountID const& issuer);
90
91[[nodiscard]] inline bool
93 ReadView const& view,
94 AccountID const& account,
95 Issue const& issue)
96{
97 return isIndividualFrozen(view, account, issue.currency, issue.account);
98}
99
100[[nodiscard]] bool
102 ReadView const& view,
103 AccountID const& account,
104 MPTIssue const& mptIssue);
105
106[[nodiscard]] inline bool
108 ReadView const& view,
109 AccountID const& account,
110 Asset const& asset)
111{
112 return std::visit(
113 [&](auto const& issue) {
114 return isIndividualFrozen(view, account, issue);
115 },
116 asset.value());
117}
118
119[[nodiscard]] bool
121 ReadView const& view,
122 AccountID const& account,
123 Currency const& currency,
124 AccountID const& issuer);
125
126[[nodiscard]] inline bool
128 ReadView const& view,
129 AccountID const& account,
130 Issue const& issue,
131 int = 0 /*ignored*/)
132{
133 return isFrozen(view, account, issue.currency, issue.account);
134}
135
136[[nodiscard]] bool
138 ReadView const& view,
139 AccountID const& account,
140 MPTIssue const& mptIssue,
141 int depth = 0);
142
148[[nodiscard]] inline bool
150 ReadView const& view,
151 AccountID const& account,
152 Asset const& asset,
153 int depth = 0)
154{
155 return std::visit(
156 [&](auto const& issue) {
157 return isFrozen(view, account, issue, depth);
158 },
159 asset.value());
160}
161
162[[nodiscard]] inline TER
163checkFrozen(ReadView const& view, AccountID const& account, Issue const& issue)
164{
165 return isFrozen(view, account, issue) ? (TER)tecFROZEN : (TER)tesSUCCESS;
166}
167
168[[nodiscard]] inline TER
170 ReadView const& view,
171 AccountID const& account,
172 MPTIssue const& mptIssue)
173{
174 return isFrozen(view, account, mptIssue) ? (TER)tecLOCKED : (TER)tesSUCCESS;
175}
176
177[[nodiscard]] inline TER
178checkFrozen(ReadView const& view, AccountID const& account, Asset const& asset)
179{
180 return std::visit(
181 [&](auto const& issue) { return checkFrozen(view, account, issue); },
182 asset.value());
183}
184
185[[nodiscard]] bool
187 ReadView const& view,
188 std::initializer_list<AccountID> const& accounts,
189 MPTIssue const& mptIssue,
190 int depth = 0);
191
192[[nodiscard]] inline bool
194 ReadView const& view,
195 std::initializer_list<AccountID> const& accounts,
196 Issue const& issue)
197{
198 for (auto const& account : accounts)
199 {
200 if (isFrozen(view, account, issue.currency, issue.account))
201 return true;
202 }
203 return false;
204}
205
206[[nodiscard]] inline bool
208 ReadView const& view,
209 std::initializer_list<AccountID> const& accounts,
210 Asset const& asset,
211 int depth = 0)
212{
213 return std::visit(
214 [&]<ValidIssueType TIss>(TIss const& issue) {
215 if constexpr (std::is_same_v<TIss, Issue>)
216 return isAnyFrozen(view, accounts, issue);
217 else
218 return isAnyFrozen(view, accounts, issue, depth);
219 },
220 asset.value());
221}
222
223[[nodiscard]] bool
225 ReadView const& view,
226 AccountID const& account,
227 Currency const& currency,
228 AccountID const& issuer);
229
230[[nodiscard]] inline bool
232 ReadView const& view,
233 AccountID const& account,
234 Issue const& issue,
235 int = 0 /*ignored*/)
236{
237 return isDeepFrozen(view, account, issue.currency, issue.account);
238}
239
240[[nodiscard]] inline bool
242 ReadView const& view,
243 AccountID const& account,
244 MPTIssue const& mptIssue,
245 int depth = 0)
246{
247 // Unlike IOUs, frozen / locked MPTs are not allowed to send or receive
248 // funds, so checking "deep frozen" is the same as checking "frozen".
249 return isFrozen(view, account, mptIssue, depth);
250}
251
257[[nodiscard]] inline bool
259 ReadView const& view,
260 AccountID const& account,
261 Asset const& asset,
262 int depth = 0)
263{
264 return std::visit(
265 [&](auto const& issue) {
266 return isDeepFrozen(view, account, issue, depth);
267 },
268 asset.value());
269}
270
271[[nodiscard]] inline TER
273 ReadView const& view,
274 AccountID const& account,
275 Issue const& issue)
276{
277 return isDeepFrozen(view, account, issue) ? (TER)tecFROZEN
278 : (TER)tesSUCCESS;
279}
280
281[[nodiscard]] inline TER
283 ReadView const& view,
284 AccountID const& account,
285 MPTIssue const& mptIssue)
286{
287 return isDeepFrozen(view, account, mptIssue) ? (TER)tecLOCKED
288 : (TER)tesSUCCESS;
289}
290
291[[nodiscard]] inline TER
293 ReadView const& view,
294 AccountID const& account,
295 Asset const& asset)
296{
297 return std::visit(
298 [&](auto const& issue) {
299 return checkDeepFrozen(view, account, issue);
300 },
301 asset.value());
302}
303
304[[nodiscard]] bool
306 ReadView const& view,
307 AccountID const& account,
308 Issue const& asset,
309 Issue const& asset2);
310
311// Returns the amount an account can spend.
312//
313// If shSIMPLE_BALANCE is specified, this is the amount the account can spend
314// without going into debt.
315//
316// If shFULL_BALANCE is specified, this is the amount the account can spend
317// total. Specifically:
318// * The account can go into debt if using a trust line, and the other side has
319// a non-zero limit.
320// * If the account is the asset issuer the limit is defined by the asset /
321// issuance.
322//
323// <-- saAmount: amount of currency held by account. May be negative.
324[[nodiscard]] STAmount
326 ReadView const& view,
327 AccountID const& account,
328 Currency const& currency,
329 AccountID const& issuer,
330 FreezeHandling zeroIfFrozen,
332 SpendableHandling includeFullBalance = shSIMPLE_BALANCE);
333
334[[nodiscard]] STAmount
336 ReadView const& view,
337 AccountID const& account,
338 Issue const& issue,
339 FreezeHandling zeroIfFrozen,
341 SpendableHandling includeFullBalance = shSIMPLE_BALANCE);
342
343[[nodiscard]] STAmount
345 ReadView const& view,
346 AccountID const& account,
347 MPTIssue const& mptIssue,
348 FreezeHandling zeroIfFrozen,
349 AuthHandling zeroIfUnauthorized,
351 SpendableHandling includeFullBalance = shSIMPLE_BALANCE);
352
353[[nodiscard]] STAmount
355 ReadView const& view,
356 AccountID const& account,
357 Asset const& asset,
358 FreezeHandling zeroIfFrozen,
359 AuthHandling zeroIfUnauthorized,
361 SpendableHandling includeFullBalance = shSIMPLE_BALANCE);
362
363// Returns the amount an account can spend of the currency type saDefault, or
364// returns saDefault if this account is the issuer of the currency in
365// question. Should be used in favor of accountHolds when questioning how much
366// an account can spend while also allowing currency issuers to spend
367// unlimited amounts of their own currency (since they can always issue more).
368[[nodiscard]] STAmount
370 ReadView const& view,
371 AccountID const& id,
372 STAmount const& saDefault,
373 FreezeHandling freezeHandling,
375
376// Return the account's liquid (not reserved) XRP. Generally prefer
377// calling accountHolds() over this interface. However, this interface
378// allows the caller to temporarily adjust the owner count should that be
379// necessary.
380//
381// @param ownerCountAdj positive to add to count, negative to reduce count.
382[[nodiscard]] XRPAmount
384 ReadView const& view,
385 AccountID const& id,
386 std::int32_t ownerCountAdj,
388
390void
392 ReadView const& view,
393 Keylet const& root,
394 std::function<void(std::shared_ptr<SLE const> const&)> const& f);
395
402bool
404 ReadView const& view,
405 Keylet const& root,
406 uint256 const& after,
407 std::uint64_t const hint,
408 unsigned int limit,
409 std::function<bool(std::shared_ptr<SLE const> const&)> const& f);
410
412inline void
414 ReadView const& view,
415 AccountID const& id,
416 std::function<void(std::shared_ptr<SLE const> const&)> const& f)
417{
418 return forEachItem(view, keylet::ownerDir(id), f);
419}
420
427inline bool
429 ReadView const& view,
430 AccountID const& id,
431 uint256 const& after,
432 std::uint64_t const hint,
433 unsigned int limit,
434 std::function<bool(std::shared_ptr<SLE const> const&)> const& f)
435{
436 return forEachItemAfter(view, keylet::ownerDir(id), after, hint, limit, f);
437}
438
444[[nodiscard]] Rate
445transferRate(ReadView const& view, AccountID const& issuer);
446
452[[nodiscard]] Rate
453transferRate(ReadView const& view, MPTID const& issuanceID);
454
459[[nodiscard]] Rate
460transferRate(ReadView const& view, STAmount const& amount);
461
465[[nodiscard]] bool
466dirIsEmpty(ReadView const& view, Keylet const& k);
467
468// Return the list of enabled amendments
469[[nodiscard]] std::set<uint256>
470getEnabledAmendments(ReadView const& view);
471
472// Return a map of amendments that have achieved majority
474[[nodiscard]] majorityAmendments_t
476
486[[nodiscard]] std::optional<uint256>
487hashOfSeq(ReadView const& ledger, LedgerIndex seq, beast::Journal journal);
488
501inline LedgerIndex
503{
504 return (requested + 255) & (~255);
505}
506
512[[nodiscard]] bool
514 ReadView const& validLedger,
515 ReadView const& testLedger,
517 char const* reason);
518
519[[nodiscard]] bool
521 uint256 const& validHash,
522 LedgerIndex validIndex,
523 ReadView const& testLedger,
525 char const* reason);
526
527//------------------------------------------------------------------------------
528//
529// Modifiers
530//
531//------------------------------------------------------------------------------
532
534void
536 ApplyView& view,
537 std::shared_ptr<SLE> const& sle,
538 std::int32_t amount,
540
556bool
558 ReadView const& view,
559 uint256 const& root,
561 unsigned int& index,
562 uint256& entry);
563
564bool
566 ApplyView& view,
567 uint256 const& root,
569 unsigned int& index,
570 uint256& entry);
588bool
590 ReadView const& view,
591 uint256 const& root,
593 unsigned int& index,
594 uint256& entry);
595
596bool
597dirNext(
598 ApplyView& view,
599 uint256 const& root,
601 unsigned int& index,
602 uint256& entry);
605[[nodiscard]] std::function<void(SLE::ref)>
606describeOwnerDir(AccountID const& account);
607
608[[nodiscard]] TER
609dirLink(
610 ApplyView& view,
611 AccountID const& owner,
612 std::shared_ptr<SLE>& object,
613 SF_UINT64 const& node = sfOwnerNode);
614
616pseudoAccountAddress(ReadView const& view, uint256 const& pseudoOwnerKey);
617
626[[nodiscard]] Expected<std::shared_ptr<SLE>, TER>
628 ApplyView& view,
629 uint256 const& pseudoOwnerKey,
630 SField const& ownerField);
631
632// Returns true if and only if sleAcct is a pseudo-account or specific
633// pseudo-accounts in pseudoFieldFilter.
634//
635// Returns false if sleAcct is
636// * NOT a pseudo-account OR
637// * NOT a ltACCOUNT_ROOT OR
638// * null pointer
639[[nodiscard]] bool
642 std::set<SField const*> const& pseudoFieldFilter = {});
643
644// Returns the list of fields that define an ACCOUNT_ROOT as a pseudo-account if
645// set
646// Pseudo-account designator fields MUST be maintained by including the
647// SField::sMD_PseudoAccount flag in the SField definition. (Don't forget to
648// "| SField::sMD_Default"!) The fields do NOT need to be amendment-gated,
649// since a non-active amendment will not set any field, by definition.
650// Specific properties of a pseudo-account are NOT checked here, that's what
651// InvariantCheck is for.
652[[nodiscard]] std::vector<SField const*> const&
654
655[[nodiscard]] inline bool
657 ReadView const& view,
658 AccountID const& accountId,
659 std::set<SField const*> const& pseudoFieldFilter = {})
660{
661 return isPseudoAccount(
662 view.read(keylet::account(accountId)), pseudoFieldFilter);
663}
664
665[[nodiscard]] TER
666canAddHolding(ReadView const& view, Asset const& asset);
667
673[[nodiscard]] TER
674checkDestinationAndTag(SLE::const_ref toSle, bool hasDestinationTag);
675
690[[nodiscard]] TER
692 ReadView const& view,
693 AccountID const& from,
694 AccountID const& to,
695 SLE::const_ref toSle,
696 STAmount const& amount,
697 bool hasDestinationTag);
698
713[[nodiscard]] TER
715 ReadView const& view,
716 AccountID const& from,
717 AccountID const& to,
718 STAmount const& amount,
719 bool hasDestinationTag);
720
735[[nodiscard]] TER
736canWithdraw(ReadView const& view, STTx const& tx);
737
738[[nodiscard]] TER
740 ApplyView& view,
741 STTx const& tx,
742 AccountID const& senderAcct,
743 AccountID const& dstAcct,
744 AccountID const& sourceAcct,
745 XRPAmount priorBalance,
746 STAmount const& amount,
748
751[[nodiscard]] TER
753 ApplyView& view,
754 AccountID const& accountID,
755 XRPAmount priorBalance,
756 Issue const& issue,
757 beast::Journal journal);
758
759[[nodiscard]] TER
761 ApplyView& view,
762 AccountID const& accountID,
763 XRPAmount priorBalance,
764 MPTIssue const& mptIssue,
765 beast::Journal journal);
766
767[[nodiscard]] inline TER
769 ApplyView& view,
770 AccountID const& accountID,
771 XRPAmount priorBalance,
772 Asset const& asset,
773 beast::Journal journal)
774{
775 return std::visit(
776 [&]<ValidIssueType TIss>(TIss const& issue) -> TER {
777 return addEmptyHolding(
778 view, accountID, priorBalance, issue, journal);
779 },
780 asset.value());
781}
782
783[[nodiscard]] TER
785 ApplyView& view,
786 XRPAmount const& priorBalance,
787 MPTID const& mptIssuanceID,
788 AccountID const& account,
789 beast::Journal journal,
790 std::uint32_t flags = 0,
792
793// VFALCO NOTE Both STAmount parameters should just
794// be "Amount", a unit-less number.
795//
800[[nodiscard]] TER
802 ApplyView& view,
803 bool const bSrcHigh,
804 AccountID const& uSrcAccountID,
805 AccountID const& uDstAccountID,
806 uint256 const& uIndex, // --> ripple state entry
807 SLE::ref sleAccount, // --> the account being set.
808 bool const bAuth, // --> authorize account.
809 bool const bNoRipple, // --> others cannot ripple through
810 bool const bFreeze, // --> funds cannot leave
811 bool bDeepFreeze, // --> can neither receive nor send funds
812 STAmount const& saBalance, // --> balance of account being set.
813 // Issuer should be noAccount()
814 STAmount const& saLimit, // --> limit for account being set.
815 // Issuer should be the account being set.
816 std::uint32_t uSrcQualityIn,
817 std::uint32_t uSrcQualityOut,
819
820[[nodiscard]] TER
822 ApplyView& view,
823 AccountID const& accountID,
824 Issue const& issue,
825 beast::Journal journal);
826
827[[nodiscard]] TER
829 ApplyView& view,
830 AccountID const& accountID,
831 MPTIssue const& mptIssue,
832 beast::Journal journal);
833
834[[nodiscard]] inline TER
836 ApplyView& view,
837 AccountID const& accountID,
838 Asset const& asset,
839 beast::Journal journal)
840{
841 return std::visit(
842 [&]<ValidIssueType TIss>(TIss const& issue) -> TER {
843 return removeEmptyHolding(view, accountID, issue, journal);
844 },
845 asset.value());
846}
847
848[[nodiscard]] TER
850 ApplyView& view,
851 std::shared_ptr<SLE> const& sleRippleState,
852 AccountID const& uLowAccountID,
853 AccountID const& uHighAccountID,
855
862// [[nodiscard]] // nodiscard commented out so Flow, BookTip and others compile.
863TER
864offerDelete(ApplyView& view, std::shared_ptr<SLE> const& sle, beast::Journal j);
865
866//------------------------------------------------------------------------------
867
868//
869// Money Transfers
870//
871
872// Direct send w/o fees:
873// - Redeeming IOUs and/or sending sender's own IOUs.
874// - Create trust line of needed.
875// --> bCheckIssuer : normally require issuer to be involved.
876// [[nodiscard]] // nodiscard commented out so DirectStep.cpp compiles.
877
881TER
883 ApplyView& view,
884 AccountID const& uSenderID,
885 AccountID const& uReceiverID,
886 STAmount const& saAmount,
887 bool bCheckIssuer,
889
890TER
892 ApplyView& view,
893 AccountID const& uGrantorID,
894 STAmount const& saAmount,
896
897TER
899 ApplyView& view,
900 AccountID const& uGrantorID,
901 AccountID const& uGranteeID,
902 STAmount const& netAmount,
903 STAmount const& grossAmount,
905
909[[nodiscard]] TER
911 ApplyView& view,
912 AccountID const& from,
913 AccountID const& to,
914 STAmount const& saAmount,
917
925[[nodiscard]] TER
927 ApplyView& view,
928 AccountID const& senderID,
929 Asset const& asset,
930 MultiplePaymentDestinations const& receivers,
933
934[[nodiscard]] TER
936 ApplyView& view,
937 AccountID const& account,
938 STAmount const& amount,
939 Issue const& issue,
941
942[[nodiscard]] TER
944 ApplyView& view,
945 AccountID const& account,
946 STAmount const& amount,
947 Issue const& issue,
949
950[[nodiscard]] TER
952 ApplyView& view,
953 AccountID const& from,
954 AccountID const& to,
955 STAmount const& amount,
957
958/* Check if MPToken (for MPT) or trust line (for IOU) exists:
959 * - StrongAuth - before checking if authorization is required
960 * - WeakAuth
961 * for MPT - after checking lsfMPTRequireAuth flag
962 * for IOU - do not check if trust line exists
963 * - Legacy
964 * for MPT - before checking lsfMPTRequireAuth flag i.e. same as StrongAuth
965 * for IOU - do not check if trust line exists i.e. same as WeakAuth
966 */
968
986[[nodiscard]] TER
988 ReadView const& view,
989 Issue const& issue,
990 AccountID const& account,
991 AuthType authType = AuthType::Legacy);
992
1016[[nodiscard]] TER
1018 ReadView const& view,
1019 MPTIssue const& mptIssue,
1020 AccountID const& account,
1021 AuthType authType = AuthType::Legacy,
1022 int depth = 0);
1023
1024[[nodiscard]] TER inline requireAuth(
1025 ReadView const& view,
1026 Asset const& asset,
1027 AccountID const& account,
1028 AuthType authType = AuthType::Legacy)
1029{
1030 return std::visit(
1031 [&]<ValidIssueType TIss>(TIss const& issue_) {
1032 return requireAuth(view, issue_, account, authType);
1033 },
1034 asset.value());
1035}
1036
1060[[nodiscard]] TER
1062 ApplyView& view,
1063 MPTID const& mptIssuanceID,
1064 AccountID const& account,
1065 XRPAmount const& priorBalance,
1066 beast::Journal j);
1067
1072[[nodiscard]] TER
1074 ReadView const& view,
1075 MPTIssue const& mptIssue,
1076 AccountID const& from,
1077 AccountID const& to);
1078
1079[[nodiscard]] TER
1081 ReadView const& view,
1082 Issue const& issue,
1083 AccountID const& from,
1084 AccountID const& to);
1085
1086[[nodiscard]] TER inline canTransfer(
1087 ReadView const& view,
1088 Asset const& asset,
1089 AccountID const& from,
1090 AccountID const& to)
1091{
1092 return std::visit(
1093 [&]<ValidIssueType TIss>(TIss const& issue) -> TER {
1094 return canTransfer(view, issue, from, to);
1095 },
1096 asset.value());
1097}
1098
1105 uint256 const&,
1114[[nodiscard]] TER
1116 ApplyView& view,
1117 Keylet const& ownerDirKeylet,
1118 EntryDeleter const& deleter,
1120 std::optional<std::uint16_t> maxNodesToDelete = std::nullopt);
1121
1126[[nodiscard]] TER
1128 ApplyView& view,
1129 std::shared_ptr<SLE> sleState,
1130 std::optional<AccountID> const& ammAccountID,
1131 beast::Journal j);
1132
1133// From the perspective of a vault, return the number of shares to give the
1134// depositor when they deposit a fixed amount of assets. Since shares are MPT
1135// this number is integral and always truncated in this calculation.
1136[[nodiscard]] std::optional<STAmount>
1138 std::shared_ptr<SLE const> const& vault,
1139 std::shared_ptr<SLE const> const& issuance,
1140 STAmount const& assets);
1141
1142// From the perspective of a vault, return the number of assets to take from
1143// depositor when they receive a fixed amount of shares. Note, since shares are
1144// MPT, they are always an integral number.
1145[[nodiscard]] std::optional<STAmount>
1147 std::shared_ptr<SLE const> const& vault,
1148 std::shared_ptr<SLE const> const& issuance,
1149 STAmount const& shares);
1150
1151enum class TruncateShares : bool { no = false, yes = true };
1152
1153// From the perspective of a vault, return the number of shares to demand from
1154// the depositor when they ask to withdraw a fixed amount of assets. Since
1155// shares are MPT this number is integral, and it will be rounded to nearest
1156// unless explicitly requested to be truncated instead.
1157[[nodiscard]] std::optional<STAmount>
1159 std::shared_ptr<SLE const> const& vault,
1160 std::shared_ptr<SLE const> const& issuance,
1161 STAmount const& assets,
1163
1164// From the perspective of a vault, return the number of assets to give the
1165// depositor when they redeem a fixed amount of shares. Note, since shares are
1166// MPT, they are always an integral number.
1167[[nodiscard]] std::optional<STAmount>
1169 std::shared_ptr<SLE const> const& vault,
1170 std::shared_ptr<SLE const> const& issuance,
1171 STAmount const& shares);
1172
1179bool
1181
1182} // namespace xrpl
1183
1184#endif
Provide a light-weight way to check active() before string formatting.
Definition Journal.h:186
A generic endpoint for log messages.
Definition Journal.h:41
Writeable view to a ledger, for applying a transaction.
Definition ApplyView.h:124
constexpr value_type const & value() const
Definition Asset.h:157
A currency issued by an account.
Definition Issue.h:14
Currency currency
Definition Issue.h:16
AccountID account
Definition Issue.h:17
std::chrono::time_point< NetClock > time_point
Definition chrono.h:50
A view into a ledger.
Definition ReadView.h:32
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:356
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition Indexes.cpp:166
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
TypedField< STInteger< std::uint64_t > > SF_UINT64
Definition SField.h:336
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:1636
std::optional< STAmount > sharesToAssetsDeposit(std::shared_ptr< SLE const > const &vault, std::shared_ptr< SLE const > const &issuance, STAmount const &shares)
Definition View.cpp:3569
TER checkDeepFrozen(ReadView const &view, AccountID const &account, Issue const &issue)
Definition View.h:272
base_uint< 160, detail::CurrencyTag > Currency
Currency is a hash representing a specific currency.
Definition UintTypes.h:37
std::vector< SField const * > const & getPseudoAccountFields()
Definition View.cpp:1153
XRPAmount xrpLiquid(ReadView const &view, AccountID const &id, std::int32_t ownerCountAdj, beast::Journal j)
Definition View.cpp:676
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:1440
FreezeHandling
Controls the treatment of frozen account balances.
Definition View.h:59
@ fhZERO_IF_FROZEN
Definition View.h:59
@ fhIGNORE_FREEZE
Definition View.h:59
bool dirFirst(ApplyView &view, uint256 const &root, std::shared_ptr< SLE > &page, unsigned int &index, uint256 &entry)
Definition View.cpp:105
AccountID pseudoAccountAddress(ReadView const &view, uint256 const &pseudoOwnerKey)
Definition View.cpp:1129
bool dirIsEmpty(ReadView const &view, Keylet const &k)
Returns true if the directory is empty.
Definition View.cpp:963
SpendableHandling
Controls whether to include the account's full spendable balance.
Definition View.h:65
@ shSIMPLE_BALANCE
Definition View.h:65
@ shFULL_BALANCE
Definition View.h:65
TER canAddHolding(ReadView const &view, Asset const &asset)
Definition View.cpp:1275
std::set< uint256 > getEnabledAmendments(ReadView const &view)
Definition View.cpp:977
TER issueIOU(ApplyView &view, AccountID const &account, STAmount const &amount, Issue const &issue, beast::Journal j)
Definition View.cpp:2877
TER removeEmptyHolding(ApplyView &view, AccountID const &accountID, Issue const &issue, beast::Journal journal)
Definition View.cpp:1763
bool isVaultPseudoAccountFrozen(ReadView const &view, AccountID const &account, MPTIssue const &mptShare, int depth)
Definition View.cpp:289
TER rippleUnlockEscrowMPT(ApplyView &view, AccountID const &uGrantorID, AccountID const &uGranteeID, STAmount const &netAmount, STAmount const &grossAmount, beast::Journal j)
Definition View.cpp:3749
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:1391
bool hasExpired(ReadView const &view, std::optional< std::uint32_t > const &exp)
Determines whether the given expiration time has passed.
Definition View.cpp:155
TER checkFrozen(ReadView const &view, AccountID const &account, Issue const &issue)
Definition View.h:163
SkipEntry
Definition View.h:26
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:713
bool isAnyFrozen(ReadView const &view, std::initializer_list< AccountID > const &accounts, MPTIssue const &mptIssue, int depth=0)
Definition View.cpp:264
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:461
WaiveTransferFee
Definition View.h:25
Number root(Number f, unsigned d)
Definition Number.cpp:997
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:138
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:29
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:1516
TER deleteAMMTrustLine(ApplyView &view, std::shared_ptr< SLE > sleState, std::optional< AccountID > const &ammAccountID, beast::Journal j)
Delete trustline to AMM.
Definition View.cpp:3464
bool isDeepFrozen(ReadView const &view, AccountID const &account, Currency const &currency, AccountID const &issuer)
Definition View.cpp:332
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:127
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:855
base_uint< 256 > uint256
Definition base_uint.h:539
LedgerIndex getCandidateLedger(LedgerIndex requested)
Find a ledger index from which we could easily get the requested ledger.
Definition View.h:502
bool isPseudoAccount(std::shared_ptr< SLE const > sleAcct, std::set< SField const * > const &pseudoFieldFilter={})
Definition View.cpp:1179
TruncateShares
Definition View.h:1151
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:2778
std::optional< STAmount > assetsToSharesDeposit(std::shared_ptr< SLE const > const &vault, std::shared_ptr< SLE const > const &issuance, STAmount const &assets)
Definition View.cpp:3541
STAmount accountFunds(ReadView const &view, AccountID const &id, STAmount const &saDefault, FreezeHandling freezeHandling, beast::Journal j)
Definition View.cpp:612
bool isGlobalFrozen(ReadView const &view, AccountID const &issuer)
Definition View.cpp:164
std::optional< uint256 > hashOfSeq(ReadView const &ledger, LedgerIndex seq, beast::Journal journal)
Return the hash of a ledger by sequence.
Definition View.cpp:1017
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:3598
TERSubset< CanCvtToTER > TER
Definition TER.h:630
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:1088
std::uint32_t LedgerIndex
A ledger index.
Definition Protocol.h:256
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:45
AuthHandling
Controls the treatment of unauthorized MPT balances.
Definition View.h:62
@ ahIGNORE_AUTH
Definition View.h:62
@ ahZERO_IF_UNAUTHORIZED
Definition View.h:62
Rate transferRate(ReadView const &view, AccountID const &issuer)
Returns IOU issuer transfer fee as Rate.
Definition View.cpp:818
majorityAmendments_t getMajorityAmendments(ReadView const &view)
Definition View.cpp:994
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Definition View.cpp:3923
AuthType
Definition View.h:967
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:3097
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:3326
bool isFrozen(ReadView const &view, AccountID const &account, Currency const &currency, AccountID const &issuer)
Definition View.cpp:229
TER transferXRP(ApplyView &view, AccountID const &from, AccountID const &to, STAmount const &amount, beast::Journal j)
Definition View.cpp:3052
std::function< void(SLE::ref)> describeOwnerDir(AccountID const &account)
Definition View.cpp:1106
TER dirLink(ApplyView &view, AccountID const &owner, std::shared_ptr< SLE > &object, SF_UINT64 const &node=sfOwnerNode)
Definition View.cpp:1114
bool isIndividualFrozen(ReadView const &view, AccountID const &account, Currency const &currency, AccountID const &issuer)
Definition View.cpp:195
TER offerDelete(ApplyView &view, std::shared_ptr< SLE > const &sle, beast::Journal j)
Delete an offer.
Definition View.cpp:1904
TER redeemIOU(ApplyView &view, AccountID const &account, STAmount const &amount, Issue const &issue, beast::Journal j)
Definition View.cpp:2977
std::optional< STAmount > sharesToAssetsWithdraw(std::shared_ptr< SLE const > const &vault, std::shared_ptr< SLE const > const &issuance, STAmount const &shares)
Definition View.cpp:3627
TER rippleLockEscrowMPT(ApplyView &view, AccountID const &uGrantorID, STAmount const &saAmount, beast::Journal j)
Definition View.cpp:3652
LedgerEntryType
Identifiers for on-ledger objects.
@ tecLOCKED
Definition TER.h:340
@ tecFROZEN
Definition TER.h:285
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:740
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:3225
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:1344
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:1199
TER checkDestinationAndTag(SLE::const_ref toSle, bool hasDestinationTag)
Validates that the destination SLE and tag are valid.
Definition View.cpp:1285
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:2799
@ no
Definition Steps.h:26
@ yes
Definition Steps.h:26
TER trustDelete(ApplyView &view, std::shared_ptr< SLE > const &sleRippleState, AccountID const &uLowAccountID, AccountID const &uHighAccountID, beast::Journal j)
Definition View.cpp:1864
bool isLPTokenFrozen(ReadView const &view, AccountID const &account, Issue const &asset, Issue const &asset2)
Definition View.cpp:358
@ tesSUCCESS
Definition TER.h:226
bool dirNext(ApplyView &view, uint256 const &root, std::shared_ptr< SLE > &page, unsigned int &index, uint256 &entry)
Definition View.cpp:116
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:3514
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:20
T visit(T... args)