UNPKG

@node-lightning/wire

Version:
73 lines 2.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AnnouncementSignaturesMessage = void 0; const bufio_1 = require("@node-lightning/bufio"); const core_1 = require("@node-lightning/core"); const MessageType_1 = require("../MessageType"); /** * This is a direct messagee between two endpoints of a channel * and serves as an opt-in mechanism to allow the * announcement of the channel to the rest of the network. It * contains the necessary signatuures, by the sender, to construct * the channel_announcement message. * * The message constructed by constructing a channel_announcement * message, corresponding to the newly created channel, and signing * it with the secrets matching an endpoint's node_id and * bitcoin_key. */ class AnnouncementSignaturesMessage { constructor() { /** * Message type - 259 */ this.type = MessageType_1.MessageType.AnnouncementSignatures; /** * Buffer of the channel_id for the message. */ this.channelId = Buffer.alloc(0); /** * Buffer containing the signature of the channel_announcement message * signed by the endpoint's node_id. */ this.nodeSignature = Buffer.alloc(0); /** * Buffer containing the signaturee of the channel_announcment message * signed by the endpoint's bitcoin_key. */ this.bitcoinSignature = Buffer.alloc(0); } /** * Deserializes a Buffer into an AnnouncementSignaturesMessage. */ static deserialize(payload) { const reader = new bufio_1.BufferReader(payload); reader.readUInt16BE(); // read off type const instance = new AnnouncementSignaturesMessage(); instance.channelId = reader.readBytes(32); instance.shortChannelId = core_1.shortChannelIdFromBuffer(reader.readBytes(8)); instance.nodeSignature = reader.readBytes(64); instance.bitcoinSignature = reader.readBytes(64); return instance; } /** * Serializes the instance into a Buffer suitable for * transmission on the wire. */ serialize() { const len = 2 + // type 32 + // channel_id 8 + // short_channel_id 64 + // node_signature 64; // bitcoin_signaturee const writer = new bufio_1.BufferWriter(Buffer.alloc(len)); writer.writeUInt16BE(this.type); writer.writeBytes(this.channelId); writer.writeBytes(this.shortChannelId.toBuffer()); writer.writeBytes(this.nodeSignature); writer.writeBytes(this.bitcoinSignature); return writer.toBuffer(); } } exports.AnnouncementSignaturesMessage = AnnouncementSignaturesMessage; //# sourceMappingURL=AnnouncementSignaturesMessage.js.map