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 herep2tr input → `schnorr` + `tweak` over the BIP-341 sighash (DEFAULT), tweak = TapTweak(xonly)BIP-137 msg → `ecdsa-recoverable` over the magic hashEvery 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.
Extends
Section titled “Extends”Implements
Section titled “Implements”IWalletAccount
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”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.
Parameters
Section titled “Parameters”signer
Section titled “signer”Signer
publicKey
Section titled “publicKey”Uint8Array
string
config?
Section titled “config?”BtcConfig = {}
Returns
Section titled “Returns”WalletAccountBtc
Overrides
Section titled “Overrides”WalletAccountReadOnlyBtc.constructor
Properties
Section titled “Properties”_client
Section titled “_client”
protectedreadonly_client:BtcClient|undefined
Defined in: wallet-btc/src/read-only-account.ts:39
Inherited from
Section titled “Inherited from”WalletAccountReadOnlyBtc._client
_config
Section titled “_config”
protectedreadonly_config:BtcConfig
Defined in: wallet-btc/src/read-only-account.ts:38
Inherited from
Section titled “Inherited from”WalletAccountReadOnlyBtc._config
_network
Section titled “_network”
protectedreadonly_network:BTC_NETWORK
Defined in: wallet-btc/src/read-only-account.ts:40
Inherited from
Section titled “Inherited from”WalletAccountReadOnlyBtc._network
_networkName
Section titled “_networkName”
protectedreadonly_networkName:BtcNetwork
Defined in: wallet-btc/src/read-only-account.ts:41
Inherited from
Section titled “Inherited from”WalletAccountReadOnlyBtc._networkName
address
Section titled “address”
readonlyaddress:string
Defined in: wallet-btc/src/read-only-account.ts:28
The address.
Inherited from
Section titled “Inherited from”WalletAccountReadOnlyBtc.address
addressType
Section titled “addressType”
readonlyaddressType: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.
Overrides
Section titled “Overrides”WalletAccountReadOnlyBtc.addressType
readonlychain: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”.
Implementation of
Section titled “Implementation of”IWalletAccount.chain
Inherited from
Section titled “Inherited from”WalletAccountReadOnlyBtc.chain
dustLimit
Section titled “dustLimit”
readonlydustLimit:bigint
Defined in: wallet-btc/src/read-only-account.ts:37
Smallest output this address type may create, in satoshis.
Inherited from
Section titled “Inherited from”WalletAccountReadOnlyBtc.dustLimit
needsNetwork
Section titled “needsNetwork”
readonlyneedsNetwork:true=true
Defined in: wallet-btc/src/account.ts:47
UTXOs, fee rate and tip height come from the network before signing.
Implementation of
Section titled “Implementation of”IWalletAccount.needsNetwork
readonlypath:string
Defined in: wallet-btc/src/account.ts:49
Derivation path, or external for an external signer.
publicKey
Section titled “publicKey”
readonlypublicKey:Uint8Array
Defined in: wallet-btc/src/account.ts:51
Compressed secp256k1 public key.
scriptKind
Section titled “scriptKind”
readonlyscriptKind:ScriptKind
Defined in: wallet-btc/src/read-only-account.ts:33
Script type of the address.
Inherited from
Section titled “Inherited from”WalletAccountReadOnlyBtc.scriptKind
scriptPubKey
Section titled “scriptPubKey”
readonlyscriptPubKey:Uint8Array
Defined in: wallet-btc/src/read-only-account.ts:31
Output script of address.
Inherited from
Section titled “Inherited from”WalletAccountReadOnlyBtc.scriptPubKey
signerKind
Section titled “signerKind”
readonlysignerKind:"seed"|"key"|"external"
Defined in: wallet-btc/src/account.ts:60
What holds the key: seed, key (one imported key) or external.
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”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.
Returns
Section titled “Returns”number | undefined
maxFeeRate
Section titled “maxFeeRate”Get Signature
Section titled “Get Signature”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.
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”WalletAccountReadOnlyBtc.maxFeeRate
Methods
Section titled “Methods”describeTransaction()
Section titled “describeTransaction()”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.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<BtcTxDescription>
dispose()
Section titled “dispose()”dispose():
void
Defined in: wallet-btc/src/account.ts:319
Zeroize this account’s key material.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”IWalletAccount.dispose
getAddress()
Section titled “getAddress()”getAddress():
Promise<string>
Defined in: wallet-btc/src/read-only-account.ts:68
The address.
Returns
Section titled “Returns”Promise<string>
Implementation of
Section titled “Implementation of”IWalletAccount.getAddress
Inherited from
Section titled “Inherited from”WalletAccountReadOnlyBtc.getAddress
getBalance()
Section titled “getBalance()”getBalance():
Promise<bigint>
Defined in: wallet-btc/src/read-only-account.ts:71
Confirmed minus pending outgoing (Bitcoin Core wallet semantics).
Returns
Section titled “Returns”Promise<bigint>
Implementation of
Section titled “Implementation of”IWalletAccount.getBalance
Inherited from
Section titled “Inherited from”WalletAccountReadOnlyBtc.getBalance
getMaxSpendable()
Section titled “getMaxSpendable()”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.
Parameters
Section titled “Parameters”confirmationTarget?
Section titled “confirmationTarget?”number
feeRate?
Section titled “feeRate?”number | bigint
string
Returns
Section titled “Returns”Promise<BtcMaxSpendableResult>
Inherited from
Section titled “Inherited from”WalletAccountReadOnlyBtc.getMaxSpendable
getTokenBalance()
Section titled “getTokenBalance()”getTokenBalance(
_token):Promise<bigint>
Defined in: wallet-btc/src/read-only-account.ts:77
Always throws: Bitcoin has no tokens.
Parameters
Section titled “Parameters”_token
Section titled “_token”string
Returns
Section titled “Returns”Promise<bigint>
Implementation of
Section titled “Implementation of”IWalletAccount.getTokenBalance
Inherited from
Section titled “Inherited from”WalletAccountReadOnlyBtc.getTokenBalance
getTransactionReceipt()
Section titled “getTransactionReceipt()”getTransactionReceipt(
hash):Promise<BtcReceipt|undefined>
Defined in: wallet-btc/src/read-only-account.ts:147
Undefined until the transaction is mined.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<BtcReceipt | undefined>
Implementation of
Section titled “Implementation of”IWalletAccount.getTransactionReceipt
Inherited from
Section titled “Inherited from”WalletAccountReadOnlyBtc.getTransactionReceipt
inputWeight()
Section titled “inputWeight()”
protectedinputWeight():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.
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”WalletAccountReadOnlyBtc.inputWeight
lockTimeHeight()
Section titled “lockTimeHeight()”
protectedlockTimeHeight():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.
Returns
Section titled “Returns”Promise<number>
Inherited from
Section titled “Inherited from”WalletAccountReadOnlyBtc.lockTimeHeight
planSpend()
Section titled “planSpend()”
protectedplanSpend(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.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<SpendPlan>
Inherited from
Section titled “Inherited from”WalletAccountReadOnlyBtc.planSpend
quoteSendTransaction()
Section titled “quoteSendTransaction()”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.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<{ fee: bigint; }>
Implementation of
Section titled “Implementation of”IWalletAccount.quoteSendTransaction
Overrides
Section titled “Overrides”WalletAccountReadOnlyBtc.quoteSendTransaction
quoteTransfer()
Section titled “quoteTransfer()”quoteTransfer(
o):Promise<{fee:bigint; }>
Defined in: wallet-btc/src/read-only-account.ts:130
Fee of a transfer in satoshis.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<{ fee: bigint; }>
Throws
Section titled “Throws”Error when token is set.
Implementation of
Section titled “Implementation of”IWalletAccount.quoteTransfer
Inherited from
Section titled “Inherited from”WalletAccountReadOnlyBtc.quoteTransfer
requireClient()
Section titled “requireClient()”
protectedrequireClient(what):BtcClient
Defined in: wallet-btc/src/read-only-account.ts:57
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”WalletAccountReadOnlyBtc.requireClient
resolveFeeRate()
Section titled “resolveFeeRate()”
protectedresolveFeeRate(spend):Promise<bigint>
Defined in: wallet-btc/src/read-only-account.ts:87
Parameters
Section titled “Parameters”confirmationTarget?
Section titled “confirmationTarget?”number
feeRate?
Section titled “feeRate?”number | bigint
Returns
Section titled “Returns”Promise<bigint>
Inherited from
Section titled “Inherited from”WalletAccountReadOnlyBtc.resolveFeeRate
sendTransaction()
Section titled “sendTransaction()”sendTransaction(
tx,options?):Promise<TransferResult>
Defined in: wallet-btc/src/account.ts:273
Sign and broadcast.
Parameters
Section titled “Parameters”options?
Section titled “options?”WriteOptions = {}
Returns
Section titled “Returns”Promise<TransferResult>
Implementation of
Section titled “Implementation of”IWalletAccount.sendTransaction
sign()
Section titled “sign()”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.
Parameters
Section titled “Parameters”message
Section titled “message”string | Uint8Array<ArrayBufferLike>
Returns
Section titled “Returns”Promise<string>
Implementation of
Section titled “Implementation of”IWalletAccount.sign
signTransaction()
Section titled “signTransaction()”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.
Parameters
Section titled “Parameters”options?
Section titled “options?”WriteOptions = {}
Returns
Section titled “Returns”Promise<string>
Implementation of
Section titled “Implementation of”IWalletAccount.signTransaction
toReadOnlyAccount()
Section titled “toReadOnlyAccount()”toReadOnlyAccount():
IWalletAccountReadOnly
Defined in: wallet-btc/src/account.ts:314
The same address as a WalletAccountReadOnlyBtc.
Returns
Section titled “Returns”IWalletAccountReadOnly
Implementation of
Section titled “Implementation of”IWalletAccount.toReadOnlyAccount
transfer()
Section titled “transfer()”transfer(
o,writeOptions?):Promise<TransferResult>
Defined in: wallet-btc/src/account.ts:289
Native BTC only (token is rejected). Subject to transferMaxFee.
Parameters
Section titled “Parameters”writeOptions?
Section titled “writeOptions?”WriteOptions = {}
Returns
Section titled “Returns”Promise<TransferResult>
Implementation of
Section titled “Implementation of”IWalletAccount.transfer
verify()
Section titled “verify()”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.
Parameters
Section titled “Parameters”message
Section titled “message”string | Uint8Array<ArrayBufferLike>
signature
Section titled “signature”string
Returns
Section titled “Returns”Promise<boolean>
Implementation of
Section titled “Implementation of”IWalletAccount.verify
Inherited from
Section titled “Inherited from”WalletAccountReadOnlyBtc.verify
fromPrivateKey()
Section titled “fromPrivateKey()”
staticfromPrivateKey(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).
Parameters
Section titled “Parameters”privateKey
Section titled “privateKey”Uint8Array
publicKey
Section titled “publicKey”Uint8Array
string
config?
Section titled “config?”BtcConfig = {}
Returns
Section titled “Returns”WalletAccountBtc