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;
4131
4137
if msg.contents.htlc_minimum_msat > usable_channel_value_msat {
@@ -4750,7 +4756,7 @@ mod tests {
4750
4756
use ln::channel::{Channel,Sign,InboundHTLCOutput,OutboundHTLCOutput,InboundHTLCState,OutboundHTLCState,HTLCOutputInCommitment,HTLCCandidate,HTLCInitiator,TxCreationKeys};
4751
4757
use ln::channel::MAX_FUNDING_SATOSHIS;
4752
4758
use ln::features::InitFeatures;
4753
-
use ln::msgs::{OptionalField,DataLossProtect,DecodeError};
4759
+
use ln::msgs::{ChannelUpdate,DataLossProtect,DecodeError,OptionalField,UnsignedChannelUpdate};
4754
4760
use ln::chan_utils;
4755
4761
use ln::chan_utils::{ChannelPublicKeys,HolderCommitmentTransaction,CounterpartyChannelTransactionParameters,HTLC_SUCCESS_TX_WEIGHT,HTLC_TIMEOUT_TX_WEIGHT};
4756
4762
use chain::chaininterface::{FeeEstimator,ConfirmationTarget};
@@ -4761,6 +4767,7 @@ mod tests {
4761
4767
use util::test_utils;
4762
4768
use util::logger::Logger;
4763
4769
use bitcoin::secp256k1::{Secp256k1,Message,Signature,All};
4770
+
use bitcoin::secp256k1::ffi::SignatureasFFISignature;
4764
4771
use bitcoin::secp256k1::key::{SecretKey,PublicKey};
4765
4772
use bitcoin::hashes::sha256::HashasSha256;
4766
4773
use bitcoin::hashes::Hash;
@@ -5017,6 +5024,55 @@ mod tests {
5017
5024
}
5018
5025
}
5019
5026
5027
+
#[test]
5028
+
fnchannel_update(){
5029
+
let feeest = TestFeeEstimator{fee_est:15000};
5030
+
let secp_ctx = Secp256k1::new();
5031
+
let seed = [42;32];
5032
+
let network = Network::Testnet;
5033
+
let chain_hash = genesis_block(network).header.block_hash();
5034
+
let keys_provider = test_utils::TestKeysInterface::new(&seed, network);
5035
+
5036
+
// Create a channel.
5037
+
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
+5-1Lines changed: 5 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ 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
-
use ln::channel::{Channel,ChannelError};
42
+
use ln::channel::{Channel,ChannelError,CounterpartyForwardingInfo};
43
43
use ln::features::{InitFeatures,NodeFeatures};
44
44
use routing::router::{Route,RouteHop};
45
45
use ln::msgs;
@@ -574,6 +574,9 @@ pub struct ChannelDetails {
574
574
/// True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
575
575
/// the peer is connected, and (c) no monitor update failure is pending resolution.
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