From f517fd6090fca0dfe1d9696c667e1de40883e042 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Sun, 10 Jan 2021 10:20:58 -0400 Subject: [PATCH] getChanInfo() --- utils/lightningServices/v2.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/utils/lightningServices/v2.js b/utils/lightningServices/v2.js index 467a15c8..6857d870 100644 --- a/utils/lightningServices/v2.js +++ b/utils/lightningServices/v2.js @@ -465,6 +465,31 @@ const listChannels = req => }) }) +/** + * https://api.lightning.community/#getchaninfo + * @param {string} chanID + * @returns {Promise} + */ +const getChanInfo = chanID => + Common.makePromise((res, rej) => { + const { lightning } = lightningServices.getServices() + + lightning.getChanInfo( + { + chan_id: chanID + }, + (err, resp) => { + if (err) { + rej(new Error(err.message)) + } else { + // Needs cast because typescript refuses to assign Record + // to an actual object :shrugs + res(/** @type {Common.ChannelEdge} */ (resp)) + } + } + ) + }) + module.exports = { sendPaymentV2Keysend, sendPaymentV2Invoice, @@ -472,5 +497,6 @@ module.exports = { decodePayReq, newAddress, listUnspent, - listChannels + listChannels, + getChanInfo }