@@ -40,7 +40,7 @@ use crate::events::{Event, EventHandler, EventsProvider, MessageSendEvent, Messa
40
40
// Since this struct is returned in `list_channels` methods, expose it here in case users want to
41
41
// construct one themselves.
42
42
use crate :: ln:: { inbound_payment, PaymentHash , PaymentPreimage , PaymentSecret } ;
43
- use crate :: ln:: channel:: { Channel , ChannelError , ChannelUpdateStatus , UpdateFulfillCommitFetch } ;
43
+ use crate :: ln:: channel:: { Channel , ChannelInterface , ChannelError , ChannelUpdateStatus , UpdateFulfillCommitFetch } ;
44
44
use crate :: ln:: features:: { ChannelFeatures , ChannelTypeFeatures , InitFeatures , NodeFeatures } ;
45
45
#[ cfg( any( feature = "_test_utils" , test) ) ]
46
46
use crate :: ln:: features:: InvoiceFeatures ;
@@ -1358,56 +1358,6 @@ impl ChannelDetails {
1358
1358
pub fn get_outbound_payment_scid ( & self ) -> Option < u64 > {
1359
1359
self . short_channel_id . or ( self . outbound_scid_alias )
1360
1360
}
1361
-
1362
- fn from_channel < Signer : WriteableEcdsaChannelSigner > ( channel : & Channel < Signer > ,
1363
- best_block_height : u32 , latest_features : InitFeatures ) -> Self {
1364
-
1365
- let balance = channel. get_available_balances ( ) ;
1366
- let ( to_remote_reserve_satoshis, to_self_reserve_satoshis) =
1367
- channel. get_holder_counterparty_selected_channel_reserve_satoshis ( ) ;
1368
- ChannelDetails {
1369
- channel_id : channel. channel_id ( ) ,
1370
- counterparty : ChannelCounterparty {
1371
- node_id : channel. get_counterparty_node_id ( ) ,
1372
- features : latest_features,
1373
- unspendable_punishment_reserve : to_remote_reserve_satoshis,
1374
- forwarding_info : channel. counterparty_forwarding_info ( ) ,
1375
- // Ensures that we have actually received the `htlc_minimum_msat` value
1376
- // from the counterparty through the `OpenChannel` or `AcceptChannel`
1377
- // message (as they are always the first message from the counterparty).
1378
- // Else `Channel::get_counterparty_htlc_minimum_msat` could return the
1379
- // default `0` value set by `Channel::new_outbound`.
1380
- outbound_htlc_minimum_msat : if channel. have_received_message ( ) {
1381
- Some ( channel. get_counterparty_htlc_minimum_msat ( ) ) } else { None } ,
1382
- outbound_htlc_maximum_msat : channel. get_counterparty_htlc_maximum_msat ( ) ,
1383
- } ,
1384
- funding_txo : channel. get_funding_txo ( ) ,
1385
- // Note that accept_channel (or open_channel) is always the first message, so
1386
- // `have_received_message` indicates that type negotiation has completed.
1387
- channel_type : if channel. have_received_message ( ) { Some ( channel. get_channel_type ( ) . clone ( ) ) } else { None } ,
1388
- short_channel_id : channel. get_short_channel_id ( ) ,
1389
- outbound_scid_alias : if channel. is_usable ( ) { Some ( channel. outbound_scid_alias ( ) ) } else { None } ,
1390
- inbound_scid_alias : channel. latest_inbound_scid_alias ( ) ,
1391
- channel_value_satoshis : channel. get_value_satoshis ( ) ,
1392
- feerate_sat_per_1000_weight : Some ( channel. get_feerate_sat_per_1000_weight ( ) ) ,
1393
- unspendable_punishment_reserve : to_self_reserve_satoshis,
1394
- balance_msat : balance. balance_msat ,
1395
- inbound_capacity_msat : balance. inbound_capacity_msat ,
1396
- outbound_capacity_msat : balance. outbound_capacity_msat ,
1397
- next_outbound_htlc_limit_msat : balance. next_outbound_htlc_limit_msat ,
1398
- user_channel_id : channel. get_user_id ( ) ,
1399
- confirmations_required : channel. minimum_depth ( ) ,
1400
- confirmations : Some ( channel. get_funding_tx_confirmations ( best_block_height) ) ,
1401
- force_close_spend_delay : channel. get_counterparty_selected_contest_delay ( ) ,
1402
- is_outbound : channel. is_outbound ( ) ,
1403
- is_channel_ready : channel. is_usable ( ) ,
1404
- is_usable : channel. is_live ( ) ,
1405
- is_public : channel. should_announce ( ) ,
1406
- inbound_htlc_minimum_msat : Some ( channel. get_holder_htlc_minimum_msat ( ) ) ,
1407
- inbound_htlc_maximum_msat : channel. get_holder_htlc_maximum_msat ( ) ,
1408
- config : Some ( channel. config ( ) ) ,
1409
- }
1410
- }
1411
1361
}
1412
1362
1413
1363
/// Used by [`ChannelManager::list_recent_payments`] to express the status of recent payments.
@@ -1974,8 +1924,7 @@ where
1974
1924
let mut peer_state_lock = peer_state_mutex. lock ( ) . unwrap ( ) ;
1975
1925
let peer_state = & mut * peer_state_lock;
1976
1926
for ( _channel_id, channel) in peer_state. channel_by_id . iter ( ) . filter ( f) {
1977
- let details = ChannelDetails :: from_channel ( channel, best_block_height,
1978
- peer_state. latest_features . clone ( ) ) ;
1927
+ let details = channel. get_channel_details ( best_block_height, peer_state. latest_features . clone ( ) ) ;
1979
1928
res. push ( details) ;
1980
1929
}
1981
1930
}
@@ -2014,7 +1963,7 @@ where
2014
1963
return peer_state. channel_by_id
2015
1964
. iter ( )
2016
1965
. map ( |( _, channel) |
2017
- ChannelDetails :: from_channel ( channel, best_block_height, features. clone ( ) ) )
1966
+ channel. get_channel_details ( best_block_height, features. clone ( ) ) )
2018
1967
. collect ( ) ;
2019
1968
}
2020
1969
vec ! [ ]
0 commit comments