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', async (req, res) => {
|
||||||
app.get('/api/lnd/pendingchannels', (req, res) => {
|
try {
|
||||||
const { lightning } = LightningServices.services
|
return res.json(await LV2.pendingChannels())
|
||||||
lightning.pendingChannels({}, async (err, response) => {
|
} catch (e) {
|
||||||
if (err) {
|
console.log(e)
|
||||||
logger.debug('PendingChannels Error:', err)
|
return res.status(500).json({
|
||||||
const health = await checkHealth()
|
errorMessage: e.message
|
||||||
if (health.LNDStatus.success) {
|
|
||||||
res.status(400).json({
|
|
||||||
field: 'pendingChannels',
|
|
||||||
errorMessage: sanitizeLNDError(err.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) => {
|
app.get('/api/lnd/unifiedTrx', (req, res) => {
|
||||||
|
|
|
||||||
|
|
@ -144,3 +144,25 @@ export interface ListChannelsReq {
|
||||||
*/
|
*/
|
||||||
peer: Common.Bytes
|
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 = {
|
module.exports = {
|
||||||
sendPaymentV2Keysend,
|
sendPaymentV2Keysend,
|
||||||
sendPaymentV2Invoice,
|
sendPaymentV2Invoice,
|
||||||
|
|
@ -524,5 +546,6 @@ module.exports = {
|
||||||
listUnspent,
|
listUnspent,
|
||||||
listChannels,
|
listChannels,
|
||||||
getChanInfo,
|
getChanInfo,
|
||||||
listPeers
|
listPeers,
|
||||||
|
pendingChannels
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue