pending channels
This commit is contained in:
parent
5cab6deeb1
commit
d6cdba2276
3 changed files with 55 additions and 21 deletions
|
|
@ -1134,26 +1134,15 @@ module.exports = async (
|
|||
}
|
||||
})
|
||||
|
||||
// get lnd node pending channels list
|
||||
app.get('/api/lnd/pendingchannels', (req, res) => {
|
||||
const { lightning } = LightningServices.services
|
||||
lightning.pendingChannels({}, async (err, response) => {
|
||||
if (err) {
|
||||
logger.debug('PendingChannels Error:', err)
|
||||
const health = await checkHealth()
|
||||
if (health.LNDStatus.success) {
|
||||
res.status(400).json({
|
||||
field: 'pendingChannels',
|
||||
errorMessage: sanitizeLNDError(err.message)
|
||||
app.get('/api/lnd/pendingchannels', async (req, res) => {
|
||||
try {
|
||||
return res.json(await LV2.pendingChannels())
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
return res.status(500).json({
|
||||
errorMessage: e.message
|
||||
})
|
||||
} else {
|
||||
res.status(500)
|
||||
res.json({ errorMessage: 'LND is down' })
|
||||
}
|
||||
}
|
||||
logger.debug('PendingChannels:', response)
|
||||
res.json(response)
|
||||
})
|
||||
})
|
||||
|
||||
app.get('/api/lnd/unifiedTrx', (req, res) => {
|
||||
|
|
|
|||
|
|
@ -144,3 +144,25 @@ export interface ListChannelsReq {
|
|||
*/
|
||||
peer: Common.Bytes
|
||||
}
|
||||
|
||||
/**
|
||||
* https://api.lightning.community/#pendingchannels
|
||||
*/
|
||||
export interface PendingChannelsRes {
|
||||
/**
|
||||
* The balance in satoshis encumbered in pending channels.
|
||||
*/
|
||||
total_limbo_balance: string
|
||||
/**
|
||||
* Channels pending opening.
|
||||
*/
|
||||
pending_open_channels: Common.PendingOpenChannel[]
|
||||
/**
|
||||
* Channels pending force closing.
|
||||
*/
|
||||
pending_force_closing_channels: Common.ForceClosedChannel[]
|
||||
/**
|
||||
* Channels waiting for closing tx to confirm.
|
||||
*/
|
||||
waiting_close_channels: Common.WaitingCloseChannel[]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -515,6 +515,28 @@ const listPeers = latestError =>
|
|||
)
|
||||
})
|
||||
|
||||
/**
|
||||
* @typedef {import('./types').PendingChannelsRes} PendingChannelsRes
|
||||
*/
|
||||
|
||||
/**
|
||||
* @returns {Promise<PendingChannelsRes>}
|
||||
*/
|
||||
const pendingChannels = () =>
|
||||
Common.makePromise((res, rej) => {
|
||||
const { lightning } = lightningServices.getServices()
|
||||
|
||||
lightning.pendingChannels({}, (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 {PendingChannelsRes} */ (resp))
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
module.exports = {
|
||||
sendPaymentV2Keysend,
|
||||
sendPaymentV2Invoice,
|
||||
|
|
@ -524,5 +546,6 @@ module.exports = {
|
|||
listUnspent,
|
||||
listChannels,
|
||||
getChanInfo,
|
||||
listPeers
|
||||
listPeers,
|
||||
pendingChannels
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue