Get account info

Gets an info of specified account.

const result = await TrezorConnect.getAccountInfo(params);

Params

**Optional common params**

Using path

  • pathrequired string | Array<number> minimum length is 3. read more
  • coinrequired string determines network definition specified in coins.json file. Coin shortcut, name or label can be used.

Using public key

  • descriptorrequired string public key of account
  • coinrequired string determines network definition specified in coins.json file. Coin shortcut, name or label can be used.

Using discovery

BIP-0044 account discovery is performed and user is presented with a list of accounts. Result is returned after account selection.

  • coinrequired string determines network definition specified in coins.json file. Coin shortcut, name or label can be used.

Other optional params

params are forwarded to BlockBook backend using @trezor/blockchain-link package

  • details — specifies level of details returned by request

    • basic (default) return only account balances, without any derived addresses or transaction history
    • tokens - response with derived addresses (Bitcoin-like accounts) and ERC20 tokens (Ethereum-like accounts), subject of tokens param
    • tokenBalances - same as tokens with balances, subject of tokens param
    • txs - tokenBalances + complete account transaction history
  • tokens — specifies which tokens (xpub addresses) are returned by the request (default nonzero)

    • nonzero - (Default) return only addresses with nonzero balance
    • used - return addresses with at least one transaction
    • derived - return all derived addresses
  • pagenumber transaction history page index, subject of details: txs

  • pageSizenumber transaction history page size, subject of details: txs

  • fromnumber transaction history from block filter, subject of details: txs

  • tonumber transaction history to block filter, subject of details: txs

  • gapnumber address derivation gap size, subject of details: tokens

  • contractFilterstring Ethereum-like accounts only: get ERC20 token info and balance

  • marker{ ledger: number, seq: number } XRP accounts only, transaction history page marker

  • defaultAccountType'normal' | 'segwit' | 'legacy' Bitcoin-like accounts only: specify which account group is displayed as default in popup, subject of Using discovery

Example

Get info about first bitcoin account

TrezorConnect.getAccountInfo({
    path: "m/49'/0'/0'",
    coin: 'btc',
});

Get info about account using public key (device is not used)

TrezorConnect.getAccountInfo({
    descriptor:
        'xpub6CVKsQYXc9awxgV1tWbG4foDvdcnieK2JkbpPEBKB5WwAPKBZ1mstLbKVB4ov7QzxzjaxNK6EfmNY5Jsk2cG26EVcEkycGW4tchT2dyUhrx',
    coin: 'btc',
});

Get info about account using BIP-0044 account discovery

TrezorConnect.getAccountInfo({
    coin: 'btc',
});

Result

{
    success: true,
    payload: {
        id: number,                           // account id
        path: string,                         // serialized path
        descriptor: string,                   // account public key
        legacyXpub?: string,                  // (optional) account public key in legacy format (only for segwit and segwit native accounts)
        balance: string,                      // account balance (confirmed transactions only)
        availableBalance: string,             // account balance (including unconfirmed transactions)
        addresses: {
            // subject of details:tokens param
            unused: Array<AccountAddress>, // unused addresses
            used: Array<AccountAddress>,   // used addresses
            change: Array<AccountAddress>, // change addresses (internal)
        }, // list of derived addresses grouped by purpose (Bitcoin-like accounts)
        history: Array<{
            total: number,
            unconfirmed: number,
            transactions?: Array<AccountTransaction>, // subject of details:txs param
        }> // account history object
        utxo?: Array<AccountUtxo>, // account utxos (Bitcoin-like accounts), subject of details:tokens param
        tokens?: Array<TokenInfo>, // account ERC20 tokens (Ethereum-like accounts), subject of details:tokens param
        misc?: {
            // Ethereum-like accounts only
            nonce: string,
            erc20Contract?: TokenInfo, // subject of contractFilter param
            // XRP accounts only
            sequence?: number,
            reserve?: string,
        },
        page?: {
            // subject of details:txs param
            index: number, // current page index
            size: number,  // current page size
            total: number, // total pages count
        },
        marker?: {
            // XRP accounts only
            // subject of details:txs param
            ledger: number,
            seq: number,
        }

    } //
}

AccountInfo AccountAddress AccountTransaction AccountUtxo TokenInfo

Error

{
    success: false,
    payload: {
        error: string // error message
    }
}