Wallet Methods

Methods for working with XRPL wallets.

class xrpl.wallet.Wallet(public_key: str, private_key: str, *, master_address: str | None = None, seed: str | None = None, algorithm: CryptoAlgorithm | None = None)

Bases: object

The cryptographic keys needed to control an XRP Ledger account. See Cryptographic Keys for details.

property address: str

The XRPL address that publicly identifies this wallet, as a base58 string. This is the same value as the classic_address.

algorithm

The algorithm that is used to convert the seed into its public/private keypair.

property classic_address: str

classic_address is the same as address. It is called classic_address to differentiate it from the x-address standard, which encodes the network, destination tag, and XRPL address into a single value. It’s also a base58 string.

classmethod create(algorithm: CryptoAlgorithm = CryptoAlgorithm.ED25519) Wallet

Generates a new seed and Wallet.

Parameters:

algorithm – The key-generation algorithm to use when generating the seed. The default is ED25519.

Returns:

The wallet that is generated from the given seed.

classmethod from_entropy(entropy: str, *, master_address: str | None = None, algorithm: CryptoAlgorithm = CryptoAlgorithm.ED25519) Wallet

Generates a new Wallet from entropy (hexadecimal string of random numbers).

Parameters:
  • entropy – A hexadecimal string of random numbers to generate a seed used to derive a wallet.

  • master_address – Include if a Wallet uses a Regular Key Pair. This sets the address that this wallet corresponds to. The default is None.

  • algorithm – The key-generation algorithm to use when generating the seed. The default is ED25519.

Returns:

The wallet that is generated from the given entropy.

Raises:

XRPLException – If passed in entropy is not a bytestring.

classmethod from_secret(seed: str, *, master_address: str | None = None, algorithm: CryptoAlgorithm = CryptoAlgorithm.ED25519) Wallet

Generates a new Wallet from seed (secret).

Parameters:
  • seed – The seed (secret) used to derive the account keys.

  • master_address – Include if a Wallet uses a Regular Key Pair. This sets the address that this wallet corresponds to. The default is None.

  • algorithm – The key-generation algorithm to use when generating the seed. The default is ED25519.

Returns:

The wallet that is generated from the given secret.

classmethod from_secret_numbers(secret_numbers: List[str] | str, *, master_address: str | None = None, algorithm: CryptoAlgorithm = CryptoAlgorithm.SECP256K1) Wallet

Generates a new Wallet from secret numbers.

Parameters:
  • secret_numbers – A string (whitespace delimited) or string array consisting of 8 times 6 numbers used to derive a wallet.

  • master_address – Include if a Wallet uses a Regular Key Pair. It must be the master address of the account. The default is None.

  • algorithm – The digital signature algorithm to generate an address for. The default is SECP256K1 (XUMM standard as of December 2022).

Returns:

The wallet that is generated from the given secret numbers.

Raises:

XRPLException – If the number of secret numbers is not 8. If the length of any secret number is not 6. If the checksum of any secret number is invalid.

classmethod from_seed(seed: str, *, master_address: str | None = None, algorithm: CryptoAlgorithm = CryptoAlgorithm.ED25519) Wallet

Generates a new Wallet from seed (secret).

Parameters:
  • seed – The seed (secret) used to derive the account keys.

  • master_address – Include if a Wallet uses a Regular Key Pair. This sets the address that this wallet corresponds to. The default is None.

  • algorithm – The key-generation algorithm to use when generating the seed. The default is ED25519.

Returns:

The wallet that is generated from the given secret.

get_xaddress(*, tag: int | None = None, is_test: bool = False) str

Returns the X-Address of the Wallet’s account.

Parameters:
  • tag – The destination tag of the address. Defaults to None.

  • is_test – Whether the address corresponds to an address on the test network. Defaults to False.

Returns:

The X-Address of the Wallet’s account.

private_key

The private key that is used to create signatures, as a hexadecimal string. MUST be kept secret!

public_key

The public key that is used to identify this wallet’s signatures, as a hexadecimal string.

seed

The core value that is used to derive all other information about this wallet. MUST be kept secret!

exception xrpl.wallet.XRPLFaucetException

Bases: XRPLException

Faucet generation exception.

xrpl.wallet.generate_faucet_wallet(client: SyncClient, wallet: Wallet | None = None, debug: bool = False, faucet_host: str | None = None, usage_context: str | None = None) Wallet

Generates a random wallet and funds it using the XRPL Testnet Faucet.

Parameters:
  • client – the network client used to make network calls.

  • wallet – the wallet to fund. If omitted or None, a new wallet is created.

  • debug – Whether to print debug information as it creates the wallet.

  • faucet_host – A custom host to use for funding a wallet. In environments other than devnet and testnet, this parameter is required.

  • usage_context – The intended use case for the funding request (for example, testing). This information will be included in json body of the HTTP request to the faucet.

Returns:

A Wallet on the testnet that contains some amount of XRP.

Raises: