Skip to main content

BitcoinRpc<T>

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

An interface for Bitcoin RPC, providing access to Bitcoin on-chain data

Extended by​

Type Parameters​

Type Parameter
T extends BtcBlock

Methods​

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>


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>


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>


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


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


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>


getTipHeight()​

getTipHeight(): Promise<number>;

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

Returns the current tip blockheight of bitcoin

Returns​

Promise<number>


getTransaction()​

getTransaction(txId): Promise<BtcTx>;

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

Returns the bitcoin transaction as identified by its txId

Parameters​

ParameterTypeDescription
txIdstring

Returns​

Promise<BtcTx>


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>


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>


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>


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>


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


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>