UNPKG

lotus-sdk

Version:

Central repository for several classes of tools for integrating with, and building for, the Lotusia ecosystem

90 lines 5.31 kB
import type { PrivateKey } from '../../bitcore/privatekey.js'; import type { PublicKey } from '../../bitcore/publickey.js'; import { Address } from '../../bitcore/address.js'; import type { UnspentOutput } from '../../bitcore/transaction/unspentoutput.js'; import { MuSig2P2PCoordinator } from '../musig2/coordinator.js'; import type { P2PConfig } from '../types.js'; import type { MuSig2P2PConfig } from '../musig2/types.js'; import { SwapPoolManager } from './pool.js'; import { SwapSigBurnMechanism } from './burn.js'; import type { SwapPool, SwapPoolAnnouncement, CreatePoolParams, PoolDiscoveryFilters, PoolStats, SwapSigEventMap } from './types.js'; export interface SwapSigConfig { preferredDenominations?: number[]; minParticipants?: number; maxParticipants?: number; feeRate?: number; setupTimeout?: number; settlementTimeout?: number; requireEncryptedDestinations?: boolean; randomizeOutputOrder?: boolean; chronikUrl?: string | string[]; requiredConfirmations?: number; confirmationPollInterval?: number; } export declare class SwapSigCoordinator extends MuSig2P2PCoordinator { private swapConfig; private poolManager; private burnMechanism; private privateKey; private swapSigProtocolHandler; private txMonitor; constructor(privateKey: PrivateKey, p2pConfig: P2PConfig, musig2Config?: Partial<MuSig2P2PConfig>, swapSigConfig?: Partial<SwapSigConfig>); start(): Promise<void>; stop(): Promise<void>; discoverPools(filters?: PoolDiscoveryFilters): Promise<SwapPoolAnnouncement[]>; createPool(params: CreatePoolParams): Promise<string>; joinPool(poolId: string, input: UnspentOutput, finalDestination: Address): Promise<number>; executeSwap(poolId: string, input: UnspentOutput, finalDestination: Address): Promise<string>; getPoolStats(poolId: string): PoolStats | undefined; getActivePools(): SwapPool[]; getPoolManager(): SwapPoolManager; getBurnMechanism(): SwapSigBurnMechanism; getSwapConfig(): SwapSigConfig; private _setupSwapSigEventHandlers; private _announcePool; private _createPoolAnnouncement; private _advertiseSwapSigner; private _broadcastParticipantRegistered; private _broadcastMessage; private _waitForMinimumParticipants; private _computeOutputGroups; private _computeSettlementMapping; private _executeSetupRound; private _buildSetupTransaction; private _waitForSetupConfirmations; private _revealFinalDestinations; private _executeSettlementRound; private _buildSettlementTransaction; private _waitForSettlementConfirmations; private _getMyParticipant; private _encryptAddress; private _decryptAddress; private _generateMessageId; _validatePoolAnnouncement(announcement: SwapPoolAnnouncement): boolean; _handlePoolJoin(poolId: string, participantIndex: number, peerId: string): Promise<void>; _handleParticipantRegistered(poolId: string, participantIndex: number, peerId: string, publicKey: PublicKey, inputTxId: string, inputIndex: number, ownershipProof: Buffer, finalOutputCommitment: Buffer, fromPeerId: string): Promise<void>; _handleRegistrationAck(poolId: string, participantIndex: number, acknowledgedBy: string, fromPeerId: string): Promise<void>; _handleSetupTxBroadcast(poolId: string, participantIndex: number, txId: string, fromPeerId: string): Promise<void>; _handleSetupConfirmed(poolId: string, participantIndex: number, txId: string, confirmations: number, fromPeerId: string): Promise<void>; _handleSetupComplete(poolId: string, fromPeerId: string): Promise<void>; _handleDestinationReveal(poolId: string, participantIndex: number, finalAddress: Address, revealProof: Buffer, fromPeerId: string): Promise<void>; _handleRevealComplete(poolId: string, fromPeerId: string): Promise<void>; _handleSettlementTxBroadcast(poolId: string, outputIndex: number, txId: string, fromPeerId: string): Promise<void>; _handleSettlementConfirmed(poolId: string, outputIndex: number, txId: string, confirmations: number, fromPeerId: string): Promise<void>; _handleSettlementComplete(poolId: string, fromPeerId: string): Promise<void>; _handlePoolAbort(poolId: string, reason: string, fromPeerId: string): Promise<void>; _handleParticipantDropped(poolId: string, peerId: string, reason: string, fromPeerId: string): Promise<void>; _onSwapSigPeerConnected(peerId: string): void; _onSwapSigPeerDisconnected(peerId: string): void; _sendMessageToPeer(peerId: string, messageType: string, payload: unknown): Promise<void>; } export interface SwapSigCoordinator { on<E extends keyof SwapSigEventMap>(event: E, listener: SwapSigEventMap[E]): this; once<E extends keyof SwapSigEventMap>(event: E, listener: SwapSigEventMap[E]): this; emit<E extends keyof SwapSigEventMap>(event: E, ...args: Parameters<SwapSigEventMap[E]>): boolean; off<E extends keyof SwapSigEventMap>(event: E, listener: SwapSigEventMap[E]): this; removeListener<E extends keyof SwapSigEventMap>(event: E, listener: SwapSigEventMap[E]): this; removeAllListeners<E extends keyof SwapSigEventMap>(event?: E): this; listenerCount<E extends keyof SwapSigEventMap>(event: E): number; } //# sourceMappingURL=coordinator.d.ts.map