Skip to main content

BitcoinRpcWithAddressIndex<T>

Defined in: atomiq-base/src/btc/rpc/BitcoinRpcWithAddressIndex.ts:36

An extended interface for Bitcoin, that allows querying balances and UTXOs of any address + other utilities

Extends

Type Parameters

Type Parameter
T extends BtcBlock

Methods

checkAddressTxos()

checkAddressTxos(address, txoHash): Promise<{
tx: Omit<BtcTxWithBlockheight, "hex" | "raw">;
vout: number;
}>;

Defined in: atomiq-base/src/btc/rpc/BitcoinRpcWithAddressIndex.ts:111

Checks if an address received the transaction with the required txoHash, returns info about that specific transaction if found, or null if not found

Parameters

ParameterTypeDescription
addressstringAddress that should receive the transaction
txoHashBufferRequired output txoHash

Returns

Promise<{ tx: Omit<BtcTxWithBlockheight, "hex" | "raw">; vout: number; }>


getAddressBalances()

getAddressBalances(address): Promise<{
confirmedBalance: bigint;
unconfirmedBalance: bigint;
}>;

Defined in: atomiq-base/src/btc/rpc/BitcoinRpcWithAddressIndex.ts:48

Returns confirmed & unconfirmed balances for a given wallet address

Parameters

ParameterTypeDescription
addressstring

Returns

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


getAddressUTXOs()

getAddressUTXOs(address): Promise<BtcAddressUtxo[]>;

Defined in: atomiq-base/src/btc/rpc/BitcoinRpcWithAddressIndex.ts:57

Returns UTXOs owned by the given wallet address

Parameters

ParameterTypeDescription
addressstring

Returns

Promise<BtcAddressUtxo[]>


getBlockhash()

getBlockhash(height): Promise<string>;

Defined in: atomiq-base/src/btc/rpc/BitcoinRpc.ts:188

Returns blockhash of a block at a given block height

Parameters

ParameterTypeDescription
heightnumber

Returns

Promise<string>

Inherited from

BitcoinRpc.getBlockhash


getBlockHeader()

getBlockHeader(blockhash): Promise<T>;

Defined in: atomiq-base/src/btc/rpc/BitcoinRpc.ts:161

Gets the bitcoin blockheader as identifier by the passed blockhash

Parameters

ParameterTypeDescription
blockhashstring

Returns

Promise<T>

Inherited from

BitcoinRpc.getBlockHeader


getBlockWithTransactions()

getBlockWithTransactions(blockhash): Promise<BtcBlockWithTxs>;

Defined in: atomiq-base/src/btc/rpc/BitcoinRpc.ts:195

Returns Bitcoin block with all the transactions based on blockhash

Parameters

ParameterTypeDescription
blockhashstring

Returns

Promise<BtcBlockWithTxs>

Inherited from

BitcoinRpc.getBlockWithTransactions


getConfirmationDelay()

getConfirmationDelay(tx, requiredConfirmations): Promise<number>;

Defined in: atomiq-base/src/btc/rpc/BitcoinRpcWithAddressIndex.ts:102

Returns an estimate after which time the tx will confirm with the required amount of confirmations, confirmationDelay of -1 means the transaction won't confirm in the near future

Parameters

ParameterTypeDescription
txBtcTx
requiredConfirmationsnumber

Returns

Promise<number>

estimated confirmation delay, -1 if the transaction won't confirm in the near future, null if the transaction was replaced or was confirmed in the meantime


getCPFPData()

getCPFPData(txId): Promise<{
adjustedVsize: number;
effectiveFeePerVsize: number;
}>;

Defined in: atomiq-base/src/btc/rpc/BitcoinRpcWithAddressIndex.ts:65

Returns CPFP (children-pay-for-parent) data for a given transaction, or null if transaction is not found or already confirmed

Parameters

ParameterTypeDescription
txIdstring

Returns

Promise<{ adjustedVsize: number; effectiveFeePerVsize: number; }>


getEffectiveFeeRate()

getEffectiveFeeRate(btcTx): Promise<{
fee: number;
feeRate: number;
vsize: number;
}>;

Defined in: atomiq-base/src/btc/rpc/BitcoinRpc.ts:243

Returns an effective fee rate of the provided bitcoin transaction, this takes into consideration the current fee rates of the potential unconfirmed inputs of the transaction that are already in the mempool

Parameters

ParameterTypeDescription
btcTxBtcTx

Returns

Promise<{ fee: number; feeRate: number; vsize: number; }>

Inherited from

BitcoinRpc.getEffectiveFeeRate


getFeeRate()

getFeeRate(): Promise<number>;

Defined in: atomiq-base/src/btc/rpc/BitcoinRpcWithAddressIndex.ts:41

Returns the current fee rate required for submitted bitcoin transactions in sats/vB

Returns

Promise<number>


getMerkleProof()

getMerkleProof(txId, blockhash): Promise<{
blockheight: number;
merkle: Buffer<ArrayBufferLike>[];
pos: number;
reversedTxId: Buffer;
}>;

Defined in: atomiq-base/src/btc/rpc/BitcoinRpc.ts:169

Returns a merkle proof for a given transaction

Parameters

ParameterTypeDescription
txIdstringIdentifies the transaction
blockhashstringThe blockhash in which the transaction was included

Returns

