@@ -1572,6 +1572,13 @@ pub(super) struct FundingScope {
1572
1572
pub(super) holder_selected_channel_reserve_satoshis: u64,
1573
1573
#[cfg(not(test))]
1574
1574
holder_selected_channel_reserve_satoshis: u64,
1575
+
1576
+ #[cfg(debug_assertions)]
1577
+ /// Max to_local and to_remote outputs in a locally-generated commitment transaction
1578
+ holder_max_commitment_tx_output: Mutex<(u64, u64)>,
1579
+ #[cfg(debug_assertions)]
1580
+ /// Max to_local and to_remote outputs in a remote-generated commitment transaction
1581
+ counterparty_max_commitment_tx_output: Mutex<(u64, u64)>,
1575
1582
}
1576
1583
1577
1584
impl FundingScope {
@@ -1719,13 +1726,6 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
1719
1726
/// time.
1720
1727
update_time_counter: u32,
1721
1728
1722
- #[cfg(debug_assertions)]
1723
- /// Max to_local and to_remote outputs in a locally-generated commitment transaction
1724
- holder_max_commitment_tx_output: Mutex<(u64, u64)>,
1725
- #[cfg(debug_assertions)]
1726
- /// Max to_local and to_remote outputs in a remote-generated commitment transaction
1727
- counterparty_max_commitment_tx_output: Mutex<(u64, u64)>,
1728
-
1729
1729
// (fee_sats, skip_remote_output, fee_range, holder_sig)
1730
1730
last_sent_closing_fee: Option<(u64, bool, ClosingSignedFeeRange, Option<Signature>)>,
1731
1731
last_received_closing_sig: Option<Signature>,
@@ -2465,6 +2465,11 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2465
2465
value_to_self_msat,
2466
2466
counterparty_selected_channel_reserve_satoshis: Some(msg_channel_reserve_satoshis),
2467
2467
holder_selected_channel_reserve_satoshis,
2468
+
2469
+ #[cfg(debug_assertions)]
2470
+ holder_max_commitment_tx_output: Mutex::new((value_to_self_msat, (channel_value_satoshis * 1000 - msg_push_msat).saturating_sub(value_to_self_msat))),
2471
+ #[cfg(debug_assertions)]
2472
+ counterparty_max_commitment_tx_output: Mutex::new((value_to_self_msat, (channel_value_satoshis * 1000 - msg_push_msat).saturating_sub(value_to_self_msat))),
2468
2473
};
2469
2474
let channel_context = ChannelContext {
2470
2475
user_id,
@@ -2521,12 +2526,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2521
2526
signer_pending_closing: false,
2522
2527
signer_pending_channel_ready: false,
2523
2528
2524
-
2525
- #[cfg(debug_assertions)]
2526
- holder_max_commitment_tx_output: Mutex::new((value_to_self_msat, (channel_value_satoshis * 1000 - msg_push_msat).saturating_sub(value_to_self_msat))),
2527
- #[cfg(debug_assertions)]
2528
- counterparty_max_commitment_tx_output: Mutex::new((value_to_self_msat, (channel_value_satoshis * 1000 - msg_push_msat).saturating_sub(value_to_self_msat))),
2529
-
2530
2529
last_sent_closing_fee: None,
2531
2530
last_received_closing_sig: None,
2532
2531
pending_counterparty_closing_signed: None,
@@ -2699,6 +2698,13 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2699
2698
value_to_self_msat,
2700
2699
counterparty_selected_channel_reserve_satoshis: None, // Filled in in accept_channel
2701
2700
holder_selected_channel_reserve_satoshis,
2701
+
2702
+ // We'll add our counterparty's `funding_satoshis` to these max commitment output assertions
2703
+ // when we receive `accept_channel2`.
2704
+ #[cfg(debug_assertions)]
2705
+ holder_max_commitment_tx_output: Mutex::new((channel_value_satoshis * 1000 - push_msat, push_msat)),
2706
+ #[cfg(debug_assertions)]
2707
+ counterparty_max_commitment_tx_output: Mutex::new((channel_value_satoshis * 1000 - push_msat, push_msat)),
2702
2708
};
2703
2709
let channel_context = Self {
2704
2710
user_id,
@@ -2753,13 +2759,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2753
2759
signer_pending_closing: false,
2754
2760
signer_pending_channel_ready: false,
2755
2761
2756
- // We'll add our counterparty's `funding_satoshis` to these max commitment output assertions
2757
- // when we receive `accept_channel2`.
2758
- #[cfg(debug_assertions)]
2759
- holder_max_commitment_tx_output: Mutex::new((channel_value_satoshis * 1000 - push_msat, push_msat)),
2760
- #[cfg(debug_assertions)]
2761
- counterparty_max_commitment_tx_output: Mutex::new((channel_value_satoshis * 1000 - push_msat, push_msat)),
2762
-
2763
2762
last_sent_closing_fee: None,
2764
2763
last_received_closing_sig: None,
2765
2764
pending_counterparty_closing_signed: None,
@@ -3490,9 +3489,9 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3490
3489
// Make sure that the to_self/to_remote is always either past the appropriate
3491
3490
// channel_reserve *or* it is making progress towards it.
3492
3491
let mut broadcaster_max_commitment_tx_output = if generated_by_local {
3493
- self .holder_max_commitment_tx_output.lock().unwrap()
3492
+ funding .holder_max_commitment_tx_output.lock().unwrap()
3494
3493
} else {
3495
- self .counterparty_max_commitment_tx_output.lock().unwrap()
3494
+ funding .counterparty_max_commitment_tx_output.lock().unwrap()
3496
3495
};
3497
3496
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);
3498
3497
broadcaster_max_commitment_tx_output.0 = cmp::max(broadcaster_max_commitment_tx_output.0, value_to_self_msat as u64);
@@ -10371,6 +10370,11 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
10371
10370
value_to_self_msat,
10372
10371
counterparty_selected_channel_reserve_satoshis,
10373
10372
holder_selected_channel_reserve_satoshis: holder_selected_channel_reserve_satoshis.unwrap(),
10373
+
10374
+ #[cfg(debug_assertions)]
10375
+ holder_max_commitment_tx_output: Mutex::new((0, 0)),
10376
+ #[cfg(debug_assertions)]
10377
+ counterparty_max_commitment_tx_output: Mutex::new((0, 0)),
10374
10378
},
10375
10379
context: ChannelContext {
10376
10380
user_id,
@@ -10426,11 +10430,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
10426
10430
update_time_counter,
10427
10431
feerate_per_kw,
10428
10432
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)),
10433
-
10434
10433
last_sent_closing_fee: None,
10435
10434
last_received_closing_sig: None,
10436
10435
pending_counterparty_closing_signed: None,
0 commit comments