Skip to content

Commit 3355400

Browse files
committed
docs: document IWP function return limit and panic case
Document the newly added saturation point for internal arithmetic.
1 parent 8559a49 commit 3355400

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

bitcoin/src/blockdata/transaction.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,12 +1126,18 @@ impl InputWeightPrediction {
11261126

11271127
/// Computes the **signature weight** added to a transaction by an input with this weight prediction,
11281128
/// not counting the prevout (txid, index), sequence, potential witness flag bytes or the witness count varint.
1129+
///
1130+
/// This function's internal arithmetic saturates at u32::MAX, so the return value of this
1131+
/// function may be inaccurate for extremely large witness predictions.
11291132
#[deprecated(since = "TBD", note = "use `InputWeightPrediction::witness_weight()` instead")]
11301133
pub const fn weight(&self) -> Weight { Self::witness_weight(self) }
11311134

11321135
/// Computes the signature, prevout (txid, index), and sequence weights of this weight
11331136
/// prediction.
11341137
///
1138+
/// This function's internal arithmetic saturates at u32::MAX, so the return value of this
1139+
/// function may be inaccurate for extremely large witness predictions.
1140+
///
11351141
/// See also [`InputWeightPrediction::witness_weight`]
11361142
pub const fn total_weight(&self) -> Weight {
11371143
// `impl const Trait` is currently unavailable: rust/issues/67792
@@ -1142,6 +1148,9 @@ impl InputWeightPrediction {
11421148

11431149
/// Computes the **signature weight** added to a transaction by an input with this weight prediction,
11441150
/// not counting the prevout (txid, index), sequence, potential witness flag bytes or the witness count varint.
1151+
///
1152+
/// This function's internal arithmetic saturates at u32::MAX, so the return value of this
1153+
/// function may be inaccurate for extremely large witness predictions.
11451154
///
11461155
/// See also [`InputWeightPrediction::total_weight`]
11471156
pub const fn witness_weight(&self) -> Weight {

0 commit comments

Comments
 (0)