Skip to content

Commit f45fe4f

Browse files
committed
f - move weight calculation
1 parent b1c569b commit f45fe4f

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lightning/src/ln/interactivetxs.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,14 +1909,9 @@ pub(super) fn calculate_change_output_value(
19091909
let weight = estimate_input_weight(output).to_wu();
19101910
our_funding_inputs_weight = our_funding_inputs_weight.saturating_add(weight);
19111911
}
1912-
// If there is a shared input, account for it,
1913-
// and for the initiator also consider the fee
1912+
19141913
if let Some(shared_input) = shared_input {
19151914
total_input_satoshis = total_input_satoshis.saturating_add(shared_input);
1916-
if is_initiator {
1917-
our_funding_inputs_weight =
1918-
our_funding_inputs_weight.saturating_add(FUNDING_TRANSACTION_WITNESS_WEIGHT);
1919-
}
19201915
}
19211916

19221917
let total_output_satoshis = funding_outputs.iter().fold(0u64, |total, out| {
@@ -1932,6 +1927,10 @@ pub(super) fn calculate_change_output_value(
19321927
if is_initiator {
19331928
weight = weight.saturating_add(get_output_weight(shared_output_funding_script).to_wu());
19341929
weight = weight.saturating_add(TX_COMMON_FIELDS_WEIGHT);
1930+
1931+
if shared_input.is_some() {
1932+
weight = weight.saturating_add(FUNDING_TRANSACTION_WITNESS_WEIGHT);
1933+
}
19351934
}
19361935

19371936
let fees_sats = fee_for_weight(funding_feerate_sat_per_1000_weight, weight);

0 commit comments

Comments
 (0)