Show / Hide Table of Contents

Class Currency

Class defining how to encode and decode Currencies

Inheritance
object
Hash
Hash160
Currency
Implements
ISerializedType
Inherited Members
Hash.Buffer
Hash.ToBytes(IBytesSink)
Hash.ToJson()
Hash.Equals(Hash)
Namespace: Xrpl.BinaryCodec.Types
Assembly: Xrpl.BinaryCodec.dll
Syntax
public class Currency : Hash160, ISerializedType

Constructors

| Edit this page View Source

Currency(byte[])

Constructs a Currency object

Declaration
public Currency(byte[] buffer)
Parameters
Type Name Description
byte[] buffer

bytes buffer

Fields

| Edit this page View Source

IsNative

Test if this amount is in units of Native Currency(XRP)

Declaration
public readonly bool IsNative
Field Value
Type Description
bool
| Edit this page View Source

IsoCode

ISO code of this currency

Declaration
public readonly string IsoCode
Field Value
Type Description
string
| Edit this page View Source

Xrp

Native XRP Currency

Declaration
public static readonly Currency Xrp
Field Value
Type Description
Currency

Methods

| Edit this page View Source

EncodeCurrency(string)

Legacy method for standard XRPL currency encoding (bytes 12-14). Used for issued currency tokens, not Oracle PriceData.

Declaration
public static byte[] EncodeCurrency(string currencyCode)
Parameters
Type Name Description
string currencyCode

currency code

Returns
Type Description
byte[]
| Edit this page View Source

EncodeOracleCurrency(string)

Encode currency for Oracle XLS-47 format (left-aligned at bytes 0-2). This format is used for BaseAsset and QuoteAsset in PriceData objects.

Declaration
public static byte[] EncodeOracleCurrency(string currencyCode)
Parameters
Type Name Description
string currencyCode

3-letter currency code.

Returns
Type Description
byte[]

20-byte array with currency at bytes 0-2.

| Edit this page View Source

FromJson(JsonNode)

decode currency from json field

Declaration
public static Currency FromJson(JsonNode token)
Parameters
Type Name Description
JsonNode token

json field

Returns
Type Description
Currency
| Edit this page View Source

FromOracleJson(JsonNode)

Decode currency from JSON for Oracle fields (XLS-47 format). Uses left-aligned ASCII encoding for 3-letter codes.

Declaration
public static Currency FromOracleJson(JsonNode token)
Parameters
Type Name Description
JsonNode token

JSON token containing currency code.

Returns
Type Description
Currency

Currency with Oracle encoding.

| Edit this page View Source

FromOracleString(string)

Create a Currency for Oracle PriceData fields (XLS-47 format). Uses left-aligned ASCII encoding (bytes 0-2) for 3-letter codes, or direct hex for 40-character non-standard currencies. This differs from standard IOU currencies which use bytes 12-14.

Declaration
public static Currency FromOracleString(string str)
Parameters
Type Name Description
string str

Currency code (XRP, 3-letter code, or 40-hex).

Returns
Type Description
Currency

Currency with XLS-47 Oracle encoding.

| Edit this page View Source

FromParser(BinaryParser, int?)

Defines how to read a Currency from a BinaryParser

Declaration
public static Currency FromParser(BinaryParser parser, int? hint = null)
Parameters
Type Name Description
BinaryParser parser

The binary parser to read Currency

int? hint
Returns
Type Description
Currency

A Blob object

| Edit this page View Source

FromString(string)

decode currency from string

Declaration
public static Currency FromString(string str)
Parameters
Type Name Description
string str

string currency code

Returns
Type Description
Currency
Exceptions
Type Condition
InvalidOperationException
| Edit this page View Source

GetCurrencyCodeFromTlcBytes(byte[], out bool)

get currency code from bytes. Supports both standard XRPL format (bytes 12-14) and Oracle XLS-47 format (left-aligned bytes 0-2).

Declaration
public static string GetCurrencyCodeFromTlcBytes(byte[] bytes, out bool isNative)
Parameters
Type Name Description
byte[] bytes

bytes

bool isNative

will true if currency is XRP

Returns
Type Description
string
| Edit this page View Source

ToString()

hash to string value

Declaration
public override string ToString()
Returns
Type Description
string
Overrides
Hash.ToString()

Operators

| Edit this page View Source

implicit operator Currency(string)

Declaration
public static implicit operator Currency(string v)
Parameters
Type Name Description
string v
Returns
Type Description
Currency
| Edit this page View Source

implicit operator Currency(JsonNode)

Declaration
public static implicit operator Currency(JsonNode v)
Parameters
Type Name Description
JsonNode v
Returns
Type Description
Currency
| Edit this page View Source

implicit operator JsonNode(Currency)

Declaration
public static implicit operator JsonNode(Currency v)
Parameters
Type Name Description
Currency v
Returns
Type Description
JsonNode

Implements

ISerializedType

Extension Methods

StExtensions.ToDebuggedHex(ISerializedType)
StExtensions.ToHex(ISerializedType)
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX