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.

1 Answer 1

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

1
  • 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
    – Aman Saran
    Commented Nov 15, 2021 at 17:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.