Skip to content

Commit ee896e7

Browse files
committed
f - move weight calculation
1 parent 455d34a commit ee896e7

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 our_funding_outputs_weight = funding_outputs.iter().fold(0u64, |weight, out| {
@@ -1929,6 +1924,10 @@ pub(super) fn calculate_change_output_value(
19291924
if is_initiator {
19301925
weight = weight.saturating_add(get_output_weight(shared_output_funding_script).to_wu());
19311926
weight = weight.saturating_add(TX_COMMON_FIELDS_WEIGHT);
1927+
1928+
if shared_input.is_some() {
1929+
weight = weight.saturating_add(FUNDING_TRANSACTION_WITNESS_WEIGHT);
1930+
}
19321931
}
19331932

19341933
let fees_sats = fee_for_weight(funding_feerate_sat_per_1000_weight, weight);

0 commit comments

Comments
 (0)