SingleAddressBitcoinWallet
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:20
Bitcoin wallet implementation deriving a single address from a WIF encoded private key
Extends
Constructors
Constructor
new SingleAddressBitcoinWallet(
mempoolApi,
_network,
addressDataOrWIF,
feeMultiplier,
feeOverride?): SingleAddressBitcoinWallet;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:27
Parameters
| Parameter | Type | Default value |
|---|---|---|
mempoolApi | BitcoinRpcWithAddressIndex<any> | undefined |
_network | any | undefined |
addressDataOrWIF | | string | { address: string; publicKey: string; } | undefined |
feeMultiplier | number | 1.25 |
feeOverride? | number | undefined |
Returns
SingleAddressBitcoinWallet
Overrides
Properties
address
protected readonly address: string;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:24
addressType
protected readonly addressType: CoinselectAddressTypes;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:25
feeMultiplier
protected feeMultiplier: number;
Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:57
Inherited from
feeOverride?
protected optional feeOverride: number;
Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:58
Inherited from
network
protected readonly network: BTC_NETWORK;
Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:56
Inherited from
privKey?
protected readonly optional privKey: Uint8Array;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:22
pubkey
protected readonly pubkey: Uint8Array;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:23
rpc
protected readonly rpc: BitcoinRpcWithAddressIndex<any>;
Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:55
Inherited from
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
Inherited from
BitcoinWallet.bitcoinNetworkToObject
fundPsbt()
fundPsbt(
inputPsbt,
feeRate?,
utxos?,
spendFully?): Promise<Transaction>;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:92
Funds (populates the inputs) for a given PSBT from wallet's UTXO set
Parameters
| Parameter | Type | Description |
|---|---|---|
inputPsbt | 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>
Overrides
generateRandomMnemonic()
static generateRandomMnemonic(): string;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:196
Generates a random 12-word long mnemonic
Returns
string
generateRandomPrivateKey()
static generateRandomPrivateKey(network?): string;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:174
Generates a new random private key WIF that can be used to instantiate the bitcoin wallet instance
Parameters
| Parameter | Type |
|---|---|
network? | any |
Returns
string
A WIF encoded bitcoin private key
getBalance()
getBalance(): Promise<{
confirmedBalance: bigint;
unconfirmedBalance: bigint;
}>;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:144
Returns confirmed and unconfirmed balance in satoshis of the wallet
Returns
Promise<{
confirmedBalance: bigint;
unconfirmedBalance: bigint;
}>
Overrides
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>
Inherited from
getFundedPsbtFee()
getFundedPsbtFee(basePsbt, feeRate?): Promise<number>;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:122
Estimates a total fee in satoshis for a given transaction as identified by the PSBT
Parameters
| Parameter | Type | Description |
|---|---|---|
basePsbt | 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>
Overrides
BitcoinWallet.getFundedPsbtFee
getPublicKey()
getPublicKey(): string;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:137
Returns the public key of the wallet
Returns
string
getReceiveAddress()
getReceiveAddress(): string;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:130
Returns the bitcoin address suitable for receiving funds
Returns
string
Overrides
BitcoinWallet.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 |
Inherited from
BitcoinWallet.getSpendableBalance
getSpendableBalance()
getSpendableBalance(
psbt?,
feeRate?,
outputAddressType?,
utxos?): Promise<{
balance: bigint;
feeRate: number;
totalFee: number;
}>;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:154
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 |
outputAddressType? | CoinselectAddressTypes | - |
utxos? | BitcoinWalletUtxoBase[] | - |
Returns
Promise<{
balance: bigint;
feeRate: number;
totalFee: number;
}>
Overrides
BitcoinWallet.getSpendableBalance
getTransactionFee()
getTransactionFee(
address,
amount,
feeRate?): Promise<number>;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:114
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>
Overrides
BitcoinWallet.getTransactionFee
getUtxoPool()
getUtxoPool(): Promise<BitcoinWalletUtxo[]>;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:165
Returns
Promise<BitcoinWalletUtxo[]>
Inherit Doc
mnemonicFromEntropy()
static mnemonicFromEntropy(entropy): string;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:187
Generates a 12-word long mnemonic from any entropy source with 128-bits or more, the entropy is first hashed using sha256, and the first 16 bytes of the hash are used to generate the mnemonic
Parameters
| Parameter | Type | Description |
|---|---|---|
entropy | Buffer | Entropy to use for generating the mnemonic |
Returns
string
mnemonicToPrivateKey()
static mnemonicToPrivateKey(
mnemonic,
network?,
derivationPath?): Promise<string>;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:207
Generates a WIF private key from mnemonic phrase
Parameters
| Parameter | Type | Description |
|---|---|---|
mnemonic | string | Mnemonic to generate the WIF key from |
network? | any | Optional bitcoin network to generate the WIF for |
derivationPath? | string | Optional custom derivation path to use for deriving the wallet |
Returns
Promise<string>
sendTransaction()
sendTransaction(
address,
amount,
feeRate?): Promise<string>;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:79
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>
Overrides
signPsbt()
signPsbt(psbt, signInputs): Promise<Transaction>;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:103
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>
Overrides
_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;
}>
Inherited from
_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;
}>
Inherited from
_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;
}>
Inherited from
_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;
}>
Inherited from
BitcoinWallet._getSpendableBalance
_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[]>
Inherited from
_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
Inherited from
BitcoinWallet._sendTransaction
toBitcoinWalletAccounts()
protected toBitcoinWalletAccounts(): [{
address: string;
addressType: CoinselectAddressTypes;
pubkey: string;
}];
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:70
Returns all the wallet addresses controlled by the wallet
Returns
[{
address: string;
addressType: CoinselectAddressTypes;
pubkey: string;
}]