rippled
Loading...
Searching...
No Matches
Indexes.h
1#ifndef XRPL_PROTOCOL_INDEXES_H_INCLUDED
2#define XRPL_PROTOCOL_INDEXES_H_INCLUDED
3
4#include <xrpl/basics/base_uint.h>
5#include <xrpl/protocol/Book.h>
6#include <xrpl/protocol/Keylet.h>
7#include <xrpl/protocol/LedgerFormats.h>
8#include <xrpl/protocol/Protocol.h>
9#include <xrpl/protocol/PublicKey.h>
10#include <xrpl/protocol/STXChainBridge.h>
11#include <xrpl/protocol/Serializer.h>
12#include <xrpl/protocol/UintTypes.h>
13#include <xrpl/protocol/jss.h>
14
15#include <cstdint>
16#include <set>
17
18namespace xrpl {
19
20class SeqProxy;
35namespace keylet {
36
39account(AccountID const& id) noexcept;
40
42Keylet const&
43amendments() noexcept;
44
47child(uint256 const& key) noexcept;
48
54Keylet const&
55skip() noexcept;
56
68skip(LedgerIndex ledger) noexcept;
69
71Keylet const&
72fees() noexcept;
73
75Keylet const&
76negativeUNL() noexcept;
77
79struct book_t
80{
81 explicit book_t() = default;
82
83 Keylet
84 operator()(Book const& b) const;
85};
86static book_t const book{};
87
97line(
98 AccountID const& id0,
99 AccountID const& id1,
100 Currency const& currency) noexcept;
101
102inline Keylet
103line(AccountID const& id, Issue const& issue) noexcept
104{
105 return line(id, issue.account, issue.currency);
106}
111Keylet
112offer(AccountID const& id, std::uint32_t seq) noexcept;
113
114inline Keylet
115offer(uint256 const& key) noexcept
116{
117 return {ltOFFER, key};
118}
122Keylet
123quality(Keylet const& k, std::uint64_t q) noexcept;
124
126struct next_t
127{
128 explicit next_t() = default;
129
130 Keylet
131 operator()(Keylet const& k) const;
132};
133static next_t const next{};
134
137{
138 explicit ticket_t() = default;
139
140 Keylet
141 operator()(AccountID const& id, std::uint32_t ticketSeq) const;
142
143 Keylet
144 operator()(AccountID const& id, SeqProxy ticketSeq) const;
145
146 Keylet
147 operator()(uint256 const& key) const
148 {
149 return {ltTICKET, key};
150 }
151};
152static ticket_t const ticket{};
153
155Keylet
156signers(AccountID const& account) noexcept;
157
160Keylet
161check(AccountID const& id, std::uint32_t seq) noexcept;
162
163inline Keylet
164check(uint256 const& key) noexcept
165{
166 return {ltCHECK, key};
167}
172Keylet
173depositPreauth(AccountID const& owner, AccountID const& preauthorized) noexcept;
174
175Keylet
177 AccountID const& owner,
178 std::set<std::pair<AccountID, Slice>> const& authCreds) noexcept;
179
180inline Keylet
181depositPreauth(uint256 const& key) noexcept
182{
183 return {ltDEPOSIT_PREAUTH, key};
184}
187//------------------------------------------------------------------------------
188
190Keylet
191unchecked(uint256 const& key) noexcept;
192
194Keylet
195ownerDir(AccountID const& id) noexcept;
196
199Keylet
200page(uint256 const& root, std::uint64_t index = 0) noexcept;
201
202inline Keylet
203page(Keylet const& root, std::uint64_t index = 0) noexcept
204{
205 XRPL_ASSERT(
206 root.type == ltDIR_NODE, "xrpl::keylet::page : valid root type");
207 return page(root.key, index);
208}
212Keylet
213escrow(AccountID const& src, std::uint32_t seq) noexcept;
214
216Keylet
217payChan(AccountID const& src, AccountID const& dst, std::uint32_t seq) noexcept;
218
228Keylet
229nftpage_min(AccountID const& owner);
230
232Keylet
233nftpage_max(AccountID const& owner);
234
235Keylet
236nftpage(Keylet const& k, uint256 const& token);
240Keylet
241nftoffer(AccountID const& owner, std::uint32_t seq);
242
243inline Keylet
245{
246 return {ltNFTOKEN_OFFER, offer};
247}
248
250Keylet
251nft_buys(uint256 const& id) noexcept;
252
254Keylet
255nft_sells(uint256 const& id) noexcept;
256
258Keylet
259amm(Asset const& issue1, Asset const& issue2) noexcept;
260
261Keylet
262amm(uint256 const& amm) noexcept;
263
265Keylet
266delegate(AccountID const& account, AccountID const& authorizedAccount) noexcept;
267
268Keylet
270
271// `seq` is stored as `sfXChainClaimID` in the object
272Keylet
274
275// `seq` is stored as `sfXChainAccountCreateCount` in the object
276Keylet
278
279Keylet
280did(AccountID const& account) noexcept;
281
282Keylet
283oracle(AccountID const& account, std::uint32_t const& documentID) noexcept;
284
285Keylet
287 AccountID const& subject,
288 AccountID const& issuer,
289 Slice const& credType) noexcept;
290
291inline Keylet
292credential(uint256 const& key) noexcept
293{
294 return {ltCREDENTIAL, key};
295}
296
297Keylet
298mptIssuance(std::uint32_t seq, AccountID const& issuer) noexcept;
299
300Keylet
301mptIssuance(MPTID const& issuanceID) noexcept;
302
303inline Keylet
304mptIssuance(uint256 const& issuanceKey)
305{
306 return {ltMPTOKEN_ISSUANCE, issuanceKey};
307}
308
309Keylet
310mptoken(MPTID const& issuanceID, AccountID const& holder) noexcept;
311
312inline Keylet
313mptoken(uint256 const& mptokenKey)
314{
315 return {ltMPTOKEN, mptokenKey};
316}
317
318Keylet
319mptoken(uint256 const& issuanceKey, AccountID const& holder) noexcept;
320
321Keylet
322vault(AccountID const& owner, std::uint32_t seq) noexcept;
323
324inline Keylet
325vault(uint256 const& vaultKey)
326{
327 return {ltVAULT, vaultKey};
328}
329
330Keylet
331loanbroker(AccountID const& owner, std::uint32_t seq) noexcept;
332
333inline Keylet
335{
336 return {ltLOAN_BROKER, key};
337}
338
339Keylet
340loan(uint256 const& loanBrokerID, std::uint32_t loanSeq) noexcept;
341
342inline Keylet
343loan(uint256 const& key)
344{
345 return {ltLOAN, key};
346}
347
348Keylet
350
351Keylet
352permissionedDomain(uint256 const& domainID) noexcept;
353} // namespace keylet
354
355// Everything below is deprecated and should be removed in favor of keylets:
356
358getBookBase(Book const& book);
359
361getQualityNext(uint256 const& uBase);
362
363// VFALCO This name could be better
365getQuality(uint256 const& uBase);
366
368getTicketIndex(AccountID const& account, std::uint32_t uSequence);
369
371getTicketIndex(AccountID const& account, SeqProxy ticketSeq);
372
373template <class... keyletParams>
380
381// This list should include all of the keylet functions that take a single
382// AccountID parameter.
384 {{&keylet::account, jss::AccountRoot, false},
385 {&keylet::ownerDir, jss::DirectoryNode, true},
386 {&keylet::signers, jss::SignerList, true},
387 // It's normally impossible to create an item at nftpage_min, but
388 // test it anyway, since the invariant checks for it.
389 {&keylet::nftpage_min, jss::NFTokenPage, true},
390 {&keylet::nftpage_max, jss::NFTokenPage, true},
391 {&keylet::did, jss::DID, true}}};
392
393MPTID
394makeMptID(std::uint32_t sequence, AccountID const& account);
395
396} // namespace xrpl
397
398#endif
Lightweight wrapper to tag static string.
Definition json_value.h:45
Specifies an order book.
Definition Book.h:17
A currency issued by an account.
Definition Issue.h:14
A type that represents either a sequence value or a ticket value.
Definition SeqProxy.h:37
An immutable linear range of bytes.
Definition Slice.h:27
STL namespace.
Keylet const & skip() noexcept
The index of the "short" skip list.
Definition Indexes.cpp:178
Keylet quality(Keylet const &k, std::uint64_t q) noexcept
The initial directory page for a specific quality.
Definition Indexes.cpp:262
Keylet signers(AccountID const &account) noexcept
A SignerList.
Definition Indexes.cpp:312
Keylet oracle(AccountID const &account, std::uint32_t const &documentID) noexcept
Definition Indexes.cpp:502
Keylet const & negativeUNL() noexcept
The (fixed) index of the object containing the ledger negativeUNL.
Definition Indexes.cpp:212
Keylet did(AccountID const &account) noexcept
Definition Indexes.cpp:496
Keylet nftpage_max(AccountID const &owner)
A keylet for the owner's last possible NFT page.
Definition Indexes.cpp:393
Keylet nftoffer(AccountID const &owner, std::uint32_t seq)
An offer from an account to buy or sell an NFT.
Definition Indexes.cpp:409
Keylet unchecked(uint256 const &key) noexcept
Any ledger entry.
Definition Indexes.cpp:350
static ticket_t const ticket
Definition Indexes.h:152
Keylet depositPreauth(AccountID const &owner, AccountID const &preauthorized) noexcept
A DepositPreauth.
Definition Indexes.cpp:324
Keylet nftpage(Keylet const &k, uint256 const &token)
Definition Indexes.cpp:401
static next_t const next
Definition Indexes.h:133
Keylet loanbroker(AccountID const &owner, std::uint32_t seq) noexcept
Definition Indexes.cpp:552
Keylet escrow(AccountID const &src, std::uint32_t seq) noexcept
An escrow entry.
Definition Indexes.cpp:371
Keylet bridge(STXChainBridge const &bridge, STXChainBridge::ChainType chainType)
Definition Indexes.cpp:455
static book_t const book
Definition Indexes.h:86
Keylet const & amendments() noexcept
The index of the amendment table.
Definition Indexes.cpp:196
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Definition Indexes.cpp:356
Keylet nft_buys(uint256 const &id) noexcept
The directory of buy offers for the specified NFT.
Definition Indexes.cpp:416
Keylet payChan(AccountID const &src, AccountID const &dst, std::uint32_t seq) noexcept
A PaymentChannel.
Definition Indexes.cpp:377
Keylet mptIssuance(std::uint32_t seq, AccountID const &issuer) noexcept
Definition Indexes.cpp:508
Keylet check(AccountID const &id, std::uint32_t seq) noexcept
A Check.
Definition Indexes.cpp:318
Keylet amm(Asset const &issue1, Asset const &issue2) noexcept
AMM entry.
Definition Indexes.cpp:428
Keylet loan(uint256 const &loanBrokerID, std::uint32_t loanSeq) noexcept
Definition Indexes.cpp:558
Keylet offer(AccountID const &id, std::uint32_t seq) noexcept
An offer from an account.
Definition Indexes.cpp:256
Keylet child(uint256 const &key) noexcept
Any item that can be in an owner dir.
Definition Indexes.cpp:172
Keylet vault(AccountID const &owner, std::uint32_t seq) noexcept
Definition Indexes.cpp:546
Keylet line(AccountID const &id0, AccountID const &id1, Currency const &currency) noexcept
The index of a trust line for a given currency.
Definition Indexes.cpp:226
Keylet nftpage_min(AccountID const &owner)
NFT page keylets.
Definition Indexes.cpp:385
Keylet xChainCreateAccountClaimID(STXChainBridge const &bridge, std::uint64_t seq)
Definition Indexes.cpp:482
Keylet mptoken(MPTID const &issuanceID, AccountID const &holder) noexcept
Definition Indexes.cpp:522
Keylet nft_sells(uint256 const &id) noexcept
The directory of sell offers for the specified NFT.
Definition Indexes.cpp:422
Keylet delegate(AccountID const &account, AccountID const &authorizedAccount) noexcept
A keylet for Delegate object.
Definition Indexes.cpp:447
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition Indexes.cpp:166
Keylet const & fees() noexcept
The (fixed) index of the object containing the ledger fees.
Definition Indexes.cpp:204
Keylet permissionedDomain(AccountID const &account, std::uint32_t seq) noexcept
Definition Indexes.cpp:564
Keylet page(uint256 const &root, std::uint64_t index=0) noexcept
A page in a directory.
Definition Indexes.cpp:362
Keylet credential(AccountID const &subject, AccountID const &issuer, Slice const &credType) noexcept
Definition Indexes.cpp:535
Keylet xChainClaimID(STXChainBridge const &bridge, std::uint64_t seq)
Definition Indexes.cpp:468
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
uint256 getTicketIndex(AccountID const &account, std::uint32_t uSequence)
Definition Indexes.cpp:138
std::uint64_t getQuality(uint256 const &uBase)
Definition Indexes.cpp:131
Number root(Number f, unsigned d)
Definition Number.cpp:644
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:29
base_uint< 256 > uint256
Definition base_uint.h:539
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
uint256 getQualityNext(uint256 const &uBase)
Definition Indexes.cpp:123
uint256 getBookBase(Book const &book)
Definition Indexes.cpp:98
MPTID makeMptID(std::uint32_t sequence, AccountID const &account)
Definition Indexes.cpp:152
std::array< keyletDesc< AccountID const & >, 6 > const directAccountKeylets
Definition Indexes.h:383
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:20
Json::StaticString expectedLEName
Definition Indexes.h:377
std::function< Keylet(keyletParams...)> function
Definition Indexes.h:376
bool includeInTests
Definition Indexes.h:378
The beginning of an order book.
Definition Indexes.h:80
Keylet operator()(Book const &b) const
Definition Indexes.cpp:220
The directory for the next lower quality.
Definition Indexes.h:127
Keylet operator()(Keylet const &k) const
Definition Indexes.cpp:281
A ticket belonging to an account.
Definition Indexes.h:137
Keylet operator()(uint256 const &key) const
Definition Indexes.h:147
Keylet operator()(AccountID const &id, std::uint32_t ticketSeq) const
Definition Indexes.cpp:290