new listPeers()
This commit is contained in:
parent
c5e48b1eb5
commit
5cab6deeb1
2 changed files with 38 additions and 20 deletions
|
|
@ -1053,25 +1053,17 @@ module.exports = async (
|
||||||
})
|
})
|
||||||
|
|
||||||
// get lnd node active channels list
|
// get lnd node active channels list
|
||||||
app.get('/api/lnd/listpeers', (req, res) => {
|
app.get('/api/lnd/listpeers', async (req, res) => {
|
||||||
const { lightning } = LightningServices.services
|
try {
|
||||||
lightning.listPeers({}, async (err, response) => {
|
return res.json({
|
||||||
if (err) {
|
peers: await LV2.listPeers(req.body.latestError)
|
||||||
logger.debug('ListPeers Error:', err)
|
})
|
||||||
const health = await checkHealth()
|
} catch (e) {
|
||||||
if (health.LNDStatus.success) {
|
console.log(e)
|
||||||
res.status(400).json({
|
return res.status(500).json({
|
||||||
field: 'listPeers',
|
errorMessage: e.message
|
||||||
errorMessage: sanitizeLNDError(err.message)
|
})
|
||||||
})
|
}
|
||||||
} else {
|
|
||||||
res.status(500)
|
|
||||||
res.json({ errorMessage: 'LND is down' })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logger.debug('ListPeers:', response)
|
|
||||||
res.json(response)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// newaddress
|
// newaddress
|
||||||
|
|
|
||||||
|
|
@ -490,6 +490,31 @@ const getChanInfo = chanID =>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://api.lightning.community/#listpeers
|
||||||
|
* @param {boolean=} latestError If true, only the last error that our peer sent
|
||||||
|
* us will be returned with the peer's information, rather than the full set of
|
||||||
|
* historic errors we have stored.
|
||||||
|
* @returns {Promise<Common.Peer[]>}
|
||||||
|
*/
|
||||||
|
const listPeers = latestError =>
|
||||||
|
Common.makePromise((res, rej) => {
|
||||||
|
const { lightning } = lightningServices.getServices()
|
||||||
|
|
||||||
|
lightning.listPeers(
|
||||||
|
{
|
||||||
|
latest_error: latestError
|
||||||
|
},
|
||||||
|
(err, resp) => {
|
||||||
|
if (err) {
|
||||||
|
rej(new Error(err.message))
|
||||||
|
} else {
|
||||||
|
res(resp.peers)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
sendPaymentV2Keysend,
|
sendPaymentV2Keysend,
|
||||||
sendPaymentV2Invoice,
|
sendPaymentV2Invoice,
|
||||||
|
|
@ -498,5 +523,6 @@ module.exports = {
|
||||||
newAddress,
|
newAddress,
|
||||||
listUnspent,
|
listUnspent,
|
||||||
listChannels,
|
listChannels,
|
||||||
getChanInfo
|
getChanInfo,
|
||||||
|
listPeers
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue