Skip to content
Integra Protocol
API

@integraledger/lcp/xrpl

The exports of @integraledger/lcp/xrpl.

Interfaces

XrplLanded

Properties

PropertyTypeDescription
deletedChannels?readonly string[]The PayChannel DeletedNodes of the transaction's meta.
invoiceId?string-
ledgerIndex?number-
resultstringmeta.TransactionResult.
transactionTypestring-
validatedboolean-

XrplReader

Bounded, read-only calls against one network's endpoint. Every failure rejects with ReaderError.

Properties

PropertyModifierType
networkreadonly`xrpl:${number}`

Methods

tx()

tx(hash, range): Promise<XrplLanded | { notFound: true; searchedAll: boolean; }>

tx by hash, with min_ledger and max_ledger when a range is given.

Parameters
ParameterType
hashstring
range{ max: number; min: number; } | null
Returns

Promise<XrplLanded | { notFound: true; searchedAll: boolean; }>

txBlob()

txBlob(hash): Promise<string | null>

tx with binary: true: the signed blob, for credentials that name only a hash.

Parameters
ParameterType
hashstring
Returns

Promise<string | null>

validatedLedger()

validatedLedger(): Promise<number>

ledger validated → ledger_index.

Returns

Promise<number>


XrplRef

The read keys recorded at claim.

Properties

PropertyType
expectstring
fromLedgernumber
lastLedgerSequencenumber | null
network`xrpl:${number}`
transactionstring

XrplTxJson

Indexable

[field: string]: unknown

Properties

PropertyType
Accountstring
InvoiceID?string
LastLedgerSequence?number
Memos?unknown
TransactionTypestring

XrplUnsigned

What the wallet signs, and how its signed blob completes the payment.

Type Parameters

Type Parameter
P

Properties

PropertyType
requestobject
request.kind"xrpl-tx"
request.txJsonXrplTxJson

Methods

complete()

complete(signedBlob): Refusal | P

Parameters
ParameterType
signedBlobstring
Returns

Refusal | P

Type Aliases

XrplCloseRef

XrplCloseRef = object

Properties

PropertyType
channelstring
networkXrplNetwork
phase"close"
transactionstring

XrplCloseStatus

XrplCloseStatus = { ledgerIndex: number; state: "settled"; } | { state: "pending"; why: "not-found" | "not-validated" | "unreadable"; } | { state: "failed"; why: "not-a-close"; }


XrplNetwork

XrplNetwork = `xrpl:${number}`

CAIP-2: xrpl: and the chain's NetworkID, 0 to 4294967295.


XrplStatus

XrplStatus = { ledgerIndex: number; state: "settled"; } | { state: "pending"; why: "not-found" | "not-validated" | "unreadable"; } | { state: "failed"; why: "expired" | "claimed-fee" | "not-this-instrument"; }

Variables

XRPL_MAX_DEPTH

const XRPL_MAX_DEPTH: 64 = 64

The deepest nesting of STObject and STArray fields inside a transaction: an object or array field one level below its container, and an array's member object one level below the array.


XRPL_MAX_FIELDS

const XRPL_MAX_FIELDS: number

The most fields, counting array members, that one blob may hold. Every field takes at least its one-byte header, so no blob within MAX_BLOB_HEX holds more.

Functions

cancelAfterOf()

cancelAfterOf(blobHex): number | undefined

The CancelAfter (field 36 of type UInt32) of a signed blob, read from the canonical field order: every UInt16 field, then every UInt32 field in field-code order, precede all others. Undefined when the blob has none.

Parameters

ParameterType
blobHexstring

Returns

number | undefined


decodeBlob()

decodeBlob(hex): Promise<Refusal | { hash: string; tx: XrplTxJson; }>

Decodes a signed blob of at most 4 KiB of hex, and computes its transaction hash as the ledger does: SHA-512Half over 54584E00 and the blob, in upper case. The blob must be the canonical serialization of what it decodes to: the codec's encoding of the decoded fields gives back the same bytes, so nothing follows a top-level end marker and every array member is an object.

Parameters

ParameterType
hexstring

Returns

Promise<Refusal | { hash: string; tx: XrplTxJson; }>


mppInvoiceId()

mppInvoiceId(h): string

The hash's 64 hex digits in upper case, without 0x: MPP's methodDetails.invoiceId.

Parameters

ParameterType
h`0x${string}`

Returns

string


x402InvoiceId()

x402InvoiceId(h): Promise<string>

Uppercase hex of SHA-256 over the UTF-8 bytes of the hash's LCP string: x402's InvoiceID for extra.invoiceId.

Parameters

ParameterType
h`0x${string}`

Returns

Promise<string>


xrplChannelId()

xrplChannelId(account, destination, sequence): string | Refusal

The PayChannel id: SHA-512Half of 0x0078 ‖ the source's AccountID ‖ the destination's AccountID ‖ the creating transaction's sequence (or ticket sequence), big-endian; upper-case hex. A malformed address or sequence is xrpl/not-channel-create.

Parameters

ParameterType
accountstring
destinationstring
sequencenumber

Returns

string | Refusal


xrplClaim()

xrplClaim(channelId, drops): Uint8Array<ArrayBufferLike> | Refusal

The bytes a channel claim signs: CLM\0 ‖ channel id (32 bytes) ‖ drops as u64 big-endian.

Parameters

ParameterType
channelIdstring
dropsbigint

Returns

Uint8Array<ArrayBufferLike> | Refusal


xrplCloseStatus()

xrplCloseStatus(ref, reader): Promise<XrplCloseStatus>

Reads a reported close: validated with the channel among the transaction's deleted PayChannel entries is settled; validated without it is failed not-a-close; otherwise pending. One call.

Parameters

ParameterType
refXrplCloseRef
readerXrplReader

Returns

Promise<XrplCloseStatus>


xrplOpenStatus()

xrplOpenStatus(ref, reader): Promise<XrplStatus>

Reads an opening by the hash computed from its signed blob: settled only when a validated ledger holds it with tesSUCCESS as a PaymentChannelCreate; tec codes are final failures that claimed the fee; past LastLedgerSequence with the whole range searched it expired. A failed read is pending. At most two calls.

Parameters

ParameterType
refOmit<XrplRef, "expect">
readerXrplReader

Returns

Promise<XrplStatus>


xrplStatus()

xrplStatus(ref, reader): Promise<XrplStatus>

Reads a transaction by the hash computed from its signed blob. Settled only when a validated ledger holds it with tesSUCCESS as a Payment whose InvoiceID is the one expected; tec codes are final failures that claimed the fee; past LastLedgerSequence with the whole range searched it expired. A failed read is pending. At most two calls.

Parameters

ParameterType
refXrplRef
readerXrplReader

Returns

Promise<XrplStatus>

Last updated on

On this page