@@ -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
impl FundingScope {
@@ -1740,13 +1747,6 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
1740
1747
/// time.
1741
1748
update_time_counter: u32,
1742
1749
1743
- #[cfg(debug_assertions)]
1744
- /// Max to_local and to_remote outputs in a locally-generated commitment transaction
1745
- holder_max_commitment_tx_output: Mutex<(u64, u64)>,
1746
- #[cfg(debug_assertions)]
1747
- /// Max to_local and to_remote outputs in a remote-generated commitment transaction
1748
- counterparty_max_commitment_tx_output: Mutex<(u64, u64)>,
1749
-
1750
1750
// (fee_sats, skip_remote_output, fee_range, holder_sig)
1751
1751
last_sent_closing_fee: Option<(u64, bool, ClosingSignedFeeRange, Option<Signature>)>,
1752
1752
last_received_closing_sig: Option<Signature>,
@@ -2486,6 +2486,11 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2486
2486
value_to_self_msat,
2487
2487
counterparty_selected_channel_reserve_satoshis: Some(msg_channel_reserve_satoshis),
2488
2488
holder_selected_channel_reserve_satoshis,
2489
+
2490
+ #[cfg(debug_assertions)]
2491
+ holder_max_commitment_tx_output: Mutex::new((value_to_self_msat, (channel_value_satoshis * 1000 - msg_push_msat).saturating_sub(value_to_self_msat))),
2492
+ #[cfg(debug_assertions)]
2493
+ counterparty_max_commitment_tx_output: Mutex::new((value_to_self_msat, (channel_value_satoshis * 1000 - msg_push_msat).saturating_sub(value_to_self_msat))),
2489
2494
};
2490
2495
let channel_context = ChannelContext {
2491
2496
user_id,
@@ -2542,12 +2547,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2542
2547
signer_pending_closing: false,
2543
2548
signer_pending_channel_ready: false,
2544
2549
2545
-
2546
- #[cfg(debug_assertions)]
2547
- holder_max_commitment_tx_output: Mutex::new((value_to_self_msat, (channel_value_satoshis * 1000 - msg_push_msat).saturating_sub(value_to_self_msat))),
2548
- #[cfg(debug_assertions)]
2549
- counterparty_max_commitment_tx_output: Mutex::new((value_to_self_msat, (channel_value_satoshis * 1000 - msg_push_msat).saturating_sub(value_to_self_msat))),
2550
-
2551
2550
last_sent_closing_fee: None,
2552
2551
last_received_closing_sig: None,
2553
2552
pending_counterparty_closing_signed: None,
@@ -2720,6 +2719,13 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2720
2719
value_to_self_msat,
2721
2720
counterparty_selected_channel_reserve_satoshis: None, // Filled in in accept_channel
2722
2721
holder_selected_channel_reserve_satoshis,
2722
+
2723
+ // We'll add our counterparty's `funding_satoshis` to these max commitment output assertions
2724
+ // when we receive `accept_channel2`.
2725
+ #[cfg(debug_assertions)]
2726
+ holder_max_commitment_tx_output: Mutex::new((channel_value_satoshis * 1000 - push_msat, push_msat)),
2727
+ #[cfg(debug_assertions)]
2728
+ counterparty_max_commitment_tx_output: Mutex::new((channel_value_satoshis * 1000 - push_msat, push_msat)),
2723
2729
};
2724
2730
let channel_context = Self {
2725
2731
user_id,
@@ -2774,13 +2780,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2774
2780
signer_pending_closing: false,
2775
2781
signer_pending_channel_ready: false,
2776
2782
2777
- // We'll add our counterparty's `funding_satoshis` to these max commitment output assertions
2778
- // when we receive `accept_channel2`.
2779
- #[cfg(debug_assertions)]
2780
- holder_max_commitment_tx_output: Mutex::new((channel_value_satoshis * 1000 - push_msat, push_msat)),
2781
- #[cfg(debug_assertions)]
2782
- counterparty_max_commitment_tx_output: Mutex::new((channel_value_satoshis * 1000 - push_msat, push_msat)),
2783
-
2784
2783
last_sent_closing_fee: None,
2785
2784
last_received_closing_sig: None,
2786
2785
pending_counterparty_closing_signed: None,
@@ -3511,9 +3510,9 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3511
3510
// Make sure that the to_self/to_remote is always either past the appropriate
3512
3511
// channel_reserve *or* it is making progress towards it.
3513
3512
let mut broadcaster_max_commitment_tx_output = if generated_by_local {
3514
- self .holder_max_commitment_tx_output.lock().unwrap()
3513
+ funding .holder_max_commitment_tx_output.lock().unwrap()
3515
3514
} else {
3516
- self .counterparty_max_commitment_tx_output.lock().unwrap()
3515
+ funding .counterparty_max_commitment_tx_output.lock().unwrap()
3517
3516
};
3518
3517
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);
3519
3518
broadcaster_max_commitment_tx_output.0 = cmp::max(broadcaster_max_commitment_tx_output.0, value_to_self_msat as u64);
@@ -10409,6 +10408,11 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
10409
10408
value_to_self_msat,
10410
10409
counterparty_selected_channel_reserve_satoshis,
10411
10410
holder_selected_channel_reserve_satoshis: holder_selected_channel_reserve_satoshis.unwrap(),
10411
+
10412
+ #[cfg(debug_assertions)]
10413
+ holder_max_commitment_tx_output: Mutex::new((0, 0)),
10414
+ #[cfg(debug_assertions)]
10415
+ counterparty_max_commitment_tx_output: Mutex::new((0, 0)),
10412
10416
},
10413
10417
context: ChannelContext {
10414
10418
user_id,
@@ -10464,11 +10468,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
10464
10468
update_time_counter,
10465
10469
feerate_per_kw,
10466
10470
10467
- #[cfg(debug_assertions)]
10468
- holder_max_commitment_tx_output: Mutex::new((0, 0)),
10469
- #[cfg(debug_assertions)]
10470
- counterparty_max_commitment_tx_output: Mutex::new((0, 0)),
10471
-
10472
10471
last_sent_closing_fee: None,
10473
10472
last_received_closing_sig: None,
10474
10473
pending_counterparty_closing_signed: None,
0 commit comments