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