transaction: extend estimated_size() docstring
What changed, and why it matters
This commit only adds explanatory text to a code comment (docstring). It does not change any program logic, transaction calculations, or security behavior. There is no security issue here.
No action needed; this is a documentation-only change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch extends the docstring of Transaction.estimated_size() in electrum/transaction.py. It documents the preference for over-estimating transaction size when exact values are impossible, because fees are computed as fee_rate times estimated size. No executable code was modified.
Changed components
electrum/transaction.pyInspect captured patch +8 / −1
diff --git a/electrum/transaction.py b/electrum/transaction.py
index c172917..82d1126 100644
--- a/electrum/transaction.py
+++ b/electrum/transaction.py
@@ -1349,7 +1349,14 @@ class Transaction:
BIP-0141 defines 'Virtual transaction size' to be weight/4 rounded up.
This definition is only for humans, and has little meaning otherwise.
If we wanted sub-byte precision, fee calculation should use transaction
- weights, but for simplicity we approximate that with (virtual_size)x4
+ weights, but for simplicity we approximate that with (virtual_size)x4.
+ note: while we try to estimate as close to the true value as possible,
+ whenever that's not possible, we should over-estimate. E.g. ecdsa DER sig
+ sizes can be 71 or 72 bytes (even 73 though that is non-standard).
+ Over-estimating is preferred as the typical use-case is the user selecting
+ a target_feerate, and the code calculating abs fees as target_feerate*est_size.
+ If we over-estimate est_size there, that means the final true_feerate is going to
+ be higher than target_feerate, which is desirable especially near the min_relay_fee.
"""
weight = self.estimated_weight()
return self.virtual_size_from_weight(weight)
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.