Merge pull request #10863 from SomberNight/202608_config_consistency
What changed, and why it matters
This commit adds internal consistency checks to make sure a wallet, its lightning component, and the network layer all share the same configuration object. It is a defensive hardening change: it does not fix an active bug by itself, but makes future misconfigurations fail loudly during development/testing rather than silently causing odd behavior.
No immediate action required. Treat as routine hardening. If backporting, ensure downstream code never passes mismatched config objects to these components, or the new assertions will crash on startup.
Security signals we found
defensive invariant assertion added
configuration consistency sanity check
no memory safety, crypto, or permission change
Evidence from the diff
The merge adds assert network.config is self.config in address_synchronizer.py, lnworker.py (two places), and wallet.py. These assertions fire at startup if the wallet/lnworker/network ever receive different SimpleConfig instances. The change is purely a runtime invariant check; no logic is altered and no vulnerability is patched in the diff.
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 21/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.