lnworker: (trivial) add a few missing type-hints
What changed, and why it matters
This commit only adds Python type-hints to three method signatures in Electrum's Lightning Network worker code. It does not change any runtime behavior, logic, or data handling. There is no security relevance.
No action needed. This is a trivial type-hint addition with no runtime or security impact.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds missing type annotations to decrypt_cb_data, encrypt_cb_data, and suggest_funding_amount in electrum/lnworker.py. The function bodies, control flow, and cryptography usage are unchanged. This is a static-typing/documentation-only change.
Changed components
electrum/lnworker.pyInspect captured patch +3 / −3
diff --git a/electrum/lnworker.py b/electrum/lnworker.py
index 1501ef0..607968d 100644
--- a/electrum/lnworker.py
+++ b/electrum/lnworker.py
@@ -1435,12 +1435,12 @@ class LNWallet(LNWorker):
def cb_data(self, node_id: bytes) -> bytes:
return CB_MAGIC_BYTES + node_id[0:NODE_ID_PREFIX_LEN]
- def decrypt_cb_data(self, encrypted_data, funding_address):
+ def decrypt_cb_data(self, encrypted_data: bytes, funding_address: str) -> bytes:
funding_scripthash = bytes.fromhex(address_to_scripthash(funding_address))
nonce = funding_scripthash[0:12]
return chacha20_decrypt(key=self.backup_key, data=encrypted_data, nonce=nonce)
- def encrypt_cb_data(self, data, funding_address):
+ def encrypt_cb_data(self, data: bytes, funding_address: str) -> bytes:
funding_scripthash = bytes.fromhex(address_to_scripthash(funding_address))
nonce = funding_scripthash[0:12]
# note: we are only using chacha20 instead of chacha20+poly1305 to save onchain space
@@ -1473,7 +1473,7 @@ class LNWallet(LNWorker):
tx.locktime = get_locktime_for_new_transaction(self.network, include_random_component=False)
return tx
- def suggest_funding_amount(self, amount_to_pay, coins) -> Tuple[int, int] | None:
+ def suggest_funding_amount(self, amount_to_pay: int, coins: Sequence[PartialTxInput]) -> Tuple[int, int] | None:
""" whether we can pay amount_sat after opening a new channel"""
num_sats_can_send = int(self.num_sats_can_send())
lightning_needed = amount_to_pay - num_sats_can_send
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.