getChanInfo()

This commit is contained in:
Daniel Lugo 2021-01-10 10:20:58 -04:00
parent bb0941d6e9
commit f517fd6090

View file

@ -465,6 +465,31 @@ const listChannels = req =>
}) })
}) })
/**
* https://api.lightning.community/#getchaninfo
* @param {string} chanID
* @returns {Promise<Common.ChannelEdge>}
*/
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<string, any>
// to an actual object :shrugs
res(/** @type {Common.ChannelEdge} */ (resp))
}
}
)
})
module.exports = { module.exports = {
sendPaymentV2Keysend, sendPaymentV2Keysend,
sendPaymentV2Invoice, sendPaymentV2Invoice,
@ -472,5 +497,6 @@ module.exports = {
decodePayReq, decodePayReq,
newAddress, newAddress,
listUnspent, listUnspent,
listChannels listChannels,
getChanInfo
} }