githubEdit

gearConfiguration

Configuration options and settings for @tetherto/wdk-wallet-btc

Wallet Configuration

import WalletManagerBtc, { ElectrumTcp } from '@tetherto/wdk-wallet-btc'

const client = new ElectrumTcp({
  host: 'electrum.blockstream.info',
  port: 50001
})

const wallet = new WalletManagerBtc(seedPhrase, {
  client,
  network: 'bitcoin'
})

Account Creation

// WalletAccountBtc is created by the WalletManagerBtc
// It takes the same configuration as the manager
const account = await wallet.getAccount(0) // Get account at index 0
const customAccount = await wallet.getAccountByPath("0'/0/5") // Custom path

Configuration Options

Client

The client option specifies an Electrum client instance to use for blockchain data. When provided, the host, port, and protocol options are ignored.

Type: IElectrumClient

Default: None (falls back to host/port/protocol configuration)

Example:

Built-in Transport Clients

The package provides four built-in transport clients:

Custom Electrum Client

You can implement your own client by extending IElectrumClient:

Host

The host option specifies the Electrum server hostname to connect to for blockchain data. Ignored if client is provided.

Type: string

Default: "electrum.blockstream.info"

Recommended: Configure your own Electrum server for production use. Public servers can be 10-300x slower and may fail for addresses with many transactions.

Example:

Port

The port option specifies the Electrum server port to connect to. Ignored if client is provided.

Type: number

Default: 50001

Common Ports:

  • 50001 - TCP (default)

  • 50002 - TLS/SSL

  • 50003 - WebSocket

Example:

Protocol

The protocol option specifies the transport protocol to use. Ignored if client is provided.

Type: string

Values:

  • "tcp" - TCP transport (default)

  • "tls" - TLS transport

  • "ssl" - SSL transport

Default: "tcp"

Example:

Network

The network option specifies which Bitcoin network to use.

Type: string

Values:

  • "bitcoin" - Bitcoin mainnet (production)

  • "testnet" - Bitcoin testnet (development)

  • "regtest" - Bitcoin regtest (local testing)

Default: "bitcoin"

Example:

BIP

The bip option specifies the address type derivation standard to use.

Type: number

Values:

  • 84 - BIP-84 (P2WPKH / Native SegWit) - addresses start with bc1 (mainnet) or tb1 (testnet)

  • 44 - BIP-44 (P2PKH / Legacy) - addresses start with 1 (mainnet) or m/n (testnet)

Default: 84

Example:

Electrum Server Configuration

Important: While the package defaults to electrum.blockstream.info:50001 for convenience, we strongly recommend configuring your own Electrum server for production use.

For Production:

  • Set up your own Fulcrum server for optimal performance and reliability

  • Use recent Fulcrum versions that support pagination for high-transaction addresses

For Development/Testing:

  • fulcrum.frznode.com:50001 - Generally faster than default

  • electrum.blockstream.info:50001 - Default fallback

Configuration Examples

Network-Specific Configuration

Bitcoin Mainnet

Bitcoin Testnet

Bitcoin Regtest

Derivation Paths

Bitcoin wallet addresses are derived using BIP-32 hierarchical deterministic paths:

BIP-84 (Native SegWit) - Default

  • m/84'/0'/0'/0/0 for mainnet account 0, address 0

  • m/84'/1'/0'/0/0 for testnet/regtest account 0, address 0

Addresses start with bc1 (mainnet) or tb1 (testnet).

BIP-44 (Legacy)

  • m/44'/0'/0'/0/0 for mainnet account 0, address 0

  • m/44'/1'/0'/0/0 for testnet/regtest account 0, address 0

Addresses start with 1 (mainnet) or m/n (testnet).

circle-exclamation

Complete Configuration Example

Performance Considerations

Electrum Server Performance:

  • Public servers like Blockstream's can be significantly slower

  • Addresses with many transactions may cause timeouts

  • Custom Fulcrum servers provide better performance and reliability

  • Consider server location and network latency

Configuration Tips:

  • Use fulcrum.frznode.com for better development performance

  • Set up your own Fulcrum server for production

  • Monitor connection stability and implement retry logic

  • Consider using multiple backup servers


Need Help?