UNPKG

@node-dlc/messaging

Version:
87 lines (86 loc) 2.92 kB
/// <reference types="node" /> import { IOrderMetadataJSON } from '..'; import { MessageType } from '../MessageType'; import { BatchFundingGroup, IBatchFundingGroupJSON } from './BatchFundingGroup'; import { ContractInfo, IContractInfoV0JSON, IContractInfoV1JSON } from './ContractInfo'; import { IDlcMessage } from './DlcMessage'; import { IOrderIrcInfoJSON, OrderIrcInfo } from './OrderIrcInfo'; import { OrderMetadata } from './OrderMetadata'; import { IOrderPositionInfoJSON, OrderPositionInfo } from './OrderPositionInfo'; export declare abstract class OrderOffer { static deserialize(buf: Buffer): OrderOffer; abstract type: number; abstract validate(): void; abstract toJSON(): IOrderOfferJSON; abstract serialize(): Buffer; } /** * OrderOffer message contains information about a node and indicates its * desire to enter into a new contract. This is the first step toward * order negotiation. */ export declare class OrderOfferV0 extends OrderOffer implements IDlcMessage { static type: MessageType; /** * Deserializes an offer_dlc_v0 message * @param buf */ static deserialize(buf: Buffer): OrderOfferV0; /** * The type for order_offer_v0 message. order_offer_v0 = 62770 */ type: MessageType; chainHash: Buffer; contractInfo: ContractInfo; offerCollateralSatoshis: bigint; feeRatePerVb: bigint; cetLocktime: number; refundLocktime: number; metadata?: OrderMetadata; ircInfo?: OrderIrcInfo; positionInfo?: OrderPositionInfo; batchFundingGroups?: BatchFundingGroup[]; validate(): void; /** * Converts order_offer_v0 to JSON */ toJSON(): IOrderOfferJSON; /** * Serializes the order_offer_v0 message into a Buffer */ serialize(): Buffer; } export interface IOrderOfferJSON { type: number; chainHash: string; contractInfo: IContractInfoV0JSON | IContractInfoV1JSON; offerCollateralSatoshis: number; feeRatePerVb: number; cetLocktime: number; refundLocktime: number; tlvs: (IOrderMetadataJSON | IOrderIrcInfoJSON | IOrderPositionInfoJSON | IBatchFundingGroupJSON)[]; } export declare class OrderOfferContainer { private offers; /** * Adds an OrderOffer to the container. * @param offer The OrderOffer to add. */ addOffer(offer: OrderOffer): void; /** * Returns all OrderOffers in the container. * @returns An array of OrderOffer instances. */ getOffers(): OrderOffer[]; /** * Serializes all OrderOffers in the container to a Buffer. * @returns A Buffer containing the serialized OrderOffers. */ serialize(): Buffer; /** * Deserializes a Buffer into an OrderOfferContainer with OrderOffers. * @param buf The Buffer to deserialize. * @returns An OrderOfferContainer instance. */ static deserialize(buf: Buffer): OrderOfferContainer; }