@atomiqlabs/sdk-lib
Version:
Basic SDK functionality library for atomiq
82 lines (81 loc) • 3.47 kB
TypeScript
/// <reference types="node" />
/// <reference types="node" />
import { BtcBlockWithTxs, BtcSyncInfo, BtcTx } from "@atomiqlabs/base";
import { MempoolBitcoinBlock } from "./MempoolBitcoinBlock";
import { MempoolApi } from "./MempoolApi";
import { Buffer } from "buffer";
import { BitcoinRpcWithTxoListener, BtcTxWithBlockheight } from "../BitcoinRpcWithTxoListener";
import { LightningNetworkApi, LNNodeLiquidity } from "../LightningNetworkApi";
export declare class MempoolBitcoinRpc implements BitcoinRpcWithTxoListener<MempoolBitcoinBlock>, LightningNetworkApi {
api: MempoolApi;
constructor(mempoolApi: MempoolApi);
/**
* Returns a txo hash for a specific transaction vout
*
* @param vout
* @private
*/
private static getTxoHash;
/**
* Returns delay in milliseconds till an unconfirmed transaction is expected to confirm, returns -1
* if the transaction won't confirm any time soon
*
* @param feeRate
* @private
*/
private getTimeTillConfirmation;
/**
* 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
*
* @param tx
* @param requiredConfirmations
* @private
*
* @returns 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
*/
getConfirmationDelay(tx: BtcTx, requiredConfirmations: number): Promise<number | null>;
/**
* Converts mempool API's transaction to BtcTx object
* @param tx Transaction to convert
* @param getRaw If the raw transaction field should be filled (requires one more network request)
* @private
*/
private toBtcTx;
getTipHeight(): Promise<number>;
getBlockHeader(blockhash: string): Promise<MempoolBitcoinBlock>;
getMerkleProof(txId: string, blockhash: string): Promise<{
reversedTxId: Buffer;
pos: number;
merkle: Buffer[];
blockheight: number;
}>;
getTransaction(txId: string): Promise<BtcTxWithBlockheight>;
isInMainChain(blockhash: string): Promise<boolean>;
getBlockhash(height: number): Promise<string>;
getBlockWithTransactions(blockhash: string): Promise<BtcBlockWithTxs>;
getSyncInfo(): Promise<BtcSyncInfo>;
getPast15Blocks(height: number): Promise<MempoolBitcoinBlock[]>;
checkAddressTxos(address: string, txoHash: Buffer): Promise<{
tx: BtcTxWithBlockheight;
vout: number;
} | null>;
/**
* Waits till the address receives a transaction containing a specific txoHash
*
* @param address
* @param txoHash
* @param requiredConfirmations
* @param stateUpdateCbk
* @param abortSignal
* @param intervalSeconds
*/
waitForAddressTxo(address: string, txoHash: Buffer, requiredConfirmations: number, stateUpdateCbk: (confirmations: number, txId: string, vout: number, txEtaMS: number) => void, abortSignal?: AbortSignal, intervalSeconds?: number): Promise<{
tx: BtcTxWithBlockheight;
vout: number;
}>;
getLNNodeLiquidity(pubkey: string): Promise<LNNodeLiquidity>;
sendRawTransaction(rawTx: string): Promise<string>;
sendRawPackage(rawTx: string[]): Promise<string[]>;
}