From be3e05d7c0700542077a93b37aa8268cedffccc5 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Wed, 28 Jan 2026 17:43:32 +0100 Subject: [PATCH] lnhtlc: move LOG_TEMPLATE to top. This commit only moves code. --- electrum/lnhtlc.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/electrum/lnhtlc.py b/electrum/lnhtlc.py index 4ccaa48ff..9901efe4d 100644 --- a/electrum/lnhtlc.py +++ b/electrum/lnhtlc.py @@ -7,25 +7,26 @@ from .util import bfh, with_lock if TYPE_CHECKING: from .json_db import StoredDict +LOG_TEMPLATE = { + 'adds': {}, # "side who offered htlc" -> htlc_id -> htlc + 'locked_in': {}, # "side who offered htlc" -> action -> htlc_id -> whose ctx -> ctn + 'settles': {}, # "side who offered htlc" -> action -> htlc_id -> whose ctx -> ctn + 'fails': {}, # "side who offered htlc" -> action -> htlc_id -> whose ctx -> ctn + 'fee_updates': {}, # "side who initiated fee update" -> index -> list of FeeUpdates + 'revack_pending': False, + 'next_htlc_id': 0, + 'ctn': -1, # oldest unrevoked ctx of sub +} + class HTLCManager: def __init__(self, log: 'StoredDict', *, initiator=None, initial_feerate=None): if len(log) == 0: - initial = { - 'adds': {}, # "side who offered htlc" -> htlc_id -> htlc - 'locked_in': {}, # "side who offered htlc" -> action -> htlc_id -> whose ctx -> ctn - 'settles': {}, # "side who offered htlc" -> action -> htlc_id -> whose ctx -> ctn - 'fails': {}, # "side who offered htlc" -> action -> htlc_id -> whose ctx -> ctn - 'fee_updates': {}, # "side who initiated fee update" -> index -> list of FeeUpdates - 'revack_pending': False, - 'next_htlc_id': 0, - 'ctn': -1, # oldest unrevoked ctx of sub - } # note: "htlc_id" keys in dict are str! but due to json_db magic they can *almost* be treated as int... - log[LOCAL] = deepcopy(initial) - log[REMOTE] = deepcopy(initial) + log[LOCAL] = deepcopy(LOG_TEMPLATE) + log[REMOTE] = deepcopy(LOG_TEMPLATE) log[LOCAL]['unacked_updates'] = {} log[LOCAL]['was_revoke_last'] = False