fix: remove unnecessary total_out counting in output_iter
What changed, and why it matters
This commit removes a local variable called total_out that was being incremented while iterating over transaction outputs in a PSBT (Partially Signed Bitcoin Transaction) parser. The variable was apparently unused and is described as 'unnecessary.' There is no direct evidence in the commit that this change fixes a security vulnerability; it appears to be a minor cleanup or optimization.
No immediate action required. Treat as routine cleanup. If this commit is part of a larger fix, review related commits or release notes for additional context.
Security signals we found
No explicit security relevance stated in commit title or message
Change is a six-line deletion described as cleanup/optimization
No functional behavior change visible in yielded values
No bounds checks, validation, or cryptographic operations modified
Evidence from the diff
In shared/psbt.py, the output_iter generator previously maintained a running sum of output values in a local variable total_out. The patch removes the initialization, the accumulation in both the v2 and v1 branches, and the unused variable itself. The generator’s yielded values and control flow are otherwise unchanged. No security impact is stated or directly inferable from the diff alone.
Changed components
shared/psbt.pypsbtObject.output_iter methodInspect captured patch +0 / −6
diff --git a/shared/psbt.py b/shared/psbt.py
index 1ffe9a6..d0ea6e9 100644
--- a/shared/psbt.py
+++ b/shared/psbt.py
@@ -1092,14 +1092,12 @@ class psbtObject(psbtProxy):
if stop is None:
stop = self.num_outputs
- total_out = 0
if self.is_v2:
for idx in range(start, stop):
out = self.outputs[idx]
amount = unpack("<q", self.get(out.amount))[0]
spk = self.get(out.script)
tx_out = CTxOut(nValue=amount, scriptPubKey=spk)
- total_out += amount
yield idx, tx_out
else:
assert self.vout_start is not None # must call input_iter/validate first
@@ -1112,11 +1110,7 @@ class psbtObject(psbtProxy):
tx_out = CTxOut()
for idx in range(start, stop):
-
tx_out.deserialize(fd)
-
- total_out += tx_out.nValue
-
cont = fd.tell()
yield idx, tx_out
Why this scored 25/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.