Show / Hide Table of Contents

Class XrplWallet

Inheritance
object
XrplWallet
Namespace: Xrpl.Wallet
Assembly: Xrpl.dll
Syntax
public class XrplWallet

Constructors

| Edit this page View Source

XrplWallet(string, string, string?, string?)

Creates a new Wallet.

Declaration
public XrplWallet(string publicKey, string privateKey, string? masterAddress = null, string? seed = null)
Parameters
Type Name Description
string publicKey

The public key for the account.

string privateKey

The private key used for signing transactions for the account.

string masterAddress

Include if a Wallet uses a Regular Key Pair. It must be the master address of the account.

string seed

The seed used to derive the account keys.

Fields

| Edit this page View Source

ClassicAddress

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

DEFAULT_ALGORITHM

Declaration
public static string DEFAULT_ALGORITHM
Field Value
Type Description
string
| Edit this page View Source

Ed25519

Declaration
public const string Ed25519 = "ed25519"
Field Value
Type Description
string
| Edit this page View Source

PrivateKey

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

PublicKey

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

Secp256k1

Declaration
public const string Secp256k1 = "secp256k1"
Field Value
Type Description
string
| Edit this page View Source

Seed

Declaration
public readonly string Seed
Field Value
Type Description
string

Methods

| Edit this page View Source

CombineBatchSigners(params string[])

Объединяет несколько частично подписанных Batch-транзакций (txBlob в hex) в один финальный blob. Условия:

  • Все входные blob'ы должны быть Batch и иметь ИДЕНТИЧНОЕ тело (кроме SigningPubKey/TxnSignature/BatchSigners).
  • Объединяются только подписи в BatchSigners (и при отсутствии BatchSigners — внешняя подпись).
  • BatchSigners сортируются по Account; вложенные Signers — по Signer.Account.
Declaration
public static SignatureResult CombineBatchSigners(params string[] txBlobs)
Parameters
Type Name Description
string[] txBlobs
Returns
Type Description
SignatureResult
| Edit this page View Source

ComputeSignature(Dictionary<string, object>, string, string?)

Declaration
public string ComputeSignature(Dictionary<string, object> transaction, string privateKey, string? signAs = null)
Parameters
Type Name Description
Dictionary<string, object> transaction
string privateKey
string signAs
Returns
Type Description
string
| Edit this page View Source

FromEntropy(byte[], string?, string?)

An array of random numbers to generate a seed used to derive a wallet.

Declaration
public static XrplWallet FromEntropy(byte[] entropy, string? masterAddress = null, string? algorithm = null)
Parameters
Type Name Description
byte[] entropy
string masterAddress

Include if a Wallet uses a Regular Key Pair. It must be the master address of the account.

string algorithm

The digital signature algorithm to generate an address for.

Returns
Type Description
XrplWallet

A Wallet derived from an entropy.

| Edit this page View Source

FromMnemonic(string, string?, string?, string?, string?, string?)

Declaration
public static XrplWallet FromMnemonic(string mnemonic, string? masterAddress = null, string? derivationPath = null, string? encoding = null, string? algorithm = null, string? passphrase = null)
Parameters
Type Name Description
string mnemonic
string masterAddress
string derivationPath
string encoding
string algorithm
string passphrase
Returns
Type Description
XrplWallet
| Edit this page View Source

FromNormalizedText(string, string?, bool, string, string, TextWalletKdf)

Creates a Wallet from any text.

Declaration
public static XrplWallet FromNormalizedText(string text, string? salt = null, bool caseInsensitive = true, string algorithm = null, string masterAddress = null, TextWalletKdf kdf = TextWalletKdf.Sha256)
Parameters
Type Name Description
string text

any text to generate wallet

string salt

user salt as a password

bool caseInsensitive

is case-insensitive

string algorithm

The digital signature algorithm to generate an address for.

string masterAddress

account master address, will use as account

TextWalletKdf kdf

Key Derivation Function

Returns
Type Description
XrplWallet

generated wallet

| Edit this page View Source

FromPrivateKey(string, string?)

Creates a new instance of the XrplWallet class using the specified private key and an optional master address.

Declaration
public static XrplWallet FromPrivateKey(string privateKey, string? masterAddress = null)
Parameters
Type Name Description
string privateKey

The private key used to derive the wallet's public key. Must be a valid XRPL private key format and should be kept secure.

string masterAddress

An optional master address associated with the wallet. If provided, it is used as part of the wallet's initialization; otherwise, the wallet is initialized without a master address.

Returns
Type Description
XrplWallet

An XrplWallet instance containing the derived public key, the provided private key, and the optional master address.

Remarks

The method derives the public key from the provided private key using XRPL keypair functionality. Supplying an invalid private key will result in an exception during wallet creation. Ensure that the private key is valid and securely managed.

