Wallet

class xchainpy2_wallet.wallet.Wallet(phrase: str, query_api: THORChainQuery | None = None, enabled_chains: Set[Chain] | List[Chain] | Tuple[Chain] | None = None, concurrency: int = 5, default_chain: Chain = Chain.THORChain)

Bases: object

Wallet class is a high-level interface to your multi-chain wallet. It allows you to get balances, transaction data, send transactions. You can enable or disable chains according to your needs.

property cache: THORChainCache

Get the cache instance of the query API.

Returns:

THORChainCache

async close()

Close all clients

explorer_url_address(address: str)

Get the explorer URL for the given address. It calls the get_explorer_address_url method of the default chain client.

Parameters:

address – Address

Returns:

URL string

explorer_url_tx(tx_id: str)

Get the explorer URL for the given transaction ID. It calls the get_explorer_tx_url method of the default chain client.

Parameters:

tx_id – Transaction ID or hash

Returns:

URs string

async get_all_balances() AllBalances

Get all balances for all enabled chains. Runs concurrently, see the concurrency parameter in the constructor.

Returns:

AllBalances

get_client(chain: Chain | Asset) XChainClient | None

Get the client class instance for the given chain.

Parameters:

chain – Chain or Asset

Returns:

XChainClient or None if not found

async get_inbound_for_chain(chain: Chain) InboundDetail | None

Get inbound details for the given chain from the THORChain. The result is cached. :param chain: Chain :return: InboundDetail or None if not found

get_thorchain_client() THORChainClient | None

Get the THORChain client instance.

Returns:

THORChainClient or None if not found

is_chain_enabled(chain: Chain)

Check if the given chain is enabled for the wallet.

Parameters:

chain – Chain

Returns:

True if enabled, False otherwise

purge_client(chain: Chain)

Purge keys from the client for the given chain. :param chain: Chain

Client detection

This module checks the installed clients in the environment.

xchainpy2_wallet.detect_clients.CLIENT_CLASSES = {Chain.Arbitrum: <class 'xchainpy2_arbitrum.arb_client.ArbitrumClient'>, Chain.Avalanche: <class 'xchainpy2_avalanche.avax_client.AvalancheClient'>, Chain.BinanceSmartChain: <class 'xchainpy2_bsc.bsc_client.BinanceSmartChainClient'>, Chain.Bitcoin: <class 'xchainpy2_bitcoin.btc_client.BitcoinClient'>, Chain.BitcoinCash: <class 'xchainpy2_bitcoincash.bch_client.BitcoinCashClient'>, Chain.Cosmos: <class 'xchainpy2_cosmos.cosm_client.CosmosGaiaClient'>, Chain.Doge: <class 'xchainpy2_dogecoin.doge_client.DogecoinClient'>, Chain.Ethereum: <class 'xchainpy2_ethereum.eth_client.EthereumClient'>, Chain.Litecoin: <class 'xchainpy2_litecoin.ltc_client.LitecoinClient'>, Chain.Maya: <class 'xchainpy2_mayachain.client.MayaChainClient'>, Chain.THORChain: <class 'xchainpy2_thorchain.client.THORChainClient'>}

A dictionary that maps Chain to its client class.

Extra wallet data types

class xchainpy2_wallet.models.AllBalances(date, balances)

Bases: NamedTuple

balances: Dict[Chain, ChainBalances]

Alias for field number 1

date: datetime

Alias for field number 0

property flat: List[CryptoAmount]
class xchainpy2_wallet.models.ChainBalances(chain, address, balances)

Bases: NamedTuple

address: str

Alias for field number 1

balances: List[CryptoAmount]

Alias for field number 2

chain: Chain

Alias for field number 0