1
0

lnworker: split dont_settle_htlcs

Splits `LNWallet.dont_settle_htlcs` into `LNWallet.dont_settle_htlcs`
and `LNWallet.dont_expire_htlcs`.

Registering a payment hash in dont_settle_htlcs will prevent it from
getting fulfilled if we have the preimage stored. The preimage will not
be released before the the payment hash gets removed from
dont_settle_htlcs. Htlcs can still get expired as usual or failed if no
preimage is known.
This is only used by Just-in-time channel openings.

Registering a payment hash in dont_expire_htlcs allows to overwrite the
minimum final cltv delta value after which htlcs would usually get
expired. This allows to delay expiry of htlcs or, if the value in the
dont_settle_htlcs dict is None, completely prevent expiry and let the
htlc get expired onchain.

Splitting this up in two different dicts makes it more explicit and
easier to reason about what they are actually doing.

 Please enter the commit message for your changes. Lines starting
This commit is contained in:
f321x
2025-11-24 13:02:42 +01:00
parent b1e58450bd
commit abc469c846
5 changed files with 48 additions and 21 deletions

View File

@@ -510,7 +510,7 @@ class TestCommandsTestnet(ElectrumTestCase):
invoice = lndecode(invoice=result['invoice'])
assert invoice.paymenthash.hex() == payment_hash
assert payment_hash in wallet.lnworker.payment_info
assert payment_hash in wallet.lnworker.dont_settle_htlcs
assert payment_hash in wallet.lnworker.dont_expire_htlcs
assert invoice.get_amount_sat() == 10000
assert invoice.get_description() == "test"
assert wallet.get_label_for_rhash(rhash=invoice.paymenthash.hex()) == "test"
@@ -521,7 +521,7 @@ class TestCommandsTestnet(ElectrumTestCase):
wallet=wallet,
)
assert payment_hash not in wallet.lnworker.payment_info
assert payment_hash not in wallet.lnworker.dont_settle_htlcs
assert payment_hash not in wallet.lnworker.dont_expire_htlcs
assert wallet.get_label_for_rhash(rhash=invoice.paymenthash.hex()) == ""
assert cancel_result['cancelled'] == payment_hash
@@ -571,7 +571,6 @@ class TestCommandsTestnet(ElectrumTestCase):
)
assert settle_result['settled'] == payment_hash
assert wallet.lnworker._preimages[payment_hash] == preimage.hex()
assert payment_hash not in wallet.lnworker.dont_settle_htlcs
with (mock.patch.object(
wallet.lnworker,
'get_payment_value',

View File

@@ -218,6 +218,7 @@ class MockLNWallet(Logger, EventListener, NetworkRetryManager[LNPeerAddr]):
self._preimages = {}
self.stopping_soon = False
self.downstream_to_upstream_htlc = {}
self.dont_expire_htlcs = {}
self.dont_settle_htlcs = {}
self.hold_invoice_callbacks = {}
self._payment_bundles_pkey_to_canon = {} # type: Dict[bytes, bytes]