Promise<{ blockheight: number; merkle: Buffer<ArrayBufferLike>[]; pos: number; reversedTxId: Buffer; }>

Inherited from

BitcoinRpc.getMerkleProof


getSyncInfo()

getSyncInfo(): Promise<BtcSyncInfo>;

Defined in: atomiq-base/src/btc/rpc/BitcoinRpc.ts:219

Returns the synchronization information of the underlying bitcoin RPC

Returns

Promise<BtcSyncInfo>

Inherited from

BitcoinRpc.getSyncInfo


getTipHeight()

getTipHeight(): Promise<number>;

Defined in: atomiq-base/src/btc/rpc/BitcoinRpc.ts:214

Returns the current tip blockheight of bitcoin

Returns

Promise<number>

Inherited from

BitcoinRpc.getTipHeight


getTransaction()

getTransaction(txId): Promise<BtcTxWithBlockheight>;

Defined in: atomiq-base/src/btc/rpc/BitcoinRpcWithAddressIndex.ts:73

Returns the bitcoin transaction as identified by its txId

Parameters

ParameterTypeDescription
txIdstring

Returns

Promise<BtcTxWithBlockheight>

Overrides

BitcoinRpc.getTransaction


isInMainChain()

isInMainChain(blockhash): Promise<boolean>;

Defined in: atomiq-base/src/btc/rpc/BitcoinRpc.ts:154

Checks whether a given blockhash is part of the canonical chain

Parameters

ParameterTypeDescription
blockhashstring

Returns

Promise<boolean>

Inherited from

BitcoinRpc.isInMainChain


isSpent()

isSpent(utxo, confirmed?): Promise<boolean>;

Defined in: atomiq-base/src/btc/rpc/BitcoinRpc.ts:234

Returns whether a given UTXO is spent or not, returns false for non-existing UTXOs

Parameters

ParameterTypeDescription
utxostringThe UTXO to check, should be in format [txId]:[vout]
confirmed?booleanWhether the spent has to be confirmed or can also be in the mempool

Returns

Promise<boolean>

Inherited from

BitcoinRpc.isSpent


outputScriptToAddress()?

optional outputScriptToAddress(outputScriptHex): Promise<string>;

Defined in: atomiq-base/src/btc/rpc/BitcoinRpc.ts:250

Parses a bitcoin address from the passed output script in hexadecimal format

Parameters

ParameterTypeDescription
outputScriptHexstring

Returns

Promise<string>

Inherited from

BitcoinRpc.outputScriptToAddress


parseTransaction()

parseTransaction(rawTx): Promise<BtcTx>;

Defined in: atomiq-base/src/btc/rpc/BitcoinRpc.ts:226

Parses a raw bitcoin transaction

Parameters

ParameterTypeDescription
rawTxstringHexadecimal-encoded bitcoin transaction

Returns

Promise<BtcTx>

Inherited from

BitcoinRpc.parseTransaction


sendRawPackage()

sendRawPackage(rawTx): Promise<string[]>;

Defined in: atomiq-base/src/btc/rpc/BitcoinRpc.ts:209

Sends a Bitcoin transaction package composed of multiple individual transactions at the same time

Parameters

ParameterTypeDescription
rawTxstring[]An array of hexadecimal-encoded bitcoin transactions

Returns

Promise<string[]>

Inherited from

BitcoinRpc.sendRawPackage


sendRawTransaction()

sendRawTransaction(rawTx): Promise<string>;

Defined in: atomiq-base/src/btc/rpc/BitcoinRpc.ts:202

Sends a single raw transaction

Parameters

ParameterTypeDescription
rawTxstringA hexadecimal-encoded bitcoin transaction

Returns

Promise<string>

Inherited from

BitcoinRpc.sendRawTransaction


waitForAddressTxo()

waitForAddressTxo(
address,
txoHash,
requiredConfirmations,
stateUpdateCbk,
abortSignal?,
intervalSeconds?): Promise<{
tx: Omit<BtcTxWithBlockheight, "hex" | "raw">;
vout: number;
}>;

Defined in: atomiq-base/src/btc/rpc/BitcoinRpcWithAddressIndex.ts:126

Waits till the address receives a transaction containing a specific txoHash

Parameters

ParameterTypeDescription
addressstringAddress that should receive the transaction
txoHashBufferRequired output txoHash
requiredConfirmationsnumberRequired confirmations of the transaction
stateUpdateCbk(btcTx?, vout?, txEtaMS?) => voidCallback for transaction state updates
abortSignal?AbortSignalAbort signal
intervalSeconds?numberHow often to check new transaction

Returns

Promise<{ tx: Omit<BtcTxWithBlockheight, "hex" | "raw">; vout: number; }>


waitForTransaction()

waitForTransaction(
txId,
requiredConfirmations,
stateUpdateCbk?,
abortSignal?,
intervalSeconds?): Promise<BtcTxWithBlockheight>;

Defined in: atomiq-base/src/btc/rpc/BitcoinRpcWithAddressIndex.ts:84

Awaits till the given transaction gets confirmed

Parameters

ParameterTypeDescription
txIdstringTransaction ID to monitor
requiredConfirmationsnumberRequired number of confirmations
stateUpdateCbk?(btcTx?, txEtaMS?) => voidOptional update callback called with the current status of the bitcoin transaction
abortSignal?AbortSignal
intervalSeconds?numberHow often to poll

Returns

Promise<BtcTxWithBlockheight>