Options
All
  • Public
  • Public/Protected
  • All
Menu

xrpl

Index

Clients

Transaction Models

Transaction Flags

Utilities

Requests

Responses

Errors

Offline Signing

Other

Streams

Utilities

isValidSecret

  • isValidSecret(secret: string): boolean
  • Check if a secret is valid.

    Parameters

    • secret: string

      Secret to test for validity.

    Returns boolean

    True if secret can be derived into a keypair.

Requests

PathFindRequest

PathFindRequest: PathFindCreateRequest | PathFindCloseRequest | PathFindStatusRequest

The path_find method searches for a path along which a transaction can possibly be made, and periodically sends updates when the path changes over time. For a simpler version that is supported by JSON-RPC, see the ripple_path_find method.

Request

Responses

Response

Other

Transaction

deriveKeypair

deriveKeypair: (seed: string, options?: object) => { privateKey: string; publicKey: string }

Type declaration

    • (seed: string, options?: object): { privateKey: string; publicKey: string }
    • Parameters

      • seed: string
      • Optional options: object

      Returns { privateKey: string; publicKey: string }

      • privateKey: string
      • publicKey: string

Const hashes

hashes: { hashAccountRoot: (address: string) => string; hashEscrow: (address: string, sequence: number) => string; hashLedger: (ledger: Ledger, options?: HashLedgerHeaderOptions) => string; hashLedgerHeader: (ledgerHeader: Ledger) => string; hashOfferId: (address: string, sequence: number) => string; hashPaymentChannel: (address: string, dstAddress: string, sequence: number) => string; hashSignedTx: (tx: Transaction | string) => string; hashSignerListId: (address: string) => string; hashStateTree: (entries: LedgerEntry[]) => string; hashTrustline: (address1: string, address2: string, currency: string) => string; hashTx: (txBlobHex: string) => string; hashTxTree: (transactions: (Transaction & { metaData?: Metadata })[]) => string } = ...

