UNPKG

@node-dlc/chainmon

Version:
49 lines (48 loc) 1.48 kB
/// <reference types="node" /> import { OutPoint, Script, Value } from '@node-dlc/bitcoin'; import { BitcoindClient, BlockSummary } from '@node-dlc/bitcoind'; import { EventEmitter } from 'events'; export declare class BlockWatcher extends EventEmitter { /** * Outpoints that are being watched */ watchedOutPoints: Map<string, OutPoint>; /** * ScriptPubKeys that are being watched */ watchedScriptPubKeys: Map<string, [Script, Value]>; receivedBlocks: Map<string, BlockSummary>; previousHashToHash: Map<string, string>; private _client; /** * TxWatcher listens for transactions that match certain patterns * and events when a transaction is found matching the pattern * * @param client */ constructor(client: BitcoindClient); /** * Starts watching for transactions */ start(latestBlock: BlockSummary): void; /** * Stops watching for transactions */ stop(): void; /** * Watches an outpoint for broadcase in a new transaction * @param outpoint */ watchOutpoint(outpoint: OutPoint): void; /** * Watches a scriptpubkey for broadcast in a new transaction * @param scriptPubKey * @param value */ watchScriptPubKey(scriptPubKey: Script, value?: Value): void; private _checkOutpoints; private _checkScriptPubkeys; private _onRawBlock; private _processBlock; private _findPreviousBlockAndProcess; }