MempoolBitcoinRpc
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:65
Bitcoin RPC implementation via Mempool.space API
Implements
BitcoinRpcWithAddressIndex<MempoolBitcoinBlock>LightningNetworkApi
Constructors
Constructor
new MempoolBitcoinRpc(urlOrMempoolApi, network): MempoolBitcoinRpc;
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:70
Parameters
| Parameter | Type | Default value |
|---|---|---|
urlOrMempoolApi | string | string[] | MempoolApi | undefined |
network | BitcoinNetwork | BitcoinNetwork.MAINNET |
Returns
MempoolBitcoinRpc
Properties
api
api: MempoolApi;
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:67
network
network: BTC_NETWORK;
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:68
Methods
checkAddressTxos()
checkAddressTxos(address, txoHash): Promise<{
tx: Omit<BtcTxWithBlockheight, "hex" | "raw">;
vout: number;
}>;
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:294
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;
}>
Implementation of
BitcoinRpcWithAddressIndex.checkAddressTxos
getAddressBalances()
getAddressBalances(address): Promise<{
confirmedBalance: bigint;
unconfirmedBalance: bigint;
}>;
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:467
Returns confirmed & unconfirmed balances for a given wallet address
Parameters
| Parameter | Type | Description |
|---|---|---|
address | string |
Returns
Promise<{
confirmedBalance: bigint;
unconfirmedBalance: bigint;
}>
Implementation of
BitcoinRpcWithAddressIndex.getAddressBalances
getAddressUTXOs()
getAddressUTXOs(address): Promise<object[]>;
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:477
Returns UTXOs owned by the given wallet address
Parameters
| Parameter | Type | Description |
|---|---|---|
address | string |
Returns
Promise<object[]>
Implementation of
BitcoinRpcWithAddressIndex.getAddressUTXOs
getBlockhash()
getBlockhash(height): Promise<string>;
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:260
Returns blockhash of a block at a given block height
Parameters
| Parameter | Type | Description |
|---|---|---|
height | number |
Returns
Promise<string>
Implementation of
BitcoinRpcWithAddressIndex.getBlockhash
getBlockHeader()
getBlockHeader(blockhash): Promise<MempoolBitcoinBlock>;
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:218
Gets the bitcoin blockheader as identifier by the passed blockhash
Parameters
| Parameter | Type | Description |
|---|---|---|
blockhash | string |
Returns
Promise<MempoolBitcoinBlock>
Implementation of
BitcoinRpcWithAddressIndex.getBlockHeader
getBlockWithTransactions()
getBlockWithTransactions(blockhash): Promise<BtcBlockWithTxs>;
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:267
Returns Bitcoin block with all the transactions based on blockhash
Parameters
| Parameter | Type | Description |
|---|---|---|
blockhash | string |
Returns
Promise<BtcBlockWithTxs>
Implementation of
BitcoinRpcWithAddressIndex.getBlockWithTransactions
getConfirmationDelay()
getConfirmationDelay(tx, requiredConfirmations): Promise<number>;
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:120
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 | { confirmations?: number; txid: string; } | |
tx.confirmations? | number | - |
tx.txid | string | - |
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
Implementation of
BitcoinRpcWithAddressIndex.getConfirmationDelay
getCPFPData()
getCPFPData(txId): Promise<{
adjustedVsize: number;
effectiveFeePerVsize: number;
}>;
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:500
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;
}>
Implementation of
BitcoinRpcWithAddressIndex.getCPFPData
getEffectiveFeeRate()
getEffectiveFeeRate(btcTx): Promise<{
fee: number;
feeRate: number;
vsize: number;
}>;
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:453
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;
}>
Implementation of
BitcoinRpcWithAddressIndex.getEffectiveFeeRate
getFeeRate()
getFeeRate(): Promise<number>;
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:460
Returns the current fee rate required for submitted bitcoin transactions in sats/vB
Returns
Promise<number>
Implementation of
BitcoinRpcWithAddressIndex.getFeeRate
getLNNodeLiquidity()
getLNNodeLiquidity(pubkey): Promise<LNNodeLiquidity>;
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:399
Returns the lightning network's node liquidity as identified by an identity public key
Parameters
| Parameter | Type | Description |
|---|---|---|
pubkey | string |
Returns
Promise<LNNodeLiquidity>
Implementation of
LightningNetworkApi.getLNNodeLiquidity
getMerkleProof()
getMerkleProof(txId, blockhash): Promise<{
blockheight: number;
merkle: Buffer<ArrayBufferLike>[];
pos: number;
reversedTxId: Buffer;
}>;
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:225
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;
}>
Implementation of
BitcoinRpcWithAddressIndex.getMerkleProof
getSyncInfo()
getSyncInfo(): Promise<BtcSyncInfo>;
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:274
Returns the synchronization information of the underlying bitcoin RPC
Returns
Promise<BtcSyncInfo>
Implementation of
BitcoinRpcWithAddressIndex.getSyncInfo
getTipHeight()
getTipHeight(): Promise<number>;
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:211
Returns the current tip blockheight of bitcoin
Returns
Promise<number>
Implementation of
BitcoinRpcWithAddressIndex.getTipHeight
getTransaction()
getTransaction(txId): Promise<BtcTxWithBlockheight>;
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:243
Returns the bitcoin transaction as identified by its txId
Parameters
| Parameter | Type | Description |
|---|---|---|
txId | string |
Returns
Promise<BtcTxWithBlockheight>
Implementation of
BitcoinRpcWithAddressIndex.getTransaction
isInMainChain()
isInMainChain(blockhash): Promise<boolean>;
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:252
Checks whether a given blockhash is part of the canonical chain
Parameters
| Parameter | Type | Description |
|---|---|---|
blockhash | string |
Returns
Promise<boolean>
Implementation of
BitcoinRpcWithAddressIndex.isInMainChain
isSpent()
isSpent(utxo, confirmed?): Promise<boolean>;
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:426
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>
Implementation of
BitcoinRpcWithAddressIndex.isSpent
outputScriptToAddress()
outputScriptToAddress(outputScriptHex): Promise<string>;
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:512
Parses a bitcoin address from the passed output script in hexadecimal format
Parameters
| Parameter | Type | Description |
|---|---|---|
outputScriptHex | string |
Returns
Promise<string>
Implementation of
BitcoinRpcWithAddressIndex.outputScriptToAddress
parseTransaction()
parseTransaction(rawTx): Promise<BtcTx>;
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:440
Parses a raw bitcoin transaction
Parameters
| Parameter | Type | Description |
|---|---|---|
rawTx | string | Hexadecimal-encoded bitcoin transaction |
Returns
Promise<BtcTx>
Implementation of
BitcoinRpcWithAddressIndex.parseTransaction
sendRawPackage()
sendRawPackage(rawTx): Promise<string[]>;
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:419
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[]>
Implementation of
BitcoinRpcWithAddressIndex.sendRawPackage
sendRawTransaction()
sendRawTransaction(rawTx): Promise<string>;
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:412
Sends a single raw transaction
Parameters
| Parameter | Type | Description |
|---|---|---|
rawTx | string | A hexadecimal-encoded bitcoin transaction |
Returns
Promise<string>
Implementation of
BitcoinRpcWithAddressIndex.sendRawTransaction
waitForAddressTxo()
waitForAddressTxo(
address,
txoHash,
requiredConfirmations,
stateUpdateCbk,
abortSignal?,
intervalSeconds?): Promise<{
tx: Omit<BtcTxWithBlockheight, "hex" | "raw">;
vout: number;
}>;
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:326
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;
}>
Implementation of
BitcoinRpcWithAddressIndex.waitForAddressTxo
waitForTransaction()
waitForTransaction(
txId,
requiredConfirmations,
stateUpdateCbk,
abortSignal?,
intervalSeconds?): Promise<BtcTxWithBlockheight>;
Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:366
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>