Skip to content

Commit 5b15f9b

Browse files
committed
f - use witness_weight
1 parent c9db499 commit 5b15f9b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lightning/src/ln/interactivetxs.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,7 +1885,7 @@ pub(super) fn calculate_change_output_value(
18851885

18861886
let mut total_input_satoshis = 0u64;
18871887
let mut our_funding_inputs_weight = 0u64;
1888-
for FundingTxInput { txin, prevtx, .. } in context.our_funding_inputs.iter() {
1888+
for FundingTxInput { txin, prevtx, witness_weight } in context.our_funding_inputs.iter() {
18891889
let txid = prevtx.compute_txid();
18901890
if txin.previous_output.txid != txid {
18911891
return Err(AbortReason::PrevTxOutInvalid);
@@ -1895,7 +1895,8 @@ pub(super) fn calculate_change_output_value(
18951895
.get(txin.previous_output.vout as usize)
18961896
.ok_or(AbortReason::PrevTxOutInvalid)?;
18971897
total_input_satoshis = total_input_satoshis.saturating_add(output.value.to_sat());
1898-
let weight = estimate_input_weight(output).to_wu();
1898+
1899+
let weight = BASE_INPUT_WEIGHT + EMPTY_SCRIPT_SIG_WEIGHT + witness_weight.to_wu();
18991900
our_funding_inputs_weight = our_funding_inputs_weight.saturating_add(weight);
19001901
}
19011902

@@ -1964,7 +1965,7 @@ mod tests {
19641965

19651966
use super::{
19661967
get_output_weight, P2TR_INPUT_WEIGHT_LOWER_BOUND, P2WPKH_INPUT_WEIGHT_LOWER_BOUND,
1967-
P2WSH_INPUT_WEIGHT_LOWER_BOUND, TX_COMMON_FIELDS_WEIGHT,
1968+
P2WPKH_WITNESS_WEIGHT, P2WSH_INPUT_WEIGHT_LOWER_BOUND, TX_COMMON_FIELDS_WEIGHT,
19681969
};
19691970

19701971
const TEST_FEERATE_SATS_PER_KW: u32 = FEERATE_FLOOR_SATS_PER_KW * 10;
@@ -2969,7 +2970,7 @@ mod tests {
29692970
sequence: Sequence::ZERO,
29702971
witness: Witness::new(),
29712972
};
2972-
let witness_weight = Weight::ZERO;
2973+
let witness_weight = Weight::from_wu(P2WPKH_WITNESS_WEIGHT);
29732974
FundingTxInput { txin, prevtx, witness_weight }
29742975
})
29752976
.collect();

0 commit comments

Comments
 (0)