UNPKG

@node-lightning/wire

Version:
136 lines (135 loc) 4.82 kB
/// <reference types="node" /> import { BitField, ShortChannelId, Value } from "@node-lightning/core"; import { Checksum } from "../domain/Checksum"; import { ChannelUpdateMessageFlags } from "../flags/ChannelUpdateMessageFlags"; import { ChannelUpdateChannelFlags } from "../flags/ChanneUpdateChannelFlags"; import { MessageType } from "../MessageType"; import { IWireMessage } from "./IWireMessage"; /** * After a channel has been announced, each side independently announces the fees * and minimum expiry delta it requires to relay HTLCs through this channel. A * node can broadcast this message multiple times in order to change fees. */ export declare class ChannelUpdateMessage implements IWireMessage { /** * Deserializes the message from a Buffer. The message * is not validated in this function. */ static deserialize(payload: Buffer): ChannelUpdateMessage; /** * Performs a double SHA-256 hash of the message with all * data excluding the signature data */ static hashForSignature(message: ChannelUpdateMessage): Buffer; /** * Performs signature validation for the message by * hashing the data post signature. A passing signature * indicates that the message was submitted by the node * that owns the channel. Becuase the nodeId is not included * in the message, we need to obtain the nodeId by accessing * the ChannelAnnouncementMessage and determining the public key * @param message * @param pubkey 33-byte ECDSA public key */ static validateSignature(message: ChannelUpdateMessage, pubkey: Buffer): boolean; /** * Message type is 258 */ type: MessageType; /** * 64-byte buffer containing the ECDSA secp256k1 signature of the double * SHA256 hash of the message as signed by the originating node. */ signature: Buffer; /** * 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; /** * Timestamp of the update message and is used to indicate ordering of * messages if multiple messages are sent by the same node. */ timestamp: number; /** * Indicate the presence of optional fields in the channel_update message. * bit, field * 0, htlc_maximum_msat */ messageFlags: BitField<ChannelUpdateMessageFlags>; /** * Indicates the direction of the channel: it identifies the node that this * update originated from and signals various options concerning the channel * such as whether it is disabled. * bit, name * 0, direction * 1, disabled */ channelFlags: BitField<ChannelUpdateChannelFlags>; /** * The number of blocks the channel will subtract from an incoming * HTLC's cltv_expiry. */ cltvExpiryDelta: number; /** * The minimum HTLC value (in millisatoshi) that the channel peer * will accept. */ htlcMinimumMsat: Value; /** * The maximum value (in millisatoshi) it will send through this * channel for a single HTLC. This value must be less than the * channel capacity. This value will only be available when the * message flag option_channel_htlc_max is set. */ htlcMaximumMsat: Value; /** * The base fee (in millisatoshi) the channel will charge for * any HTLC. */ feeBaseMsat: Value; /** * The amount (in millionths of a satoshi) it will charge per * transferred satoshi. */ feeProportionalMillionths: Value; /** * Returns true when message flags have the optional * maximum HTLC msat value available */ get hasHtlcMaximumMsatFlag(): boolean; /** * Direction is determined by channel_flags bit 0. * When set to 0, node_1 is the sender. When set to 1 * node_2 is the sender */ get direction(): number; set direction(val: number); /** * Disabled flag is determined by channel_flags bit 1. * When set to 0, the channel is active. When set to 1 * the channel is disabled. */ get disabled(): boolean; set disabled(val: boolean); /** * Serializes the instance into a Buffer that can be * transmitted over the wire */ serialize(): Buffer; /** * CRC32C checksum is calculated from the raw channel_update * message and excludes the signature and timestamp. * * @remarks * Defined in BOLT 07 gossip queries section: * https://github.com/lightningnetwork/lightning-rfc/blob/master/07-routing-gossip.md#query-messages * */ checksum(): Checksum; }