| Edit this page View Source

FromSecretString(string, string)

Creates a Wallet from a space-separated secret numbers string. Accepts formats like "554872 394230 209376 323698 140250 387423 652803 258676".

Declaration
public static XrplWallet FromSecretString(string secretString, string algorithm = "secp256k1")
Parameters
Type Name Description
string secretString

Space-separated secret numbers string (8 groups of 6 digits)

string algorithm

The digital signature algorithm to use. Default is secp256k1.

Returns
Type Description
XrplWallet

A Wallet created from the secret numbers.

| Edit this page View Source

FromSeed(string, string?, string?)

Derives a wallet from a seed.

Declaration
public static XrplWallet FromSeed(string seed, string? masterAddress = null, string? algorithm = null)
Parameters
Type Name Description
string seed

A string used to generate a keypair (publicKey/privateKey) to derive a wallet.

string masterAddress

Include if a Wallet uses a Regular Key Pair. It must be the master address of the account.

string algorithm

The digital signature algorithm to generate an address for.

Returns
Type Description
XrplWallet

A Wallet derived from a seed.

| Edit this page View Source

FromXummNumbers(string[], string, string?)

Creates a Wallet from xumm numbers.

Declaration
public static XrplWallet FromXummNumbers(string[] numbers, string algorithm = "secp256k1", string? masterAddress = null)
Parameters
Type Name Description
string[] numbers
string algorithm
string masterAddress
Returns
Type Description
XrplWallet

A Wallet from xumm numbers.

| Edit this page View Source

Generate(string)

Generates a new Wallet using a generated seed.

Declaration
public static XrplWallet Generate(string algorithm = "ed25519")
Parameters
Type Name Description
string algorithm

The digital signature algorithm to generate an address for.

Returns
Type Description
XrplWallet

A new Wallet derived from a generated seed.

| Edit this page View Source

GenerateMnemonic(int)

Generates a random BIP-39 mnemonic phrase.

BIP-39 defines a standard for mnemonic phrases - human-readable word sequences that encode cryptographic entropy. The words are selected from a standardized 2048-word English wordlist.

The number of words determines the entropy strength:

  • 12 words = 128 bits of entropy (standard)
  • 15 words = 160 bits of entropy
  • 18 words = 192 bits of entropy
  • 21 words = 224 bits of entropy
  • 24 words = 256 bits of entropy (maximum)
Declaration
public static string[] GenerateMnemonic(int wordCount = 12)
Parameters
Type Name Description
int wordCount

The number of words to generate (12, 15, 18, 21, or 24). Default is 12.

Returns
Type Description
string[]

An array of mnemonic words.

Remarks

Reference: https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki

Examples
// Generate 12-word mnemonic (default)
string[] words12 = XrplWallet.GenerateMnemonic();

// Generate 24-word mnemonic for maximum security
string[] words24 = XrplWallet.GenerateMnemonic(24);

// Create wallet from mnemonic
var wallet = XrplWallet.FromMnemonic(string.Join(" ", words24));
Exceptions
Type Condition
ArgumentException

Thrown when wordCount is not 12, 15, 18, 21, or 24.

| Edit this page View Source

GetSecretNumbers()

Gets the Secret Numbers representation of this wallet's seed. Returns 8 groups of 6 digits each, where 5 digits are entropy and 1 digit is checksum.

Declaration
public string[] GetSecretNumbers()
Returns
Type Description
string[]

Array of 8 secret number strings, or null if the wallet was not created from a seed.

| Edit this page View Source

GetSecretString()

Gets the Secret Numbers as a formatted string with spaces between groups.

Declaration
public string GetSecretString()
Returns
Type Description
string

Space-separated secret numbers string, or null if the wallet was not created from a seed.

| Edit this page View Source

GetXAddress(uint, bool)

Declaration
public string GetXAddress(uint tag, bool isTestnet = false)
Parameters
Type Name Description
uint tag
bool isTestnet
Returns
Type Description
string
| Edit this page View Source

Sign(Dictionary<string, object>, bool, string?)

Signs a transaction offline.

Declaration
public SignatureResult Sign(Dictionary<string, object> transaction, bool multisign = false, string? signingFor = null)
Parameters
Type Name Description
Dictionary<string, object> transaction

A transaction to be signed offline.

bool multisign

Specify true/false to use multisign or actual address (classic/x-address) to make multisign tx request.

string signingFor
Returns
Type Description
SignatureResult

A Wallet derived from the seed.

| Edit this page View Source

Sign(ITransactionRequest, bool, string?)

Signs a transaction offline.

Declaration
public SignatureResult Sign(ITransactionRequest tx, bool multisign = false, string? signingFor = null)
Parameters
Type Name Description
ITransactionRequest tx

