@@ -1593,6 +1593,13 @@ pub(super) struct FundingScope {
1593
1593
pub(super) holder_selected_channel_reserve_satoshis: u64,
1594
1594
#[cfg(not(test))]
1595
1595
holder_selected_channel_reserve_satoshis: u64,
1596
+
1597
+ #[cfg(debug_assertions)]
1598
+ /// Max to_local and to_remote outputs in a locally-generated commitment transaction
1599
+ holder_max_commitment_tx_output: Mutex<(u64, u64)>,
1600
+ #[cfg(debug_assertions)]
1601
+ /// Max to_local and to_remote outputs in a remote-generated commitment transaction
1602
+ counterparty_max_commitment_tx_output: Mutex<(u64, u64)>,
1596
1603
}
1597
1604
1598
1605
/// Contains everything about the channel including state, and various flags.
@@ -1716,13 +1723,6 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
1716
1723
/// time.
1717
1724
update_time_counter: u32,
1718
1725
1719
- #[cfg(debug_assertions)]
1720
- /// Max to_local and to_remote outputs in a locally-generated commitment transaction
1721
- holder_max_commitment_tx_output: Mutex<(u64, u64)>,
1722
- #[cfg(debug_assertions)]
1723
- /// Max to_local and to_remote outputs in a remote-generated commitment transaction
1724
- counterparty_max_commitment_tx_output: Mutex<(u64, u64)>,
1725
-
1726
1726
// (fee_sats, skip_remote_output, fee_range, holder_sig)
1727
1727
last_sent_closing_fee: Option<(u64, bool, ClosingSignedFeeRange, Option<Signature>)>,
1728
1728
last_received_closing_sig: Option<Signature>,
@@ -2462,6 +2462,11 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2462
2462
value_to_self_msat,
2463
2463
counterparty_selected_channel_reserve_satoshis: Some(msg_channel_reserve_satoshis),
2464
2464
holder_selected_channel_reserve_satoshis,
2465
+
2466
+ #[cfg(debug_assertions)]
2467
+ holder_max_commitment_tx_output: Mutex::new((value_to_self_msat, (channel_value_satoshis * 1000 - msg_push_msat).saturating_sub(value_to_self_msat))),
2468
+ #[cfg(debug_assertions)]
2469
+ counterparty_max_commitment_tx_output: Mutex::new((value_to_self_msat, (channel_value_satoshis * 1000 - msg_push_msat).saturating_sub(value_to_self_msat))),
2465
2470
};
2466
2471
let channel_context = ChannelContext {
2467
2472
user_id,
@@ -2518,12 +2523,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2518
2523
signer_pending_closing: false,
2519
2524
signer_pending_channel_ready: false,
2520
2525
2521
-
2522
- #[cfg(debug_assertions)]
2523
- holder_max_commitment_tx_output: Mutex::new((value_to_self_msat, (channel_value_satoshis * 1000 - msg_push_msat).saturating_sub(value_to_self_msat))),
2524
- #[cfg(debug_assertions)]
2525
- counterparty_max_commitment_tx_output: Mutex::new((value_to_self_msat, (channel_value_satoshis * 1000 - msg_push_msat).saturating_sub(value_to_self_msat))),
2526
-
2527
2526
last_sent_closing_fee: None,
2528
2527
last_received_closing_sig: None,
2529
2528
pending_counterparty_closing_signed: None,
@@ -2696,6 +2695,13 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2696
2695
value_to_self_msat,
2697
2696
counterparty_selected_channel_reserve_satoshis: None, // Filled in in accept_channel
2698
2697
holder_selected_channel_reserve_satoshis,
2698
+
2699
+ // We'll add our counterparty's `funding_satoshis` to these max commitment output assertions
2700
+ // when we receive `accept_channel2`.
2701
+ #[cfg(debug_assertions)]
2702
+ holder_max_commitment_tx_output: Mutex::new((channel_value_satoshis * 1000 - push_msat, push_msat)),
2703
+ #[cfg(debug_assertions)]
2704
+ counterparty_max_commitment_tx_output: Mutex::new((channel_value_satoshis * 1000 - push_msat, push_msat)),
2699
2705
};
2700
2706
let channel_context = Self {
2701
2707
user_id,
@@ -2750,13 +2756,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2750
2756
signer_pending_closing: false,
2751
2757
signer_pending_channel_ready: false,
2752
2758
2753
- // We'll add our counterparty's `funding_satoshis` to these max commitment output assertions
2754
- // when we receive `accept_channel2`.
2755
- #[cfg(debug_assertions)]
2756
- holder_max_commitment_tx_output: Mutex::new((channel_value_satoshis * 1000 - push_msat, push_msat)),
2757
- #[cfg(debug_assertions)]
2758
- counterparty_max_commitment_tx_output: Mutex::new((channel_value_satoshis * 1000 - push_msat, push_msat)),
2759
-
2760
2759
last_sent_closing_fee: None,
2761
2760
last_received_closing_sig: None,
2762
2761
pending_counterparty_closing_signed: None,
@@ -3533,9 +3532,9 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3533
3532
// Make sure that the to_self/to_remote is always either past the appropriate
3534
3533
// channel_reserve *or* it is making progress towards it.
3535
3534
let mut broadcaster_max_commitment_tx_output = if generated_by_local {
3536
- self .holder_max_commitment_tx_output.lock().unwrap()
3535
+ funding .holder_max_commitment_tx_output.lock().unwrap()
3537
3536
} else {
3538
- self .counterparty_max_commitment_tx_output.lock().unwrap()
3537
+ funding .counterparty_max_commitment_tx_output.lock().unwrap()
3539
3538
};
3540
3539
debug_assert!(broadcaster_max_commitment_tx_output.0 <= value_to_self_msat as u64 || value_to_self_msat / 1000 >= funding.counterparty_selected_channel_reserve_satoshis.unwrap() as i64);
3541
3540
broadcaster_max_commitment_tx_output.0 = cmp::max(broadcaster_max_commitment_tx_output.0, value_to_self_msat as u64);
@@ -10426,6 +10425,11 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
10426
10425
value_to_self_msat,
10427
10426
counterparty_selected_channel_reserve_satoshis,
10428
10427
holder_selected_channel_reserve_satoshis: holder_selected_channel_reserve_satoshis.unwrap(),
10428
+
10429
+ #[cfg(debug_assertions)]
10430
+ holder_max_commitment_tx_output: Mutex::new((0, 0)),
10431
+ #[cfg(debug_assertions)]
10432
+ counterparty_max_commitment_tx_output: Mutex::new((0, 0)),
10429
10433
},
10430
10434
context: ChannelContext {
10431
10435
user_id,
@@ -10481,11 +10485,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
10481
10485
update_time_counter,
10482
10486
feerate_per_kw,
10483
10487
10484
- #[cfg(debug_assertions)]
10485
- holder_max_commitment_tx_output: Mutex::new((0, 0)),
10486
- #[cfg(debug_assertions)]
10487
- counterparty_max_commitment_tx_output: Mutex::new((0, 0)),
10488
-
10489
10488
last_sent_closing_fee: None,
10490
10489
last_received_closing_sig: None,
10491
10490
pending_counterparty_closing_signed: None,
0 commit comments