Type declaration

  • hashAccountRoot: (address: string) => string
      • (address: string): string
      • Compute AccountRoot Ledger Object Index.

        All objects in a ledger's state tree have a unique Index. The AccountRoot Ledger Object Index is derived by hashing the address with a namespace identifier. This ensures every Index is unique.

        See Ledger Object Indexes.

        Parameters

        • address: string

          The classic account address.

        Returns string

        The Ledger Object Index for the account.

  • hashEscrow: (address: string, sequence: number) => string
      • (address: string, sequence: number): string
      • Compute the Hash of an Escrow LedgerEntry.

        Parameters

        • address: string

          Address of the Escrow.

        • sequence: number

          OfferSequence of the Escrow.

        Returns string

        The hash of the Escrow LedgerEntry.

  • hashLedger: (ledger: Ledger, options?: HashLedgerHeaderOptions) => string
      • (ledger: Ledger, options?: HashLedgerHeaderOptions): string
      • Compute the hash of a ledger.

        Parameters

        • ledger: Ledger

          Ledger to compute the hash for.

        • options: HashLedgerHeaderOptions = {}

          Allow client to recompute Transaction and State Hashes.

        Returns string

        The has of ledger.

  • hashLedgerHeader: (ledgerHeader: Ledger) => string
      • (ledgerHeader: Ledger): string
      • Compute the hash of a ledger.

        Parameters

        • ledgerHeader: Ledger

          Ledger to compute the hash of.

        Returns string

        The hash of the ledger.

  • hashOfferId: (address: string, sequence: number) => string
      • (address: string, sequence: number): string
      • The Index of a Offer object is the SHA-512Half of the following values, concatenated in order:

        • The Offer space key (0x006F)
        • The AccountID of the account placing the offer
        • The Sequence number of the OfferCreate transaction that created the offer.

        This method computes an Offer Index.

        Parameters

        • address: string

          The classic account address of the SignerList owner (starting with r).

        • sequence: number

          Sequence of the Offer.

        Returns string

        The Index of the account's Offer object.

  • hashPaymentChannel: (address: string, dstAddress: string, sequence: number) => string
      • (address: string, dstAddress: string, sequence: number): string
      • Compute the hash of a Payment Channel.

        Parameters

        • address: string

          Account of the Payment Channel.

        • dstAddress: string

          Destination Account of the Payment Channel.

        • sequence: number

          Sequence number of the Transaction that created the Payment Channel.

        Returns string

        Hash of the Payment Channel.

  • hashSignedTx: (tx: Transaction | string) => string
      • Hashes the Transaction object as the ledger does. Throws if the transaction is unsigned.

        throws

        ValidationError if the Transaction is unsigned.

        Parameters

        • tx: Transaction | string

          A transaction to hash. Tx may be in binary blob form. Tx must be signed.

        Returns string

        A hash of tx.

  • hashSignerListId: (address: string) => string
      • (address: string): string
      • The Index of a SignerList object is the SHA-512Half of the following values, concatenated in order:

        • The RippleState space key (0x0053)
        • The AccountID of the owner of the SignerList
        • The SignerListID (currently always 0).

        This method computes a SignerList Ledger Object Index.

        Parameters

        • address: string

          The classic account address of the SignerList owner (starting with r).

        Returns string

        The Index of the account's SignerList object.

  • hashStateTree: (entries: LedgerEntry[]) => string
      • (entries: LedgerEntry[]): string
      • Compute the state hash of a list of LedgerEntries.

        Parameters

        • entries: LedgerEntry[]

          List of LedgerEntries.

        Returns string

        Hash of SHAMap that consists of all entries.

  • hashTrustline: (address1: string, address2: string, currency: string) => string
      • (address1: string, address2: string, currency: string): string
      • Compute the hash of a Trustline.

        Parameters

        • address1: string

          One of the addresses in the Trustline.

        • address2: string

          The other address in the Trustline.

        • currency: string

          Currency in the Trustline.

        Returns string

        The hash of the Trustline.

  • hashTx: (txBlobHex: string) => string
      • (txBlobHex: string): string
      • Hash the given binary transaction data with the single-signing prefix.

        See Serialization Format.

        Parameters

        • txBlobHex: string

          The binary transaction blob as a hexadecimal string.

        Returns string

        The hash to sign.

  • hashTxTree: (transactions: (Transaction & { metaData?: Metadata })[]) => string
      • (transactions: (Transaction & { metaData?: Metadata })[]): string
      • Compute the root hash of the SHAMap containing all transactions.

        Parameters

        • transactions: (Transaction & { metaData?: Metadata })[]

          List of Transactions.

        Returns string

        The root hash of the SHAMap.

ISOTimeToRippleTime

  • ISOTimeToRippleTime(iso8601: string): number
  • Convert an Iso8601 timestmap to a ripple timestamp.

    Parameters

    • iso8601: string

      International standard date format.

    Returns number

    Seconds since ripple epoch (1/1/2000 GMT).

authorizeChannel

  • authorizeChannel(wallet: Wallet, channelId: string, amount: string): string
  • Creates a signature that can be used to redeem a specific amount of XRP from a payment channel.

    Parameters

    • wallet: Wallet

      The account that will sign for this payment channel.

    • channelId: string

      An id for the payment channel to redeem XRP from.

    • amount: string

      The amount in drops to redeem.

    Returns string

    A signature that can be used to redeem a specific amount of XRP from a payment channel.

classicAddressToXAddress

  • classicAddressToXAddress(classicAddress: string, tag: number | false, test: boolean): string
  • Parameters

    • classicAddress: string
    • tag: number | false
    • test: boolean

    Returns string

convertStringToHex

  • convertStringToHex(string: string): string
  • Converts a string to its hex equivalent. Useful for Memos.

    Parameters

    • string: string

      The string to convert to Hex.

    Returns string

    The Hex equivalent of the string.

decodeAccountID

  • decodeAccountID(accountId: string): Buffer
  • Parameters

    • accountId: string

    Returns Buffer

decodeAccountPublic

  • decodeAccountPublic(base58string: string): Buffer
  • Parameters

    • base58string: string

    Returns Buffer

decodeNodePublic

  • decodeNodePublic(base58string: string): Buffer
  • Parameters

    • base58string: string

    Returns Buffer

decodeSeed

  • decodeSeed(seed: string, opts?: { expectedLength: number; versionTypes: ["ed25519", "secp256k1"]; versions: (number | number[])[] }): { bytes: Buffer; type: string | null; version: number[] }
  • Parameters

    • seed: string
    • Optional opts: { expectedLength: number; versionTypes: ["ed25519", "secp256k1"]; versions: (number | number[])[] }
      • expectedLength: number
      • versionTypes: ["ed25519", "secp256k1"]
      • versions: (number | number[])[]

    Returns { bytes: Buffer; type: string | null; version: number[] }

    • bytes: Buffer
    • type: string | null
    • version: number[]

decodeXAddress

  • decodeXAddress(xAddress: string): { accountId: Buffer; tag: number | false; test: boolean }
  • Parameters

    • xAddress: string

    Returns { accountId: Buffer; tag: number | false; test: boolean }

    • accountId: Buffer
    • tag: number | false
    • test: boolean

deriveXAddress

  • deriveXAddress(options: DeriveOptions): string
  • Derive an X-Address from a public key and a destination tag.

    Parameters

    • options: DeriveOptions

      Public key and destination tag to encode as an X-Address.

    Returns string

    X-Address.

dropsToXrp

  • dropsToXrp(dropsToConvert: BigNumber.Value): string
  • Convert Drops to XRP.

    throws

    When drops amount is invalid.

    Parameters

    • dropsToConvert: BigNumber.Value

      Drops to convert to XRP.

    Returns string

    Amount in XRP.

encodeAccountID

  • encodeAccountID(bytes: Buffer): string
  • Parameters

    • bytes: Buffer

    Returns string

encodeAccountPublic

  • encodeAccountPublic(bytes: Buffer): string
  • Parameters

    • bytes: Buffer

    Returns string

encodeNodePublic

  • encodeNodePublic(bytes: Buffer): string
  • Parameters

    • bytes: Buffer

    Returns string

encodeSeed

  • encodeSeed(entropy: Buffer, type: "ed25519" | "secp256k1"): string
  • Parameters

    • entropy: Buffer
    • type: "ed25519" | "secp256k1"

    Returns string

encodeXAddress

  • encodeXAddress(accountId: Buffer, tag: number | false, test: boolean): string
  • Parameters

    • accountId: Buffer
    • tag: number | false
    • test: boolean

    Returns string

generateXAddress

  • generateXAddress(options?: GenerateAddressOptions): GeneratedAddress
  • TODO: Move this function to be a static function of the Wallet Class. TODO: Doc this function.

    throws

    When cannot generate an address.

    Parameters

    • options: GenerateAddressOptions = {}

      Options for generating X-Address.

    Returns GeneratedAddress

    A generated address.

getBalanceChanges

  • getBalanceChanges(metadata: TransactionMetadata): BalanceChanges[]
  • Computes the complete list of every balance that changed in the ledger as a result of the given transaction.

    Parameters

    • metadata: TransactionMetadata

      Transaction metada.

    Returns BalanceChanges[]

    Parsed balance changes.

isValidAddress

  • isValidAddress(address: string): boolean
  • Validates that a given address is a valid X-Address or a valid classic address.

    Parameters

    • address: string

      Address to validate.

    Returns boolean

    True if address is a valid X-Address or classic address.

isValidClassicAddress

  • isValidClassicAddress(address: string): boolean
  • Parameters

    • address: string

    Returns boolean

isValidXAddress

  • isValidXAddress(xAddress: string): boolean
  • Parameters

    • xAddress: string

    Returns boolean

multisign

  • multisign(transactions: (Transaction | string)[]): string
  • Takes several transactions with Signer fields (in object or blob form) and creates a single transaction with all Signers that then gets signed and returned.

    throws

    ValidationError if:

    • There were no transactions given to sign
    • The SigningPubKey field is not the empty string in any given transaction
    • Any transaction is missing a Signers field.

    Parameters

    • transactions: (Transaction | string)[]

      An array of signed Transactions (in object or blob form) to combine into a single signed Transaction.

    Returns string

    A single signed Transaction which has all Signers from transactions within it.

removeUndefined

  • removeUndefined<T>(obj: T): T
  • Removes undefined values from an object.

    Type parameters

    • T: Record<string, unknown>

    Parameters

    • obj: T

      Object to remove undefined values from.

    Returns T

    The same object, but without undefined values.

rippleTimeToISOTime

  • rippleTimeToISOTime(rippleTime: number): string
  • Convert a ripple timestamp to an Iso8601 timestamp.

    Parameters

    • rippleTime: number

      Is the number of seconds since Ripple Epoch (1/1/2000 GMT).

    Returns string

    Iso8601 international standard date format.

rippleTimeToUnixTime

  • rippleTimeToUnixTime(rpepoch: number): number
  • Convert a ripple timestamp to a unix timestamp.

    Parameters

    • rpepoch: number

      (seconds since 1/1/2000 GMT).

    Returns number

    Milliseconds since unix epoch.

signPaymentChannelClaim

  • signPaymentChannelClaim(channel: string, amount: string, privateKey: string): string
  • Sign a payment channel claim.

    Parameters

    • channel: string

      Channel identifier specified by the paymentChannelClaim.

    • amount: string

      Amount specified by the paymentChannelClaim.

    • privateKey: string

      Private Key to sign paymentChannelClaim with.

    Returns string

    True if the channel is valid.

unixTimeToRippleTime

  • unixTimeToRippleTime(timestamp: number): number
  • Convert a unix timestamp to a ripple timestamp.

    Parameters

    • timestamp: number

      (ms since unix epoch).

    Returns number

    Seconds since Ripple Epoch (1/1/2000 GMT).

validate

  • validate(transaction: Record<string, unknown>): void
  • Verifies various Transaction Types. Encode/decode and individual type validation.

    throws

    ValidationError When the Transaction is malformed.

    Parameters

    • transaction: Record<string, unknown>

      A Transaction.

    Returns void

verifyPaymentChannelClaim

  • verifyPaymentChannelClaim(channel: string, amount: string, signature: string, publicKey: string): boolean
  • Verify the signature of a payment channel claim.

    Parameters

    • channel: string

      Channel identifier specified by the paymentChannelClaim.

    • amount: string

      Amount specified by the paymentChannelClaim.

    • signature: string

      Signature produced from signing paymentChannelClaim.

    • publicKey: string

      Public key that signed the paymentChannelClaim.

    Returns boolean

    True if the channel is valid.

verifySignature

  • Verifies that the given transaction has a valid signature based on public-key encryption.

    Parameters

    • tx: Transaction | string

      A transaction to verify the signature of. (Can be in object or encoded string format).

    Returns boolean

    Returns true if tx has a valid signature, and returns false otherwise.

xAddressToClassicAddress

  • xAddressToClassicAddress(xAddress: string): { classicAddress: string; tag: number | false; test: boolean }
  • Parameters

    • xAddress: string

    Returns { classicAddress: string; tag: number | false; test: boolean }

    • classicAddress: string
    • tag: number | false
    • test: boolean

xrpToDrops

  • xrpToDrops(xrpToConvert: BigNumber.Value): string
  • Convert an amount in XRP to an amount in drops.

    throws

    When amount in xrp is invalid.

    Parameters

    • xrpToConvert: BigNumber.Value

      Amount in XRP.

    Returns string

    Amount in drops.

Streams

Stream

Generated using TypeDoc