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/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 ripple {
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
63[[nodiscard]] bool
64isGlobalFrozen(ReadView const& view, AccountID const& issuer);
65
66[[nodiscard]] bool
67isGlobalFrozen(ReadView const& view, MPTIssue const& mptIssue);
68
69[[nodiscard]] bool
70isGlobalFrozen(ReadView const& view, Asset const& asset);
71
72// Note, depth parameter is used to limit the recursion depth
73[[nodiscard]] bool
75 ReadView const& view,
76 AccountID const& account,
77 MPTIssue const& mptShare,
78 int depth);
79
80[[nodiscard]] bool
82 ReadView const& view,
83 AccountID const& account,
84 Currency const& currency,
85 AccountID const& issuer);
86
87[[nodiscard]] inline bool
89 ReadView const& view,
90 AccountID const& account,
91 Issue const& issue)
92{
93 return isIndividualFrozen(view, account, issue.currency, issue.account);
94}
95
96[[nodiscard]] bool
98 ReadView const& view,
99 AccountID const& account,
100 MPTIssue const& mptIssue);
101
102[[nodiscard]] inline bool
104 ReadView const& view,
105 AccountID const& account,
106 Asset const& asset)
107{
108 return std::visit(
109 [&](auto const& issue) {
110 return isIndividualFrozen(view, account, issue);
111 },
112 asset.value());
113}
114
115[[nodiscard]] bool
117 ReadView const& view,
118 AccountID const& account,
119 Currency const& currency,
120 AccountID const& issuer);
121
122[[nodiscard]] inline bool
124 ReadView const& view,
125 AccountID const& account,
126 Issue const& issue,
127 int = 0 /*ignored*/)
128{
129 return isFrozen(view, account, issue.currency, issue.account);
130}
131
132[[nodiscard]] bool
134 ReadView const& view,
135 AccountID const& account,
136 MPTIssue const& mptIssue,
137 int depth = 0);
138
144[[nodiscard]] inline bool
146 ReadView const& view,
147 AccountID const& account,
148 Asset const& asset,
149 int depth = 0)
150{
151 return std::visit(
152 [&](auto const& issue) {
153 return isFrozen(view, account, issue, depth);
154 },
155 asset.value());
156}
157
158[[nodiscard]] inline TER
159checkFrozen(ReadView const& view, AccountID const& account, Issue const& issue)
160{
161 return isFrozen(view, account, issue) ? (TER)tecFROZEN : (TER)tesSUCCESS;
162}
163
164[[nodiscard]] inline TER
166 ReadView const& view,
167 AccountID const& account,
168 MPTIssue const& mptIssue)
169{
170 return isFrozen(view, account, mptIssue) ? (TER)tecLOCKED : (TER)tesSUCCESS;
171}
172
173[[nodiscard]] inline TER
174checkFrozen(ReadView const& view, AccountID const& account, Asset const& asset)
175{
176 return std::visit(
177 [&](auto const& issue) { return checkFrozen(view, account, issue); },
178 asset.value());
179}
180
181[[nodiscard]] bool
183 ReadView const& view,
184 std::initializer_list<AccountID> const& accounts,
185 MPTIssue const& mptIssue,
186 int depth = 0);
187
188[[nodiscard]] inline bool
190 ReadView const& view,
191 std::initializer_list<AccountID> const& accounts,
192 Issue const& issue)
193{
194 for (auto const& account : accounts)
195 {
196 if (isFrozen(view, account, issue.currency, issue.account))
197 return true;
198 }
199 return false;
200}
201
202[[nodiscard]] inline bool
204 ReadView const& view,
205 std::initializer_list<AccountID> const& accounts,
206 Asset const& asset,
207 int depth = 0)
208{
209 return std::visit(
210 [&]<ValidIssueType TIss>(TIss const& issue) {
211 if constexpr (std::is_same_v<TIss, Issue>)
212 return isAnyFrozen(view, accounts, issue);
213 else
214 return isAnyFrozen(view, accounts, issue, depth);
215 },
216 asset.value());
217}
218
219[[nodiscard]] bool
221 ReadView const& view,
222 AccountID const& account,
223 Currency const& currency,
224 AccountID const& issuer);
225
226[[nodiscard]] bool
228 ReadView const& view,
229 AccountID const& account,
230 Issue const& asset,
231 Issue const& asset2);
232
233// Returns the amount an account can spend without going into debt.
234//
235// <-- saAmount: amount of currency held by account. May be negative.
236[[nodiscard]] STAmount
238 ReadView const& view,
239 AccountID const& account,
240 Currency const& currency,
241 AccountID const& issuer,
242 FreezeHandling zeroIfFrozen,
244
245[[nodiscard]] STAmount
247 ReadView const& view,
248 AccountID const& account,
249 Issue const& issue,
250 FreezeHandling zeroIfFrozen,
252
253[[nodiscard]] STAmount
255 ReadView const& view,
256 AccountID const& account,
257 MPTIssue const& mptIssue,
258 FreezeHandling zeroIfFrozen,
259 AuthHandling zeroIfUnauthorized,
261
262[[nodiscard]] STAmount
264 ReadView const& view,
265 AccountID const& account,
266 Asset const& asset,
267 FreezeHandling zeroIfFrozen,
268 AuthHandling zeroIfUnauthorized,
270
271// Returns the amount an account can spend of the currency type saDefault, or
272// returns saDefault if this account is the issuer of the currency in
273// question. Should be used in favor of accountHolds when questioning how much
274// an account can spend while also allowing currency issuers to spend
275// unlimited amounts of their own currency (since they can always issue more).
276[[nodiscard]] STAmount
278 ReadView const& view,
279 AccountID const& id,
280 STAmount const& saDefault,
281 FreezeHandling freezeHandling,
283
284// Return the account's liquid (not reserved) XRP. Generally prefer
285// calling accountHolds() over this interface. However, this interface
286// allows the caller to temporarily adjust the owner count should that be
287// necessary.
288//
289// @param ownerCountAdj positive to add to count, negative to reduce count.
290[[nodiscard]] XRPAmount
292 ReadView const& view,
293 AccountID const& id,
294 std::int32_t ownerCountAdj,
296
298void
300 ReadView const& view,
301 Keylet const& root,
302 std::function<void(std::shared_ptr<SLE const> const&)> const& f);
303
310bool
312 ReadView const& view,
313 Keylet const& root,
314 uint256 const& after,
315 std::uint64_t const hint,
316 unsigned int limit,
317 std::function<bool(std::shared_ptr<SLE const> const&)> const& f);
318
320inline void
322 ReadView const& view,
323 AccountID const& id,
324 std::function<void(std::shared_ptr<SLE const> const&)> const& f)
325{
326 return forEachItem(view, keylet::ownerDir(id), f);
327}
328
335inline bool
337 ReadView const& view,
338 AccountID const& id,
339 uint256 const& after,
340 std::uint64_t const hint,
341 unsigned int limit,
342 std::function<bool(std::shared_ptr<SLE const> const&)> const& f)
343{
344 return forEachItemAfter(view, keylet::ownerDir(id), after, hint, limit, f);
345}
346
352[[nodiscard]] Rate
353transferRate(ReadView const& view, AccountID const& issuer);
354
360[[nodiscard]] Rate
361transferRate(ReadView const& view, MPTID const& issuanceID);
362
367[[nodiscard]] Rate
368transferRate(ReadView const& view, STAmount const& amount);
369
373[[nodiscard]] bool
374dirIsEmpty(ReadView const& view, Keylet const& k);
375
376// Return the list of enabled amendments
377[[nodiscard]] std::set<uint256>
378getEnabledAmendments(ReadView const& view);
379
380// Return a map of amendments that have achieved majority
382[[nodiscard]] majorityAmendments_t
384
394[[nodiscard]] std::optional<uint256>
395hashOfSeq(ReadView const& ledger, LedgerIndex seq, beast::Journal journal);
396
409inline LedgerIndex
411{
412 return (requested + 255) & (~255);
413}
414
420[[nodiscard]] bool
422 ReadView const& validLedger,
423 ReadView const& testLedger,
425 char const* reason);
426
427[[nodiscard]] bool
429 uint256 const& validHash,
430 LedgerIndex validIndex,
431 ReadView const& testLedger,
433 char const* reason);
434
435//------------------------------------------------------------------------------
436//
437// Modifiers
438//
439//------------------------------------------------------------------------------
440
442void
444 ApplyView& view,
445 std::shared_ptr<SLE> const& sle,
446 std::int32_t amount,
448
464bool
466 ReadView const& view,
467 uint256 const& root,
469 unsigned int& index,
470 uint256& entry);
471
472bool
474 ApplyView& view,
475 uint256 const& root,
477 unsigned int& index,
478 uint256& entry);
496bool
498 ReadView const& view,
499 uint256 const& root,
501 unsigned int& index,
502 uint256& entry);
503
504bool
505dirNext(
506 ApplyView& view,
507 uint256 const& root,
509 unsigned int& index,
510 uint256& entry);
513[[nodiscard]] std::function<void(SLE::ref)>
514describeOwnerDir(AccountID const& account);
515
516[[nodiscard]] TER
517dirLink(ApplyView& view, AccountID const& owner, std::shared_ptr<SLE>& object);
518
520pseudoAccountAddress(ReadView const& view, uint256 const& pseudoOwnerKey);
521
530[[nodiscard]] Expected<std::shared_ptr<SLE>, TER>
532 ApplyView& view,
533 uint256 const& pseudoOwnerKey,
534 SField const& ownerField);
535
536// Returns true iff sleAcct is a pseudo-account.
537//
538// Returns false if sleAcct is
539// * NOT a pseudo-account OR
540// * NOT a ltACCOUNT_ROOT OR
541// * null pointer
542[[nodiscard]] bool
544
545// Returns the list of fields that define an ACCOUNT_ROOT as a pseudo-account if
546// set
547// Pseudo-account designator fields MUST be maintained by including the
548// SField::sMD_PseudoAccount flag in the SField definition. (Don't forget to
549// "| SField::sMD_Default"!) The fields do NOT need to be amendment-gated,
550// since a non-active amendment will not set any field, by definition.
551// Specific properties of a pseudo-account are NOT checked here, that's what
552// InvariantCheck is for.
553[[nodiscard]] std::vector<SField const*> const&
555
556[[nodiscard]] inline bool
557isPseudoAccount(ReadView const& view, AccountID accountId)
558{
559 return isPseudoAccount(view.read(keylet::account(accountId)));
560}
561
562[[nodiscard]] TER
563canAddHolding(ReadView const& view, Asset const& asset);
564
567[[nodiscard]] TER
569 ApplyView& view,
570 AccountID const& accountID,
571 XRPAmount priorBalance,
572 Issue const& issue,
573 beast::Journal journal);
574
575[[nodiscard]] TER
577 ApplyView& view,
578 AccountID const& accountID,
579 XRPAmount priorBalance,
580 MPTIssue const& mptIssue,
581 beast::Journal journal);
582
583[[nodiscard]] inline TER
585 ApplyView& view,
586 AccountID const& accountID,
587 XRPAmount priorBalance,
588 Asset const& asset,
589 beast::Journal journal)
590{
591 return std::visit(
592 [&]<ValidIssueType TIss>(TIss const& issue) -> TER {
593 return addEmptyHolding(
594 view, accountID, priorBalance, issue, journal);
595 },
596 asset.value());
597}
598
599[[nodiscard]] TER
601 ApplyView& view,
602 XRPAmount const& priorBalance,
603 MPTID const& mptIssuanceID,
604 AccountID const& account,
605 beast::Journal journal,
606 std::uint32_t flags = 0,
608
609// VFALCO NOTE Both STAmount parameters should just
610// be "Amount", a unit-less number.
611//
616[[nodiscard]] TER
618 ApplyView& view,
619 bool const bSrcHigh,
620 AccountID const& uSrcAccountID,
621 AccountID const& uDstAccountID,
622 uint256 const& uIndex, // --> ripple state entry
623 SLE::ref sleAccount, // --> the account being set.
624 bool const bAuth, // --> authorize account.
625 bool const bNoRipple, // --> others cannot ripple through
626 bool const bFreeze, // --> funds cannot leave
627 bool bDeepFreeze, // --> can neither receive nor send funds
628 STAmount const& saBalance, // --> balance of account being set.
629 // Issuer should be noAccount()
630 STAmount const& saLimit, // --> limit for account being set.
631 // Issuer should be the account being set.
632 std::uint32_t uSrcQualityIn,
633 std::uint32_t uSrcQualityOut,
635
636[[nodiscard]] TER
638 ApplyView& view,
639 AccountID const& accountID,
640 Issue const& issue,
641 beast::Journal journal);
642
643[[nodiscard]] TER
645 ApplyView& view,
646 AccountID const& accountID,
647 MPTIssue const& mptIssue,
648 beast::Journal journal);
649
650[[nodiscard]] inline TER
652 ApplyView& view,
653 AccountID const& accountID,
654 Asset const& asset,
655 beast::Journal journal)
656{
657 return std::visit(
658 [&]<ValidIssueType TIss>(TIss const& issue) -> TER {
659 return removeEmptyHolding(view, accountID, issue, journal);
660 },
661 asset.value());
662}
663
664[[nodiscard]] TER
666 ApplyView& view,
667 std::shared_ptr<SLE> const& sleRippleState,
668 AccountID const& uLowAccountID,
669 AccountID const& uHighAccountID,
671
678// [[nodiscard]] // nodiscard commented out so Flow, BookTip and others compile.
679TER
680offerDelete(ApplyView& view, std::shared_ptr<SLE> const& sle, beast::Journal j);
681
682//------------------------------------------------------------------------------
683
684//
685// Money Transfers
686//
687
688// Direct send w/o fees:
689// - Redeeming IOUs and/or sending sender's own IOUs.
690// - Create trust line of needed.
691// --> bCheckIssuer : normally require issuer to be involved.
692// [[nodiscard]] // nodiscard commented out so DirectStep.cpp compiles.
693
697TER
699 ApplyView& view,
700 AccountID const& uSenderID,
701 AccountID const& uReceiverID,
702 STAmount const& saAmount,
703 bool bCheckIssuer,
705
706TER
708 ApplyView& view,
709 AccountID const& uGrantorID,
710 STAmount const& saAmount,
712
713TER
715 ApplyView& view,
716 AccountID const& uGrantorID,
717 AccountID const& uGranteeID,
718 STAmount const& netAmount,
719 STAmount const& grossAmount,
721
725[[nodiscard]] TER
727 ApplyView& view,
728 AccountID const& from,
729 AccountID const& to,
730 STAmount const& saAmount,
733
734[[nodiscard]] TER
736 ApplyView& view,
737 AccountID const& account,
738 STAmount const& amount,
739 Issue const& issue,
741
742[[nodiscard]] TER
744 ApplyView& view,
745 AccountID const& account,
746 STAmount const& amount,
747 Issue const& issue,
749
750[[nodiscard]] TER
752 ApplyView& view,
753 AccountID const& from,
754 AccountID const& to,
755 STAmount const& amount,
757
758/* Check if MPToken (for MPT) or trust line (for IOU) exists:
759 * - StrongAuth - before checking if authorization is required
760 * - WeakAuth
761 * for MPT - after checking lsfMPTRequireAuth flag
762 * for IOU - do not check if trust line exists
763 * - Legacy
764 * for MPT - before checking lsfMPTRequireAuth flag i.e. same as StrongAuth
765 * for IOU - do not check if trust line exists i.e. same as WeakAuth
766 */
768
786[[nodiscard]] TER
788 ReadView const& view,
789 Issue const& issue,
790 AccountID const& account,
791 AuthType authType = AuthType::Legacy);
792
815[[nodiscard]] TER
817 ReadView const& view,
818 MPTIssue const& mptIssue,
819 AccountID const& account,
820 AuthType authType = AuthType::Legacy,
821 int depth = 0);
822
823[[nodiscard]] TER inline requireAuth(
824 ReadView const& view,
825 Asset const& asset,
826 AccountID const& account,
827 AuthType authType = AuthType::Legacy)
828{
829 return std::visit(
830 [&]<ValidIssueType TIss>(TIss const& issue_) {
831 return requireAuth(view, issue_, account, authType);
832 },
833 asset.value());
834}
835
859[[nodiscard]] TER
861 ApplyView& view,
862 MPTID const& mptIssuanceID,
863 AccountID const& account,
864 XRPAmount const& priorBalance,
866
871[[nodiscard]] TER
873 ReadView const& view,
874 MPTIssue const& mptIssue,
875 AccountID const& from,
876 AccountID const& to);
877
884 uint256 const&,
893[[nodiscard]] TER
895 ApplyView& view,
896 Keylet const& ownerDirKeylet,
897 EntryDeleter const& deleter,
899 std::optional<std::uint16_t> maxNodesToDelete = std::nullopt);
900
905[[nodiscard]] TER
907 ApplyView& view,
908 std::shared_ptr<SLE> sleState,
909 std::optional<AccountID> const& ammAccountID,
911
912// From the perspective of a vault, return the number of shares to give the
913// depositor when they deposit a fixed amount of assets. Since shares are MPT
914// this number is integral and always truncated in this calculation.
915[[nodiscard]] std::optional<STAmount>
917 std::shared_ptr<SLE const> const& vault,
918 std::shared_ptr<SLE const> const& issuance,
919 STAmount const& assets);
920
921// From the perspective of a vault, return the number of assets to take from
922// depositor when they receive a fixed amount of shares. Note, since shares are
923// MPT, they are always an integral number.
924[[nodiscard]] std::optional<STAmount>
926 std::shared_ptr<SLE const> const& vault,
927 std::shared_ptr<SLE const> const& issuance,
928 STAmount const& shares);
929
930enum class TruncateShares : bool { no = false, yes = true };
931
932// From the perspective of a vault, return the number of shares to demand from
933// the depositor when they ask to withdraw a fixed amount of assets. Since
934// shares are MPT this number is integral, and it will be rounded to nearest
935// unless explicitly requested to be truncated instead.
936[[nodiscard]] std::optional<STAmount>
938 std::shared_ptr<SLE const> const& vault,
939 std::shared_ptr<SLE const> const& issuance,
940 STAmount const& assets,
942
943// From the perspective of a vault, return the number of assets to give the
944// depositor when they redeem a fixed amount of shares. Note, since shares are
945// MPT, they are always an integral number.
946[[nodiscard]] std::optional<STAmount>
948 std::shared_ptr<SLE const> const& vault,
949 std::shared_ptr<SLE const> const& issuance,
950 STAmount const& shares);
951
958bool
960
961} // namespace ripple
962
963#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:137
A currency issued by an account.
Definition Issue.h:14
AccountID account
Definition Issue.h:17
Currency currency
Definition Issue.h:16
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
T is_same_v
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition Indexes.cpp:165
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Definition Indexes.cpp:355
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:29
std::uint32_t LedgerIndex
A ledger index.
Definition Protocol.h:120
TER checkFrozen(ReadView const &view, AccountID const &account, Issue const &issue)
Definition View.h:159
STAmount accountFunds(ReadView const &view, AccountID const &id, STAmount const &saDefault, FreezeHandling freezeHandling, beast::Journal j)
Definition View.cpp:535
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 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:780
TER rippleLockEscrowMPT(ApplyView &view, AccountID const &uGrantorID, STAmount const &saAmount, beast::Journal j)
Definition View.cpp:2976
LedgerIndex getCandidateLedger(LedgerIndex requested)
Find a ledger index from which we could easily get the requested ledger.
Definition View.h:410
std::optional< STAmount > sharesToAssetsDeposit(std::shared_ptr< SLE const > const &vault, std::shared_ptr< SLE const > const &issuance, STAmount const &shares)
Definition View.cpp:2893
bool isIndividualFrozen(ReadView const &view, AccountID const &account, Currency const &currency, AccountID const &issuer)
Definition View.cpp:194
bool dirFirst(ApplyView &view, uint256 const &root, std::shared_ptr< SLE > &page, unsigned int &index, uint256 &entry)
Definition View.cpp:104
base_uint< 256 > uint256
Definition base_uint.h:539
bool dirNext(ApplyView &view, uint256 const &root, std::shared_ptr< SLE > &page, unsigned int &index, uint256 &entry)
Definition View.cpp:115
bool isDeepFrozen(ReadView const &view, AccountID const &account, Currency const &currency, AccountID const &issuer)
Definition View.cpp:331
std::optional< uint256 > hashOfSeq(ReadView const &ledger, LedgerIndex seq, beast::Journal journal)
Return the hash of a ledger by sequence.
Definition View.cpp:942
TER redeemIOU(ApplyView &view, AccountID const &account, STAmount const &amount, Issue const &issue, beast::Journal j)
Definition View.cpp:2346
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
AuthType
Definition View.h:767
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:1013
std::optional< STAmount > assetsToSharesDeposit(std::shared_ptr< SLE const > const &vault, std::shared_ptr< SLE const > const &issuance, STAmount const &assets)
Definition View.cpp:2865
AuthHandling
Controls the treatment of unauthorized MPT balances.
Definition View.h:61
@ ahZERO_IF_UNAUTHORIZED
Definition View.h:61
@ ahIGNORE_AUTH
Definition View.h:61
std::function< void(SLE::ref)> describeOwnerDir(AccountID const &account)
Definition View.cpp:1031
SkipEntry
Definition View.h:25
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:2922
TER transferXRP(ApplyView &view, AccountID const &from, AccountID const &to, STAmount const &amount, beast::Journal j)
Definition View.cpp:2421
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:2172
bool dirIsEmpty(ReadView const &view, Keylet const &k)
Returns true if the directory is empty.
Definition View.cpp:888
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.
bool isFrozen(ReadView const &view, AccountID const &account, Currency const &currency, AccountID const &issuer)
Definition View.cpp:228
std::set< uint256 > getEnabledAmendments(ReadView const &view)
Definition View.cpp:902
TER rippleUnlockEscrowMPT(ApplyView &view, AccountID const &uGrantorID, AccountID const &uGranteeID, STAmount const &netAmount, STAmount const &grossAmount, beast::Journal j)
Definition View.cpp:3073
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:2466
@ no
Definition Steps.h:26
@ yes
Definition Steps.h:26
std::optional< STAmount > sharesToAssetsWithdraw(std::shared_ptr< SLE const > const &vault, std::shared_ptr< SLE const > const &issuance, STAmount const &shares)
Definition View.cpp:2951
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:637
base_uint< 160, detail::CurrencyTag > Currency
Currency is a hash representing a specific currency.
Definition UintTypes.h:37
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:2685
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:1113
bool hasExpired(ReadView const &view, std::optional< std::uint32_t > const &exp)
Determines whether the given expiration time has passed.
Definition View.cpp:154
bool isVaultPseudoAccountFrozen(ReadView const &view, AccountID const &account, MPTIssue const &mptShare, int depth)
Definition View.cpp:288
TER issueIOU(ApplyView &view, AccountID const &account, STAmount const &amount, Issue const &issue, beast::Journal j)
Definition View.cpp:2246
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:665
Rate transferRate(ReadView const &view, AccountID const &issuer)
Returns IOU issuer transfer fee as Rate.
Definition View.cpp:743
WaiveTransferFee
Definition View.h:24
TER trustDelete(ApplyView &view, std::shared_ptr< SLE > const &sleRippleState, AccountID const &uLowAccountID, AccountID const &uHighAccountID, beast::Journal j)
Definition View.cpp:1588
@ tecFROZEN
Definition TER.h:285
@ tecLOCKED
Definition TER.h:340
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:2837
@ tesSUCCESS
Definition TER.h:226
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:1197
AccountID pseudoAccountAddress(ReadView const &view, uint256 const &pseudoOwnerKey)
Definition View.cpp:1050
STAmount accountHolds(ReadView const &view, AccountID const &account, Currency const &currency, AccountID const &issuer, FreezeHandling zeroIfFrozen, beast::Journal j)
Definition View.cpp:368
bool isLPTokenFrozen(ReadView const &view, AccountID const &account, Issue const &asset, Issue const &asset2)
Definition View.cpp:357
majorityAmendments_t getMajorityAmendments(ReadView const &view)
Definition View.cpp:919
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:126
LedgerEntryType
Identifiers for on-ledger objects.
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Definition View.cpp:3247
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:1379
TruncateShares
Definition View.h:930
Number root(Number f, unsigned d)
Definition Number.cpp:617
TER deleteAMMTrustLine(ApplyView &view, std::shared_ptr< SLE > sleState, std::optional< AccountID > const &ammAccountID, beast::Journal j)
Delete trustline to AMM.
Definition View.cpp:2787
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:2584
TER canAddHolding(ReadView const &view, Asset const &asset)
Definition View.cpp:1187
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:137
bool isAnyFrozen(ReadView const &view, std::initializer_list< AccountID > const &accounts, MPTIssue const &mptIssue, int depth=0)
Definition View.cpp:263
std::vector< SField const * > const & getPseudoAccountFields()
Definition View.cpp:1073
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:1271
TERSubset< CanCvtToTER > TER
Definition TER.h:630
TER removeEmptyHolding(ApplyView &view, AccountID const &accountID, Issue const &issue, beast::Journal journal)
Definition View.cpp:1498
TER offerDelete(ApplyView &view, std::shared_ptr< SLE > const &sle, beast::Journal j)
Delete an offer.
Definition View.cpp:1628
bool isPseudoAccount(std::shared_ptr< SLE const > sleAcct)
Definition View.cpp:1099
TER dirLink(ApplyView &view, AccountID const &owner, std::shared_ptr< SLE > &object)
Definition View.cpp:1039
XRPAmount xrpLiquid(ReadView const &view, AccountID const &id, std::int32_t ownerCountAdj, beast::Journal j)
Definition View.cpp:599
bool isGlobalFrozen(ReadView const &view, AccountID const &issuer)
Definition View.cpp:163
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:20
T visit(T... args)