Skip to content
docs

WalletAccountBtc

Defined in: wallet-btc/src/account.ts:45

Signing Bitcoin account — BIP-84 p2wpkh or BIP-86 p2tr (key-path). The key never enters this package: every signature is one signer.sign(...) call over a btc-signer-computed sighash — a LocalSigner for seed wallets, anything else (hardware, MPC, backend) through externalSigner():

p2wpkh input → `ecdsa` over the BIP-143 sighash (SIGHASH_ALL), DER-encoded here
p2tr input → `schnorr` + `tweak` over the BIP-341 sighash (DEFAULT), tweak = TapTweak(xonly)
BIP-137 msg → `ecdsa-recoverable` over the magic hash

Every spend is resolved to a full description (“what you sign”) and run through the hard safety checks (fee-rate ceiling, recipient/amount exactness, change ownership) before signing AND before broadcast — also for caller-supplied raw hex.

  • IWalletAccount

new WalletAccountBtc(signer, publicKey, path, config?): WalletAccountBtc

Defined in: wallet-btc/src/account.ts:65

publicKey is the signer’s compressed secp256k1 key (33 bytes); it is needed synchronously for the address.

Signer

Uint8Array

string

BtcConfig = {}

WalletAccountBtc

WalletAccountReadOnlyBtc.constructor

protected readonly _client: BtcClient | undefined

Defined in: wallet-btc/src/read-only-account.ts:39

WalletAccountReadOnlyBtc._client


protected readonly _config: BtcConfig

Defined in: wallet-btc/src/read-only-account.ts:38

WalletAccountReadOnlyBtc._config


protected readonly _network: BTC_NETWORK

Defined in: wallet-btc/src/read-only-account.ts:40

WalletAccountReadOnlyBtc._network


protected readonly _networkName: BtcNetwork

Defined in: wallet-btc/src/read-only-account.ts:41

WalletAccountReadOnlyBtc._networkName


readonly address: string

Defined in: wallet-btc/src/read-only-account.ts:28

The address.

WalletAccountReadOnlyBtc.address


readonly addressType: BtcAddressType

Defined in: wallet-btc/src/account.ts:52

p2wpkh / p2tr when the address is one we know how to spend from; undefined for other script types.

WalletAccountReadOnlyBtc.addressType


readonly chain: string

Defined in: wallet-btc/src/read-only-account.ts:29

CAIP-2 chain id, e.g. “eip155:1”, “solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp”, “ton:-239”, “tron:0x2b6653dc”, “bip122:000000000019d6689c085ae165831e93”.

IWalletAccount.chain

WalletAccountReadOnlyBtc.chain


readonly dustLimit: bigint

Defined in: wallet-btc/src/read-only-account.ts:37

Smallest output this address type may create, in satoshis.

WalletAccountReadOnlyBtc.dustLimit


readonly needsNetwork: true = true

Defined in: wallet-btc/src/account.ts:47

UTXOs, fee rate and tip height come from the network before signing.

IWalletAccount.needsNetwork


readonly path: string

Defined in: wallet-btc/src/account.ts:49

Derivation path, or external for an external signer.


readonly publicKey: Uint8Array

Defined in: wallet-btc/src/account.ts:51

Compressed secp256k1 public key.


readonly scriptKind: ScriptKind

Defined in: wallet-btc/src/read-only-account.ts:33

Script type of the address.

WalletAccountReadOnlyBtc.scriptKind


readonly scriptPubKey: Uint8Array

Defined in: wallet-btc/src/read-only-account.ts:31

Output script of address.

WalletAccountReadOnlyBtc.scriptPubKey


readonly signerKind: "seed" | "key" | "external"

Defined in: wallet-btc/src/account.ts:60

What holds the key: seed, key (one imported key) or external.

get index(): number | undefined

Defined in: wallet-btc/src/account.ts:84

Account index for the standard m/{84|86}‘/{0|1}’/0’/0/i path.

number | undefined


get maxFeeRate(): number

Defined in: wallet-btc/src/read-only-account.ts:63

Fee-rate ceiling in sat/vB: BtcConfig.maxFeeRate or DEFAULT_MAX_FEE_RATE.

number

WalletAccountReadOnlyBtc.maxFeeRate

describeTransaction(tx): Promise<BtcTxDescription>

Defined in: wallet-btc/src/account.ts:250

“What you sign”: the fully resolved spend (signed, NOT broadcast) or a caller’s raw hex.

BtcTransaction

Promise<BtcTxDescription>


dispose(): void

Defined in: wallet-btc/src/account.ts:319

Zeroize this account’s key material.

void

IWalletAccount.dispose


getAddress(): Promise<string>

Defined in: wallet-btc/src/read-only-account.ts:68

The address.

Promise<string>

IWalletAccount.getAddress

WalletAccountReadOnlyBtc.getAddress


getBalance(): Promise<bigint>

Defined in: wallet-btc/src/read-only-account.ts:71

Confirmed minus pending outgoing (Bitcoin Core wallet semantics).

Promise<bigint>

IWalletAccount.getBalance

