@@ -602,6 +602,29 @@ const CHECK_CLTV_EXPIRY_SANITY: u32 = MIN_CLTV_EXPIRY_DELTA as u32 - LATENCY_GRA
602
602
#[ allow( dead_code) ]
603
603
const CHECK_CLTV_EXPIRY_SANITY_2 : u32 = MIN_CLTV_EXPIRY_DELTA as u32 - LATENCY_GRACE_PERIOD_BLOCKS - 2 * CLTV_CLAIM_BUFFER ;
604
604
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 ChannelCounterpartyParameters {
609
+ /// The Features the channel counterparty provided upon last connection.
610
+ /// Useful for routing as it is the most up-to-date copy of the counterparty's features and
611
+ /// many routing-relevant features are present in the init context.
612
+ pub features : InitFeatures ,
613
+ /// The node_id of our counterparty
614
+ pub node_id : PublicKey ,
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
+
605
628
/// Details of a channel, as returned by ChannelManager::list_channels and ChannelManager::list_usable_channels
606
629
#[ derive( Clone , Debug , PartialEq ) ]
607
630
pub struct ChannelDetails {
@@ -610,6 +633,8 @@ pub struct ChannelDetails {
610
633
/// Note that this means this value is *not* persistent - it can change once during the
611
634
/// lifetime of the channel.
612
635
pub channel_id : [ u8 ; 32 ] ,
636
+ /// Parameters which apply to our counterparty. See individual fields for more information.
637
+ pub counterparty : ChannelCounterpartyParameters ,
613
638
/// The Channel's funding transaction output, if we've negotiated the funding transaction with
614
639
/// our counterparty already.
615
640
///
@@ -619,12 +644,6 @@ pub struct ChannelDetails {
619
644
/// The position of the funding transaction in the chain. None if the funding transaction has
620
645
/// not yet been confirmed and the channel fully opened.
621
646
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 ,
628
647
/// The value, in satoshis, of this channel as appears in the funding output
629
648
pub channel_value_satoshis : u64 ,
630
649
/// The value, in satoshis, that must always be held in the channel for us. This value ensures
@@ -636,15 +655,7 @@ pub struct ChannelDetails {
636
655
/// This value will be `None` for outbound channels until the counterparty accepts the channel.
637
656
///
638
657
/// [`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 > ,
648
659
/// The user_id passed in to create_channel, or 0 if the channel was inbound.
649
660
pub user_id : u64 ,
650
661
/// The available outbound capacity for sending HTLCs to the remote peer. This does not include
@@ -685,7 +696,7 @@ pub struct ChannelDetails {
685
696
/// time to claim our non-HTLC-encumbered funds.
686
697
///
687
698
/// 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 > ,
689
700
/// True if the channel was initiated (and thus funded) by us.
690
701
pub is_outbound : bool ,
691
702
/// True if the channel is confirmed, funding_locked messages have been exchanged, and the
@@ -703,9 +714,6 @@ pub struct ChannelDetails {
703
714
pub is_usable : bool ,
704
715
/// True if this channel is (or will be) publicly-announced.
705
716
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 > ,
709
717
}
710
718
711
719
/// If a payment fails to send, it can be in one of several states. This enum is returned as the
@@ -1170,30 +1178,32 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
1170
1178
channel. get_holder_counterparty_selected_channel_reserve_satoshis ( ) ;
1171
1179
res. push ( ChannelDetails {
1172
1180
channel_id : ( * channel_id) . clone ( ) ,
1181
+ counterparty : ChannelCounterpartyParameters {
1182
+ node_id : channel. get_counterparty_node_id ( ) ,
1183
+ features : InitFeatures :: empty ( ) ,
1184
+ unspendable_punishment_reserve : to_remote_reserve_satoshis,
1185
+ forwarding_info : channel. counterparty_forwarding_info ( ) ,
1186
+ } ,
1173
1187
funding_txo : channel. get_funding_txo ( ) ,
1174
1188
short_channel_id : channel. get_short_channel_id ( ) ,
1175
- remote_network_id : channel. get_counterparty_node_id ( ) ,
1176
- counterparty_features : InitFeatures :: empty ( ) ,
1177
1189
channel_value_satoshis : channel. get_value_satoshis ( ) ,
1178
- to_self_reserve_satoshis,
1179
- to_remote_reserve_satoshis,
1190
+ unspendable_punishment_reserve : to_self_reserve_satoshis,
1180
1191
inbound_capacity_msat,
1181
1192
outbound_capacity_msat,
1182
1193
user_id : channel. get_user_id ( ) ,
1183
1194
confirmations_required : channel. minimum_depth ( ) ,
1184
- spend_csv_on_our_commitment_funds : channel. get_counterparty_selected_contest_delay ( ) ,
1195
+ force_close_spend_delay : channel. get_counterparty_selected_contest_delay ( ) ,
1185
1196
is_outbound : channel. is_outbound ( ) ,
1186
1197
is_funding_locked : channel. is_usable ( ) ,
1187
1198
is_usable : channel. is_live ( ) ,
1188
1199
is_public : channel. should_announce ( ) ,
1189
- counterparty_forwarding_info : channel. counterparty_forwarding_info ( ) ,
1190
1200
} ) ;
1191
1201
}
1192
1202
}
1193
1203
let per_peer_state = self . per_peer_state . read ( ) . unwrap ( ) ;
1194
1204
for chan in res. iter_mut ( ) {
1195
- if let Some ( peer_state) = per_peer_state. get ( & chan. remote_network_id ) {
1196
- chan. counterparty_features = peer_state. lock ( ) . unwrap ( ) . latest_features . clone ( ) ;
1205
+ if let Some ( peer_state) = per_peer_state. get ( & chan. counterparty . node_id ) {
1206
+ chan. counterparty . features = peer_state. lock ( ) . unwrap ( ) . latest_features . clone ( ) ;
1197
1207
}
1198
1208
}
1199
1209
res
@@ -4286,7 +4296,7 @@ impl<Signer: Sign, M: Deref , T: Deref , K: Deref , F: Deref , L: Deref >
4286
4296
4287
4297
if msg. channel_id == [ 0 ; 32 ] {
4288
4298
for chan in self . list_channels ( ) {
4289
- if chan. remote_network_id == * counterparty_node_id {
4299
+ if chan. counterparty . node_id == * counterparty_node_id {
4290
4300
// Untrusted messages from peer, we throw away the error if id points to a non-existent channel
4291
4301
let _ = self . force_close_channel_with_peer ( & chan. channel_id , Some ( counterparty_node_id) ) ;
4292
4302
}
0 commit comments