You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expose counterparty forwarding info in ChannelDetails.
Useful for constructing route hints for private channels in invoices.
Co-authored-by: Valentine Wallace <[email protected]>
Co-authored-by: Antoine Riard <[email protected]>
let usable_channel_value_msat = (self.channel_value_satoshis - self.counterparty_selected_channel_reserve_satoshis)*1000;
4140
4146
if msg.contents.htlc_minimum_msat >= usable_channel_value_msat {
@@ -4759,7 +4765,7 @@ mod tests {
4759
4765
use ln::channel::{Channel,Sign,InboundHTLCOutput,OutboundHTLCOutput,InboundHTLCState,OutboundHTLCState,HTLCOutputInCommitment,HTLCCandidate,HTLCInitiator,TxCreationKeys};
4760
4766
use ln::channel::MAX_FUNDING_SATOSHIS;
4761
4767
use ln::features::InitFeatures;
4762
-
use ln::msgs::{OptionalField,DataLossProtect,DecodeError};
4768
+
use ln::msgs::{ChannelUpdate,DataLossProtect,DecodeError,OptionalField,UnsignedChannelUpdate};
4763
4769
use ln::chan_utils;
4764
4770
use ln::chan_utils::{ChannelPublicKeys,HolderCommitmentTransaction,CounterpartyChannelTransactionParameters,HTLC_SUCCESS_TX_WEIGHT,HTLC_TIMEOUT_TX_WEIGHT};
4765
4771
use chain::chaininterface::{FeeEstimator,ConfirmationTarget};
@@ -4770,6 +4776,7 @@ mod tests {
4770
4776
use util::test_utils;
4771
4777
use util::logger::Logger;
4772
4778
use bitcoin::secp256k1::{Secp256k1,Message,Signature,All};
4779
+
use bitcoin::secp256k1::ffi::SignatureasFFISignature;
4773
4780
use bitcoin::secp256k1::key::{SecretKey,PublicKey};
4774
4781
use bitcoin::hashes::sha256::HashasSha256;
4775
4782
use bitcoin::hashes::Hash;
@@ -5026,6 +5033,54 @@ mod tests {
5026
5033
}
5027
5034
}
5028
5035
5036
+
#[test]
5037
+
fnchannel_update(){
5038
+
let feeest = TestFeeEstimator{fee_est:15000};
5039
+
let secp_ctx = Secp256k1::new();
5040
+
let seed = [42;32];
5041
+
let network = Network::Testnet;
5042
+
let chain_hash = genesis_block(network).header.block_hash();
5043
+
let keys_provider = test_utils::TestKeysInterface::new(&seed, network);
5044
+
5045
+
// Create a channel.
5046
+
let node_b_node_id = PublicKey::from_secret_key(&secp_ctx,&SecretKey::from_slice(&[42;32]).unwrap());
Copy file name to clipboardExpand all lines: lightning/src/ln/channelmanager.rs
+8Lines changed: 8 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -39,6 +39,9 @@ use chain::Watch;
39
39
use chain::chaininterface::{BroadcasterInterface,FeeEstimator};
40
40
use chain::channelmonitor::{ChannelMonitor,ChannelMonitorUpdate,ChannelMonitorUpdateStep,ChannelMonitorUpdateErr,HTLC_FAIL_BACK_BUFFER,CLTV_CLAIM_BUFFER,LATENCY_GRACE_PERIOD_BLOCKS,ANTI_REORG_DELAY,MonitorEvent,CLOSED_CHANNEL_UPDATE_ID};
41
41
use chain::transaction::{OutPoint,TransactionData};
42
+
// Since this struct is returned in `list_channels` methods, expose it here in case users want to
43
+
// construct one themselves.
44
+
pubuse ln::channel::CounterpartyForwardingInfo;
42
45
use ln::channel::{Channel,ChannelError};
43
46
use ln::features::{InitFeatures,NodeFeatures};
44
47
use routing::router::{Route,RouteHop};
@@ -574,6 +577,10 @@ pub struct ChannelDetails {
574
577
/// True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
575
578
/// the peer is connected, and (c) no monitor update failure is pending resolution.
576
579
pubis_live:bool,
580
+
581
+
/// Information on the fees and requirements that the counterparty requires when forwarding
let route = get_route(&our_id,&net_graph_msg_handler.network_graph.read().unwrap(),&nodes[2],None,Some(&our_chans.iter().collect::<Vec<_>>()),&Vec::new(),100,42,Arc::clone(&logger)).unwrap();
1795
1797
assert_eq!(route.paths[0].len(),2);
@@ -1837,6 +1839,7 @@ mod tests {
1837
1839
outbound_capacity_msat:250_000_000,
1838
1840
inbound_capacity_msat:0,
1839
1841
is_live:true,
1842
+
counterparty_forwarding_info:None,
1840
1843
}];
1841
1844
let route = get_route(&our_id,&net_graph_msg_handler.network_graph.read().unwrap(),&nodes[2],None,Some(&our_chans.iter().collect::<Vec<_>>()),&Vec::new(),100,42,Arc::clone(&logger)).unwrap();
1842
1845
assert_eq!(route.paths[0].len(),2);
@@ -1901,6 +1904,7 @@ mod tests {
1901
1904
outbound_capacity_msat:250_000_000,
1902
1905
inbound_capacity_msat:0,
1903
1906
is_live:true,
1907
+
counterparty_forwarding_info:None,
1904
1908
}];
1905
1909
let route = get_route(&our_id,&net_graph_msg_handler.network_graph.read().unwrap(),&nodes[2],None,Some(&our_chans.iter().collect::<Vec<_>>()),&Vec::new(),100,42,Arc::clone(&logger)).unwrap();
1906
1910
assert_eq!(route.paths[0].len(),2);
@@ -2037,6 +2041,7 @@ mod tests {
2037
2041
outbound_capacity_msat:250_000_000,
2038
2042
inbound_capacity_msat:0,
2039
2043
is_live:true,
2044
+
counterparty_forwarding_info:None,
2040
2045
}];
2041
2046
letmut last_hops = last_hops(&nodes);
2042
2047
let route = get_route(&our_id,&net_graph_msg_handler.network_graph.read().unwrap(),&nodes[6],None,Some(&our_chans.iter().collect::<Vec<_>>()),&last_hops.iter().collect::<Vec<_>>(),100,42,Arc::clone(&logger)).unwrap();
@@ -2165,6 +2170,7 @@ mod tests {
2165
2170
outbound_capacity_msat:100000,
2166
2171
inbound_capacity_msat:100000,
2167
2172
is_live:true,
2173
+
counterparty_forwarding_info:None,
2168
2174
}];
2169
2175
let route = get_route(&source_node_id,&NetworkGraph::new(genesis_block(Network::Testnet).header.block_hash()),&target_node_id,None,Some(&our_chans.iter().collect::<Vec<_>>()),&last_hops.iter().collect::<Vec<_>>(),100,42,Arc::new(test_utils::TestLogger::new())).unwrap();
0 commit comments