WalletAccountReadOnlyBtc.getBalance


getMaxSpendable(opts?): Promise<BtcMaxSpendableResult>

Defined in: wallet-btc/src/read-only-account.ts:136

Everything spendable in ONE transaction to a single output of our own address type, no change.

number

number | bigint

string

Promise<BtcMaxSpendableResult>

WalletAccountReadOnlyBtc.getMaxSpendable


getTokenBalance(_token): Promise<bigint>

Defined in: wallet-btc/src/read-only-account.ts:77

Always throws: Bitcoin has no tokens.

string

Promise<bigint>

IWalletAccount.getTokenBalance

WalletAccountReadOnlyBtc.getTokenBalance


getTransactionReceipt(hash): Promise<BtcReceipt | undefined>

Defined in: wallet-btc/src/read-only-account.ts:147

Undefined until the transaction is mined.

string

Promise<BtcReceipt | undefined>

IWalletAccount.getTransactionReceipt

WalletAccountReadOnlyBtc.getTransactionReceipt


protected inputWeight(): number

Defined in: wallet-btc/src/read-only-account.ts:82

Weight one of OUR inputs adds; throws for address types we cannot spend from.

number

WalletAccountReadOnlyBtc.inputWeight


protected lockTimeHeight(): Promise<number>

Defined in: wallet-btc/src/read-only-account.ts:167

Chain tip for anti-fee-sniping; undefined when disabled or the transport cannot tell.

Promise<number>

WalletAccountReadOnlyBtc.lockTimeHeight


protected planSpend(spend): Promise<SpendPlan>

Defined in: wallet-btc/src/read-only-account.ts:97

Coin selection for a spend (see coinselect.ts). Validates the recipient and the dust floor first.

BtcSpend

Promise<SpendPlan>

WalletAccountReadOnlyBtc.planSpend


quoteSendTransaction(tx): Promise<{ fee: bigint; }>

Defined in: wallet-btc/src/account.ts:268

Fee of a spend in satoshis, from a coin selection at the current fee rate.

BtcTransaction

Promise<{ fee: bigint; }>

IWalletAccount.quoteSendTransaction

WalletAccountReadOnlyBtc.quoteSendTransaction


quoteTransfer(o): Promise<{ fee: bigint; }>

Defined in: wallet-btc/src/read-only-account.ts:130

Fee of a transfer in satoshis.

BtcTransferOptions

Promise<{ fee: bigint; }>

Error when token is set.

IWalletAccount.quoteTransfer

WalletAccountReadOnlyBtc.quoteTransfer


protected requireClient(what): BtcClient

Defined in: wallet-btc/src/read-only-account.ts:57

string

BtcClient

WalletAccountReadOnlyBtc.requireClient


protected resolveFeeRate(spend): Promise<bigint>

Defined in: wallet-btc/src/read-only-account.ts:87

number

number | bigint

Promise<bigint>

WalletAccountReadOnlyBtc.resolveFeeRate


sendTransaction(tx, options?): Promise<TransferResult>

Defined in: wallet-btc/src/account.ts:273

Sign and broadcast.

BtcTransaction

WriteOptions = {}

Promise<TransferResult>

IWalletAccount.sendTransaction


sign(message): Promise<string>

Defined in: wallet-btc/src/account.ts:94

BIP-137 p2wpkh signature, base64 (Electrum / Bitcoin Core encoding). Not available for taproot accounts.

string | Uint8Array<ArrayBufferLike>

Promise<string>

IWalletAccount.sign


signTransaction(tx, options?): Promise<string>

Defined in: wallet-btc/src/account.ts:256

Sign without broadcasting. Returns the raw transaction hex. Raw hex input gets the checks sendTransaction runs (prevouts through the client) and is returned unchanged, never re-signed.

BtcTransaction

WriteOptions = {}

Promise<string>

IWalletAccount.signTransaction


toReadOnlyAccount(): IWalletAccountReadOnly

Defined in: wallet-btc/src/account.ts:314

The same address as a WalletAccountReadOnlyBtc.

IWalletAccountReadOnly

IWalletAccount.toReadOnlyAccount


transfer(o, writeOptions?): Promise<TransferResult>

Defined in: wallet-btc/src/account.ts:289

Native BTC only (token is rejected). Subject to transferMaxFee.

BtcTransferOptions

WriteOptions = {}

Promise<TransferResult>

IWalletAccount.transfer


verify(message, signature): Promise<boolean>

Defined in: wallet-btc/src/read-only-account.ts:159

BIP-137: recover the key and compare its p2wpkh address with ours. Taproot addresses have no BIP-137 form.

string | Uint8Array<ArrayBufferLike>

string

Promise<boolean>

IWalletAccount.verify

WalletAccountReadOnlyBtc.verify


static fromPrivateKey(privateKey, publicKey, path, config?): WalletAccountBtc

Defined in: wallet-btc/src/account.ts:79

Back-compat: wrap a raw derived key in a LocalSigner (the account takes ownership; it cannot derive).

Uint8Array

Uint8Array

string

BtcConfig = {}

WalletAccountBtc