SingleAddressBitcoinWallet
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:17
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:24
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:21
addressType
protected readonly addressType: CoinselectAddressTypes;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:22
feeMultiplier
protected feeMultiplier: number;
Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:75
Inherited from
feeOverride?
protected optional feeOverride: number;
Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:76
Inherited from
network
protected readonly network: BTC_NETWORK;
Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:74
Inherited from
privKey?
protected readonly optional privKey: Uint8Array;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:19
pubkey
protected readonly pubkey: Uint8Array;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:20
rpc
protected readonly rpc: BitcoinRpcWithAddressIndex<any>;
Defined in: atomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:73
Inherited from
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
Inherited from
BitcoinWallet.bitcoinNetworkToObject
fundPsbt()
fundPsbt(inputPsbt, feeRate?): Promise<Transaction>;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:79
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 |
Returns
Promise<Transaction>
Overrides
generateRandomMnemonic()
static generateRandomMnemonic(): string;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:176
Generates a random 12-word long mnemonic
Returns
string
generateRandomPrivateKey()
static generateRandomPrivateKey(network?): string;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:154
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:131
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:92
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:109
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:124
Returns the public key of the wallet
Returns
string
getReceiveAddress()
getReceiveAddress(): string;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:117
Returns the bitcoin address suitable for receiving funds
Returns
string
Overrides
BitcoinWallet.getReceiveAddress
getSpendableBalance()
getSpendableBalance(psbt?, feeRate?): Promise<{
balance: bigint;
feeRate: number;
totalFee: number;
}>;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:141
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;
}>
Overrides
BitcoinWallet.getSpendableBalance
getTransactionFee()
getTransactionFee(
address,
amount,
feeRate?): Promise<number>;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:101
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
mnemonicFromEntropy()
static mnemonicFromEntropy(entropy): string;
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:167
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:187
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:66
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:90
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?): 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;
}>
Inherited from
_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;
}>
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:174
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?): 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;
}>
Inherited from
BitcoinWallet._getSpendableBalance
_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[]>
Inherited from
_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
Inherited from
BitcoinWallet._sendTransaction
toBitcoinWalletAccounts()
protected toBitcoinWalletAccounts(): [{
address: string;
addressType: CoinselectAddressTypes;
pubkey: string;
}];
Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:57
Returns all the wallet addresses controlled by the wallet
Returns
[{
address: string;
addressType: CoinselectAddressTypes;
pubkey: string;
}]