What changed, and why it matters
This commit only adjusts Python type hints and one test counter variable. It does not change any runtime behavior, so it cannot introduce or fix a security vulnerability on its own.
No security action needed. Treat as normal code-quality/type-checking maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff is a collection of trivial type-hint corrections: adding | None to optional attributes, correcting a test flag from False to 0, and updating a return-type annotation. None of these changes alter program logic, data flow, or security boundaries.
Changed components
electrum/gui/qml/qetxfinalizer.pyelectrum/gui/qt/main_window.pyelectrum/invoices.pyelectrum/lnonion.pyelectrum/plugins/watchtower/watchtower.pyelectrum/submarine_swaps.pyelectrum/transaction.pytests/test_commands.pytests/test_lnpeer.pytests/toyserver/toyserver.pyInspect captured patch +15 / −15
### electrum/gui/qml/qetxfinalizer.py
@@ -941,7 +941,7 @@ def __init__(self, parent=None):
self._parent_tx = None
self._new_tx = None
self._parent_tx_size = 0
- self._parent_fee = 0
+ self._parent_fee = 0 # type: int | None
self._max_fee = 0
self._txid = ''
self._rbf = True
### electrum/gui/qt/main_window.py
@@ -184,7 +184,7 @@ def __init__(self, gui_object: 'ElectrumGui', wallet: Abstract_Wallet):
Exception_Hook.maybe_setup(config=self.config, wallet=self.wallet)
- self.network = gui_object.daemon.network # type: Network
+ self.network = gui_object.daemon.network # type: Network | None
self.fx = gui_object.daemon.fx # type: FxThread
self.contacts = wallet.contacts
self.tray = gui_object.tray
### electrum/invoices.py
@@ -257,7 +257,7 @@ def as_dict(self, status):
@attr.s
class Invoice(BaseInvoice):
lightning_invoice = attr.ib(type=str, kw_only=True) # type: Optional[str]
- __lnaddr = None
+ __lnaddr = None # type: BOLT11Addr | None
_broadcasting_status = None # can be None or PR_BROADCASTING or PR_BROADCAST
def is_lightning(self):
### electrum/lnonion.py
@@ -389,7 +389,7 @@ class ProcessedOnionPacket(NamedTuple):
are_we_final: bool
hop_data: OnionHopsDataSingle
next_packet: OnionPacket
- trampoline_onion_packet: OnionPacket
+ trampoline_onion_packet: OnionPacket | None
@property
def amt_to_forward(self) -> Optional[int]:
### electrum/plugins/watchtower/watchtower.py
@@ -152,7 +152,7 @@ async def check_onchain_situation(self, address, funding_outpoint):
if not keep_watching:
await self.unwatch_channel(address, funding_outpoint)
- def inspect_tx_candidate(self, outpoint, n: int) -> Dict[str, str]:
+ def inspect_tx_candidate(self, outpoint: str, n: int) -> Dict[str, str | None]:
"""
returns a dict of spenders for a transaction of interest.
subscribes to addresses as a side effect.
### electrum/submarine_swaps.py
@@ -253,11 +253,11 @@ class SwapManager(Logger):
def __init__(self, *, wallet: 'Abstract_Wallet', lnworker: 'LNWallet'):
Logger.__init__(self)
- self.mining_fee = None
+ self.mining_fee = None # type: int | None
self.percentage = None # type: Optional[Decimal]
- self._min_amount = None
- self._max_forward = None
- self._max_reverse = None
+ self._min_amount = None # type: int | None
+ self._max_forward = None # type: int | None
+ self._max_reverse = None # type: int | None
self.wallet = wallet
self.config = wallet.config
### electrum/transaction.py
@@ -907,8 +907,8 @@ def __init__(self, raw):
self._cached_network_ser = raw.hex()
else:
raise Exception(f"cannot initialize transaction from {raw}")
- self._inputs = None # type: List[TxInput]
- self._outputs = None # type: List[TxOutput]
+ self._inputs = None # type: List[TxInput] | None
+ self._outputs = None # type: List[TxOutput] | None
self._locktime = 0
self._version = 2
@@ -2495,7 +2495,7 @@ def sign_txin(
txin_index: int,
privkey_bytes: bytes,
*,
- sighash_cache: SighashCache = None,
+ sighash_cache: SighashCache | None = None,
) -> bytes:
txin = self.inputs()[txin_index]
txin.validate_data(for_signing=True)
### tests/test_commands.py
@@ -748,7 +748,7 @@ async def test_add_peer(self, *mock_args):
mock_peer = mock.Mock()
mock_peer.initialized = asyncio.Future()
connection_string = "test_node_id@127.0.0.1:9735"
- called = False
+ called = 0
async def lnpeermgr_add_peer(*args, **kwargs):
assert args[0] == connection_string
nonlocal called
### tests/test_lnpeer.py
@@ -2668,7 +2668,7 @@ async def test_forwarder_fails_for_inconsistent_trampoline_onions(self):
"""
# store a modified trampoline onion to be injected into lnworker.new_onion_packet later when sending the htlcs
- modified_trampoline_onion = None
+ modified_trampoline_onion = None # type: OnionPacket | None
def modified_new_onion_packet_trampoline(payment_path_pubkeys, session_key, hops_data: List[OnionHopsDataSingle], **kwargs):
nonlocal modified_trampoline_onion
assert modified_trampoline_onion is None, "this mock should get called only once"
### tests/toyserver/toyserver.py
@@ -62,7 +62,7 @@ def recurse(node: str):
@dataclass(kw_only=True, slots=True, frozen=True)
class FakeBlock:
header: bytes
- txids: Sequence[str] = None # FIXME needs OrderedSet with index-based lookup? >.<
+ txids: Sequence[str] | None = None # FIXME needs OrderedSet with index-based lookup? >.<
def __post_init__(self):
if self.txids is None: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.