@@ -11,8 +11,9 @@ use lightning::routing::router::DefaultRouter;
11
11
use lightning:: routing:: scoring:: { ProbabilisticScorer , ProbabilisticScoringFeeParameters } ;
12
12
use lightning:: sign:: InMemorySigner ;
13
13
use lightning:: util:: ser:: { Hostname , Readable , Writeable , Writer } ;
14
- use lightning_net_tokio:: SocketDescriptor ;
15
- use lightning_transaction_sync:: EsploraSyncClient ;
14
+ use lightning:: util:: config:: ChannelConfig as LdkChannelConfig ;
15
+ use lightning:: util:: config:: MaxDustHTLCExposure as LdkMaxDustHTLCExposure ;
16
+ use lightning_net_tokio:: SocketDescriptor ; use lightning_transaction_sync:: EsploraSyncClient ;
16
17
17
18
use bitcoin:: secp256k1:: PublicKey ;
18
19
use bitcoin:: OutPoint ;
@@ -393,3 +394,68 @@ impl Readable for NetAddress {
393
394
Ok ( Self ( addr) )
394
395
}
395
396
}
397
+
398
+ /// Options which apply on a per-channel basis.
399
+ pub struct ChannelConfig {
400
+ /// See documentation of [`LdkChannelConfig::forwarding_fee_proportional_millionths`].
401
+ pub forwarding_fee_proportional_millionths : u32 ,
402
+ /// See documentation of [`LdkChannelConfig::forwarding_fee_base_msat`].
403
+ pub forwarding_fee_base_msat : u32 ,
404
+ /// See documentation of [`LdkChannelConfig::cltv_expiry_delta`].
405
+ pub cltv_expiry_delta : u16 ,
406
+ /// See documentation of [`LdkChannelConfig::max_dust_htlc_exposure`].
407
+ pub max_dust_htlc_exposure : Arc < MaxDustHTLCExposure > ,
408
+ /// See documentation of [`LdkChannelConfig::force_close_avoidance_max_fee_satoshis`].
409
+ pub force_close_avoidance_max_fee_satoshis : u64 ,
410
+ /// See documentation of [`LdkChannelConfig::accept_underpaying_htlcs`].
411
+ pub accept_underpaying_htlcs : bool ,
412
+ }
413
+
414
+ impl From < LdkChannelConfig > for ChannelConfig {
415
+ fn from ( value : LdkChannelConfig ) -> Self {
416
+ Self {
417
+ forwarding_fee_proportional_millionths : value. forwarding_fee_proportional_millionths ,
418
+ forwarding_fee_base_msat : value. forwarding_fee_base_msat ,
419
+ cltv_expiry_delta : value. cltv_expiry_delta ,
420
+ max_dust_htlc_exposure : Arc :: new ( MaxDustHTLCExposure ( value. max_dust_htlc_exposure ) ) ,
421
+ force_close_avoidance_max_fee_satoshis : value. force_close_avoidance_max_fee_satoshis ,
422
+ accept_underpaying_htlcs : value. accept_underpaying_htlcs ,
423
+ }
424
+ }
425
+ }
426
+
427
+ impl From < ChannelConfig > for LdkChannelConfig {
428
+ fn from ( value : ChannelConfig ) -> Self {
429
+ Self {
430
+ forwarding_fee_proportional_millionths : value. forwarding_fee_proportional_millionths ,
431
+ forwarding_fee_base_msat : value. forwarding_fee_base_msat ,
432
+ cltv_expiry_delta : value. cltv_expiry_delta ,
433
+ max_dust_htlc_exposure : value. max_dust_htlc_exposure . 0 . clone ( ) ,
434
+ force_close_avoidance_max_fee_satoshis : value. force_close_avoidance_max_fee_satoshis ,
435
+ accept_underpaying_htlcs : value. accept_underpaying_htlcs ,
436
+ }
437
+ }
438
+ }
439
+
440
+ impl Default for ChannelConfig {
441
+ fn default ( ) -> Self {
442
+ LdkChannelConfig :: default ( ) . into ( )
443
+ }
444
+ }
445
+
446
+ /// Options for how to set the max dust HTLC exposure allowed on a channel.
447
+ ///
448
+ /// See documentation of [`LdkMaxDustHTLCExposure`] for details.
449
+ pub struct MaxDustHTLCExposure ( pub LdkMaxDustHTLCExposure ) ;
450
+
451
+ impl MaxDustHTLCExposure {
452
+ /// See documentation of [`LdkMaxDustHTLCExposure::FixedLimitMsat`] for details.
453
+ pub fn from_fixed_limit ( limit_msat : u64 ) -> Self {
454
+ Self ( LdkMaxDustHTLCExposure :: FixedLimitMsat ( limit_msat) )
455
+ }
456
+
457
+ /// See documentation of [`LdkMaxDustHTLCExposure::FeeRateMultiplier`] for details.
458
+ pub fn from_fee_multiplier ( multiplier : u64 ) -> Self {
459
+ Self ( LdkMaxDustHTLCExposure :: FeeRateMultiplier ( multiplier) )
460
+ }
461
+ }
0 commit comments