1

When a user sets up their Trezor hardware wallet to store bitcoin, does the wallet always create the first account at index 0? Is it possible for a user to generate an account at subsequent indices if there are no funds at the previous index? (i.e. a user creates an account at index 1 without having created an account at index 0)

For context, I'm working on a project that integrates with the Trezor Connect API and I want the user to be able to query their bitcoin balance from the accounts on their hardware wallet.

EDIT: For clarity, I'm referring to the account and not the addresses derived from that account. The Trezor Suite does not seem to allow subsequent accounts to be generated if a previous one is empty as shown in this screenshot but my goal is to be able to calculate the balance of all or some of a user's bitcoin accounts so I would need to know at which point to stop looking for new accounts.

Aman Saran
  • 23
  • 4

1 Answers1

1

does the wallet always create the first account at index 0?

Yes, the wallet derivation path defaults are declared in the trezor suite wallet source code. https://github.com/trezor/trezor-suite/blob/5377ec9e20d5e37951db2ad4a8bbeca437ed8d69/packages/suite/src/utils/wallet/coinmarket/coinmarketUtils.ts#L115

{
    name: 'Bitcoin (legacy)',
    networkType: 'bitcoin',
    accountType: 'legacy',
    symbol: 'btc',
    bip44: "m/44'/0'/i'",
    decimals: 8,
    explorer: {
        tx: 'https://btc1.trezor.io/tx/',
        account: 'https://btc1.trezor.io/xpub/',
    },
    features: ['rbf', 'sign-verify'],
},
    

const result = await TrezorConnect.getAddress({
    device,
    coin: legacy.symbol,
    path: `${legacy.bip44.replace('i', '0')}/0/0`,
    useEmptyPassphrase: device.useEmptyPassphrase,
    showOnTrezor: false,
});
if (result.success) {
    return result.payload.address;
}

Is it possible for a user to generate an account at subsequent indices if there are no funds at the previous index?

Yes, under the receive tab of the wallet. Although it shows index 0 by default, there's a "+ More Addresses" button the users could click on and send BTC to a higher index prior to receiving anything at index 0. A user going too far ahead of the index on their own doing can complicate the way an HD wallet works due to look-ahead gaps. See https://bitcoin.stackexchange.com/a/54664/26873

m1xolyd1an
  • 5,566
  • 2
  • 14
  • 30
  • Hey @m1xolyd1an, thanks for the reply. I see that you can add more addresses and create gaps for a particular account. In my use case, I'm concerned about a user creating gaps at the account level. In the suite, I see that it blocks them from adding new accounts if the previous one is empty. Is there any other way for them to create gaps at the account level? [Screenshot for clarity](https://imgur.com/a/6aGi9aU) – Aman Saran Nov 15 '21 at 17:36