@node-dlc/messaging
Version:
DLC Messaging Protocol
74 lines (73 loc) • 2.8 kB
TypeScript
/// <reference types="node" />
import { MessageType } from '../MessageType';
import { IDlcMessage } from './DlcMessage';
import { OracleAnnouncement } from './OracleAnnouncement';
/**
* Oracle attestation providing signatures over an outcome value.
* This represents the oracle's actual attestation to a specific outcome.
* Updated to match rust-dlc specification with 2-byte count prefixes.
*
* An attestation from an oracle providing signatures over an outcome value.
* This is what the oracle publishes when they want to attest to a specific outcome.
*/
export declare class OracleAttestation implements IDlcMessage {
static type: MessageType;
/**
* Creates an Attestation from JSON data
* @param json JSON object representing oracle announcement
*/
static fromJSON(json: any): OracleAttestation;
/**
* Deserializes an oracle_attestation message
* @param buf
*/
static deserialize(buf: Buffer): OracleAttestation;
/**
* The type for oracle_attestation message. oracle_attestation = 55400
*/
type: MessageType;
length: bigint;
/** The identifier of the announcement. */
eventId: string;
/** The public key of the oracle (32 bytes, x-only). */
oraclePublicKey: Buffer;
/** The signatures over the event outcome (64 bytes each, Schnorr format). */
signatures: Buffer[];
/** The set of strings representing the outcome value. */
outcomes: string[];
/**
* Validates the oracle attestation according to rust-dlc specification.
* This includes validating signatures and ensuring consistency with announcement.
* @param announcement The corresponding oracle announcement for validation (optional)
* @throws Will throw an error if validation fails
*/
validate(announcement?: OracleAnnouncement): void;
/**
* Validates the attestation against the corresponding oracle announcement.
* This ensures the attestation is consistent with the original announcement.
* @param announcement The oracle announcement to validate against
* @throws Will throw an error if validation fails
*/
private validateAgainstAnnouncement;
/**
* Returns the nonces used by the oracle to sign the event outcome.
* This is used for finding the matching oracle announcement.
* The nonce is extracted from the first 32 bytes of each signature.
*/
getNonces(): Buffer[];
/**
* Converts oracle_attestation to JSON
*/
toJSON(): OracleAttestationJSON;
/**
* Serializes the oracle_attestation message into a Buffer
*/
serialize(): Buffer;
}
export interface OracleAttestationJSON {
type?: number;
eventId: string;
oraclePublicKey: string;
signatures: string[];
outcomes: string[];
}