@@ -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:: { KVStore , KVStoreSync , MonitorUpdatingPersisterAsync } ;
2729use lightning:: util:: ser:: { Readable , Writeable , Writer } ;
2830use lightning:: util:: sweep:: OutputSweeper ;
@@ -376,6 +378,56 @@ impl fmt::Display for UserChannelId {
376378 }
377379}
378380
381+ /// Information needed for constructing an invoice route hint for this channel.
382+ #[ cfg( feature = "uniffi" ) ]
383+ #[ uniffi:: remote( Record ) ]
384+ pub struct CounterpartyForwardingInfo {
385+ /// Base routing fee in millisatoshis.
386+ pub fee_base_msat : u32 ,
387+ /// Amount in millionths of a satoshi the channel will charge per transferred satoshi.
388+ pub fee_proportional_millionths : u32 ,
389+ /// The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart,
390+ /// such that the outgoing HTLC is forwardable to this counterparty.
391+ pub cltv_expiry_delta : u16 ,
392+ }
393+
394+ #[ cfg( feature = "uniffi" ) ]
395+ uniffi:: custom_type!( InitFeatures , Vec <u8 >, {
396+ remote,
397+ try_lift: |val| Ok ( InitFeatures :: from_le_bytes( val) ) ,
398+ lower: |obj| obj. le_flags( ) . to_vec( ) ,
399+ } ) ;
400+
401+ /// Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`]
402+ /// to better separate parameters.
403+ #[ derive( Clone , Debug , PartialEq ) ]
404+ #[ cfg_attr( feature = "uniffi" , derive( uniffi:: Record ) ) ]
405+ pub struct ChannelCounterparty {
406+ /// The node_id of our counterparty
407+ pub node_id : PublicKey ,
408+ /// The Features the channel counterparty provided upon last connection.
409+ /// Useful for routing as it is the most up-to-date copy of the counterparty's features and
410+ /// many routing-relevant features are present in the init context.
411+ pub features : InitFeatures ,
412+ /// The value, in satoshis, that must always be held in the channel for our counterparty. This
413+ /// value ensures that if our counterparty broadcasts a revoked state, we can punish them by
414+ /// claiming at least this value on chain.
415+ ///
416+ /// This value is not included in [`inbound_capacity_msat`] as it can never be spent.
417+ ///
418+ /// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
419+ pub unspendable_punishment_reserve : u64 ,
420+ /// Information on the fees and requirements that the counterparty requires when forwarding
421+ /// payments to us through this channel.
422+ pub forwarding_info : Option < CounterpartyForwardingInfo > ,
423+ /// The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field
424+ /// is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message
425+ /// from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107.
426+ pub outbound_htlc_minimum_msat : Option < u64 > ,
427+ /// The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
428+ pub outbound_htlc_maximum_msat : Option < u64 > ,
429+ }
430+
379431/// Details of a channel as returned by [`Node::list_channels`].
380432///
381433/// When a channel is spliced, most fields continue to refer to the original pre-splice channel
@@ -392,8 +444,8 @@ pub struct ChannelDetails {
392444 /// Note that this means this value is *not* persistent - it can change once during the
393445 /// lifetime of the channel.
394446 pub channel_id : ChannelId ,
395- /// The node ID of our the channel's counterparty .
396- pub counterparty_node_id : PublicKey ,
447+ /// Parameters which apply to our counterparty. See individual fields for more information .
448+ pub counterparty : ChannelCounterparty ,
397449 /// The channel's funding transaction output, if we've negotiated the funding transaction with
398450 /// our counterparty already.
399451 ///
@@ -509,28 +561,6 @@ pub struct ChannelDetails {
509561 /// The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
510562 /// the channel.
511563 pub cltv_expiry_delta : Option < u16 > ,
512- /// The value, in satoshis, that must always be held in the channel for our counterparty. This
513- /// value ensures that if our counterparty broadcasts a revoked state, we can punish them by
514- /// claiming at least this value on chain.
515- ///
516- /// This value is not included in [`inbound_capacity_msat`] as it can never be spent.
517- ///
518- /// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
519- pub counterparty_unspendable_punishment_reserve : u64 ,
520- /// The smallest value HTLC (in msat) the remote peer will accept, for this channel.
521- ///
522- /// This field is only `None` before we have received either the `OpenChannel` or
523- /// `AcceptChannel` message from the remote peer.
524- pub counterparty_outbound_htlc_minimum_msat : Option < u64 > ,
525- /// The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
526- pub counterparty_outbound_htlc_maximum_msat : Option < u64 > ,
527- /// Base routing fee in millisatoshis.
528- pub counterparty_forwarding_info_fee_base_msat : Option < u32 > ,
529- /// Proportional fee, in millionths of a satoshi the channel will charge per transferred satoshi.
530- pub counterparty_forwarding_info_fee_proportional_millionths : Option < u32 > ,
531- /// The minimum difference in CLTV expiry between an ingoing HTLC and its outgoing counterpart,
532- /// such that the outgoing HTLC is forwardable to this counterparty.
533- pub counterparty_forwarding_info_cltv_expiry_delta : Option < u16 > ,
534564 /// The available outbound capacity for sending a single HTLC to the remote peer. This is
535565 /// similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by
536566 /// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us
@@ -564,7 +594,14 @@ impl From<LdkChannelDetails> for ChannelDetails {
564594 fn from ( value : LdkChannelDetails ) -> Self {
565595 ChannelDetails {
566596 channel_id : value. channel_id ,
567- counterparty_node_id : value. counterparty . node_id ,
597+ counterparty : ChannelCounterparty {
598+ node_id : value. counterparty . node_id ,
599+ features : value. counterparty . features ,
600+ unspendable_punishment_reserve : value. counterparty . unspendable_punishment_reserve ,
601+ forwarding_info : value. counterparty . forwarding_info ,
602+ outbound_htlc_minimum_msat : value. counterparty . outbound_htlc_minimum_msat ,
603+ outbound_htlc_maximum_msat : value. counterparty . outbound_htlc_maximum_msat ,
604+ } ,
568605 funding_txo : value. funding_txo . map ( |o| o. into_bitcoin_outpoint ( ) ) ,
569606 funding_redeem_script : value. funding_redeem_script ,
570607 short_channel_id : value. short_channel_id ,
@@ -585,26 +622,6 @@ impl From<LdkChannelDetails> for ChannelDetails {
585622 is_usable : value. is_usable ,
586623 is_announced : value. is_announced ,
587624 cltv_expiry_delta : value. config . map ( |c| c. cltv_expiry_delta ) ,
588- counterparty_unspendable_punishment_reserve : value
589- . counterparty
590- . unspendable_punishment_reserve ,
591- counterparty_outbound_htlc_minimum_msat : value. counterparty . outbound_htlc_minimum_msat ,
592- counterparty_outbound_htlc_maximum_msat : value. counterparty . outbound_htlc_maximum_msat ,
593- counterparty_forwarding_info_fee_base_msat : value
594- . counterparty
595- . forwarding_info
596- . as_ref ( )
597- . map ( |f| f. fee_base_msat ) ,
598- counterparty_forwarding_info_fee_proportional_millionths : value
599- . counterparty
600- . forwarding_info
601- . as_ref ( )
602- . map ( |f| f. fee_proportional_millionths ) ,
603- counterparty_forwarding_info_cltv_expiry_delta : value
604- . counterparty
605- . forwarding_info
606- . as_ref ( )
607- . map ( |f| f. cltv_expiry_delta ) ,
608625 next_outbound_htlc_limit_msat : value. next_outbound_htlc_limit_msat ,
609626 next_outbound_htlc_minimum_msat : value. next_outbound_htlc_minimum_msat ,
610627 force_close_spend_delay : value. force_close_spend_delay ,
0 commit comments