What changed, and why it matters
This commit is a minor code-quality change. It adds a clarifying comment to a payment-batching helper, makes a type annotation more specific, and adds a hash method to a transaction output class so outputs can be used in sets or as dictionary keys. There is no security fix or behavior change visible in the diff.
No security action needed. Treat as routine maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff touches three files: (1) network.py adds explicit type hints to try_broadcasting; (2) transaction.py adds hash to TxOutput based on scriptpubkey and value; (3) txbatcher.py adds a comment explaining that _to_pay_after computes a multiset difference. None of these changes alter runtime behavior in a security-relevant way. The new hash is consistent with the existing eq, which is good practice but not a vulnerability fix.
Changed components
electrum/network.pyelectrum/transaction.pyelectrum/txbatcher.pyInspect captured patch +6 / −1
diff --git a/electrum/network.py b/electrum/network.py
index b9a9bb7..f1ce71f 100644
--- a/electrum/network.py
+++ b/electrum/network.py
@@ -1069,7 +1069,7 @@ class Network(Logger, NetworkRetryManager[ServerAddr]):
raise RequestTimedOut()
await self.interface.broadcast_transaction(tx, timeout=timeout)
- async def try_broadcasting(self, tx, name) -> bool:
+ async def try_broadcasting(self, tx: 'Transaction', name: str) -> bool:
try:
await self.broadcast_transaction(tx)
except Exception as e:
diff --git a/electrum/transaction.py b/electrum/transaction.py
index cdab347..33040b7 100644
--- a/electrum/transaction.py
+++ b/electrum/transaction.py
@@ -203,6 +203,9 @@ class TxOutput:
def __ne__(self, other):
return not (self == other)
+ def __hash__(self) -> int:
+ return hash((self.scriptpubkey, self.value))
+
def to_json(self):
d = {
'scriptpubkey': self.scriptpubkey.hex(),
diff --git a/electrum/txbatcher.py b/electrum/txbatcher.py
index 419621c..7aca7cd 100644
--- a/electrum/txbatcher.py
+++ b/electrum/txbatcher.py
@@ -303,6 +303,8 @@ class TxBatch(Logger):
def _to_pay_after(self, tx: Optional[PartialTransaction]) -> Sequence[PartialTxOutput]:
if not tx:
return self.batch_payments
+ # note: the below is equivalent to
+ # to_pay = multiset(self.batch_payments) - multiset(tx.outputs())
to_pay = []
outputs = copy.deepcopy(tx.outputs())
for x in self.batch_payments:
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.