@node-lightning/wire
Version:
Lightning Network Wire Protocol
112 lines (111 loc) • 3.95 kB
TypeScript
/// <reference types="node" />
import { BitField } from "@node-lightning/core";
import { ShortChannelId } from "@node-lightning/core";
import { ChannelFeatureFlags } from "../flags/ChannelFeatureFlags";
import { MessageType } from "../MessageType";
import { IWireMessage } from "./IWireMessage";
/**
* Message contains ownership information regarding a channel.
* It ties each on-chain Bitcoin key to the associated Lightning
* node key, and vice-versa. Proviing the existance of a channel
* between node_1 and node_2 requires:
* 1. proving that the funding pays to bitcoin_key_1 and bitcoin_key_2
* 2. proving that node_1 owns bitcoin_key_1
* 3. proving that node_2 owns bitcoin_key_2
*
* This also varifies that both nodes want to announce the channel.
* The required data to perform all of these proofs is available
* in this message.
*/
export declare class ChannelAnnouncementMessage implements IWireMessage {
/**
* Deserializes the Buffer into a ChannelAnnouncementMessage.
*/
static deserialize(payload: Buffer): ChannelAnnouncementMessage;
/**
* Message hashing is after the first 258 bytes of the message
* and excludes the type and signatures. It performs a double
* sha-256 hash of the remaining bytes.
*/
static hash(msg: ChannelAnnouncementMessage): Buffer;
/**
* Performs validation the message was signed by each node and the
* the corresponding bitcoin key is owned by the owner of the node.
*
* This is accomplished by:
* 1. verifying the bitcoinSignatures1/2 are validate signatures
* from bitcoinKey1/2
* 2. verifying the nodeSignature1/2 are validate signatures
* from nodeId1/2
*/
static verifySignatures(msg: ChannelAnnouncementMessage): boolean;
/**
* The message type - 256
*/
type: MessageType;
/**
* Validate signature from node_1 of the hash containing the
* data: features, chainHash, shortChannelId, nodeId1,
* nodeId1, bitcoinKey1, and bitcoinKey2.
*/
nodeSignature1: Buffer;
/**
* Validate signature from node_2 of the hash containing the
* data: features, chainHash, shortChannelId, nodeId1,
* nodeId1, bitcoinKey1, and bitcoinKey2.
*/
nodeSignature2: Buffer;
/**
* Validate signature from bitcoin_key_1 of the hash containing the
* data: features, chainHash, shortChannelId, nodeId1,
* nodeId1, bitcoinKey1, and bitcoinKey2.
*/
bitcoinSignature1: Buffer;
/**
* Validate signature from bitcoin_key_2 of the hash containing the
* data: features, chainHash, shortChannelId, nodeId1,
* nodeId1, bitcoinKey1, and bitcoinKey2.
*/
bitcoinSignature2: Buffer;
/**
* The channel features are a bitmask
*/
features: BitField<ChannelFeatureFlags>;
/**
* Must set chain_hash to a 32-byte hash that uniquely identifies
* the chain that the channel opened within.
*/
chainHash: Buffer;
/**
* ShortChannelId is a unique reference to the funding output of the
* channel.
*/
shortChannelId: ShortChannelId;
/**
* The 33-byte compressed public key identifying the
* numerically greater of the two DER-encoded keys
* sorted in ascending numerical order.
*/
nodeId1: Buffer;
/**
* The 33-byte compressed public key identifying the
* numerically greater of the two DER-encoded keys
* sorted in ascending numerical order.
*/
nodeId2: Buffer;
/**
* The 33-byte compressed Bitcoin public key used by
* node_id_1 to create the funding transaction.
*/
bitcoinKey1: Buffer;
/**
* The 33-byte compressed Bitcoin public key used by
* node_id_2 to create the funding transaction.
*/
bitcoinKey2: Buffer;
/**
* Serializes the intancee into a Buffer suitable
* for wire transport
*/
serialize(): Buffer;
}