1
0

lnpeer/lnworker: refactor htlc_switch

refactor `htlc_switch` to new architecture to make it more robust
against partial settlement of htlc sets and increase maintainability.
Htlcs are now processed in two steps, first the htlcs are collected into
sets from the channels, and potentially failed on their own already.
Then a second loop iterates over the htlc sets and finalizes only on
whole sets.

# Conflicts:
#	electrum/lnpeer.py
This commit is contained in:
f321x
2025-09-09 13:10:17 +02:00
parent 41d391a617
commit 0f314d1dd9
11 changed files with 1038 additions and 448 deletions

View File

@@ -549,13 +549,13 @@ class TestCommandsTestnet(ElectrumTestCase):
)
mock_htlc1 = mock.Mock()
mock_htlc1.cltv_abs = 800_000
mock_htlc1.amount_msat = 4_500_000
mock_htlc1.htlc.cltv_abs = 800_000
mock_htlc1.htlc.amount_msat = 4_500_000
mock_htlc2 = mock.Mock()
mock_htlc2.cltv_abs = 800_144
mock_htlc2.amount_msat = 5_500_000
mock_htlc2.htlc.cltv_abs = 800_144
mock_htlc2.htlc.amount_msat = 5_500_000
mock_htlc_status = mock.Mock()
mock_htlc_status.htlc_set = [(None, mock_htlc1), (None, mock_htlc2)]
mock_htlc_status.htlcs = [mock_htlc1, mock_htlc2]
mock_htlc_status.resolution = RecvMPPResolution.COMPLETE
payment_key = wallet.lnworker._get_payment_key(bytes.fromhex(payment_hash)).hex()