xrpld
Loading...
Searching...
No Matches
Indexes.h
1#pragma once
2
3#include <xrpl/basics/base_uint.h>
4#include <xrpl/protocol/Book.h>
5#include <xrpl/protocol/Keylet.h>
6#include <xrpl/protocol/LedgerFormats.h>
7#include <xrpl/protocol/Protocol.h>
8#include <xrpl/protocol/PublicKey.h>
9#include <xrpl/protocol/STXChainBridge.h>
10#include <xrpl/protocol/Serializer.h>
11#include <xrpl/protocol/UintTypes.h>
12#include <xrpl/protocol/jss.h>
13
14#include <cstdint>
15#include <set>
16
17namespace xrpl {
18
19class SeqProxy;
34namespace keylet {
35
38account(AccountID const& id) noexcept;
39
41Keylet const&
42amendments() noexcept;
43
46child(uint256 const& key) noexcept;
47
53Keylet const&
54skip() noexcept;
55
67skip(LedgerIndex ledger) noexcept;
68
70Keylet const&
71feeSettings() noexcept;
72
74Keylet const&
75negativeUNL() noexcept;
76
79book(Book const& b);
80
90trustLine(AccountID const& id0, AccountID const& id1, Currency const& currency) noexcept;
91
92inline Keylet
93trustLine(AccountID const& id, Issue const& issue) noexcept
94{
95 return trustLine(id, issue.account, issue.currency);
96}
97
98
101Keylet
102offer(AccountID const& id, std::uint32_t seq) noexcept;
103
104inline Keylet
105offer(uint256 const& key) noexcept
106{
107 return {ltOFFER, key};
108}
109
110
112Keylet
113quality(Keylet const& k, std::uint64_t q) noexcept;
114
116Keylet
117next(Keylet const& k);
118
121Keylet
122ticket(AccountID const& id, std::uint32_t ticketSeq);
123
124Keylet
125ticket(AccountID const& id, SeqProxy ticketSeq);
126
127inline Keylet
128ticket(uint256 const& key)
129{
130 return {ltTICKET, key};
131}
132
133
135Keylet
136signerList(AccountID const& account) noexcept;
137
140Keylet
141check(AccountID const& id, std::uint32_t seq) noexcept;
142
143inline Keylet
144check(uint256 const& key) noexcept
145{
146 return {ltCHECK, key};
147}
148
149
152Keylet
153depositPreauth(AccountID const& owner, AccountID const& preauthorized) noexcept;
154
155Keylet
157 AccountID const& owner,
158 std::set<std::pair<AccountID, Slice>> const& authCreds) noexcept;
159
160inline Keylet
161depositPreauth(uint256 const& key) noexcept
162{
163 return {ltDEPOSIT_PREAUTH, key};
164}
165
166
167//------------------------------------------------------------------------------
168
170Keylet
171unchecked(uint256 const& key) noexcept;
172
174Keylet
175ownerDir(AccountID const& id) noexcept;
176
179Keylet
180page(uint256 const& root, std::uint64_t index = 0) noexcept;
181
182inline Keylet
183page(Keylet const& root, std::uint64_t index = 0) noexcept
184{
185 XRPL_ASSERT(root.type == ltDIR_NODE, "xrpl::keylet::page : valid root type");
186 return page(root.key, index);
187}
188
189
191Keylet
192escrow(AccountID const& src, std::uint32_t seq) noexcept;
193
195Keylet
196payChannel(AccountID const& src, AccountID const& dst, std::uint32_t seq) noexcept;
197
207Keylet
208nftokenPageMin(AccountID const& owner);
209
211Keylet
212nftokenPageMax(AccountID const& owner);
213
214Keylet
215nftokenPage(Keylet const& k, uint256 const& token);
217
219Keylet
220nftokenOffer(AccountID const& owner, std::uint32_t seq);
221
222inline Keylet
224{
225 return {ltNFTOKEN_OFFER, offer};
226}
227
229Keylet
230nftBuys(uint256 const& id) noexcept;
231
233Keylet
234nftSells(uint256 const& id) noexcept;
235
237Keylet
238amm(Asset const& issue1, Asset const& issue2) noexcept;
239
240Keylet
241amm(uint256 const& amm) noexcept;
242
244Keylet
245delegate(AccountID const& account, AccountID const& authorizedAccount) noexcept;
246
247Keylet
249
250// `seq` is stored as `sfXChainClaimID` in the object
251Keylet
253
254// `seq` is stored as `sfXChainAccountCreateCount` in the object
255Keylet
257
258Keylet
259did(AccountID const& account) noexcept;
260
261Keylet
262oracle(AccountID const& account, std::uint32_t const& documentID) noexcept;
263
264Keylet
265credential(AccountID const& subject, AccountID const& issuer, Slice const& credType) noexcept;
266
267inline Keylet
268credential(uint256 const& key) noexcept
269{
270 return {ltCREDENTIAL, key};
271}
272
273Keylet
274mptokenIssuance(std::uint32_t seq, AccountID const& issuer) noexcept;
275
276Keylet
277mptokenIssuance(MPTID const& issuanceID) noexcept;
278
279inline Keylet
280mptokenIssuance(uint256 const& issuanceKey)
281{
282 return {ltMPTOKEN_ISSUANCE, issuanceKey};
283}
284
285Keylet
286mptoken(MPTID const& issuanceID, AccountID const& holder) noexcept;
287
288inline Keylet
289mptoken(uint256 const& mptokenKey)
290{
291 return {ltMPTOKEN, mptokenKey};
292}
293
294Keylet
295mptoken(uint256 const& issuanceKey, AccountID const& holder) noexcept;
296
297Keylet
298vault(AccountID const& owner, std::uint32_t seq) noexcept;
299
300inline Keylet
301vault(uint256 const& vaultKey)
302{
303 return {ltVAULT, vaultKey};
304}
305
306Keylet
307loanBroker(AccountID const& owner, std::uint32_t seq) noexcept;
308
309inline Keylet
311{
312 return {ltLOAN_BROKER, key};
313}
314
315Keylet
316loan(uint256 const& loanBrokerID, std::uint32_t loanSeq) noexcept;
317
318inline Keylet
319loan(uint256 const& key)
320{
321 return {ltLOAN, key};
322}
323
324Keylet
326
327Keylet
328permissionedDomain(uint256 const& domainID) noexcept;
329} // namespace keylet
330
331// Everything below is deprecated and should be removed in favor of keylets:
332
334getBookBase(Book const& book);
335
337getQualityNext(uint256 const& uBase);
338
339// VFALCO This name could be better
341getQuality(uint256 const& uBase);
342
344getTicketIndex(AccountID const& account, std::uint32_t uSequence);
345
347getTicketIndex(AccountID const& account, SeqProxy ticketSeq);
348
349template <class... KeyletParams>
350// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
357
358// This list should include all of the keylet functions that take a single
359// AccountID parameter.
361 {{.function = &keylet::account, .expectedLEName = jss::AccountRoot, .includeInTests = false},
362 {.function = &keylet::ownerDir, .expectedLEName = jss::DirectoryNode, .includeInTests = true},
363 {.function = &keylet::signerList, .expectedLEName = jss::SignerList, .includeInTests = true},
364 // It's normally impossible to create an item at nftpage_min, but
365 // test it anyway, since the invariant checks for it.
366 {.function = &keylet::nftokenPageMin,
367 .expectedLEName = jss::NFTokenPage,
368 .includeInTests = true},
369 {.function = &keylet::nftokenPageMax,
370 .expectedLEName = jss::NFTokenPage,
371 .includeInTests = true},
372 {.function = &keylet::did, .expectedLEName = jss::DID, .includeInTests = true}}};
373
374MPTID
375makeMptID(std::uint32_t sequence, AccountID const& account);
376
377} // namespace xrpl
Lightweight wrapper to tag static string.
Definition json_value.h:44
Specifies an order book.
Definition Book.h:16
A currency issued by an account.
Definition Issue.h:13
A type that represents either a sequence value or a ticket value.
Definition SeqProxy.h:36
An immutable linear range of bytes.
Definition Slice.h:26
STL namespace.
Keylet computation functions.
Definition Indexes.h:34
Keylet const & skip() noexcept
The index of the "short" skip list.
Definition Indexes.cpp:198
Keylet quality(Keylet const &k, std::uint64_t q) noexcept
The initial directory page for a specific quality.
Definition Indexes.cpp:270
Keylet next(Keylet const &k)
The directory for the next lower quality.
Definition Indexes.cpp:288
Keylet ticket(AccountID const &id, std::uint32_t ticketSeq)
A ticket belonging to an account.
Definition Indexes.cpp:295
Keylet oracle(AccountID const &account, std::uint32_t const &documentID) noexcept
Definition Indexes.cpp:515
Keylet loanBroker(AccountID const &owner, std::uint32_t seq) noexcept
Definition Indexes.cpp:557
Keylet const & negativeUNL() noexcept
The (fixed) index of the object containing the ledger negativeUNL.
Definition Indexes.cpp:228
Keylet did(AccountID const &account) noexcept
Definition Indexes.cpp:509
Keylet unchecked(uint256 const &key) noexcept
Any ledger entry.
Definition Indexes.cpp:351
Keylet mptokenIssuance(std::uint32_t seq, AccountID const &issuer) noexcept
Definition Indexes.cpp:521
Keylet depositPreauth(AccountID const &owner, AccountID const &preauthorized) noexcept
A DepositPreauth.
Definition Indexes.cpp:328
Keylet book(Book const &b)
The beginning of an order book.
Definition Indexes.cpp:235
Keylet escrow(AccountID const &src, std::uint32_t seq) noexcept
An escrow entry.
Definition Indexes.cpp:372
Keylet bridge(STXChainBridge const &bridge, STXChainBridge::ChainType chainType)
Definition Indexes.cpp:471
Keylet const & feeSettings() noexcept
The (fixed) index of the object containing the ledger fees.
Definition Indexes.cpp:221
Keylet payChannel(AccountID const &src, AccountID const &dst, std::uint32_t seq) noexcept
A PaymentChannel.
Definition Indexes.cpp:378
Keylet const & amendments() noexcept
The index of the amendment table.
Definition Indexes.cpp:214
Keylet signerList(AccountID const &account) noexcept
A SignerList.
Definition Indexes.cpp:316
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Definition Indexes.cpp:357
Keylet check(AccountID const &id, std::uint32_t seq) noexcept
A Check.
Definition Indexes.cpp:322
Keylet amm(Asset const &issue1, Asset const &issue2) noexcept
AMM entry.
Definition Indexes.cpp:425
Keylet nftokenPageMin(AccountID const &owner)
NFT page keylets.
Definition Indexes.cpp:384
Keylet loan(uint256 const &loanBrokerID, std::uint32_t loanSeq) noexcept
Definition Indexes.cpp:563
Keylet offer(AccountID const &id, std::uint32_t seq) noexcept
An offer from an account.
Definition Indexes.cpp:264
Keylet child(uint256 const &key) noexcept
Any item that can be in an owner dir.
Definition Indexes.cpp:192
Keylet nftokenPage(Keylet const &k, uint256 const &token)
Definition Indexes.cpp:400
Keylet vault(AccountID const &owner, std::uint32_t seq) noexcept
Definition Indexes.cpp:551
Keylet nftokenPageMax(AccountID const &owner)
A keylet for the owner's last possible NFT page.
Definition Indexes.cpp:392
Keylet xChainCreateAccountClaimID(STXChainBridge const &bridge, std::uint64_t seq)
Definition Indexes.cpp:495
Keylet mptoken(MPTID const &issuanceID, AccountID const &holder) noexcept
Definition Indexes.cpp:533
Keylet nftSells(uint256 const &id) noexcept
The directory of sell offers for the specified NFT.
Definition Indexes.cpp:419
Keylet nftBuys(uint256 const &id) noexcept
The directory of buy offers for the specified NFT.
Definition Indexes.cpp:413
Keylet delegate(AccountID const &account, AccountID const &authorizedAccount) noexcept
A keylet for Delegate object.
Definition Indexes.cpp:465
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition Indexes.cpp:186
Keylet permissionedDomain(AccountID const &account, std::uint32_t seq) noexcept
Definition Indexes.cpp:569
Keylet page(uint256 const &root, std::uint64_t index=0) noexcept
A page in a directory.
Definition Indexes.cpp:363
Keylet credential(AccountID const &subject, AccountID const &issuer, Slice const &credType) noexcept
Definition Indexes.cpp:545
Keylet xChainClaimID(STXChainBridge const &bridge, std::uint64_t seq)
Definition Indexes.cpp:481
Keylet nftokenOffer(AccountID const &owner, std::uint32_t seq)
An offer from an account to buy or sell an NFT.
Definition Indexes.cpp:407
Keylet trustLine(AccountID const &id0, AccountID const &id1, Currency const &currency) noexcept
The index of a trust line for a given currency.
Definition Indexes.cpp:241
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
std::uint32_t LedgerIndex
A ledger index.
Definition Protocol.h:259
uint256 getTicketIndex(AccountID const &account, std::uint32_t uSequence)
Definition Indexes.cpp:159
std::uint64_t getQuality(uint256 const &uBase)
Definition Indexes.cpp:152
std::array< KeyletDesc< AccountID const & >, 6 > const kDirectAccountKeylets
Definition Indexes.h:360
BaseUInt< 160, detail::CurrencyTag > Currency
Currency is a hash representing a specific currency.
Definition UintTypes.h:36
Number root(Number f, unsigned d)
Definition Number.cpp:1201
uint256 getQualityNext(uint256 const &uBase)
Definition Indexes.cpp:144
BaseUInt< 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
uint256 getBookBase(Book const &book)
Definition Indexes.cpp:102
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:28
BaseUInt< 256 > uint256
Definition base_uint.h:562
MPTID makeMptID(std::uint32_t sequence, AccountID const &account)
Definition Indexes.cpp:172
bool includeInTests
Definition Indexes.h:355
std::function< Keylet(KeyletParams...)> function
Definition Indexes.h:353
json::StaticString expectedLEName
Definition Indexes.h:354
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:19