CLI: separate list_channels and list_channel_backups
Add '--public' option flag to list public channels
This commit is contained in:
@@ -1829,15 +1829,14 @@ class Commands(Logger):
|
||||
return wallet.lnworker.node_keypair.pubkey.hex() + (('@' + listen_addr) if listen_addr else '')
|
||||
|
||||
@command('wl')
|
||||
async def list_channels(self, wallet: Abstract_Wallet = None):
|
||||
"""Return the list of Lightning channels in a wallet"""
|
||||
# FIXME: we need to be online to display capacity of backups
|
||||
async def list_channels(self, public: bool = False, wallet: Abstract_Wallet = None):
|
||||
"""Return the list of private channels in the wallet
|
||||
|
||||
arg:bool:public:list public channels instead.
|
||||
"""
|
||||
from .lnutil import LOCAL, REMOTE, format_short_channel_id
|
||||
channels = list(wallet.lnworker.channels.items())
|
||||
backups = list(wallet.lnworker.channel_backups.items())
|
||||
return [
|
||||
{
|
||||
'type': 'CHANNEL',
|
||||
'short_channel_id': format_short_channel_id(chan.short_channel_id) if chan.short_channel_id else None,
|
||||
'channel_id': chan.channel_id.hex(),
|
||||
'channel_point': chan.funding_outpoint.to_str(),
|
||||
@@ -1853,16 +1852,22 @@ class Commands(Logger):
|
||||
'remote_reserve': chan.config[LOCAL].reserve_sat,
|
||||
'local_unsettled_sent': chan.balance_tied_up_in_htlcs_by_direction(LOCAL, direction=SENT) // 1000,
|
||||
'remote_unsettled_sent': chan.balance_tied_up_in_htlcs_by_direction(REMOTE, direction=SENT) // 1000,
|
||||
} for channel_id, chan in channels
|
||||
] + [
|
||||
} for chan in wallet.lnworker.channels.values() if not (public != chan.is_public())
|
||||
]
|
||||
|
||||
@command('wl')
|
||||
async def list_channel_backups(self, wallet: Abstract_Wallet = None):
|
||||
"""Return the list of channel backups in the wallet"""
|
||||
# FIXME: we need to be online to display capacity of backups
|
||||
from .lnutil import LOCAL, REMOTE, format_short_channel_id
|
||||
return [
|
||||
{
|
||||
'type': 'BACKUP',
|
||||
'short_channel_id': format_short_channel_id(chan.short_channel_id) if chan.short_channel_id else None,
|
||||
'channel_id': chan.channel_id.hex(),
|
||||
'channel_point': chan.funding_outpoint.to_str(),
|
||||
'closing_txid': chan.get_closing_height()[0] if chan.get_closing_height() else None,
|
||||
'state': chan.get_state().name,
|
||||
} for channel_id, chan in backups
|
||||
} for chan in wallet.lnworker.channel_backups.values()
|
||||
]
|
||||
|
||||
@command('wnl')
|
||||
|
||||
Reference in New Issue
Block a user