A transaction to be signed offline.

bool multisign

Specify true/false to use multisign or actual address (classic/x-address) to make multisign tx request.

string signingFor
Returns
Type Description
SignatureResult

A Wallet derived from the seed.

| Edit this page View Source

SignAsBatchPart(Dictionary<string, object>, bool, string?)

Declaration
public SignatureResult SignAsBatchPart(Dictionary<string, object> transaction, bool multisign, string? signingFor)
Parameters
Type Name Description
Dictionary<string, object> transaction
bool multisign
string signingFor
Returns
Type Description
SignatureResult
| Edit this page View Source

SignAsBatchPart(IBatch, bool, string?)

Declaration
public SignatureResult SignAsBatchPart(IBatch transaction, bool multisign, string? signingFor)
Parameters
Type Name Description
IBatch transaction
bool multisign
string signingFor
Returns
Type Description
SignatureResult
| Edit this page View Source

SuggestMnemonicWords(string, int)

Suggests BIP-39 words similar to the given input for autocomplete and typo correction.

Returns matching words in priority order: exact prefix matches first (sorted alphabetically), then fuzzy matches by Levenshtein distance (for typo correction). Duplicates are removed so prefix matches are not repeated in fuzzy results.

Declaration
public static string[] SuggestMnemonicWords(string input, int maxSuggestions = 5)
Parameters
Type Name Description
string input

The partial or misspelled word to find suggestions for.

int maxSuggestions

Maximum number of suggestions to return. Default is 5.

Returns
Type Description
string[]

An array of suggested words from the BIP-39 English wordlist, ordered by relevance. Returns an empty array if input is null or empty.

Remarks

The algorithm uses two strategies:

  1. Prefix matching: words that start with the input string.
  2. Levenshtein distance: words within edit distance 2 of the input (for typo correction).

Reference: https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki

Examples
// Prefix matching
string[] suggestions = XrplWallet.SuggestMnemonicWords("aban");
// Returns: ["abandon", "ability", ...] — words starting with "aban"

// Typo correction
string[] typoFix = XrplWallet.SuggestMnemonicWords("abandonn");
// Returns: ["abandon"] — corrects the typo
| Edit this page View Source

ValidateMnemonicChecksum(string[])

Validates the checksum of a complete BIP-39 mnemonic phrase.

In BIP-39, the last word of a mnemonic contains checksum bits derived from the SHA-256 hash of the entropy. This method verifies that the checksum is correct, which confirms that all words are valid and in the correct order.

Declaration
public static bool ValidateMnemonicChecksum(string[] words)
Parameters
Type Name Description
string[] words

The complete mnemonic phrase as an array of words.

Returns
Type Description
bool

true if the mnemonic has a valid checksum; otherwise, false.

Remarks

This method performs three levels of validation:

  1. Word count: must be 12, 15, 18, 21, or 24.
  2. Word validity: all words must exist in the BIP-39 English wordlist.
  3. Checksum: the last word's checksum bits must match the SHA-256 hash of the entropy.

Call this method after the user has entered all mnemonic words. For per-word validation during input, use ValidateMnemonicWord(string).

Reference: https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki

Examples
string[] words = { "assault", "rare", "scout", "seed", "design", "extend",
                    "noble", "drink", "talk", "control", "guitar", "quote" };
bool valid = XrplWallet.ValidateMnemonicChecksum(words); // true

words[11] = "abandon"; // corrupt last word
bool invalid = XrplWallet.ValidateMnemonicChecksum(words); // false
| Edit this page View Source

ValidateMnemonicWord(string)

Validates whether a word exists in the BIP-39 English wordlist.

The BIP-39 standard defines a fixed set of 2048 English words used for mnemonic phrases. This method checks if a given word is present in that wordlist. Use this for real-time validation as the user types each word.

Declaration
public static bool ValidateMnemonicWord(string word)
Parameters
Type Name Description
string word

The word to validate (case-insensitive).

Returns
Type Description
bool

true if the word exists in the BIP-39 English wordlist; otherwise, false.

Remarks

Note: In BIP-39, any valid word can appear at any position in the mnemonic. Position-level correctness can only be verified via checksum validation after all words have been entered (see ValidateMnemonicChecksum(string[])).

Reference: https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki

Examples
bool valid = XrplWallet.ValidateMnemonicWord("abandon"); // true
bool invalid = XrplWallet.ValidateMnemonicWord("xyz123"); // false
| Edit this page View Source

VerifyTransaction(string)

Verifies a signed transaction offline.

Declaration
public bool VerifyTransaction(string signedTransaction)
Parameters
Type Name Description
string signedTransaction

A signed transaction (hex string of signTransaction result) to be verified offline.

Returns
Type Description
bool

Returns true if a signedTransaction is valid.

  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX