Last updated

RippleState

[Source]

A RippleState ledger entry represents a trust line between two accounts. Each account can change its own limit and other settings, but the balance is a single shared value. A trust line that is entirely in its default state is considered the same as a trust line that does not exist and is automatically deleted.

High vs. Low Account

There can only be one RippleState entry per currency for any given pair of accounts. Since no account is privileged in the XRP Ledger, a RippleState entry sorts account addresses numerically, to ensure a canonical form. Whichever address is numerically lower when decoded is deemed the "low account" and the other is the "high account". The net balance of the trust line is stored from the low account's perspective.

The "issuer" for the balance in a trust line depends on whether the balance is positive or negative. If a RippleState entry shows a positive balance, the high account is the issuer. If the balance is negative, the low account is the issuer. Often, the issuer has its limit set to 0 and the other account has a positive limit, but this is not reliable because limits can change without affecting an existing balance.

Example RippleState JSON

{
    "Balance": {
        "currency": "USD",
        "issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
        "value": "-10"
    },
    "Flags": 393216,
    "HighLimit": {
        "currency": "USD",
        "issuer": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
        "value": "110"
    },
    "HighNode": "0000000000000000",
    "LedgerEntryType": "RippleState",
    "LowLimit": {
        "currency": "USD",
        "issuer": "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW",
        "value": "0"
    },
    "LowNode": "0000000000000000",
    "PreviousTxnID": "E3FE6EA3D48F0C2B639448020EA4F03D4F4F8FFDB243A852A0F59177921B4879",
    "PreviousTxnLgrSeq": 14090896,
    "index": "9CA88CDEDFF9252B3DE183CE35B038F57282BC9503CDFA1923EF9A95DF0D6F7B"
}

RippleState Fields

In addition to the common fields, RippleState entries have the following fields:

NameJSON TypeInternal TypeRequired?Description
BalanceObjectAmountYesThe balance of the trust line, from the perspective of the low account. A negative balance indicates that the high account holds tokens issued by the low account. The issuer in this is always set to the neutral value ACCOUNT_ONE.
FlagsNumberUInt32YesA bit-map of boolean options enabled for this entry.
HighLimitObjectAmountYesThe limit that the high account has set on the trust line. The issuer is the address of the high account that set this limit.
HighNodeStringUInt64Yes(Omitted in some historical ledgers) A hint indicating which page of the high account's owner directory links to this entry, in case the directory consists of multiple pages.
HighQualityInNumberUInt32NoThe inbound quality set by the high account, as an integer in the implied ratio HighQualityIn:1,000,000,000. As a special case, the value 0 is equivalent to 1 billion, or face value.
HighQualityOutNumberUInt32NoThe outbound quality set by the high account, as an integer in the implied ratio HighQualityOut:1,000,000,000. As a special case, the value 0 is equivalent to 1 billion, or face value.
LedgerEntryTypeStringUInt16YesThe value 0x0072, mapped to the string RippleState, indicates that this is a RippleState entry.
LowLimitObjectAmountYesThe limit that the low account has set on the trust line. The issuer is the address of the low account that set this limit.
LowNodeStringUInt64Yes(Omitted in some historical ledgers) A hint indicating which page of the low account's owner directory links to this entry, in case the directory consists of multiple pages.
LowQualityInNumberUInt32NoThe inbound quality set by the low account, as an integer in the implied ratio LowQualityIn:1,000,000,000. As a special case, the value 0 is equivalent to 1 billion, or face value.
LowQualityOutNumberUInt32NoThe outbound quality set by the low account, as an integer in the implied ratio LowQualityOut:1,000,000,000. As a special case, the value 0 is equivalent to 1 billion, or face value.
PreviousTxnIDStringHash256YesThe identifying hash of the transaction that most recently modified this entry.
PreviousTxnLgrSeqNumberUInt32YesThe index of the ledger that contains the transaction that most recently modified this entry.

RippleState Flags

RippleState entries can have the following flags combined into the Flags field:

Flag NameHex ValueDecimal ValueCorresponding TrustSet FlagDescription
lsfLowReserve0x0001000065536(None)This entry contributes to the low account's owner reserve.
lsfHighReserve0x00020000131072(None)This entry contributes to the high account's owner reserve.
lsfLowAuth0x00040000262144tfSetAuthThe low account has authorized the high account to hold tokens issued by the low account.
lsfHighAuth0x00080000524288tfSetAuthThe high account has authorized the low account to hold tokens issued by the high account.
lsfLowNoRipple0x001000001048576tfSetNoRippleThe low account has disabled rippling from this trust line.
lsfHighNoRipple0x002000002097152tfSetNoRippleThe high account has disabled rippling from this trust line.
lsfLowFreeze0x004000004194304tfSetFreezeThe low account has frozen the trust line, preventing the high account from transferring the asset.
lsfHighFreeze0x008000008388608tfSetFreezeThe high account has frozen the trust line, preventing the low account from transferring the asset.

The two accounts connected by the trust line can each change their own settings with a TrustSet transaction.

RippleState Reserve

A RippleState entry counts as one item towards the owner reserve of one or both of the accounts it connects. In typical cases, the holder of a token owes a reserve and the issuer of the token does not.

Specifically, the entry counts towards an account's reserve if that account modifies a trust line to put it in a non-default state. The lsfLowReserve and lsfHighReserve flags indicate which account(s) are responsible for the owner reserve. The protocol automatically sets these flags when it modifies a trust line.

The values that count towards a trust line's non-default state are as follows:

High account responsible if...Low account responsible if...
Balance is negative (the high account holds currency)Balance is positive (the low account holds currency)
HighLimit is not 0LowLimit is not 0
LowQualityIn is not 0 and not 1000000000HighQualityIn is not 0 and not 1000000000
LowQualityOut is not 0 and not 1000000000HighQualityOut is not 0 and not 1000000000
lsfHighNoRipple flag is not in its default statelsfLowNoRipple flag is not in its default state
lsfHighFreeze flag is enabledlsfLowFreeze flag is enabled

The lsfLowAuth and lsfHighAuth flags do not count against the default state, because they cannot be disabled.

The default state of the two No Ripple flags depends on the state of the lsfDefaultRipple flag in their corresponding AccountRoot entries. If Default Ripple is disabled (the default), then the default state of the lsfNoRipple flag is enabled for all of an account's trust lines. If an account enables Default Ripple, then the lsfNoRipple flag is disabled (rippling is enabled) for an account's trust lines by default.

Note: Prior to the introduction of the Default Ripple flag in rippled version 0.27.3 (March 10, 2015), the default state for all trust lines was with both No Ripple flags disabled (rippling enabled).

The XRP Ledger uses lazy evaluation to calculate the owner reserve. This means that even if an account changes the default state of all its trust lines by changing the Default Ripple flag, that account's reserve stays the same initially. When an account modifies a trust line, the protocol re-evaluates whether that individual trust line is in its default state and should contribute to the owner reserve.

RippleState ID Format

The ID of a RippleState entry is the SHA-512Half of the following values, concatenated in order:

  • The RippleState space key (0x0072)
  • The AccountID of the low account
  • The AccountID of the high account
  • The 160-bit currency code of the trust line(s)