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
BitcoinRpc<T>
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
| Parameter | Type | Description |
|---|---|---|
address | string | Address that should receive the transaction |
txoHash | Buffer | Required 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
| Parameter | Type | Description |
|---|---|---|
address | string |
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
| Parameter | Type | Description |
|---|---|---|
address | string |
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
| Parameter | Type | Description |
|---|---|---|
height | number |
Returns
Promise<string>
Inherited from
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
| Parameter | Type | Description |
|---|---|---|
blockhash | string |
Returns
Promise<T>
Inherited from
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
| Parameter | Type | Description |
|---|---|---|
blockhash | string |
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
| Parameter | Type | Description |
|---|---|---|
tx | BtcTx | |
requiredConfirmations | number |
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
| Parameter | Type | Description |
|---|---|---|
txId | string |
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
| Parameter | Type | Description |
|---|---|---|
btcTx | BtcTx |
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
| Parameter | Type | Description |
|---|---|---|
txId | string | Identifies the transaction |
blockhash | string | The blockhash in which the transaction was included |
Returns
Promise<{
blockheight: number;
merkle: Buffer<ArrayBufferLike>[];
pos: number;
reversedTxId: Buffer;
}>
Inherited from
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
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
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
| Parameter | Type | Description |
|---|---|---|
txId | string |
Returns
Promise<BtcTxWithBlockheight>
Overrides
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
| Parameter | Type | Description |
|---|---|---|
blockhash | string |
Returns
Promise<boolean>
Inherited from
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
| Parameter | Type | Description |
|---|---|---|
utxo | string | The UTXO to check, should be in format [txId]:[vout] |
confirmed? | boolean | Whether the spent has to be confirmed or can also be in the mempool |
Returns
Promise<boolean>
Inherited from
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
| Parameter | Type | Description |
|---|---|---|
outputScriptHex | string |
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
| Parameter | Type | Description |
|---|---|---|
rawTx | string | Hexadecimal-encoded bitcoin transaction |
Returns
Promise<BtcTx>
Inherited from
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
| Parameter | Type | Description |
|---|---|---|
rawTx | string[] | An array of hexadecimal-encoded bitcoin transactions |
Returns
Promise<string[]>
Inherited from
sendRawTransaction()
sendRawTransaction(rawTx): Promise<string>;
Defined in: atomiq-base/src/btc/rpc/BitcoinRpc.ts:202
Sends a single raw transaction
Parameters
| Parameter | Type | Description |
|---|---|---|
rawTx | string | A hexadecimal-encoded bitcoin transaction |
Returns
Promise<string>
Inherited from
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
| Parameter | Type | Description |
|---|---|---|
address | string | Address that should receive the transaction |
txoHash | Buffer | Required output txoHash |
requiredConfirmations | number | Required confirmations of the transaction |
stateUpdateCbk | (btcTx?, vout?, txEtaMS?) => void | Callback for transaction state updates |
abortSignal? | AbortSignal | Abort signal |
intervalSeconds? | number | How 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
| Parameter | Type | Description |
|---|---|---|
txId | string | Transaction ID to monitor |
requiredConfirmations | number | Required number of confirmations |
stateUpdateCbk? | (btcTx?, txEtaMS?) => void | Optional update callback called with the current status of the bitcoin transaction |
abortSignal? | AbortSignal | |
intervalSeconds? | number | How often to poll |
Returns
Promise<BtcTxWithBlockheight>