What changed, and why it matters
This commit is a minor code cleanup that adds Python type-hints and slightly refactors two helper methods. It does not change program behavior or fix any security issue.
No security action needed; treat as routine maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds return type annotations (Sequence[PartialTxOutput], bool, None) and an argument type annotation (PartialTransaction instead of Transaction) in electrum/transaction.py and electrum/txbatcher.py. It also replaces a for...return loop with direct indexing and makes an implicit return explicit as return None. These are stylistic/type-safety improvements with no functional change.
Changed components
electrum/transaction.pyelectrum/txbatcher.pyInspect captured patch +7 / −7
diff --git a/electrum/transaction.py b/electrum/transaction.py
index eed3820..cca06ff 100644
--- a/electrum/transaction.py
+++ b/electrum/transaction.py
@@ -2420,19 +2420,19 @@ class PartialTransaction(Transaction):
self.add_outputs([funding_output])
delattr(self, '_script_to_output_idx')
- def get_change_outputs(self):
- return [o for o in self._outputs if o.is_change]
+ def get_change_outputs(self) -> Sequence[PartialTxOutput]:
+ return [o for o in self._outputs if o.is_change]
- def has_change(self):
+ def has_change(self) -> bool:
return len(self.get_change_outputs()) > 0
def get_dummy_output(self, dummy_addr: str) -> Optional['PartialTxOutput']:
idxs = self.get_output_idxs_from_address(dummy_addr)
if not idxs:
- return
+ return None
assert len(idxs) == 1
- for i in idxs:
- return self.outputs()[i]
+ idx = list(idxs)[0]
+ return self.outputs()[idx]
def set_rbf(self, rbf: bool) -> None:
nSequence = 0xffffffff - (2 if rbf else 1)
diff --git a/electrum/txbatcher.py b/electrum/txbatcher.py
index 3dcf159..6451bfb 100644
--- a/electrum/txbatcher.py
+++ b/electrum/txbatcher.py
@@ -559,7 +559,7 @@ class TxBatch(Logger):
self._prevout = None
@locked
- def _new_base_tx(self, tx: Transaction) -> None:
+ def _new_base_tx(self, tx: PartialTransaction) -> None:
self._prevout = tx.inputs()[0].prevout.to_str()
self.storage['prevout'] = self._prevout
if tx.has_change():
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.