CLI: separate list_channels and list_channel_backups
What changed, and why it matters
This commit is a routine user-interface cleanup for Electrum's command-line tool. It splits one command that previously showed both active Lightning channels and channel backups into two separate commands, and adds an option to filter channels by whether they are public or private. There is no indication this fixes a security vulnerability or introduces a security risk.
No security action required. Treat as normal feature/refactoring commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors the CLI list_channels command in electrum/commands.py. Previously it returned a combined list of CHANNEL and BACKUP entries. The change removes the backup entries from list_channels, adds a public: bool parameter to filter channels by chan.is_public(), and introduces a new list_channel_backups command for backups. No cryptographic, network, or permission logic is changed.
Changed components
electrum/commands.py CLI command definitionsInspect captured patch +15 / −10
diff --git a/electrum/commands.py b/electrum/commands.py
index 87dcd83..9ff0eaa 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')
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.