UNPKG

@node-lightning/wire

Version:
51 lines 1.96 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FundingCreatedMessage = void 0; const bufio_1 = require("@node-lightning/bufio"); const MessageType_1 = require("../MessageType"); /** * The `funding_created` message is sent by the channel initiator after * the channel has been accepted with `accept_channel`. The channel * initiator includes the outpoint for the funding transaction as well * as their signature for the counter-parties first commitment * transaction. This message provides the channel acceptor the * information they need to sign the initiator's first commitment * transaction in the next message: `funding_signed`. */ class FundingCreatedMessage { constructor() { /** * The type for message. funding_created = 34 */ this.type = FundingCreatedMessage.type; } /** * Deserializes an funding_created message * @param buf */ static deserialize(buf) { const instance = new FundingCreatedMessage(); const reader = new bufio_1.BufferReader(buf); reader.readUInt16BE(); // read type instance.temporaryChannelId = reader.readBytes(32); instance.fundingTxId = reader.readBytes(32); instance.fundingOutputIndex = reader.readUInt16BE(); 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.temporaryChannelId); writer.writeBytes(this.fundingTxId); writer.writeUInt16BE(this.fundingOutputIndex); writer.writeBytes(this.signature); return writer.toBuffer(); } } exports.FundingCreatedMessage = FundingCreatedMessage; FundingCreatedMessage.type = MessageType_1.MessageType.FundingCreated; //# sourceMappingURL=FundingCreatedMessage.js.map