UNPKG

@node-lightning/wire

Version:
51 lines 1.93 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FundingSignedMessage = void 0; const bufio_1 = require("@node-lightning/bufio"); const core_1 = require("@node-lightning/core"); const MessageType_1 = require("../MessageType"); /** * The `funding_signed` message is sent by the channel acceptor after * they have recieved a `funding_created` message from the initiator. * This message includes the signature for the initiator's first * commitment transaction. After the initiator receives this message * the channel can be broadcast to the Bitcoin network as both * participants can spend the outputs of the funding transaction. This * message also is the first instance of the `channel_id` and both sides * can transition from using the `temporary_channel_id` to the actual * `channel_id`. */ class FundingSignedMessage { constructor() { /** * The type for message. funding_signed = 35 */ this.type = FundingSignedMessage.type; } /** * Deserializes the funding_signed message * @param buf * @returns */ static deserialize(buf) { const instance = new FundingSignedMessage(); const reader = new bufio_1.BufferReader(buf); reader.readUInt16BE(); // read type instance.channelId = new core_1.ChannelId(reader.readBytes(32)); instance.signature = reader.readBytes(64); return instance; } /** * Serializes the message into a Buffer */ serialize() { const writer = new bufio_1.BufferWriter(); writer.writeUInt16BE(this.type); writer.writeBytes(this.channelId.toBuffer()); writer.writeBytes(this.signature); return writer.toBuffer(); } } exports.FundingSignedMessage = FundingSignedMessage; FundingSignedMessage.type = MessageType_1.MessageType.FundingSigned; //# sourceMappingURL=FundingSignedMessage.js.map