@@ -16,13 +16,15 @@ use bitcoin_payment_instructions::onion_message_resolver::LDKOnionMessageDNSSECH
1616use lightning:: chain:: chainmonitor;
1717use lightning:: impl_writeable_tlv_based;
1818use lightning:: ln:: channel_state:: ChannelDetails as LdkChannelDetails ;
19+ pub use lightning:: ln:: channel_state:: CounterpartyForwardingInfo ;
1920use lightning:: ln:: msgs:: { RoutingMessageHandler , SocketAddress } ;
2021use lightning:: ln:: peer_handler:: IgnoringMessageHandler ;
2122use lightning:: ln:: types:: ChannelId ;
2223use lightning:: routing:: gossip;
2324use lightning:: routing:: router:: DefaultRouter ;
2425use lightning:: routing:: scoring:: { CombinedScorer , ProbabilisticScoringFeeParameters } ;
2526use lightning:: sign:: InMemorySigner ;
27+ use lightning:: types:: features:: InitFeatures ;
2628use lightning:: util:: persist:: {
2729 KVStore , KVStoreSync , MonitorUpdatingPersister , MonitorUpdatingPersisterAsync ,
2830} ;
@@ -346,6 +348,56 @@ impl fmt::Display for UserChannelId {
346348 }
347349}
348350
351+ /// Information needed for constructing an invoice route hint for this channel.
352+ #[ cfg( feature = "uniffi" ) ]
353+ #[ uniffi:: remote( Record ) ]
354+ pub struct CounterpartyForwardingInfo {
355+ /// Base routing fee in millisatoshis.
356+ pub fee_base_msat : u32 ,
357+ /// Amount in millionths of a satoshi the channel will charge per transferred satoshi.
358+ pub fee_proportional_millionths : u32 ,
359+ /// The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart,
360+ /// such that the outgoing HTLC is forwardable to this counterparty.
361+ pub cltv_expiry_delta : u16 ,
362+ }
363+
364+ #[ cfg( feature = "uniffi" ) ]
365+ uniffi:: custom_type!( InitFeatures , Vec <u8 >, {
366+ remote,
367+ try_lift: |val| Ok ( InitFeatures :: from_le_bytes( val) ) ,
368+ lower: |obj| obj. le_flags( ) . to_vec( ) ,
369+ } ) ;
370+
371+ /// Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`]
372+ /// to better separate parameters.
373+ #[ derive( Clone , Debug , PartialEq ) ]
374+ #[ cfg_attr( feature = "uniffi" , derive( uniffi:: Record ) ) ]
375+ pub struct ChannelCounterparty {
376+ /// The node_id of our counterparty
377+ pub node_id : PublicKey ,
378+ /// The Features the channel counterparty provided upon last connection.
379+ /// Useful for routing as it is the most up-to-date copy of the counterparty's features and
380+ /// many routing-relevant features are present in the init context.
381+ pub features : InitFeatures ,
382+ /// The value, in satoshis, that must always be held in the channel for our counterparty. This
383+ /// value ensures that if our counterparty broadcasts a revoked state, we can punish them by
384+ /// claiming at least this value on chain.
385+ ///
386+ /// This value is not included in [`inbound_capacity_msat`] as it can never be spent.
387+ ///
388+ /// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
389+ pub unspendable_punishment_reserve : u64 ,
390+ /// Information on the fees and requirements that the counterparty requires when forwarding
391+ /// payments to us through this channel.
392+ pub forwarding_info : Option < CounterpartyForwardingInfo > ,
393+ /// The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field
394+ /// is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message
395+ /// from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107.
396+ pub outbound_htlc_minimum_msat : Option < u64 > ,
397+ /// The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
398+ pub outbound_htlc_maximum_msat : Option < u64 > ,
399+ }
400+
349401/// Details of a channel as returned by [`Node::list_channels`].
350402///
351403/// When a channel is spliced, most fields continue to refer to the original pre-splice channel
@@ -362,8 +414,8 @@ pub struct ChannelDetails {
362414 /// Note that this means this value is *not* persistent - it can change once during the
363415 /// lifetime of the channel.
364416 pub channel_id : ChannelId ,
365- /// The node ID of our the channel's counterparty .
366- pub counterparty_node_id : PublicKey ,
417+ /// Parameters which apply to our counterparty. See individual fields for more information .
418+ pub counterparty : ChannelCounterparty ,
367419 /// The channel's funding transaction output, if we've negotiated the funding transaction with
368420 /// our counterparty already.
369421 ///
@@ -479,28 +531,6 @@ pub struct ChannelDetails {
479531 /// The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
480532 /// the channel.
481533 pub cltv_expiry_delta : Option < u16 > ,
482- /// The value, in satoshis, that must always be held in the channel for our counterparty. This
483- /// value ensures that if our counterparty broadcasts a revoked state, we can punish them by
484- /// claiming at least this value on chain.
485- ///
486- /// This value is not included in [`inbound_capacity_msat`] as it can never be spent.
487- ///
488- /// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
489- pub counterparty_unspendable_punishment_reserve : u64 ,
490- /// The smallest value HTLC (in msat) the remote peer will accept, for this channel.
491- ///
492- /// This field is only `None` before we have received either the `OpenChannel` or
493- /// `AcceptChannel` message from the remote peer.
494- pub counterparty_outbound_htlc_minimum_msat : Option < u64 > ,
495- /// The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
496- pub counterparty_outbound_htlc_maximum_msat : Option < u64 > ,
497- /// Base routing fee in millisatoshis.
498- pub counterparty_forwarding_info_fee_base_msat : Option < u32 > ,
499- /// Proportional fee, in millionths of a satoshi the channel will charge per transferred satoshi.
500- pub counterparty_forwarding_info_fee_proportional_millionths : Option < u32 > ,
501- /// The minimum difference in CLTV expiry between an ingoing HTLC and its outgoing counterpart,
502- /// such that the outgoing HTLC is forwardable to this counterparty.
503- pub counterparty_forwarding_info_cltv_expiry_delta : Option < u16 > ,
504534 /// The available outbound capacity for sending a single HTLC to the remote peer. This is
505535 /// similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by
506536 /// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us
@@ -534,7 +564,14 @@ impl From<LdkChannelDetails> for ChannelDetails {
534564 fn from ( value : LdkChannelDetails ) -> Self {
535565 ChannelDetails {
536566 channel_id : value. channel_id ,
537- counterparty_node_id : value. counterparty . node_id ,
567+ counterparty : ChannelCounterparty {
568+ node_id : value. counterparty . node_id ,
569+ features : value. counterparty . features ,
570+ unspendable_punishment_reserve : value. counterparty . unspendable_punishment_reserve ,
571+ forwarding_info : value. counterparty . forwarding_info ,
572+ outbound_htlc_minimum_msat : value. counterparty . outbound_htlc_minimum_msat ,
573+ outbound_htlc_maximum_msat : value. counterparty . outbound_htlc_maximum_msat ,
574+ } ,
538575 funding_txo : value. funding_txo . map ( |o| o. into_bitcoin_outpoint ( ) ) ,
539576 funding_redeem_script : value. funding_redeem_script ,
540577 short_channel_id : value. short_channel_id ,
@@ -555,26 +592,6 @@ impl From<LdkChannelDetails> for ChannelDetails {
555592 is_usable : value. is_usable ,
556593 is_announced : value. is_announced ,
557594 cltv_expiry_delta : value. config . map ( |c| c. cltv_expiry_delta ) ,
558- counterparty_unspendable_punishment_reserve : value
559- . counterparty
560- . unspendable_punishment_reserve ,
561- counterparty_outbound_htlc_minimum_msat : value. counterparty . outbound_htlc_minimum_msat ,
562- counterparty_outbound_htlc_maximum_msat : value. counterparty . outbound_htlc_maximum_msat ,
563- counterparty_forwarding_info_fee_base_msat : value
564- . counterparty
565- . forwarding_info
566- . as_ref ( )
567- . map ( |f| f. fee_base_msat ) ,
568- counterparty_forwarding_info_fee_proportional_millionths : value
569- . counterparty
570- . forwarding_info
571- . as_ref ( )
572- . map ( |f| f. fee_proportional_millionths ) ,
573- counterparty_forwarding_info_cltv_expiry_delta : value
574- . counterparty
575- . forwarding_info
576- . as_ref ( )
577- . map ( |f| f. cltv_expiry_delta ) ,
578595 next_outbound_htlc_limit_msat : value. next_outbound_htlc_limit_msat ,
579596 next_outbound_htlc_minimum_msat : value. next_outbound_htlc_minimum_msat ,
580597 force_close_spend_delay : value. force_close_spend_delay ,
0 commit comments