UNPKG

@node-dlc/messaging

Version:
97 lines (96 loc) 3.2 kB
/// <reference types="node" /> import { MessageType } from '../MessageType'; import { BatchFundingGroup } from './BatchFundingGroup'; import { CetAdaptorSignatures, ICetAdaptorSignaturesJSON } from './CetAdaptorSignatures'; import { IDlcMessage } from './DlcMessage'; import { FundingSignatures, IFundingSignaturesJSON } from './FundingSignatures'; /** * DlcSign gives all of the initiator's signatures, which allows the * receiver to broadcast the funding transaction with both parties being * fully committed to all closing transactions. * Updated to support dlcspecs PR #163 format. */ export declare class DlcSign implements IDlcMessage { static type: MessageType; /** * Creates a DlcSign from JSON data (e.g., from test vectors) * Handles both our internal format and external test vector formats * @param json JSON object representing a DLC sign */ static fromJSON(json: any): DlcSign; /** * Parses CetAdaptorSignatures from JSON * @param cetSigsJson JSON object representing CET adaptor signatures */ private static parseCetAdaptorSignaturesFromJSON; /** * Parses FundingSignatures from JSON * @param fundingSigsJson JSON object representing funding signatures */ private static parseFundingSignaturesFromJSON; /** * Deserializes a sign_dlc message * @param buf */ static deserialize(buf: Buffer): DlcSign; /** * The type for sign_dlc message. sign_dlc = 42782 */ type: MessageType; protocolVersion: number; contractId: Buffer; cetAdaptorSignatures: CetAdaptorSignatures; refundSignature: Buffer; fundingSignatures: FundingSignatures; batchFundingGroups?: BatchFundingGroup[]; unknownTlvs?: Array<{ type: number; data: Buffer; }>; /** * Validates correctness of all fields * Updated validation rules as per dlcspecs PR #163 * @throws Will throw an error if validation fails */ validate(): void; /** * Converts sign_dlc to JSON (canonical rust-dlc format) */ toJSON(): IDlcSignJSON; /** * Serializes the sign_dlc message into a Buffer * Updated serialization format as per dlcspecs PR #163 */ serialize(): Buffer; } export interface IDlcSignJSON { protocolVersion: number; contractId: string; cetAdaptorSignatures: ICetAdaptorSignaturesJSON; refundSignature: string; fundingSignatures: IFundingSignaturesJSON; } export declare class DlcSignContainer { private signs; /** * Adds a DlcSign to the container. * @param sign The DlcSign to add. */ addSign(sign: DlcSign): void; /** * Returns all DlcSigns in the container. * @returns An array of DlcSign instances. */ getSigns(): DlcSign[]; /** * Serializes all DlcSigns in the container to a Buffer. * @returns A Buffer containing the serialized DlcSigns. */ serialize(): Buffer; /** * Deserializes a Buffer into a DlcSignContainer with DlcSigns. * @param buf The Buffer to deserialize. * @returns A DlcSignContainer instance. */ static deserialize(buf: Buffer): DlcSignContainer; }