@node-lightning/wire
Version:
Lightning Network Wire Protocol
57 lines (56 loc) • 2.41 kB
TypeScript
import { IWireMessage } from "../messages/IWireMessage";
import { WireError } from "../WireError";
import { IGossipStore } from "./GossipStore";
import { IGossipFilterChainClient } from "./IGossipFilterChainClient";
export declare class Result<V, E> {
readonly value?: V;
readonly error?: E;
static err<V, E>(error: E): Result<V, E>;
static ok<V, E>(value: V): Result<V, E>;
constructor(value?: V, error?: E);
get isOk(): boolean;
get isErr(): boolean;
}
export declare type GossipFilterResult = Result<IWireMessage[], WireError>;
/**
* GossipFilter recieves messages from peers and performs validation
* on the messages to ensure that they are valid messages. These validation
* follow messaging rules defined in Bolt #7 and include things like
* signature checks, on-chain validation, and message sequencing requirements.
* Successful message validation results in messages being written to an
* instance of IGossipStore and returned as results
*
* The GossipFilter will also store pending messages, such as channel_update
* message arriving before the channel_announcement.
*/
export declare class GossipFilter {
readonly gossipStore: IGossipStore;
readonly pendingStore: IGossipStore;
readonly chainClient?: IGossipFilterChainClient;
constructor(gossipStore: IGossipStore, pendingStore: IGossipStore, chainClient?: IGossipFilterChainClient);
/**
* Validates a message and writes it to the appropriate store.
* A fully processed messages (or releated messages) will be
* returned when a message is successfully processed.
*
*/
validateMessage(msg: IWireMessage): Promise<GossipFilterResult>;
/**
* Validate a node announcement message by checking to see if the
* message is newer than the prior timestamp and if the message
* has a valid signature from the corresponding node
*/
private _validateNodeAnnouncement;
/**
* Validates a ChannelAnnouncementMessage by verifying the signatures
* and validating the transaction on chain work. This message will
*/
private _validateChannelAnnouncement;
/**
* Validates a channel_update message by ensuring that:
* - the channel_announcement has already been recieved
* - the channel_update is not old
* - the channel_update is correctly signed by the node
*/
private _validateChannelUpdate;
}