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
| Parameter | Type | Description |
|---|---|---|
height | number |
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
| Parameter | Type | Description |
|---|---|---|
blockhash | string |
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
| Parameter | Type | Description |
|---|---|---|
blockhash | string |
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
| Parameter | Type | Description |
|---|---|---|
btcTx | BtcTx |
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
| 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;
}>
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
| Parameter | Type | Description |
|---|---|---|
txId | string |
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
| Parameter | Type | Description |
|---|---|---|
blockhash | string |
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
| 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>
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>
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>
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[]>
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>