BitcoinWallet
Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:53
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:60
Parameters
| Parameter | Type | Default value |
|---|---|---|
mempoolApi | BitcoinRpcWithAddressIndex<any> | undefined |
network | any | undefined |
feeMultiplier | number | 1.25 |
feeOverride? | number | undefined |
Returns
BitcoinWallet
Properties
feeMultiplier
protected feeMultiplier: number;
Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:57
feeOverride?
protected optional feeOverride: number;
Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:58
network
protected readonly network: BTC_NETWORK;
Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:56
rpc
protected readonly rpc: BitcoinRpcWithAddressIndex<any>;
Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:55
Methods
bitcoinNetworkToObject()
static bitcoinNetworkToObject(network): BTC_NETWORK;
Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:385
Parameters
| Parameter | Type |
|---|---|
network | BitcoinNetwork |
Returns
BTC_NETWORK
fundPsbt()
abstract fundPsbt(
psbt,
feeRate?,
utxos?,
spendFully?): Promise<Transaction>;
Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:368
Funds (populates the inputs) for a given PSBT from wallet's UTXO set
Parameters
| Parameter | Type | Description |
|---|---|---|
psbt | Transaction | PSBT to add the inputs to |
feeRate? | number | Optional fee rate in sats/vB to use for the transaction |
utxos? | BitcoinWalletUtxo[] | Pre-fetched list of UTXOs to spend from |
spendFully? | boolean | Instructs the wallet to spend all the passed UTXOs in the transaction without creating any change output, if the feeRate is passed, it will also enforce that the feeRate in sats/vB for the resulting transaction is not more than 50% and 10 sats/vB larger (considering also the CPFP adjustments) |
Returns
Promise<Transaction>
Implementation of
getBalance()
abstract getBalance(): Promise<{
confirmedBalance: bigint;
unconfirmedBalance: bigint;
}>;
Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:375
Returns confirmed and unconfirmed balance in satoshis of the wallet
Returns
Promise<{
confirmedBalance: bigint;
unconfirmedBalance: bigint;
}>
Implementation of
getFeeRate()
getFeeRate(): Promise<number>;
Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:74
Returns the current fee rate in sats/vB
Returns
Promise<number>
Implementation of
getFundedPsbtFee()
abstract getFundedPsbtFee(psbt, feeRate?): Promise<number>;
Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:372
Estimates a total fee in satoshis for a given transaction as identified by the PSBT
Parameters
| Parameter | Type | Description |
|---|---|---|
psbt | Transaction | A PSBT to which additional inputs from wallet's UTXO set will be added and fee estimated |
feeRate? | number | Optional 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:374
Returns the bitcoin address suitable for receiving funds
Returns
string
Implementation of
IBitcoinWallet.getReceiveAddress
getSpendableBalance()
static getSpendableBalance(
utxoPool,
feeRate,
psbt?,
outputAddressType?): object;
Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:389
Parameters
| Parameter | Type |
|---|---|
utxoPool | BitcoinWalletUtxoBase[] |
feeRate | number |
psbt? | Transaction |
outputAddressType? | CoinselectAddressTypes |
Returns
object
| Name | Type | Defined in |
|---|---|---|
balance | bigint | atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:395 |
totalFee | number | atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:396 |
getSpendableBalance()
abstract getSpendableBalance(psbt?, feeRate?): Promise<{
balance: bigint;
feeRate: number;
totalFee: number;
}>;
Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:379
Returns the maximum spendable balance in satoshis given a specific PSBT that should be funded
Parameters
| Parameter | Type | Description |
|---|---|---|
psbt? | Transaction | A PSBT to which additional inputs from wallet's UTXO set will be added and fee estimated |
feeRate? | number | Optional 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:371
Estimates a total fee in satoshis for a given transaction
Parameters
| Parameter | Type | Description |
|---|---|---|
address | string | Destination address of the transaction |
amount | bigint | Amount of satoshis to send (1 BTC = 100,000,000 sats) |
feeRate? | number | Optional 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:367
Signs and broadcasts a transaction sending amount of sats to address, optionally with the
feeRate sats/vB fee rate.
Parameters
| Parameter | Type | Description |
|---|---|---|
address | string | Destination address of the transaction |
amount | bigint | Amount of satoshis to send (1 BTC = 100,000,000 sats) |
feeRate? | number | Optional 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:369
Signs inputs in the provided PSBT
Parameters
| Parameter | Type | Description |
|---|---|---|
psbt | Transaction | A PSBT to sign |
signInputs | number[] | Indices of the inputs to sign |
Returns
Promise<Transaction>
Implementation of
_fundPsbt()
protected _fundPsbt(
sendingAccounts,
psbt,
_feeRate?,
utxos?,
spendFully?): Promise<{
fee: number;
inputAddressIndexes?: {
[address: string]: number[];
};
psbt?: Transaction;
}>;
Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:178
Parameters
| Parameter | Type |
|---|---|
sendingAccounts | object[] |
psbt | Transaction |
_feeRate? | number |
utxos? | BitcoinWalletUtxo[] |
spendFully? | boolean |
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:99
Internal helper function for fetching the balance of the wallet given a specific bitcoin wallet address
Parameters
| Parameter | Type | Description |
|---|---|---|
address | string |
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:156
Parameters
| Parameter | Type | Description |
|---|---|---|
sendingAccounts | object[] | |
recipient | string | |
amount | number | |
feeRate? | number |
Returns
Promise<{
fee: number;
inputAddressIndexes?: {
[address: string]: number[];
};
psbt?: Transaction;
}>
_getSpendableBalance()
protected _getSpendableBalance(
sendingAccounts,
psbt?,
feeRate?,
outputAddressType?,
utxoPool?): Promise<{
balance: bigint;
feeRate: number;
totalFee: number;
}>;
Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:339
Parameters
| Parameter | Type |
|---|---|
sendingAccounts | object[] |
psbt? | Transaction |
feeRate? | number |
outputAddressType? | CoinselectAddressTypes |
utxoPool? | BitcoinWalletUtxoBase[] |
Returns
Promise<{
balance: bigint;
feeRate: number;
totalFee: number;
}>
_getUtxoPool()
protected _getUtxoPool(sendingAddress, sendingAddressType): Promise<BitcoinWalletUtxo[]>;
Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:110
Internal helper function for fetching the UTXO set of a given wallet address
Parameters
| Parameter | Type | Description |
|---|---|---|
sendingAddress | string | |
sendingAddressType | CoinselectAddressTypes |
Returns
Promise<BitcoinWalletUtxo[]>
_sendTransaction()
protected _sendTransaction(rawHex): Promise<string>;
Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:89
Internal helper function for sending a raw transaction through the underlying RPC
Parameters
| Parameter | Type | Description |
|---|---|---|
rawHex | string | Serialized bitcoin transaction in hexadecimal format |
Returns
Promise<string>
txId Transaction ID of the submitted bitcoin transaction