Skip to content

Commit 2560fce

Browse files
committed
fix Simplify prev txout existence check
1 parent 5f5e3b7 commit 2560fce

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

lightning/src/ln/interactivetxs.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,13 +1910,14 @@ pub(super) fn calculate_change_output_value(
19101910
if txin.previous_output.txid != txid {
19111911
return Err(AbortReason::PrevTxOutInvalid);
19121912
}
1913-
if let Some(output) = tx.as_transaction().output.get(txin.previous_output.vout as usize) {
1914-
total_input_satoshis = total_input_satoshis.saturating_add(output.value.to_sat());
1915-
let weight = estimate_input_weight(output).to_wu();
1916-
our_funding_inputs_weight = our_funding_inputs_weight.saturating_add(weight);
1917-
} else {
1918-
return Err(AbortReason::PrevTxOutInvalid);
1919-
}
1913+
let output = tx
1914+
.as_transaction()
1915+
.output
1916+
.get(txin.previous_output.vout as usize)
1917+
.ok_or(AbortReason::PrevTxOutInvalid)?;
1918+
total_input_satoshis = total_input_satoshis.saturating_add(output.value.to_sat());
1919+
let weight = estimate_input_weight(output).to_wu();
1920+
our_funding_inputs_weight = our_funding_inputs_weight.saturating_add(weight);
19201921
}
19211922
// If there is a shared input, account for it,
19221923
// and for the initiator also consider the fee

0 commit comments

Comments
 (0)