DirectoryNode
The DirectoryNode
ledger entry type provides a list of links to other entries in the ledger's state data. A single conceptual Directory takes the form of a doubly linked list, with one or more DirectoryNode entries each containing up to 32 IDs of other entries. The first DirectoryNode entry is called the root of the directory, and all entries other than the root can be added or deleted as necessary.
There are three kinds of directory:
- Owner directories list other entries owned by an account, such as
RippleState
(trust line) orOffer
entries. - Offer directories list the offers available in the decentralized exchange. A single Offer directory contains all the offers that have the same exchange rate for the same token (currency code and issuer).
- NFT Offer directories list buy and sell offers for NFTs. Each NFT has up to two directories, one for buy offers, the other for sell offers.
Example DirectoryNode JSON
{ "ExchangeRate": "4e133c40576f7c00", "Flags": 0, "Indexes": [ "353E55E7A0B0E82D16DF6E748D48BDAFE4C56045DF5A8B0ED723FF3C38A4787A" ], "LedgerEntryType": "DirectoryNode", "PreviousTxnID": "0F79E60C8642A23658ECB29D939499EA0F28D804077B7EE16613BE0C813A2DD6", "PreviousTxnLgrSeq": 91448326, "RootIndex": "79C54A4EBD69AB2EADCE313042F36092BE432423CC6A4F784E133C40576F7C00", "TakerGetsCurrency": "0000000000000000000000000000000000000000", "TakerGetsIssuer": "0000000000000000000000000000000000000000", "TakerPaysCurrency": "0000000000000000000000005553440000000000", "TakerPaysIssuer": "2ADB0B3959D60A6E6991F729E1918B7163925230", "index": "79C54A4EBD69AB2EADCE313042F36092BE432423CC6A4F784E133C40576F7C00" }
DirectoryNode Fields
Name | JSON Type | Internal Type | Required? | Description |
---|---|---|---|---|
ExchangeRate | String | UInt64 | No | (Offer directories only) DEPRECATED. Do not use. |
Flags | Number | UInt32 | Yes | A bit-map of boolean flags enabled for this object. Currently, the protocol defines no flags for DirectoryNode objects. The value is always 0 . |
Indexes | Array | Vector256 | Yes | The contents of this directory: an array of IDs of other objects. |
IndexNext | Number | UInt64 | No | If this directory consists of multiple pages, this ID links to the next object in the chain, wrapping around at the end. |
IndexPrevious | Number | UInt64 | No | If this directory consists of multiple pages, this ID links to the previous object in the chain, wrapping around at the beginning. |
LedgerEntryType | String | UInt16 | Yes | The value 0x0064 , mapped to the string DirectoryNode , indicates that this object is part of a directory. |
NFTokenID | String | Hash256 | No | (NFT offer directories only) ID of the NFT in a buy or sell offer. |
Owner | String | AccountID | No | (Owner directories only) The address of the account that owns the objects in this directory. |
PreviousTxnID | String | Hash256 | No | The identifying hash of the transaction that most recently modified this entry. (Added by the fixPreviousTxnID amendment.) |
PreviousTxnLgrSeq | Number | UInt32 | No | The index of the ledger that contains the transaction that most recently modified this entry. (Added by the fixPreviousTxnID amendment.) |
RootIndex | String | Hash256 | Yes | The ID of root object for this directory. |
TakerGetsCurrency | String | Hash160 | No | (Offer directories only) The currency code of the TakerGets amount from the offers in this directory. |
TakerGetsIssuer | String | Hash160 | No | (Offer directories only) The issuer of the TakerGets amount from the offers in this directory. |
TakerPaysCurrency | String | Hash160 | No | (Offer directories only) The currency code of the TakerPays amount from the offers in this directory. |
TakerPaysIssuer | String | Hash160 | No | (Offer directories only) The issuer of the TakerPays amount from the offers in this directory. |
DirectoryNode Flags
DirectoryNode
entries can have the following values in the Flags
field:
Flag Name | Hex Value | Decimal Value | Description |
---|---|---|---|
lsfNFTokenBuyOffers | 0x00000001 | 1 | This directory contains NFT buy offers. |
lsfNFTokenSellOffers | 0x00000002 | 2 | This directory contains NFT sell offers. |
Owner directories and offer directories for fungible tokens do not use flags; their Flags
value is always 0.
DirectoryNode Reserve
DirectoryNode
entries do not require a reserve.
Directory ID Formats
There are three different formulas for creating the ID of a DirectoryNode, depending on which of the following the DirectoryNode represents:
- The first page (also called the root) of an Owner or NFT Offer directory
- The first page of an Offer directory
- Later pages of either type
The first page of an Owner directory or NFT Offer directory has an ID that is the SHA-512Half of the following values, concatenated in order:
- The Owner directory space key (
0x004F
) - The AccountID from the
Owner
field.
The first page of an Offer directory has a special ID: the higher 192 bits define the order book, and the remaining 64 bits define the exchange rate of the offers in that directory. (The ID is big-endian, so the book is in the more significant bits, which come first, and the quality is in the less significant bits which come last.) This provides a way to iterate through an order book from best offers to worst. Specifically: the first 192 bits are the first 192 bits of the SHA-512Half of the following values, concatenated in order:
- The Book directory space key (
0x0042
) - The 160-bit currency code from the
TakerPaysCurrency
- The 160-bit currency code from the
TakerGetsCurrency
- The AccountID from the
TakerPaysIssuer
- The AccountID from the
TakerGetsIssuer
The lower 64 bits of an Offer directory's ID represent the TakerPays
amount divided by TakerGets
amount from the offer(s) in that directory as a 64-bit number in the XRP Ledger's internal amount format.
If the DirectoryNode is not the first page in the directory, it has an ID that is the SHA-512Half of the following values, concatenated in order:
- The DirectoryNode space key (
0x0064
) - The ID of the root DirectoryNode
- The page number of this object. (Since 0 is the root DirectoryNode, this value is an integer 1 or higher.)