add sanity check: wallet.config == lnworker.config == network.config
What changed, and why it matters
This commit adds internal consistency checks (assertions) to make sure that a wallet, its lightning worker, and the network connection all share the same configuration object. It is a hardening/test-quality change only; it does not fix any user-facing bug or vulnerability and does not change runtime behavior except to fail loudly during tests or development if the invariant is violated.
No security action required. Treat as normal code-quality/test-hardening commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch inserts assert network.config is self.config into start_network() methods of address_synchronizer.py, lnworker.py (two call sites), and wallet.py. The commit message explicitly states the purpose: a sanity check useful for unit tests to avoid accidentally breaking the invariant when creating MockNetwork. No functional logic is altered, no bug is fixed, and no security boundary is changed.
Changed components
electrum/address_synchronizer.pyelectrum/lnworker.pyelectrum/wallet.pyInspect captured patch +4 / −0
### electrum/address_synchronizer.py
@@ -204,6 +204,7 @@ def start_network(self, network: Optional['Network']) -> None:
assert self.network is None, "already started"
self.network = network
if self.network is not None:
+ assert network.config is self.config
self.synchronizer = Synchronizer(self)
self.verifier = SPV(self.network, self)
self.asyncio_loop = network.asyncio_loop
### electrum/lnworker.py
@@ -424,6 +424,7 @@ def start_network(
assert network
assert self.network is None, "already started"
self.network = network
+ assert network.config is self.config
self._add_peers_from_config()
asyncio.run_coroutine_threadsafe(self.main_loop(), get_asyncio_loop())
if listen:
@@ -1211,6 +1212,7 @@ async def main_loop(self):
self.logger.info("taskgroup stopped.")
def start_network(self, network: 'Network'):
+ assert network.config is self.config
asyncio.run_coroutine_threadsafe(self.main_loop(), get_asyncio_loop())
self.lnpeermgr.start_network(network, listen=True)
self.lnwatcher.start_network(network)
### electrum/wallet.py
@@ -681,6 +681,7 @@ def start_network(self, network: 'Network'):
self.taskgroup = OldTaskGroup()
self.network = network
if network:
+ assert network.config is self.config
asyncio.run_coroutine_threadsafe(self.main_loop(), self.network.asyncio_loop)
self.adb.start_network(network)
if self.lnworker: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.