What changed, and why it matters
This is a test-only cleanup commit. It removes a redundant 'anchor_outputs' parameter from helper functions used in Lightning Network tests and instead derives the channel type from a wallet configuration flag. It also re-enables an internal assertion that was previously commented out. There is no change to production wallet behavior or user-facing security.
No security action required. Treat as normal test refactoring.
Security signals we found
No production code behavior change
Re-enabled internal consistency assertion in lnworker.py
Test helper simplification to remove inconsistent degrees of freedom
No mention of vulnerability, CVE, bug bounty, or security fix
Evidence from the diff
The commit refactors test helpers in tests/test_lnchannel.py, tests/test_lnpeer.py, and tests/test_lnwallet.py so that create_test_channels() no longer takes an explicit anchor_outputs boolean. Instead, the channel type is determined by alice_lnwallet.config.TEST_LN_OPEN_SRK_CHANNELS: if true, only OPTION_STATIC_REMOTEKEY is used; otherwise, OPTION_STATIC_REMOTEKEY | OPTION_ANCHORS. In electrum/lnworker.py, a previously commented-out assertion (‘assert self.config.TEST_LN_OPEN_SRK_CHANNELS’) in the static_remotekey branch of make_local_config_for_new_channel is re-enabled. This ensures internal consistency between the channel type and the test configuration flag.
Changed components
electrum/lnworker.pytests/test_lnchannel.pytests/test_lnpeer.pytests/test_lnwallet.pyInspect captured patch +12 / −14
diff --git a/electrum/lnworker.py b/electrum/lnworker.py
index b59be13..68127c1 100644
--- a/electrum/lnworker.py
+++ b/electrum/lnworker.py
@@ -1695,7 +1695,7 @@ class LNWallet(Logger):
static_remotekey = None
else: # static_remotekey
assert channel_type & channel_type.OPTION_STATIC_REMOTEKEY
- #assert self.config.TEST_LN_OPEN_SRK_CHANNELS
+ assert self.config.TEST_LN_OPEN_SRK_CHANNELS
wallet = self.wallet
assert wallet.txin_type == 'p2wpkh'
addr = wallet.get_new_sweep_address_for_channel()
diff --git a/tests/test_lnchannel.py b/tests/test_lnchannel.py
index 932aabb..759fd22 100644
--- a/tests/test_lnchannel.py
+++ b/tests/test_lnchannel.py
@@ -130,7 +130,6 @@ def create_test_channels(
local_msat=None,
remote_msat=None,
random_seed=None,
- anchor_outputs: bool = False,
local_max_inflight=None,
remote_max_inflight=None,
max_accepted_htlcs=5,
@@ -154,9 +153,11 @@ def create_test_channels(
config.LIGHTNING_MAX_FUNDING_SAT = max(config.LIGHTNING_MAX_FUNDING_SAT, funding_sat)
peer_features = alice_lnwallet.features | LnFeatures.OPTION_SUPPORT_LARGE_CHANNEL_OPT
- channel_type = ChannelType.OPTION_STATIC_REMOTEKEY
- if anchor_outputs:
- channel_type |= ChannelType.OPTION_ANCHORS
+ assert alice_lnwallet.config.TEST_LN_OPEN_SRK_CHANNELS == bob_lnwallet.config.TEST_LN_OPEN_SRK_CHANNELS
+ if alice_lnwallet.config.TEST_LN_OPEN_SRK_CHANNELS:
+ channel_type = ChannelType.OPTION_STATIC_REMOTEKEY
+ else:
+ channel_type = ChannelType.OPTION_STATIC_REMOTEKEY | ChannelType.OPTION_ANCHORS
# create alice's local config
alice_lconfig = alice_lnwallet.make_local_config_for_new_channel(
funding_sat=funding_sat,
@@ -273,7 +274,6 @@ class TestFee(ElectrumTestCase):
feerate=253,
local_msat=10_000_000_000,
remote_msat=5_000_000_000,
- anchor_outputs=self.TEST_ANCHOR_CHANNELS,
alice_lnwallet=self.alice_lnwallet,
bob_lnwallet=self.bob_lnwallet,
)
@@ -308,7 +308,7 @@ class TestChannel(ElectrumTestCase):
# unittest. The channel will be funded evenly with Alice having 5 BTC,
# and Bob having 5 BTC.
self.alice_channel, self.bob_channel = create_test_channels(
- anchor_outputs=self.TEST_ANCHOR_CHANNELS, alice_lnwallet=self.alice_lnwallet, bob_lnwallet=self.bob_lnwallet)
+ alice_lnwallet=self.alice_lnwallet, bob_lnwallet=self.bob_lnwallet)
self.paymentPreimage = b"\x01" * 32
paymentHash = bitcoin.sha256(self.paymentPreimage)
@@ -861,7 +861,7 @@ class TestAvailableToSpend(ElectrumTestCase):
async def test_DesyncHTLCs(self):
alice_channel, bob_channel = create_test_channels(
- anchor_outputs=self.TEST_ANCHOR_CHANNELS, alice_lnwallet=self.alice_lnwallet, bob_lnwallet=self.bob_lnwallet)
+ alice_lnwallet=self.alice_lnwallet, bob_lnwallet=self.bob_lnwallet)
self.assertEqual(499986152000 if not alice_channel.has_anchors() else 499980692000, alice_channel.available_to_spend(LOCAL))
self.assertEqual(500000000000, bob_channel.available_to_spend(LOCAL))
@@ -908,7 +908,6 @@ class TestAvailableToSpend(ElectrumTestCase):
async def test_single_payment(self):
alice_channel, bob_channel = create_test_channels(
- anchor_outputs=self.TEST_ANCHOR_CHANNELS,
local_msat=4000000000,
remote_msat=4000000000,
local_max_inflight=1000000000,
@@ -975,7 +974,7 @@ class TestChanReserve(ElectrumTestCase):
await super().asyncSetUp()
alice_lnwallet = self.create_mock_lnwallet(name="alice", has_anchors=self.TEST_ANCHOR_CHANNELS)
bob_lnwallet = self.create_mock_lnwallet(name="bob", has_anchors=self.TEST_ANCHOR_CHANNELS)
- alice_channel, bob_channel = create_test_channels(anchor_outputs=False, alice_lnwallet=alice_lnwallet, bob_lnwallet=bob_lnwallet)
+ alice_channel, bob_channel = create_test_channels(alice_lnwallet=alice_lnwallet, bob_lnwallet=bob_lnwallet)
alice_min_reserve = int(.5 * one_bitcoin_in_msat // 1000)
# We set Bob's channel reserve to a value that is larger than
# his current balance in the channel. This will ensure that
@@ -1115,7 +1114,7 @@ class TestDust(ElectrumTestCase):
async def test_DustLimit(self):
"""Test that addition of an HTLC below the dust limit changes the balances."""
- alice_channel, bob_channel = create_test_channels(anchor_outputs=self.TEST_ANCHOR_CHANNELS, alice_lnwallet=self.alice_lnwallet, bob_lnwallet=self.bob_lnwallet)
+ alice_channel, bob_channel = create_test_channels(alice_lnwallet=self.alice_lnwallet, bob_lnwallet=self.bob_lnwallet)
dust_limit_alice = alice_channel.config[LOCAL].dust_limit_sat
dust_limit_bob = bob_channel.config[LOCAL].dust_limit_sat
self.assertLess(dust_limit_alice, dust_limit_bob)
diff --git a/tests/test_lnpeer.py b/tests/test_lnpeer.py
index 0baef73..9d4d106 100644
--- a/tests/test_lnpeer.py
+++ b/tests/test_lnpeer.py
@@ -517,7 +517,6 @@ class TestPeer(ElectrumTestCase):
bob_lnwallet=workers[b],
local_msat=channel_def['local_balance_msat'],
remote_msat=channel_def['remote_balance_msat'],
- anchor_outputs=self.TEST_ANCHOR_CHANNELS
)
channels[(a, b)], channels[(b, a)] = channel_ab, channel_ba
workers[a]._add_channel(channel_ab)
diff --git a/tests/test_lnwallet.py b/tests/test_lnwallet.py
index d35c90d..d4f94ce 100644
--- a/tests/test_lnwallet.py
+++ b/tests/test_lnwallet.py
@@ -79,8 +79,8 @@ class TestLNWallet(ElectrumTestCase):
regular_peer = self.create_mock_lnwallet(name='regular_peer', has_anchors=True)
regular_pubkey = regular_peer.node_keypair.pubkey
- chan_t, _ = create_test_channels(alice_lnwallet=wallet, bob_lnwallet=trampoline_peer, anchor_outputs=True)
- chan_r, _ = create_test_channels(alice_lnwallet=wallet, bob_lnwallet=regular_peer, anchor_outputs=True)
+ chan_t, _ = create_test_channels(alice_lnwallet=wallet, bob_lnwallet=trampoline_peer)
+ chan_r, _ = create_test_channels(alice_lnwallet=wallet, bob_lnwallet=regular_peer)
wallet._add_channel(chan_t)
wallet._add_channel(chan_r)
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.