@@ -602,6 +602,29 @@ const CHECK_CLTV_EXPIRY_SANITY: u32 = MIN_CLTV_EXPIRY_DELTA as u32 - LATENCY_GRA
602602#[ allow( dead_code) ]
603603const CHECK_CLTV_EXPIRY_SANITY_2 : u32 = MIN_CLTV_EXPIRY_DELTA as u32 - LATENCY_GRACE_PERIOD_BLOCKS - 2 * CLTV_CLAIM_BUFFER ;
604604
605+ /// Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`]
606+ /// to better separate parameters.
607+ #[ derive( Clone , Debug , PartialEq ) ]
608+ pub struct ChannelCounterparty {
609+ /// The node_id of our counterparty
610+ pub node_id : PublicKey ,
611+ /// The Features the channel counterparty provided upon last connection.
612+ /// Useful for routing as it is the most up-to-date copy of the counterparty's features and
613+ /// many routing-relevant features are present in the init context.
614+ pub features : InitFeatures ,
615+ /// The value, in satoshis, that must always be held in the channel for our counterparty. This
616+ /// value ensures that if our counterparty broadcasts a revoked state, we can punish them by
617+ /// claiming at least this value on chain.
618+ ///
619+ /// This value is not included in [`inbound_capacity_msat`] as it can never be spent.
620+ ///
621+ /// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
622+ pub unspendable_punishment_reserve : u64 ,
623+ /// Information on the fees and requirements that the counterparty requires when forwarding
624+ /// payments to us through this channel.
625+ pub forwarding_info : Option < CounterpartyForwardingInfo > ,
626+ }
627+
605628/// Details of a channel, as returned by ChannelManager::list_channels and ChannelManager::list_usable_channels
606629#[ derive( Clone , Debug , PartialEq ) ]
607630pub struct ChannelDetails {
@@ -610,6 +633,8 @@ pub struct ChannelDetails {
610633 /// Note that this means this value is *not* persistent - it can change once during the
611634 /// lifetime of the channel.
612635 pub channel_id : [ u8 ; 32 ] ,
636+ /// Parameters which apply to our counterparty. See individual fields for more information.
637+ pub counterparty : ChannelCounterparty ,
613638 /// The Channel's funding transaction output, if we've negotiated the funding transaction with
614639 /// our counterparty already.
615640 ///
@@ -619,12 +644,6 @@ pub struct ChannelDetails {
619644 /// The position of the funding transaction in the chain. None if the funding transaction has
620645 /// not yet been confirmed and the channel fully opened.
621646 pub short_channel_id : Option < u64 > ,
622- /// The node_id of our counterparty
623- pub remote_network_id : PublicKey ,
624- /// The Features the channel counterparty provided upon last connection.
625- /// Useful for routing as it is the most up-to-date copy of the counterparty's features and
626- /// many routing-relevant features are present in the init context.
627- pub counterparty_features : InitFeatures ,
628647 /// The value, in satoshis, of this channel as appears in the funding output
629648 pub channel_value_satoshis : u64 ,
630649 /// The value, in satoshis, that must always be held in the channel for us. This value ensures
@@ -636,15 +655,7 @@ pub struct ChannelDetails {
636655 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
637656 ///
638657 /// [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat
639- pub to_self_reserve_satoshis : Option < u64 > ,
640- /// The value, in satoshis, that must always be held in the channel for our counterparty. This
641- /// value ensures that if our counterparty broadcasts a revoked state, we can punish them by
642- /// claiming at least this value on chain.
643- ///
644- /// This value is not included in [`inbound_capacity_msat`] as it can never be spent.
645- ///
646- /// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
647- pub to_remote_reserve_satoshis : u64 ,
658+ pub unspendable_punishment_reserve : Option < u64 > ,
648659 /// The user_id passed in to create_channel, or 0 if the channel was inbound.
649660 pub user_id : u64 ,
650661 /// The available outbound capacity for sending HTLCs to the remote peer. This does not include
@@ -685,7 +696,7 @@ pub struct ChannelDetails {
685696 /// time to claim our non-HTLC-encumbered funds.
686697 ///
687698 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
688- pub spend_csv_on_our_commitment_funds : Option < u16 > ,
699+ pub force_close_spend_delay : Option < u16 > ,
689700 /// True if the channel was initiated (and thus funded) by us.
690701 pub is_outbound : bool ,
691702 /// True if the channel is confirmed, funding_locked messages have been exchanged, and the
@@ -703,9 +714,6 @@ pub struct ChannelDetails {
703714 pub is_usable : bool ,
704715 /// True if this channel is (or will be) publicly-announced.
705716 pub is_public : bool ,
706- /// Information on the fees and requirements that the counterparty requires when forwarding
707- /// payments to us through this channel.
708- pub counterparty_forwarding_info : Option < CounterpartyForwardingInfo > ,
709717}
710718
711719/// If a payment fails to send, it can be in one of several states. This enum is returned as the
@@ -1171,30 +1179,32 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
11711179 channel. get_holder_counterparty_selected_channel_reserve_satoshis ( ) ;
11721180 res. push ( ChannelDetails {
11731181 channel_id : ( * channel_id) . clone ( ) ,
1182+ counterparty : ChannelCounterparty {
1183+ node_id : channel. get_counterparty_node_id ( ) ,
1184+ features : InitFeatures :: empty ( ) ,
1185+ unspendable_punishment_reserve : to_remote_reserve_satoshis,
1186+ forwarding_info : channel. counterparty_forwarding_info ( ) ,
1187+ } ,
11741188 funding_txo : channel. get_funding_txo ( ) ,
11751189 short_channel_id : channel. get_short_channel_id ( ) ,
1176- remote_network_id : channel. get_counterparty_node_id ( ) ,
1177- counterparty_features : InitFeatures :: empty ( ) ,
11781190 channel_value_satoshis : channel. get_value_satoshis ( ) ,
1179- to_self_reserve_satoshis,
1180- to_remote_reserve_satoshis,
1191+ unspendable_punishment_reserve : to_self_reserve_satoshis,
11811192 inbound_capacity_msat,
11821193 outbound_capacity_msat,
11831194 user_id : channel. get_user_id ( ) ,
11841195 confirmations_required : channel. minimum_depth ( ) ,
1185- spend_csv_on_our_commitment_funds : channel. get_counterparty_selected_contest_delay ( ) ,
1196+ force_close_spend_delay : channel. get_counterparty_selected_contest_delay ( ) ,
11861197 is_outbound : channel. is_outbound ( ) ,
11871198 is_funding_locked : channel. is_usable ( ) ,
11881199 is_usable : channel. is_live ( ) ,
11891200 is_public : channel. should_announce ( ) ,
1190- counterparty_forwarding_info : channel. counterparty_forwarding_info ( ) ,
11911201 } ) ;
11921202 }
11931203 }
11941204 let per_peer_state = self . per_peer_state . read ( ) . unwrap ( ) ;
11951205 for chan in res. iter_mut ( ) {
1196- if let Some ( peer_state) = per_peer_state. get ( & chan. remote_network_id ) {
1197- chan. counterparty_features = peer_state. lock ( ) . unwrap ( ) . latest_features . clone ( ) ;
1206+ if let Some ( peer_state) = per_peer_state. get ( & chan. counterparty . node_id ) {
1207+ chan. counterparty . features = peer_state. lock ( ) . unwrap ( ) . latest_features . clone ( ) ;
11981208 }
11991209 }
12001210 res
@@ -4353,7 +4363,7 @@ impl<Signer: Sign, M: Deref , T: Deref , K: Deref , F: Deref , L: Deref >
43534363
43544364 if msg. channel_id == [ 0 ; 32 ] {
43554365 for chan in self . list_channels ( ) {
4356- if chan. remote_network_id == * counterparty_node_id {
4366+ if chan. counterparty . node_id == * counterparty_node_id {
43574367 // Untrusted messages from peer, we throw away the error if id points to a non-existent channel
43584368 let _ = self . force_close_channel_with_peer ( & chan. channel_id , Some ( counterparty_node_id) ) ;
43594369 }
0 commit comments