Skip to main content

BitcoinWallet

Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:71

Abstract base class for Bitcoin wallet implementations, using bitcoin rpc with address index as a backend for fetching balances, UTXOs, etc.

Extended by

Implements

Constructors

Constructor

new BitcoinWallet(
mempoolApi,
network,
feeMultiplier,
feeOverride?): BitcoinWallet;

Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:78

Parameters

ParameterTypeDefault value
mempoolApiBitcoinRpcWithAddressIndex<any>undefined
networkanyundefined
feeMultipliernumber1.25
feeOverride?numberundefined

Returns

BitcoinWallet

Properties

feeMultiplier

protected feeMultiplier: number;

Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:75


feeOverride?

protected optional feeOverride: number;

Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:76


network

protected readonly network: BTC_NETWORK;

Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:74


rpc

protected readonly rpc: BitcoinRpcWithAddressIndex<any>;

Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:73

Methods

bitcoinNetworkToObject()

static bitcoinNetworkToObject(network): BTC_NETWORK;

Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:424

Parameters

ParameterType
networkBitcoinNetwork

Returns

BTC_NETWORK


fundPsbt()

abstract fundPsbt(psbt, feeRate?): Promise<Transaction>;

Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:407

Funds (populates the inputs) for a given PSBT from wallet's UTXO set

Parameters

ParameterTypeDescription
psbtTransactionPSBT to add the inputs to
feeRate?numberOptional fee rate in sats/vB to use for the transaction

Returns

Promise<Transaction>

Implementation of

IBitcoinWallet.fundPsbt


getBalance()

abstract getBalance(): Promise<{
confirmedBalance: bigint;
unconfirmedBalance: bigint;
}>;

Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:414

Returns confirmed and unconfirmed balance in satoshis of the wallet

Returns

Promise<{ confirmedBalance: bigint; unconfirmedBalance: bigint; }>

Implementation of

IBitcoinWallet.getBalance


getFeeRate()

getFeeRate(): Promise<number>;

Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:92

Returns the current fee rate in sats/vB

Returns

Promise<number>

Implementation of

IBitcoinWallet.getFeeRate


getFundedPsbtFee()

abstract getFundedPsbtFee(psbt, feeRate?): Promise<number>;

Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:411

Estimates a total fee in satoshis for a given transaction as identified by the PSBT

Parameters

ParameterTypeDescription
psbtTransactionA PSBT to which additional inputs from wallet's UTXO set will be added and fee estimated
feeRate?numberOptional fee rate in sats/vB to use for the transaction

Returns

Promise<number>

Implementation of

IBitcoinWallet.getFundedPsbtFee


getReceiveAddress()

abstract getReceiveAddress(): string;

Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:413

Returns the bitcoin address suitable for receiving funds

Returns

string

Implementation of

IBitcoinWallet.getReceiveAddress


getSpendableBalance()

abstract getSpendableBalance(psbt?, feeRate?): Promise<{
balance: bigint;
feeRate: number;
totalFee: number;
}>;

Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:418

Returns the maximum spendable balance in satoshis given a specific PSBT that should be funded

Parameters

ParameterTypeDescription
psbt?TransactionA PSBT to which additional inputs from wallet's UTXO set will be added and fee estimated
feeRate?numberOptional fee rate in sats/vB to use for the transaction

Returns

Promise<{ balance: bigint; feeRate: number; totalFee: number; }>

Implementation of

IBitcoinWallet.getSpendableBalance


getTransactionFee()

abstract getTransactionFee(
address,
amount,
feeRate?): Promise<number>;

Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:410

Estimates a total fee in satoshis for a given transaction

Parameters

ParameterTypeDescription
addressstringDestination address of the transaction
amountbigintAmount of satoshis to send (1 BTC = 100,000,000 sats)
feeRate?numberOptional fee rate in sats/vB to use for the transaction

Returns

Promise<number>

Implementation of

IBitcoinWallet.getTransactionFee


sendTransaction()

abstract sendTransaction(
address,
amount,
feeRate?): Promise<string>;

Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:406

Signs and broadcasts a transaction sending amount of sats to address, optionally with the feeRate sats/vB fee rate.

Parameters

ParameterTypeDescription
addressstringDestination address of the transaction
amountbigintAmount of satoshis to send (1 BTC = 100,000,000 sats)
feeRate?numberOptional fee rate in sats/vB to use for the transaction

Returns

Promise<string>

Implementation of

IBitcoinWallet.sendTransaction


signPsbt()

abstract signPsbt(psbt, signInputs): Promise<Transaction>;

Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:408

Signs inputs in the provided PSBT

Parameters

ParameterTypeDescription
psbtTransactionA PSBT to sign
signInputsnumber[]Indices of the inputs to sign

Returns

Promise<Transaction>

Implementation of

IBitcoinWallet.signPsbt


_fundPsbt()

protected _fundPsbt(
sendingAccounts,
psbt,
feeRate?): Promise<{
fee: number;
inputAddressIndexes?: {
[address: string]: number[];
};
psbt?: Transaction;
}>;

Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:196

Parameters

ParameterType
sendingAccountsobject[]
psbtTransaction
feeRate?number

Returns

Promise<{ fee: number; inputAddressIndexes?: { [address: string]: number[]; }; psbt?: Transaction; }>


_getBalance()

protected _getBalance(address): Promise<{
confirmedBalance: bigint;
unconfirmedBalance: bigint;
}>;

Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:117

Internal helper function for fetching the balance of the wallet given a specific bitcoin wallet address

Parameters

ParameterTypeDescription
addressstring

Returns

Promise<{ confirmedBalance: bigint; unconfirmedBalance: bigint; }>


_getPsbt()

protected _getPsbt(
sendingAccounts,
recipient,
amount,
feeRate?): Promise<{
fee: number;
inputAddressIndexes?: {
[address: string]: number[];
};
psbt?: Transaction;
}>;

Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:174

Parameters

ParameterTypeDescription
sendingAccountsobject[]
recipientstring
amountnumber
feeRate?number

Returns

Promise<{ fee: number; inputAddressIndexes?: { [address: string]: number[]; }; psbt?: Transaction; }>


_getSpendableBalance()

protected _getSpendableBalance(
sendingAccounts,
psbt?,
feeRate?): Promise<{
balance: bigint;
feeRate: number;
totalFee: number;
}>;

Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:343

Parameters

ParameterType
sendingAccountsobject[]
psbt?Transaction
feeRate?number

Returns

Promise<{ balance: bigint; feeRate: number; totalFee: number; }>


_getUtxoPool()

protected _getUtxoPool(sendingAddress, sendingAddressType): Promise<BitcoinWalletUtxo[]>;

Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:128

Internal helper function for fetching the UTXO set of a given wallet address

Parameters

ParameterTypeDescription
sendingAddressstring
sendingAddressTypeCoinselectAddressTypes

Returns

Promise<BitcoinWalletUtxo[]>


_sendTransaction()

protected _sendTransaction(rawHex): Promise<string>;

Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:107

Internal helper function for sending a raw transaction through the underlying RPC

Parameters

ParameterTypeDescription
rawHexstringSerialized bitcoin transaction in hexadecimal format

Returns

Promise<string>

txId Transaction ID of the submitted bitcoin transaction