From b6e224c8646dd773f947043fb1808d6d39f0cfe9 Mon Sep 17 00:00:00 2001 From: bitromortac Date: Mon, 13 Sep 2021 14:48:48 +0200 Subject: [PATCH] lnwatcher: add field for onchain htlc settlement control --- electrum/lnwatcher.py | 5 +++++ electrum/lnworker.py | 1 + 2 files changed, 6 insertions(+) diff --git a/electrum/lnwatcher.py b/electrum/lnwatcher.py index 648582b87..9138b9dc0 100644 --- a/electrum/lnwatcher.py +++ b/electrum/lnwatcher.py @@ -539,6 +539,11 @@ class LNWalletWatcher(LNWatcher): # self.logger.debug( # f"pending redeem for {prevout}. waiting for {name}: CSV " # f"({local_height=}, {wanted_height=}, {prev_height.height=}, {sweep_info.csv_delay=})") + if not (sweep_info.cltv_abs or sweep_info.csv_delay): + # used to control settling of htlcs onchain for testing purposes + # careful, this prevents revocation as well + if not self.lnworker.enable_htlc_settle_onchain: + return if can_broadcast: self.logger.info(f'we can broadcast: {name}') tx_was_added = await self.network.try_broadcasting(new_tx, name) diff --git a/electrum/lnworker.py b/electrum/lnworker.py index 65c6dff46..edd2b7a43 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -845,6 +845,7 @@ class LNWallet(LNWorker): self.logs = defaultdict(list) # type: Dict[str, List[HtlcLog]] # key is RHASH # (not persisted) # used in tests self.enable_htlc_settle = True + self.enable_htlc_settle_onchain = True self.enable_htlc_forwarding = True # note: accessing channels (besides simple lookup) needs self.lock!