Skip to main content

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​

ParameterTypeDefault value
mempoolApiBitcoinRpcWithAddressIndex<any>undefined
_networkanyundefined
addressDataOrWIF| string | { address: string; publicKey: string; }undefined
feeMultipliernumber1.25
feeOverride?numberundefined

Returns​

SingleAddressBitcoinWallet

Overrides​

BitcoinWallet.constructor

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​

BitcoinWallet.feeMultiplier


feeOverride?​

protected optional feeOverride: number;

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

Inherited from​

BitcoinWallet.feeOverride


network​

protected readonly network: BTC_NETWORK;

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

Inherited from​

BitcoinWallet.network


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​

BitcoinWallet.rpc

Methods​

bitcoinNetworkToObject()​

static bitcoinNetworkToObject(network): BTC_NETWORK;

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

Parameters​

ParameterType
networkBitcoinNetwork

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​

ParameterTypeDescription
inputPsbtTransactionPSBT to add the inputs to
feeRate?numberOptional fee rate in sats/vB to use for the transaction
utxos?BitcoinWalletUtxo[]Pre-fetched list of UTXOs to spend from
spendFully?booleanInstructs 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​

BitcoinWallet.fundPsbt


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​

ParameterType
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​

BitcoinWallet.getBalance


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​

BitcoinWallet.getFeeRate


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​

ParameterTypeDescription
basePsbtTransactionA 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>

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​

ParameterType
utxoPoolBitcoinWalletUtxoBase[]
feeRatenumber
psbt?Transaction
outputAddressType?CoinselectAddressTypes

Returns​

object

NameTypeDefined in
balancebigintatomiq-sdk/src/bitcoin/wallet/BitcoinWallet.ts:395
totalFeenumberatomiq-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​

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
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​

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>

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​

ParameterTypeDescription
entropyBufferEntropy 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​

ParameterTypeDescription
mnemonicstringMnemonic to generate the WIF key from
network?anyOptional bitcoin network to generate the WIF for
derivationPath?stringOptional 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​

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>

Overrides​

BitcoinWallet.sendTransaction


signPsbt()​

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

Defined in: atomiq-sdk/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts:103

Signs inputs in the provided PSBT

Parameters​

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

Returns​

Promise<Transaction>

Overrides​

BitcoinWallet.signPsbt


_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​

ParameterType
sendingAccountsobject[]
psbtTransaction
_feeRate?number
utxos?BitcoinWalletUtxo[]
spendFully?boolean

Returns​

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

Inherited from​

BitcoinWallet._fundPsbt


_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​

ParameterTypeDescription
addressstring

Returns​

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

Inherited from​

BitcoinWallet._getBalance


_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​

ParameterTypeDescription
sendingAccountsobject[]
recipientstring
amountnumber
feeRate?number

Returns​

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

Inherited from​

BitcoinWallet._getPsbt


_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​

ParameterType
sendingAccountsobject[]
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​

ParameterTypeDescription
sendingAddressstring
sendingAddressTypeCoinselectAddressTypes

Returns​

Promise<BitcoinWalletUtxo[]>

Inherited from​

BitcoinWallet._getUtxoPool


_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​

ParameterTypeDescription
rawHexstringSerialized 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; }]