What changed, and why it matters
This commit simply moves an internal data template from inside a class constructor to the top of the same file. No behavior, logic, or security properties change. It is a routine code cleanup with no user-facing or security impact.
No action required. This is a non-functional refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff extracts the initial dictionary from HTLCManager.__init__ into a module-level constant named LOG_TEMPLATE. The constructor now references deepcopy(LOG_TEMPLATE) instead of deepcopy(initial). The values assigned to log[LOCAL] and log[REMOTE] are identical before and after the change. No functional, cryptographic, or protocol change is introduced.
Changed components
electrum/lnhtlc.pyInspect captured patch +13 / −12
diff --git a/electrum/lnhtlc.py b/electrum/lnhtlc.py
index 4ccaa48..9901efe 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
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.