Class AssetIdentity
Case-correct identity comparisons for currency codes and issuer addresses, for code that prices, routes or matches assets (quotes, books, pools, trust lines).
Inheritance
Namespace: Xrpl.Models.Common
Assembly: Xrpl.dll
Syntax
public static class AssetIdentity
Remarks
Ledger rules this type encodes:
-
A 3-character (or otherwise non-hex) currency code is case-sensitive: "XPM", "xpm" and
"Xpm" are three tokens, possibly with the same issuer. The exact code "XRP" is reserved for
native XRP, so an issued currency cannot use it (the JSON code "XRP" is parsed as native, and
the hex form of ASCII "XRP" is refused with
temBAD_CURRENCY); an ordinal match on "XRP" therefore identifies native XRP, and a lowercase "xrp" IOU is a different, legal asset. - A 40-character hex code (a non-standard currency name, or an LP token starting with "03") is the hex rendering of 20 bytes. "58504D..." and "58504d..." are the same token; sources differ in hex casing, so two hex codes compare case-insensitively.
- An issuer is a base58 address and compares ordinally.
These rules hold for codes in the canonical form the node returns. The 3-character code "USD"
and its 40-digit standard-code hex form are the same currency on the ledger, but
CurrencyEquals(string, string) returns false for them, and IsXrp of an all-zero
40-digit code is false although the ledger reads that as native XRP. MPT issuance ids
are not compared here.
User-facing search and filter inputs (a token picker's name filter) should stay case-insensitive; this type is for identity, not search.
The three IsXrp variants treat the issuer differently: Currency.IsXrp() requires
Issuer == null, IsXrp(string, string) requires it null, empty or whitespace,
and IssuedCurrency.IsXrp() does not look at the code at all (no issuer and no MPT id).
Methods
| Edit this page View SourceAssetEquals(string, string, string, string)
Whether two assets are the same: CurrencyEquals(string, string) on the codes and IssuerEquals(string, string) on the issuers. A null, empty or whitespace issuer is the empty issuer, so two native-XRP assets are equal however they spell "no issuer".
Declaration
public static bool AssetEquals(string codeA, string issuerA, string codeB, string issuerB)
Parameters
| Type | Name | Description |
|---|---|---|
| string | codeA | |
| string | issuerA | |
| string | codeB | |
| string | issuerB |
Returns
| Type | Description |
|---|---|
| bool |
CurrencyEquals(string, string)
Whether two currency codes are the same currency: two 40-digit hex codes compare case-insensitively, anything else ordinally (a hex code never equals a non-hex code).
Declaration
public static bool CurrencyEquals(string a, string b)
Parameters
| Type | Name | Description |
|---|---|---|
| string | a | |
| string | b |
Returns
| Type | Description |
|---|---|
| bool |
IsHexCurrencyCode(string)
Whether code is exactly 40 hex digits in either case: a non-standard
currency code or an LP token.
Declaration
public static bool IsHexCurrencyCode(string code)
Parameters
| Type | Name | Description |
|---|---|---|
| string | code |
Returns
| Type | Description |
|---|---|
| bool |
Remarks
Accepts null (a code read from a DTO may be absent) and scans the string instead
of using a regular expression, because asset comparison runs per candidate while routes
are enumerated.
IsXrp(string)
Whether code is exactly "XRP", compared ordinally (case-sensitive: "xrp"
does not match). The exact code is reserved for native XRP, so an issued currency cannot use
it and the code alone identifies native XRP; "xrp" and "Xrp" are legal IOU codes.
Declaration
public static bool IsXrp(string code)
Parameters
| Type | Name | Description |
|---|---|---|
| string | code |
Returns
| Type | Description |
|---|---|
| bool |
IsXrp(string, string)
IsXrp(string) that also requires an empty issuer. Native XRP has none, so "XRP" next to an issuer is malformed input and not an asset.
Declaration
public static bool IsXrp(string code, string issuer)
Parameters
| Type | Name | Description |
|---|---|---|
| string | code | |
| string | issuer |
Returns
| Type | Description |
|---|---|
| bool |
IssuerEquals(string, string)
Whether two issuer addresses are the same account. Ordinal: a classic address has no case-insensitive form.
Declaration
public static bool IssuerEquals(string a, string b)
Parameters
| Type | Name | Description |
|---|---|---|
| string | a | |
| string | b |
Returns
| Type | Description |
|---|---|
| bool |