@interlay/interbtc-api / Exports / ElectrsAPI
Bitcoin Core API
▸ getCoinbaseTxId(userTxId): Promise<undefined | string>
Returns tx id of the coinbase tx of block in which userTxId was included.
| Name | Type | Description |
|---|---|---|
userTxId |
string |
User tx ID which block’s txId will be returned. |
Promise<undefined | string>
Tx ID of coinbase transaction or undefined if block was not found.
▸ 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.
| 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. |
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.
▸ 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.
| Name | Type | Description |
|---|---|---|
recipientAddress |
string |
Match the receiving address of a transaction output |
Promise<string>
A Bitcoin transaction ID
Remarks
Performs the lookup using an external service, Esplora
▸ getLatestBlock(): Promise<string>
Promise<string>
The block hash of the latest Bitcoin block
▸ getLatestBlockHeight(): Promise<number>
Promise<number>
The height of the latest Bitcoin block
▸ getMerkleProof(txid): Promise<string>
| Name | Type | Description |
|---|---|---|
txid |
string |
The ID of a Bitcoin transaction |
Promise<string>
The merkle inclusion proof for the transaction using bitcoind’s merkleblock format.
▸ getParsedExecutionParameters(txid): Promise<[BitcoinMerkleProof, Transaction]>
Get the parsed (as Bytes) merkle proof and raw transaction
| Name | Type | Description |
|---|---|---|
txid |
string |
A Bitcoin transaction ID |
Promise<[BitcoinMerkleProof, Transaction]>
A tuple representing [merkleProof, transaction]
Remarks
Performs the lookup using an external service, Esplora
▸ getRawTransaction(txid): Promise<string>
| Name | Type | Description |
|---|---|---|
txid |
string |
The ID of a Bitcoin transaction |
Promise<string>
The raw transaction data, represented as a hex string
▸ getTransactionBlockHeight(txid): Promise<undefined | number>
| Name | Type | Description |
|---|---|---|
txid |
string |
The ID of a Bitcoin transaction |
Promise<undefined | number>
The height of the block the transaction was included in. If the block has not been confirmed, returns undefined.
▸ getTransactionStatus(txid): Promise<TxStatus>
| Name | Type | Description |
|---|---|---|
txid |
string |
The ID of a Bitcoin transaction |
Promise<TxStatus>
A TxStatus object, containing the confirmation status and number of confirmations, plus block height if the tx is included in the blockchain
▸ getTx(txid): Promise<Transaction>
Fetch the Bitcoin transaction that matches the given TxId
| Name | Type | Description |
|---|---|---|
txid |
string |
A Bitcoin transaction ID |
Promise<Transaction>
A Bitcoin Transaction object
Remarks
Performs the lookup using an external service, Esplora
▸ 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.
| 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. |
Promise<string>
A Bitcoin transaction ID
Remarks
Performs the lookup using an external service, Esplora. Requires the input string to be a hex
▸ getUtxoAmount(txid, recipient): Promise<number>
Fetch the Bitcoin UTXO amount that matches the given TxId and recipient
| Name | Type | Description |
|---|---|---|
txid |
string |
A Bitcoin transaction ID |
recipient |
string |
A Bitcoin scriptpubkey address |
Promise<number>
A UTXO amount if found, 0 otherwise
Remarks
Performs the lookup using an external service, Esplora
▸ 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.
| 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 |
Promise<string>
The Bitcoin txid
Remarks
Every 5 seconds, performs the lookup using an external service, Esplora
▸ waitForTxInclusion(txid, timeoutMs, retryIntervalMs): Promise<TxStatus>
| Name | Type | Description |
|---|---|---|
txid |
string |
The ID of a Bitcoin transaction |
timeoutMs |
number |
- |
retryIntervalMs |
number |
- |
Promise<TxStatus>
A TxStatus object, containing the confirmation status and number of confirmations, plus block height if the tx is included in the blockchain