UNPKG

@node-lightning/graph

Version:
27 lines 1.2 kB
"use strict"; /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ Object.defineProperty(exports, "__esModule", { value: true }); exports.channelFromJson = void 0; const core_1 = require("@node-lightning/core"); const core_2 = require("@node-lightning/core"); const channel_1 = require("../channel"); const channel_settings_from_json_1 = require("./channel-settings-from-json"); /** * Constructs a channel from a JSON string */ function channelFromJson(text) { const t = JSON.parse(text); const c = new channel_1.Channel(); c.channelPoint = core_2.OutPoint.fromString(t.channelPoint); c.shortChannelId = core_1.shortChannelIdFromString(t.shortChannelId); c.nodeId1 = Buffer.from(t.nodeId1, "hex"); c.nodeId2 = Buffer.from(t.nodeId2, "hex"); c.capacity = BigInt(t.capacity); c.features = t.features; c.node1Settings = channel_settings_from_json_1.channelSettingsFromJson(t.node1Settings); c.node2Settings = channel_settings_from_json_1.channelSettingsFromJson(t.node2Settings); return c; } exports.channelFromJson = channelFromJson; //# sourceMappingURL=channel-from-json.js.map