1#include <xrpl/protocol/Indexes.h>
3#include <xrpl/basics/Slice.h>
4#include <xrpl/basics/base_uint.h>
5#include <xrpl/basics/safe_cast.h>
6#include <xrpl/beast/utility/instrumentation.h>
7#include <xrpl/protocol/AccountID.h>
8#include <xrpl/protocol/Asset.h>
9#include <xrpl/protocol/Book.h>
10#include <xrpl/protocol/Concepts.h>
11#include <xrpl/protocol/Issue.h>
12#include <xrpl/protocol/LedgerFormats.h>
13#include <xrpl/protocol/MPTIssue.h>
14#include <xrpl/protocol/Protocol.h>
15#include <xrpl/protocol/SField.h>
16#include <xrpl/protocol/STXChainBridge.h>
17#include <xrpl/protocol/SeqProxy.h>
18#include <xrpl/protocol/UintTypes.h>
19#include <xrpl/protocol/digest.h>
20#include <xrpl/protocol/nftPageMask.h>
22#include <boost/endian/conversion.hpp>
94template <
class... Args>
104 XRPL_ASSERT(
isConsistent(book),
"xrpl::getBookBase : input is consistent");
106 auto getIndexHash = [&book]<
typename... Args>(Args... args) {
146 static constexpr uint256 kNextQuality(
147 "0000000000000000000000000000000000000000000000010000000000000000");
148 return uBase + kNextQuality;
167 XRPL_ASSERT(ticketSeq.
isTicket(),
"xrpl::getTicketIndex : valid input");
175 sequence = boost::endian::native_to_big(sequence);
176 memcpy(u.
data(), &sequence,
sizeof(sequence));
177 memcpy(u.
data() +
sizeof(sequence), account.data(),
sizeof(account));
272 XRPL_ASSERT(k.type == ltDIR_NODE,
"xrpl::keylet::quality : valid input type");
284 return {ltDIR_NODE, x};
290 XRPL_ASSERT(k.
type == ltDIR_NODE,
"xrpl::keylet::next : valid input type");
340 hashes.
reserve(authCreds.size());
341 for (
auto const& o : authCreds)
366 return {ltDIR_NODE, key};
396 return {ltNFTOKEN_PAGE,
id};
402 XRPL_ASSERT(k.
type == ltNFTOKEN_PAGE,
"xrpl::keylet::nftokenPage : valid input type");
427 auto const& [minA, maxA] =
std::minmax(asset1, asset2);
476 auto const& issue =
bridge.issue(chainType);
484 ltXCHAIN_OWNED_CLAIM_ID,
487 bridge.lockingChainDoor(),
488 bridge.lockingChainIssue(),
489 bridge.issuingChainDoor(),
490 bridge.issuingChainIssue(),
498 ltXCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID,
501 bridge.lockingChainDoor(),
502 bridge.lockingChainIssue(),
503 bridge.issuingChainDoor(),
504 bridge.issuingChainIssue(),
577 return {ltPERMISSIONED_DOMAIN, domainID};
static BaseUInt fromRaw(Container const &c)
static constexpr std::size_t size()
A type that represents either a sequence value or a ticket value.
constexpr bool isTicket() const
constexpr std::uint32_t value() const
An immutable linear range of bytes.
T emplace_back(T... args)
Keylet const & skip() noexcept
The index of the "short" skip list.
Keylet quality(Keylet const &k, std::uint64_t q) noexcept
The initial directory page for a specific quality.
Keylet next(Keylet const &k)
The directory for the next lower quality.
Keylet ticket(AccountID const &id, std::uint32_t ticketSeq)
A ticket belonging to an account.
Keylet oracle(AccountID const &account, std::uint32_t const &documentID) noexcept
Keylet loanBroker(AccountID const &owner, std::uint32_t seq) noexcept
Keylet const & negativeUNL() noexcept
The (fixed) index of the object containing the ledger negativeUNL.
Keylet did(AccountID const &account) noexcept
Keylet unchecked(uint256 const &key) noexcept
Any ledger entry.
Keylet mptokenIssuance(std::uint32_t seq, AccountID const &issuer) noexcept
Keylet depositPreauth(AccountID const &owner, AccountID const &preauthorized) noexcept
A DepositPreauth.
Keylet book(Book const &b)
The beginning of an order book.
Keylet escrow(AccountID const &src, std::uint32_t seq) noexcept
An escrow entry.
Keylet bridge(STXChainBridge const &bridge, STXChainBridge::ChainType chainType)
Keylet const & feeSettings() noexcept
The (fixed) index of the object containing the ledger fees.
Keylet payChannel(AccountID const &src, AccountID const &dst, std::uint32_t seq) noexcept
A PaymentChannel.
Keylet const & amendments() noexcept
The index of the amendment table.
Keylet signerList(AccountID const &account) noexcept
A SignerList.
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Keylet check(AccountID const &id, std::uint32_t seq) noexcept
A Check.
Keylet amm(Asset const &issue1, Asset const &issue2) noexcept
AMM entry.
Keylet nftokenPageMin(AccountID const &owner)
NFT page keylets.
Keylet loan(uint256 const &loanBrokerID, std::uint32_t loanSeq) noexcept
Keylet offer(AccountID const &id, std::uint32_t seq) noexcept
An offer from an account.
Keylet child(uint256 const &key) noexcept
Any item that can be in an owner dir.
Keylet nftokenPage(Keylet const &k, uint256 const &token)
Keylet vault(AccountID const &owner, std::uint32_t seq) noexcept
Keylet nftokenPageMax(AccountID const &owner)
A keylet for the owner's last possible NFT page.
Keylet xChainCreateAccountClaimID(STXChainBridge const &bridge, std::uint64_t seq)
Keylet mptoken(MPTID const &issuanceID, AccountID const &holder) noexcept
Keylet nftSells(uint256 const &id) noexcept
The directory of sell offers for the specified NFT.
Keylet nftBuys(uint256 const &id) noexcept
The directory of buy offers for the specified NFT.
Keylet delegate(AccountID const &account, AccountID const &authorizedAccount) noexcept
A keylet for Delegate object.
Keylet account(AccountID const &id) noexcept
AccountID root.
Keylet permissionedDomain(AccountID const &account, std::uint32_t seq) noexcept
Keylet page(uint256 const &root, std::uint64_t index=0) noexcept
A page in a directory.
Keylet credential(AccountID const &subject, AccountID const &issuer, Slice const &credType) noexcept
Keylet xChainClaimID(STXChainBridge const &bridge, std::uint64_t seq)
Keylet nftokenOffer(AccountID const &owner, std::uint32_t seq)
An offer from an account to buy or sell an NFT.
Keylet trustLine(AccountID const &id0, AccountID const &id1, Currency const ¤cy) noexcept
The index of a trust line for a given currency.
constexpr uint256 kPageMask(std::string_view("0000000000000000000000000000000000000000ffffffffffffffffffffffff"))
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
sha512_half_hasher::result_type sha512Half(Args const &... args)
Returns the SHA512-Half of a series of objects.
std::uint32_t LedgerIndex
A ledger index.
uint256 getTicketIndex(AccountID const &account, std::uint32_t uSequence)
constexpr std::enable_if_t< std::is_integral_v< Dest > &&std::is_integral_v< Src >, Dest > safeCast(Src s) noexcept
std::uint64_t getQuality(uint256 const &uBase)
BaseUInt< 160, detail::CurrencyTag > Currency
Currency is a hash representing a specific currency.
static uint256 indexHash(LedgerNameSpace space, Args const &... args)
uint256 getQualityNext(uint256 const &uBase)
BaseUInt< 192 > MPTID
MPTID is a 192-bit value representing MPT Issuance ID, which is a concatenation of a 32-bit sequence ...
LedgerNameSpace
Type-specific prefix for calculating ledger indices.
@ XchainCreateAccountClaimId
@ DepositPreauthCredentials
uint256 getBookBase(Book const &book)
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
bool isConsistent(Asset const &asset)
@ ltANY
A special type, matching any ledger entry type.
@ ltCHILD
A special type, matching any ledger type except directory nodes.
MPTID makeMptID(std::uint32_t sequence, AccountID const &account)
A pair of SHAMap key and LedgerEntryType.