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
| 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: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
| Parameter | Type |
|---|---|
network | BitcoinNetwork |
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
| Parameter | Type | Description |
|---|---|---|
psbt | Transaction | PSBT to add the inputs to |
feeRate? | number | Optional fee rate in sats/vB to use for the transaction |
Returns
Promise<Transaction>
Implementation of
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
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
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
| 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: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
| 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:410
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:406
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:408
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?): Promise<{
fee: number;
inputAddressIndexes?: {
[address: string]: number[];
};
psbt?: Transaction;
}>;
Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:196
Parameters
| Parameter | Type |
|---|---|
sendingAccounts | object[] |
psbt | Transaction |
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
| 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:174
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?): Promise<{
balance: bigint;
feeRate: number;
totalFee: number;
}>;
Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:343
Parameters
| Parameter | Type |
|---|---|
sendingAccounts | object[] |
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
| 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:107
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