Skip to main content

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

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

BitcoinWallet.feeMultiplier


feeOverride?

protected optional feeOverride: number;

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

Inherited from

BitcoinWallet.feeOverride


network

protected readonly network: BTC_NETWORK;

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

Inherited from

BitcoinWallet.network


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

BitcoinWallet.rpc

Methods

bitcoinNetworkToObject()

static bitcoinNetworkToObject(network): BTC_NETWORK;

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

Parameters

ParameterType
networkBitcoinNetwork

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

ParameterTypeDescription
inputPsbtTransactionPSBT to add the inputs to
feeRate?numberOptional fee rate in sats/vB to use for the transaction

Returns

Promise<Transaction>

Overrides

BitcoinWallet.fundPsbt


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

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:131

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:92

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:109

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

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

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

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


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

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:187

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:66

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:90

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?): Promise<{
fee: number;
inputAddressIndexes?: {
[address: string]: number[];
};
psbt?: Transaction;
}>;

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

Parameters

ParameterType
sendingAccountsobject[]
psbtTransaction
feeRate?number

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:117

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:174

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?): Promise<{
balance: bigint;
feeRate: number;
totalFee: number;
}>;

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

Parameters

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

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:107

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:57

Returns all the wallet addresses controlled by the wallet

Returns

[{ address: string; addressType: CoinselectAddressTypes; pubkey: string; }]