@@ -1466,7 +1466,12 @@ impl<Signer: Sign> Channel<Signer> {
1466
1466
( $htlc: expr, $outbound: expr, $source: expr, $state_name: expr) => {
1467
1467
if $outbound == local { // "offered HTLC output"
1468
1468
let htlc_in_tx = get_htlc_in_commitment!( $htlc, true ) ;
1469
- if $htlc. amount_msat / 1000 >= broadcaster_dust_limit_satoshis + ( feerate_per_kw as u64 * htlc_timeout_tx_weight( self . opt_anchors( ) ) / 1000 ) {
1469
+ let htlc_tx_fee = if self . opt_anchors( ) {
1470
+ 0
1471
+ } else {
1472
+ feerate_per_kw as u64 * htlc_timeout_tx_weight( false ) / 1000
1473
+ } ;
1474
+ if $htlc. amount_msat / 1000 >= broadcaster_dust_limit_satoshis + htlc_tx_fee {
1470
1475
log_trace!( logger, " ...including {} {} HTLC {} (hash {}) with value {}" , if $outbound { "outbound" } else { "inbound" } , $state_name, $htlc. htlc_id, log_bytes!( $htlc. payment_hash. 0 ) , $htlc. amount_msat) ;
1471
1476
included_non_dust_htlcs. push( ( htlc_in_tx, $source) ) ;
1472
1477
} else {
@@ -1475,7 +1480,12 @@ impl<Signer: Sign> Channel<Signer> {
1475
1480
}
1476
1481
} else {
1477
1482
let htlc_in_tx = get_htlc_in_commitment!( $htlc, false ) ;
1478
- if $htlc. amount_msat / 1000 >= broadcaster_dust_limit_satoshis + ( feerate_per_kw as u64 * htlc_success_tx_weight( self . opt_anchors( ) ) / 1000 ) {
1483
+ let htlc_tx_fee = if self . opt_anchors( ) {
1484
+ 0
1485
+ } else {
1486
+ feerate_per_kw as u64 * htlc_success_tx_weight( false ) / 1000
1487
+ } ;
1488
+ if $htlc. amount_msat / 1000 >= broadcaster_dust_limit_satoshis + htlc_tx_fee {
1479
1489
log_trace!( logger, " ...including {} {} HTLC {} (hash {}) with value {}" , if $outbound { "outbound" } else { "inbound" } , $state_name, $htlc. htlc_id, log_bytes!( $htlc. payment_hash. 0 ) , $htlc. amount_msat) ;
1480
1490
included_non_dust_htlcs. push( ( htlc_in_tx, $source) ) ;
1481
1491
} else {
@@ -2396,8 +2406,15 @@ impl<Signer: Sign> Channel<Signer> {
2396
2406
on_holder_tx_holding_cell_htlcs_count : 0 ,
2397
2407
} ;
2398
2408
2399
- let counterparty_dust_limit_timeout_sat = ( self . get_dust_buffer_feerate ( outbound_feerate_update) as u64 * htlc_timeout_tx_weight ( self . opt_anchors ( ) ) / 1000 ) + self . counterparty_dust_limit_satoshis ;
2400
- let holder_dust_limit_success_sat = ( self . get_dust_buffer_feerate ( outbound_feerate_update) as u64 * htlc_success_tx_weight ( self . opt_anchors ( ) ) / 1000 ) + self . holder_dust_limit_satoshis ;
2409
+ let ( htlc_timeout_dust_limit, htlc_success_dust_limit) = if self . opt_anchors ( ) {
2410
+ ( 0 , 0 )
2411
+ } else {
2412
+ let dust_buffer_feerate = self . get_dust_buffer_feerate ( outbound_feerate_update) as u64 ;
2413
+ ( dust_buffer_feerate * htlc_timeout_tx_weight ( false ) / 1000 ,
2414
+ dust_buffer_feerate * htlc_success_tx_weight ( false ) / 1000 )
2415
+ } ;
2416
+ let counterparty_dust_limit_timeout_sat = htlc_timeout_dust_limit + self . counterparty_dust_limit_satoshis ;
2417
+ let holder_dust_limit_success_sat = htlc_success_dust_limit + self . holder_dust_limit_satoshis ;
2401
2418
for ref htlc in self . pending_inbound_htlcs . iter ( ) {
2402
2419
stats. pending_htlcs_value_msat += htlc. amount_msat ;
2403
2420
if htlc. amount_msat / 1000 < counterparty_dust_limit_timeout_sat {
@@ -2421,8 +2438,15 @@ impl<Signer: Sign> Channel<Signer> {
2421
2438
on_holder_tx_holding_cell_htlcs_count : 0 ,
2422
2439
} ;
2423
2440
2424
- let counterparty_dust_limit_success_sat = ( self . get_dust_buffer_feerate ( outbound_feerate_update) as u64 * htlc_success_tx_weight ( self . opt_anchors ( ) ) / 1000 ) + self . counterparty_dust_limit_satoshis ;
2425
- let holder_dust_limit_timeout_sat = ( self . get_dust_buffer_feerate ( outbound_feerate_update) as u64 * htlc_timeout_tx_weight ( self . opt_anchors ( ) ) / 1000 ) + self . holder_dust_limit_satoshis ;
2441
+ let ( htlc_timeout_dust_limit, htlc_success_dust_limit) = if self . opt_anchors ( ) {
2442
+ ( 0 , 0 )
2443
+ } else {
2444
+ let dust_buffer_feerate = self . get_dust_buffer_feerate ( outbound_feerate_update) as u64 ;
2445
+ ( dust_buffer_feerate * htlc_timeout_tx_weight ( false ) / 1000 ,
2446
+ dust_buffer_feerate * htlc_success_tx_weight ( false ) / 1000 )
2447
+ } ;
2448
+ let counterparty_dust_limit_success_sat = htlc_success_dust_limit + self . counterparty_dust_limit_satoshis ;
2449
+ let holder_dust_limit_timeout_sat = htlc_timeout_dust_limit + self . holder_dust_limit_satoshis ;
2426
2450
for ref htlc in self . pending_outbound_htlcs . iter ( ) {
2427
2451
stats. pending_htlcs_value_msat += htlc. amount_msat ;
2428
2452
if htlc. amount_msat / 1000 < counterparty_dust_limit_success_sat {
@@ -2512,8 +2536,14 @@ impl<Signer: Sign> Channel<Signer> {
2512
2536
fn next_local_commit_tx_fee_msat ( & self , htlc : HTLCCandidate , fee_spike_buffer_htlc : Option < ( ) > ) -> u64 {
2513
2537
assert ! ( self . is_outbound( ) ) ;
2514
2538
2515
- let real_dust_limit_success_sat = ( self . feerate_per_kw as u64 * htlc_success_tx_weight ( self . opt_anchors ( ) ) / 1000 ) + self . holder_dust_limit_satoshis ;
2516
- let real_dust_limit_timeout_sat = ( self . feerate_per_kw as u64 * htlc_timeout_tx_weight ( self . opt_anchors ( ) ) / 1000 ) + self . holder_dust_limit_satoshis ;
2539
+ let ( htlc_success_dust_limit, htlc_timeout_dust_limit) = if self . opt_anchors ( ) {
2540
+ ( 0 , 0 )
2541
+ } else {
2542
+ ( self . feerate_per_kw as u64 * htlc_success_tx_weight ( false ) / 1000 ,
2543
+ self . feerate_per_kw as u64 * htlc_timeout_tx_weight ( false ) / 1000 )
2544
+ } ;
2545
+ let real_dust_limit_success_sat = htlc_success_dust_limit + self . holder_dust_limit_satoshis ;
2546
+ let real_dust_limit_timeout_sat = htlc_timeout_dust_limit + self . holder_dust_limit_satoshis ;
2517
2547
2518
2548
let mut addl_htlcs = 0 ;
2519
2549
if fee_spike_buffer_htlc. is_some ( ) { addl_htlcs += 1 ; }
@@ -2603,8 +2633,14 @@ impl<Signer: Sign> Channel<Signer> {
2603
2633
fn next_remote_commit_tx_fee_msat ( & self , htlc : HTLCCandidate , fee_spike_buffer_htlc : Option < ( ) > ) -> u64 {
2604
2634
assert ! ( !self . is_outbound( ) ) ;
2605
2635
2606
- let real_dust_limit_success_sat = ( self . feerate_per_kw as u64 * htlc_success_tx_weight ( self . opt_anchors ( ) ) / 1000 ) + self . counterparty_dust_limit_satoshis ;
2607
- let real_dust_limit_timeout_sat = ( self . feerate_per_kw as u64 * htlc_timeout_tx_weight ( self . opt_anchors ( ) ) / 1000 ) + self . counterparty_dust_limit_satoshis ;
2636
+ let ( htlc_success_dust_limit, htlc_timeout_dust_limit) = if self . opt_anchors ( ) {
2637
+ ( 0 , 0 )
2638
+ } else {
2639
+ ( self . feerate_per_kw as u64 * htlc_success_tx_weight ( false ) / 1000 ,
2640
+ self . feerate_per_kw as u64 * htlc_timeout_tx_weight ( false ) / 1000 )
2641
+ } ;
2642
+ let real_dust_limit_success_sat = htlc_success_dust_limit + self . counterparty_dust_limit_satoshis ;
2643
+ let real_dust_limit_timeout_sat = htlc_timeout_dust_limit + self . counterparty_dust_limit_satoshis ;
2608
2644
2609
2645
let mut addl_htlcs = 0 ;
2610
2646
if fee_spike_buffer_htlc. is_some ( ) { addl_htlcs += 1 ; }
@@ -2727,7 +2763,14 @@ impl<Signer: Sign> Channel<Signer> {
2727
2763
}
2728
2764
}
2729
2765
2730
- let exposure_dust_limit_timeout_sats = ( self . get_dust_buffer_feerate ( None ) as u64 * htlc_timeout_tx_weight ( self . opt_anchors ( ) ) / 1000 ) + self . counterparty_dust_limit_satoshis ;
2766
+ let ( htlc_timeout_dust_limit, htlc_success_dust_limit) = if self . opt_anchors ( ) {
2767
+ ( 0 , 0 )
2768
+ } else {
2769
+ let dust_buffer_feerate = self . get_dust_buffer_feerate ( None ) as u64 ;
2770
+ ( dust_buffer_feerate * htlc_timeout_tx_weight ( false ) / 1000 ,
2771
+ dust_buffer_feerate * htlc_success_tx_weight ( false ) / 1000 )
2772
+ } ;
2773
+ let exposure_dust_limit_timeout_sats = htlc_timeout_dust_limit + self . counterparty_dust_limit_satoshis ;
2731
2774
if msg. amount_msat / 1000 < exposure_dust_limit_timeout_sats {
2732
2775
let on_counterparty_tx_dust_htlc_exposure_msat = inbound_stats. on_counterparty_tx_dust_exposure_msat + outbound_stats. on_counterparty_tx_dust_exposure_msat + msg. amount_msat ;
2733
2776
if on_counterparty_tx_dust_htlc_exposure_msat > self . get_max_dust_htlc_exposure_msat ( ) {
@@ -2737,7 +2780,7 @@ impl<Signer: Sign> Channel<Signer> {
2737
2780
}
2738
2781
}
2739
2782
2740
- let exposure_dust_limit_success_sats = ( self . get_dust_buffer_feerate ( None ) as u64 * htlc_success_tx_weight ( self . opt_anchors ( ) ) / 1000 ) + self . holder_dust_limit_satoshis ;
2783
+ let exposure_dust_limit_success_sats = htlc_success_dust_limit + self . holder_dust_limit_satoshis ;
2741
2784
if msg. amount_msat / 1000 < exposure_dust_limit_success_sats {
2742
2785
let on_holder_tx_dust_htlc_exposure_msat = inbound_stats. on_holder_tx_dust_exposure_msat + outbound_stats. on_holder_tx_dust_exposure_msat + msg. amount_msat ;
2743
2786
if on_holder_tx_dust_htlc_exposure_msat > self . get_max_dust_htlc_exposure_msat ( ) {
@@ -5444,7 +5487,14 @@ impl<Signer: Sign> Channel<Signer> {
5444
5487
}
5445
5488
}
5446
5489
5447
- let exposure_dust_limit_success_sats = ( self . get_dust_buffer_feerate ( None ) as u64 * htlc_success_tx_weight ( self . opt_anchors ( ) ) / 1000 ) + self . counterparty_dust_limit_satoshis ;
5490
+ let ( htlc_success_dust_limit, htlc_timeout_dust_limit) = if self . opt_anchors ( ) {
5491
+ ( 0 , 0 )
5492
+ } else {
5493
+ let dust_buffer_feerate = self . get_dust_buffer_feerate ( None ) as u64 ;
5494
+ ( dust_buffer_feerate * htlc_success_tx_weight ( false ) / 1000 ,
5495
+ dust_buffer_feerate * htlc_timeout_tx_weight ( false ) / 1000 )
5496
+ } ;
5497
+ let exposure_dust_limit_success_sats = htlc_success_dust_limit + self . counterparty_dust_limit_satoshis ;
5448
5498
if amount_msat / 1000 < exposure_dust_limit_success_sats {
5449
5499
let on_counterparty_dust_htlc_exposure_msat = inbound_stats. on_counterparty_tx_dust_exposure_msat + outbound_stats. on_counterparty_tx_dust_exposure_msat + amount_msat;
5450
5500
if on_counterparty_dust_htlc_exposure_msat > self . get_max_dust_htlc_exposure_msat ( ) {
@@ -5453,7 +5503,7 @@ impl<Signer: Sign> Channel<Signer> {
5453
5503
}
5454
5504
}
5455
5505
5456
- let exposure_dust_limit_timeout_sats = ( self . get_dust_buffer_feerate ( None ) as u64 * htlc_timeout_tx_weight ( self . opt_anchors ( ) ) / 1000 ) + self . holder_dust_limit_satoshis ;
5506
+ let exposure_dust_limit_timeout_sats = htlc_timeout_dust_limit + self . holder_dust_limit_satoshis ;
5457
5507
if amount_msat / 1000 < exposure_dust_limit_timeout_sats {
5458
5508
let on_holder_dust_htlc_exposure_msat = inbound_stats. on_holder_tx_dust_exposure_msat + outbound_stats. on_holder_tx_dust_exposure_msat + amount_msat;
5459
5509
if on_holder_dust_htlc_exposure_msat > self . get_max_dust_htlc_exposure_msat ( ) {
0 commit comments