interbtc-api

@interlay/interbtc-api / Exports / ElectrsAPI

Interface: ElectrsAPI

Bitcoin Core API

Implemented by

Table of contents

Methods

Methods

getCoinbaseTxId

getCoinbaseTxId(userTxId): Promise<undefined | string>

Returns tx id of the coinbase tx of block in which userTxId was included.

Parameters

Name Type Description
userTxId string User tx ID which block’s txId will be returned.

Returns

Promise<undefined | string>

Tx ID of coinbase transaction or undefined if block was not found.

Defined in

src/external/electrs.ts:138


getEarliestPaymentToRecipientAddressTxId

getEarliestPaymentToRecipientAddressTxId(recipientAddress, amount?): Promise<string>

Fetch the earliest/oldest bitcoin transaction ID based on the recipient address and amount. Throw an error if no such transaction is found.

Parameters

Name Type Description
recipientAddress string Match the receiving address of a transaction output
amount? BitcoinAmount Match the amount (in BTC) of a transaction output that contains said recipientAddress.

Returns

Promise<string>

A Bitcoin transaction ID

Remarks

Performs the lookup using an external service, Esplora

Deprecated

For most cases where this is used today, getLargestPaymentToRecipientAddressTxId is better suited.

Defined in

src/external/electrs.ts:97


getLargestPaymentToRecipientAddressTxId

getLargestPaymentToRecipientAddressTxId(recipientAddress): Promise<string>

Fetch the bitcoin transaction ID with the largest payment based on the recipient address. Throw an error if no transactions are found.

Parameters

Name Type Description
recipientAddress string Match the receiving address of a transaction output

Returns

Promise<string>

A Bitcoin transaction ID

Remarks

Performs the lookup using an external service, Esplora

Defined in

src/external/electrs.ts:83


getLatestBlock

getLatestBlock(): Promise<string>

Returns

Promise<string>

The block hash of the latest Bitcoin block

Defined in

src/external/electrs.ts:31


getLatestBlockHeight

getLatestBlockHeight(): Promise<number>

Returns

Promise<number>

The height of the latest Bitcoin block

Defined in

src/external/electrs.ts:35


getMerkleProof

getMerkleProof(txid): Promise<string>

Parameters

Name Type Description
txid string The ID of a Bitcoin transaction

Returns

Promise<string>

The merkle inclusion proof for the transaction using bitcoind’s merkleblock format.

Defined in

src/external/electrs.ts:40


getParsedExecutionParameters

getParsedExecutionParameters(txid): Promise<[BitcoinMerkleProof, Transaction]>

Get the parsed (as Bytes) merkle proof and raw transaction

Parameters

Name Type Description
txid string A Bitcoin transaction ID

Returns

Promise<[BitcoinMerkleProof, Transaction]>

A tuple representing [merkleProof, transaction]

Remarks

Performs the lookup using an external service, Esplora

Defined in

src/external/electrs.ts:131


getRawTransaction

getRawTransaction(txid): Promise<string>

Parameters

Name Type Description
txid string The ID of a Bitcoin transaction

Returns

Promise<string>

The raw transaction data, represented as a hex string

Defined in

src/external/electrs.ts:56


getTransactionBlockHeight

getTransactionBlockHeight(txid): Promise<undefined | number>

Parameters

Name Type Description
txid string The ID of a Bitcoin transaction

Returns

Promise<undefined | number>

The height of the block the transaction was included in. If the block has not been confirmed, returns undefined.

Defined in

src/external/electrs.ts:51


getTransactionStatus

getTransactionStatus(txid): Promise<TxStatus>

Parameters

Name Type Description
txid string The ID of a Bitcoin transaction

Returns

Promise<TxStatus>

A TxStatus object, containing the confirmation status and number of confirmations, plus block height if the tx is included in the blockchain

Defined in

src/external/electrs.ts:46


getTx

getTx(txid): Promise<Transaction>

Fetch the Bitcoin transaction that matches the given TxId

Parameters

Name Type Description
txid string A Bitcoin transaction ID

Returns

Promise<Transaction>

A Bitcoin Transaction object

Remarks

Performs the lookup using an external service, Esplora

Defined in

src/external/electrs.ts:108


getTxIdByOpReturn

getTxIdByOpReturn(opReturn, recipientAddress?, amount?): Promise<string>

Fetch the first bitcoin transaction ID based on the OP_RETURN field, recipient and amount. Throw an error unless there is exactly one transaction with the given opcode.

Parameters

Name Type Description
opReturn string Data string used for matching the OP_CODE of Bitcoin transactions
recipientAddress? string Match the receiving address of a transaction that contains said op_return
amount? BitcoinAmount Match the amount (in BTC) of a transaction that contains said op_return and recipientAddress. This parameter is only considered if recipientAddress is defined.

Returns

Promise<string>

A Bitcoin transaction ID

Remarks

Performs the lookup using an external service, Esplora. Requires the input string to be a hex

Defined in

src/external/electrs.ts:71


getUtxoAmount

getUtxoAmount(txid, recipient): Promise<number>

Fetch the Bitcoin UTXO amount that matches the given TxId and recipient

Parameters

Name Type Description
txid string A Bitcoin transaction ID
recipient string A Bitcoin scriptpubkey address

Returns

Promise<number>

A UTXO amount if found, 0 otherwise

Remarks

Performs the lookup using an external service, Esplora

Defined in

src/external/electrs.ts:120


waitForOpreturn

waitForOpreturn(data, timeoutMs, retryIntervalMs): Promise<string>

Return a promise that either resolves to the first txid with the given opreturn data, or rejects if the timeout has elapsed.

Parameters

Name Type Description
data string The opReturn of the bitcoin transaction
timeoutMs number The duration until the Promise times out (in milliseconds)
retryIntervalMs number The time to wait (in milliseconds) between retries

Returns

Promise<string>

The Bitcoin txid

Remarks

Every 5 seconds, performs the lookup using an external service, Esplora

Defined in

src/external/electrs.ts:152


waitForTxInclusion

waitForTxInclusion(txid, timeoutMs, retryIntervalMs): Promise<TxStatus>

Parameters

Name Type Description
txid string The ID of a Bitcoin transaction
timeoutMs number -
retryIntervalMs number -

Returns

Promise<TxStatus>

A TxStatus object, containing the confirmation status and number of confirmations, plus block height if the tx is included in the blockchain

Defined in

src/external/electrs.ts:158