WDK logoWDK documentation

Manage Accounts

Work with multiple accounts and custom derivation paths.

This guide explains how to retrieve accounts by index and use custom derivation paths.

Retrieve Accounts by Index

You can retrieve multiple accounts using wallet.getAccount() with different index values:

Retrieve Multiple Accounts
const account0 = await wallet.getAccount(0)
const address0 = await account0.getAddress()
console.log('Account 0 address:', address0)

const account1 = await wallet.getAccount(1)
const address1 = await account1.getAddress()
console.log('Account 1 address:', address1)

You can iterate through multiple accounts using wallet.getAccount() to inspect addresses and balances in bulk:

Iterate Over Accounts
for (let i = 0; i < 5; i++) {
  const account = await wallet.getAccount(i)
  const address = await account.getAddress()
  const balance = await account.getBalance()
  console.log(`Account ${i}: ${address} (${balance} satoshis)`)
}

Retrieve Account by Custom Derivation Path

You can retrieve an account at a specific derivation path using wallet.getAccountByPath():

Custom Derivation Path
const customAccount = await wallet.getAccountByPath("0'/0/5")
const customAddress = await customAccount.getAddress()
console.log('Custom account address:', customAddress)

The default derivation scheme is BIP-84 (Native SegWit): m/84'/0'/0'/0/{index} on mainnet. Set bip: 44 in the wallet configuration for legacy BIP-44 paths: m/44'/0'/0'/0/{index}.

Next Steps

With accounts set up, learn how to check balances.

On this page