@node-dlc/messaging
Version:
DLC Messaging Protocol
70 lines (69 loc) • 2.1 kB
TypeScript
/// <reference types="node" />
import { Sequence, Tx } from '@node-dlc/bitcoin';
import { MessageType } from '../MessageType';
import { DlcInput } from './DlcInput';
import { IDlcMessage } from './DlcMessage';
/**
* FundingInput contains information about a specific input to be used
* in a funding transaction, as well as its corresponding on-chain UTXO.
* Matches rust-dlc FundingInput struct.
*/
export declare class FundingInput implements IDlcMessage {
static type: MessageType;
/**
* Creates a FundingInput from JSON data (e.g., from test vectors)
* @param json JSON object representing funding input
*/
static fromJSON(json: any): FundingInput;
/**
* Deserializes a funding_input message
* @param buf
*/
static deserialize(buf: Buffer): FundingInput;
/**
* Deserializes a funding_input message without TLV wrapper (for use in DlcOffer)
* This matches rust-dlc behavior where FundingInput is in a vector without individual TLV wrappers
* @param buf
*/
static deserializeBody(buf: Buffer): FundingInput;
/**
* The type for funding_input message. funding_input = 42772
*/
type: MessageType;
length: bigint;
inputSerialId: bigint;
prevTx: Tx;
prevTxVout: number;
sequence: Sequence;
maxWitnessLen: number;
redeemScript: Buffer;
dlcInput?: DlcInput;
scriptSigLength(): number;
/**
* Validates correctness of all fields
* @throws Will throw an error if validation fails
*/
validate(): void;
/**
* Converts funding_input to JSON (canonical rust-dlc format)
*/
toJSON(): IFundingInputJSON;
/**
* Serializes the funding_input message into a Buffer
*/
serialize(): Buffer;
serializeBody(): Buffer;
}
export interface IFundingInputJSON {
inputSerialId: number;
prevTx: string;
prevTxVout: number;
sequence: number;
maxWitnessLen: number;
redeemScript: string;
dlcInput?: {
localFundPubkey: string;
remoteFundPubkey: string;
contractId: string;
};
}