@node-dlc/messaging
Version:
DLC Messaging Protocol
69 lines (68 loc) • 2.23 kB
TypeScript
/// <reference types="node" />
import { MessageType } from '../MessageType';
import { IDlcMessage } from './DlcMessage';
import { FundingInput, IFundingInputJSON } from './FundingInput';
import { FundingSignatures, IFundingSignaturesJSON } from './FundingSignatures';
/**
* DlcClose message contains information about a node and indicates its
* desire to close an existing contract.
* Updated to follow DlcOffer architectural patterns.
*/
export declare class DlcClose implements IDlcMessage {
static type: MessageType;
/**
* Creates a DlcClose 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 close message
*/
static fromJSON(json: any): DlcClose;
/**
* Deserializes a close_dlc message with backward compatibility
* Detects old format (without protocol_version) vs new format (with protocol_version)
* @param buf
*/
static deserialize(buf: Buffer): DlcClose;
/**
* The type for close_dlc message. close_dlc = 52170
*/
type: MessageType;
protocolVersion: number;
contractId: Buffer;
closeSignature: Buffer;
offerPayoutSatoshis: bigint;
acceptPayoutSatoshis: bigint;
fundInputSerialId: bigint;
fundingInputs: FundingInput[];
fundingSignatures: FundingSignatures;
unknownTlvs?: Array<{
type: number;
data: Buffer;
}>;
/**
* Validates correctness of all fields
* @throws Will throw an error if validation fails
*/
validate(): void;
/**
* Converts dlc_close to JSON (canonical rust-dlc format)
*/
toJSON(): IDlcCloseJSON;
/**
* Serializes the close_dlc message into a Buffer
* Updated serialization format to match DlcOffer patterns
*/
serialize(): Buffer;
}
export interface IDlcCloseJSON {
type?: number;
protocolVersion: number;
contractId: string;
closeSignature: string;
offerPayoutSatoshis: number;
acceptPayoutSatoshis: number;
fundInputSerialId: number;
fundingInputs: IFundingInputJSON[];
fundingSignatures: IFundingSignaturesJSON;
serialized?: string;
tlvs?: any[];
}