new listChannels()
This commit is contained in:
parent
4665e9332b
commit
bb0941d6e9
3 changed files with 47 additions and 20 deletions
|
|
@ -1144,25 +1144,17 @@ module.exports = async (
|
||||||
})
|
})
|
||||||
|
|
||||||
// get lnd node opened channels list
|
// get lnd node opened channels list
|
||||||
app.get('/api/lnd/listchannels', (req, res) => {
|
app.get('/api/lnd/listchannels', async (_, res) => {
|
||||||
const { lightning } = LightningServices.services
|
try {
|
||||||
lightning.listChannels({}, async (err, response) => {
|
return res.json({
|
||||||
if (err) {
|
channels: await LV2.listChannels()
|
||||||
logger.debug('ListChannels 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: 'listChannels',
|
errorMessage: e.message
|
||||||
errorMessage: sanitizeLNDError(err.message)
|
})
|
||||||
})
|
}
|
||||||
} else {
|
|
||||||
res.status(500)
|
|
||||||
res.json({ errorMessage: 'LND is down' })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logger.debug('ListChannels:', response)
|
|
||||||
res.json(response)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// get lnd node pending channels list
|
// get lnd node pending channels list
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
import * as Common from 'shock-common'
|
||||||
|
|
||||||
export interface PaymentV2 {
|
export interface PaymentV2 {
|
||||||
payment_hash: string
|
payment_hash: string
|
||||||
|
|
@ -131,3 +132,15 @@ export interface Services {
|
||||||
walletUnlocker: Record<string, LightningMethod>
|
walletUnlocker: Record<string, LightningMethod>
|
||||||
router: Record<string, LightningMethod>
|
router: Record<string, LightningMethod>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ListChannelsReq {
|
||||||
|
active_only: boolean
|
||||||
|
inactive_only: boolean
|
||||||
|
public_only: boolean
|
||||||
|
private_only: boolean
|
||||||
|
/**
|
||||||
|
* Filters the response for channels with a target peer's pubkey. If peer is
|
||||||
|
* empty, all channels will be returned.
|
||||||
|
*/
|
||||||
|
peer: Common.Bytes
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -444,11 +444,33 @@ const listUnspent = (minConfs = 3, maxConfs = 6) =>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {import('./types').ListChannelsReq} ListChannelsReq
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ListChannelsReq} req
|
||||||
|
* @returns {Promise<Common.Channel[]>}
|
||||||
|
*/
|
||||||
|
const listChannels = req =>
|
||||||
|
Common.makePromise((res, rej) => {
|
||||||
|
const { lightning } = lightningServices.getServices()
|
||||||
|
|
||||||
|
lightning.listChannels(req, (err, resp) => {
|
||||||
|
if (err) {
|
||||||
|
rej(new Error(err.message))
|
||||||
|
} else {
|
||||||
|
res(resp.channels)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
sendPaymentV2Keysend,
|
sendPaymentV2Keysend,
|
||||||
sendPaymentV2Invoice,
|
sendPaymentV2Invoice,
|
||||||
listPayments,
|
listPayments,
|
||||||
decodePayReq,
|
decodePayReq,
|
||||||
newAddress,
|
newAddress,
|
||||||
listUnspent
|
listUnspent,
|
||||||
|
listChannels
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue