Show / Hide Table of Contents

Class CurrencyExtensions

Inheritance
object
CurrencyExtensions
Namespace: Xrpl.Models.Common
Assembly: Xrpl.dll
Syntax
public static class CurrencyExtensions

Methods

| Edit this page View Source

CurrencyReadableName(string)

get readable token code

Declaration
public static string CurrencyReadableName(this string currencyCode)
Parameters
Type Name Description
string currencyCode

token code

Returns
Type Description
string

readable token code

| Edit this page View Source

GetValue(Currency, int?)

Returns the human-readable value of this currency amount. For XRP, returns the value in XRP (drops / 1,000,000). For tokens, returns the raw numeric value.

Declaration
public static decimal? GetValue(this Currency currency, int? round = null)
Parameters
Type Name Description
Currency currency

The currency to get the value from.

int? round

Optional number of decimal places to round to.

Returns
Type Description
decimal?

The decimal value, or null if the currency is null.

| Edit this page View Source

IsLpToken(string)

Declaration
public static bool IsLpToken(this string currencyCode)
Parameters
Type Name Description
string currencyCode
Returns
Type Description
bool
| Edit this page View Source

IsLpToken(Currency)

Declaration
public static bool IsLpToken(this Currency currency)
Parameters
Type Name Description
Currency currency
Returns
Type Description
bool
| Edit this page View Source

IsLpToken(TrustLine)

Declaration
public static bool IsLpToken(this TrustLine currency)
Parameters
Type Name Description
TrustLine currency
Returns
Type Description
bool
| Edit this page View Source

IsMPTToken(Currency)

Whether this amount is a multi-purpose token - that is, whether it carries an issuance id.

Declaration
public static bool IsMPTToken(this Currency currency)
Parameters
Type Name Description
Currency currency
Returns
Type Description
bool
Remarks

An issuance id is what distinguishes a multi-purpose token from every other kind of amount, so this is exclusive with IsXrp(Currency) and with an issued currency: an amount is at most one of the three.

| Edit this page View Source

IsNFT14D(Currency)

check that currency is NFT XLS14D

Declaration
public static bool IsNFT14D(this Currency cur)
Parameters
Type Name Description
Currency cur
Returns
Type Description
bool
| Edit this page View Source

IsXrp(Currency)

Determines whether this currency represents XRP. A currency is XRP if its code is exactly "XRP" (case-sensitive) and it has no issuer.

Declaration
public static bool IsXrp(this Currency currency)
Parameters
Type Name Description
Currency currency

The currency to check.

Returns
Type Description
bool

true if this currency is XRP; otherwise, false.

Remarks

The comparison is ordinal because 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): "xrp" and "Xrp" are legal issued currency codes, distinct from native XRP. An issued currency always has an issuer, so a legal IOU was never reported as XRP; what changed in 11.24.0.0 is that a currency with the code "xrp" or "Xrp" and no issuer (malformed input) used to be reported as XRP because the code was upper-cased first, and now is not.

| Edit this page View Source

NormalCurrency(string)

Declaration
public static bool NormalCurrency(this string currencyCode)
Parameters
Type Name Description
string currencyCode
Returns
Type Description
bool
| Edit this page View Source

NormalizeCurrencyCode(string, int)

Declaration
public static string NormalizeCurrencyCode(this string currencyCode, int maxLength = 20)
Parameters
Type Name Description
string currencyCode
int maxLength
Returns
Type Description
string
| Edit this page View Source

ToDecimalClamped(Currency)

The amount as a decimal (drops for XRP, as ValueAsNumber reads it), saturating at decimal.MinValue or decimal.MaxValue for an amount the ledger allows but decimal cannot hold.

Declaration
public static decimal ToDecimalClamped(this Currency amount)
Parameters
Type Name Description
Currency amount

The amount, or null.

Returns
Type Description
decimal

The value; zero for a null amount or a blank Value.

Remarks

For a value that is compared or displayed, where "at least this large" is the whole question: a trust line limit against a balance, the sign of an issuer's supply. It is not for an amount that goes back to the ledger; build that from Value, which is the text as the node sent it. Everything else is read as ValueAsNumber reads it, including drops for XRP and zero for an amount below 1e-28.

Exceptions
Type Condition
FormatException

Value is not a number at all.

| Edit this page View Source

ToIssued(Currency)

The asset of this amount, without its value: currency code and issuer, or the MPT issuance ID.

Declaration
public static Common.IssuedCurrency ToIssued(this Currency currency)
Parameters
Type Name Description
Currency currency
Returns
Type Description
Common.IssuedCurrency
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX