What changed, and why it matters
This commit adds new filtering options to Electrum's list_channels command. It is a straightforward feature enhancement that lets users view public, private, active, or open Lightning channels. There is no security issue visible in the change.
No security action required. Review as normal feature code.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch extends the list_channels RPC/command with boolean filters (public, private, active, open) and a helper _filter() function. It also adds a guard that raises an exception if public and private are both set. The change only affects how channel data is displayed/returned; it does not modify channel state, authorization, network behavior, or any sensitive logic.
Changed components
electrum/commands.py - list_channels commandInspect captured patch +20 / −4
diff --git a/electrum/commands.py b/electrum/commands.py
index 419d1c4..dca66ed 100644
--- a/electrum/commands.py
+++ b/electrum/commands.py
@@ -1829,12 +1829,28 @@ class Commands(Logger):
return wallet.lnworker.node_keypair.pubkey.hex() + (('@' + listen_addr) if listen_addr else '')
@command('wl')
- async def list_channels(self, public: bool = False, wallet: Abstract_Wallet = None):
- """Return the list of private channels in the wallet
+ async def list_channels(self, public: bool = False, private: bool = False, active: bool = False, open: bool = False, wallet: Abstract_Wallet = None):
+ """Return the list of channels in the wallet
- arg:bool:public:list public channels instead.
+ arg:bool:public:list only public channels
+ arg:bool:private:list only private channels
+ arg:bool:open:list only open channels
+ arg:bool:active:list only active channels
"""
from .lnutil import LOCAL, REMOTE, format_short_channel_id
+ if public and private:
+ raise Exception("incompatible options")
+ def _filter(chan):
+ if public and not chan.is_public():
+ return False
+ if private and chan.is_public():
+ return False
+ if active and not chan.is_redeemed():
+ return False
+ if open and not chan.is_open():
+ return False
+ return True
+
return [
{
'short_channel_id': format_short_channel_id(chan.short_channel_id) if chan.short_channel_id else None,
@@ -1852,7 +1868,7 @@ 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 chan in wallet.lnworker.channels.values() if not (public != chan.is_public())
+ } for chan in wallet.lnworker.channels.values() if _filter(chan)
]
@command('wl')
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.