@@ -57,6 +57,7 @@ use crate::chain::transaction::{OutPoint, TransactionData};
5757use crate::sign::ecdsa::EcdsaChannelSigner;
5858use crate::sign::{EntropySource, ChannelSigner, SignerProvider, NodeSigner, Recipient};
5959use crate::events::{ClosureReason, Event};
60+ use crate::events::bump_transaction::BASE_INPUT_WEIGHT;
6061use crate::routing::gossip::NodeId;
6162use crate::util::ser::{Readable, ReadableArgs, TransactionU16LenLimited, Writeable, Writer};
6263use crate::util::logger::{Logger, Record, WithContext};
@@ -4475,7 +4476,6 @@ pub(super) fn calculate_our_funding_satoshis(
44754476 holder_dust_limit_satoshis: u64,
44764477) -> Result<u64, APIError> {
44774478 let mut total_input_satoshis = 0u64;
4478- let mut our_contributed_weight = 0u64;
44794479
44804480 for (idx, input) in funding_inputs.iter().enumerate() {
44814481 if let Some(output) = input.1.as_transaction().output.get(input.0.previous_output.vout as usize) {
@@ -4486,6 +4486,9 @@ pub(super) fn calculate_our_funding_satoshis(
44864486 input.1.as_transaction().compute_txid(), input.0.previous_output.vout, idx) });
44874487 }
44884488 }
4489+ // inputs:
4490+ let mut our_contributed_weight = (funding_inputs.len() as u64) * BASE_INPUT_WEIGHT;
4491+ // witnesses:
44894492 our_contributed_weight = our_contributed_weight.saturating_add(total_witness_weight.to_wu());
44904493
44914494 // If we are the initiator, we must pay for weight of all common fields in the funding transaction.
@@ -12268,25 +12271,25 @@ mod tests {
1226812271 assert_eq!(
1226912272 calculate_our_funding_satoshis(true, &inputs_2, witness_weight, 2000, 1000)
1227012273 .unwrap(),
12271- 298972
12274+ 298332
1227212275 );
1227312276
1227412277 assert_eq!(
1227512278 calculate_our_funding_satoshis(true, &inputs_1, witness_weight, 2000, 1000)
1227612279 .unwrap(),
12277- 18972
12280+ 18652
1227812281 );
1227912282
1228012283 assert_eq!(
1228112284 calculate_our_funding_satoshis(true, &inputs_1, Weight::from_wu(0), 2000, 1000)
1228212285 .unwrap(),
12283- 19572
12286+ 19252
1228412287 );
1228512288
1228612289 assert_eq!(
1228712290 calculate_our_funding_satoshis(false, &inputs_1, Weight::from_wu(0), 2000, 1000)
1228812291 .unwrap(),
12289- 20000
12292+ 19680
1229012293 );
1229112294
1229212295 // below dust limit
0 commit comments