chaingate
Version:
Multi-chain cryptocurrency SDK for TypeScript — unified API for Bitcoin, Ethereum, Litecoin, Dogecoin, Bitcoin Cash, Polygon, Arbitrum, and any EVM-compatible chain. Create wallets, query balances, send transactions, and manage tokens and NFTs across UTXO
56 lines (55 loc) • 2.05 kB
TypeScript
import type { UtxoExplorer } from '../../Explorer/UtxoExplorer';
/** Details passed to the confirmation callback. */
export interface UtxoConfirmationDetails {
/** Transaction hash. */
transactionId: string;
/** Block height the transaction was included in. */
blockHeight: number;
}
/**
* Represents a UTXO transaction that has been signed and broadcast to the network.
*
* Use {@link onConfirmed} to register a callback that fires when the
* transaction is confirmed on-chain.
*
* @example
* ```ts
* const broadcasted = await tx.signAndBroadcast();
* console.log('TX sent:', broadcasted.transactionId);
*
* const cancel = broadcasted.onConfirmed((details) => {
* console.log('Confirmed in block', details.blockHeight);
* });
*
* // Stop waiting at any time:
* cancel();
* ```
*/
export declare class BroadcastedUtxoTransaction {
/** The transaction ID returned by the network. */
readonly transactionId: string;
private readonly explorer;
private confirmationDetails;
private polling;
private cancelled;
private callbacks;
/** @internal */
constructor(transactionId: string, explorer: UtxoExplorer);
/**
* Registers a callback to be invoked when the transaction is confirmed.
*
* - If the transaction is already confirmed, the callback fires immediately.
* - Multiple callbacks can be registered; they all fire once on confirmation.
* - Polling starts automatically on the first call and stops after confirmation
* or when the returned `cancel` function is called.
*
* @param callback - Function invoked with confirmation details.
* @returns A function that, when called, removes this callback and stops
* polling if no other callbacks remain.
*/
onConfirmed(callback: (details: UtxoConfirmationDetails) => void): () => void;
/** Polls the explorer for transaction confirmation. */
private poll;
/** Invokes all registered callbacks and clears the list. */
private fireCallbacks;
}