Skip to main content

MempoolBitcoinRpc

Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:65

Bitcoin RPC implementation via Mempool.space API

Implements

Constructors

Constructor

new MempoolBitcoinRpc(urlOrMempoolApi, network): MempoolBitcoinRpc;

Defined in: atomiq-btc-mempool/src/mempool/MempoolBitcoinRpc.ts:70

Parameters

ParameterTypeDefault value
urlOrMempoolApistring | string[] | MempoolApiundefined
networkBitcoinNetworkBitcoinNetwork.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

ParameterTypeDescription
addressstringAddress that should receive the transaction
txoHashBufferRequired 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

ParameterTypeDescription
addressstring

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

ParameterTypeDescription
addressstring

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

ParameterTypeDescription
heightnumber

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

ParameterTypeDescription
blockhashstring

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

ParameterTypeDescription
blockhashstring

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

ParameterTypeDescription
tx{ confirmations?: number; txid: string; }
tx.confirmations?number-
tx.txidstring-
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

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

ParameterTypeDescription
txIdstring

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

ParameterTypeDescription
btcTxBtcTx

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

ParameterTypeDescription
pubkeystring

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

ParameterTypeDescription
txIdstringIdentifies the transaction
blockhashstringThe 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

ParameterTypeDescription
txIdstring

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

ParameterTypeDescription
blockhashstring

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

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>

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

ParameterTypeDescription
outputScriptHexstring

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

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

ParameterTypeDescription
rawTxstring[]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

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

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; }>

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

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>

Implementation of

BitcoinRpcWithAddressIndex.waitForTransaction