From 7e73aa7b7ae3a1c5d8d8b98bbc0a1c91ab3f5e56 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Mon, 9 Feb 2026 11:34:21 +0100 Subject: [PATCH] CLI: separate list_channels and list_channel_backups Add '--public' option flag to list public channels --- electrum/commands.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/electrum/commands.py b/electrum/commands.py index 87dcd83a9..9ff0eaa60 100644 --- a/electrum/commands.py +++ b/electrum/commands.py @@ -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')