mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-24 15:02:20 +01:00
Merge pull request #1946 from wpaulino/init-features-user-config
Use UserConfig to determine advertised InitFeatures by ChannelManager
This commit is contained in:
commit
de783e0b95
25 changed files with 824 additions and 761 deletions
|
@ -38,7 +38,7 @@ use lightning::chain::transaction::OutPoint;
|
|||
use lightning::chain::chaininterface::{BroadcasterInterface, ConfirmationTarget, FeeEstimator};
|
||||
use lightning::chain::keysinterface::{KeyMaterial, InMemorySigner, Recipient, EntropySource, NodeSigner, SignerProvider};
|
||||
use lightning::ln::{PaymentHash, PaymentPreimage, PaymentSecret};
|
||||
use lightning::ln::channelmanager::{self, ChainParameters, ChannelDetails, ChannelManager, PaymentSendFailure, ChannelManagerReadArgs, PaymentId};
|
||||
use lightning::ln::channelmanager::{ChainParameters, ChannelDetails, ChannelManager, PaymentSendFailure, ChannelManagerReadArgs, PaymentId};
|
||||
use lightning::ln::channel::FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE;
|
||||
use lightning::ln::msgs::{self, CommitmentUpdate, ChannelMessageHandler, DecodeError, UpdateAddHTLC, Init};
|
||||
use lightning::ln::script::ShutdownScript;
|
||||
|
@ -351,9 +351,9 @@ fn send_payment(source: &ChanMan, dest: &ChanMan, dest_chan_id: u64, amt: u64, p
|
|||
if let Err(err) = source.send_payment(&Route {
|
||||
paths: vec![vec![RouteHop {
|
||||
pubkey: dest.get_our_node_id(),
|
||||
node_features: channelmanager::provided_node_features(),
|
||||
node_features: dest.node_features(),
|
||||
short_channel_id: dest_chan_id,
|
||||
channel_features: channelmanager::provided_channel_features(),
|
||||
channel_features: dest.channel_features(),
|
||||
fee_msat: amt,
|
||||
cltv_expiry_delta: 200,
|
||||
}]],
|
||||
|
@ -373,16 +373,16 @@ fn send_hop_payment(source: &ChanMan, middle: &ChanMan, middle_chan_id: u64, des
|
|||
if let Err(err) = source.send_payment(&Route {
|
||||
paths: vec![vec![RouteHop {
|
||||
pubkey: middle.get_our_node_id(),
|
||||
node_features: channelmanager::provided_node_features(),
|
||||
node_features: middle.node_features(),
|
||||
short_channel_id: middle_chan_id,
|
||||
channel_features: channelmanager::provided_channel_features(),
|
||||
channel_features: middle.channel_features(),
|
||||
fee_msat: 50000,
|
||||
cltv_expiry_delta: 100,
|
||||
},RouteHop {
|
||||
pubkey: dest.get_our_node_id(),
|
||||
node_features: channelmanager::provided_node_features(),
|
||||
node_features: dest.node_features(),
|
||||
short_channel_id: dest_chan_id,
|
||||
channel_features: channelmanager::provided_channel_features(),
|
||||
channel_features: dest.channel_features(),
|
||||
fee_msat: amt,
|
||||
cltv_expiry_delta: 200,
|
||||
}]],
|
||||
|
@ -470,8 +470,8 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
|
|||
let mut channel_txn = Vec::new();
|
||||
macro_rules! make_channel {
|
||||
($source: expr, $dest: expr, $chan_id: expr) => { {
|
||||
$source.peer_connected(&$dest.get_our_node_id(), &Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
$dest.peer_connected(&$source.get_our_node_id(), &Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
$source.peer_connected(&$dest.get_our_node_id(), &Init { features: $dest.init_features(), remote_network_address: None }).unwrap();
|
||||
$dest.peer_connected(&$source.get_our_node_id(), &Init { features: $source.init_features(), remote_network_address: None }).unwrap();
|
||||
|
||||
$source.create_channel($dest.get_our_node_id(), 100_000, 42, 0, None).unwrap();
|
||||
let open_channel = {
|
||||
|
@ -482,7 +482,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
|
|||
} else { panic!("Wrong event type"); }
|
||||
};
|
||||
|
||||
$dest.handle_open_channel(&$source.get_our_node_id(), channelmanager::provided_init_features(), &open_channel);
|
||||
$dest.handle_open_channel(&$source.get_our_node_id(), $source.init_features(), &open_channel);
|
||||
let accept_channel = {
|
||||
let events = $dest.get_and_clear_pending_msg_events();
|
||||
assert_eq!(events.len(), 1);
|
||||
|
@ -491,7 +491,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
|
|||
} else { panic!("Wrong event type"); }
|
||||
};
|
||||
|
||||
$source.handle_accept_channel(&$dest.get_our_node_id(), channelmanager::provided_init_features(), &accept_channel);
|
||||
$source.handle_accept_channel(&$dest.get_our_node_id(), $dest.init_features(), &accept_channel);
|
||||
let funding_output;
|
||||
{
|
||||
let events = $source.get_and_clear_pending_events();
|
||||
|
@ -990,15 +990,15 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
|
|||
},
|
||||
0x0e => {
|
||||
if chan_a_disconnected {
|
||||
nodes[0].peer_connected(&nodes[1].get_our_node_id(), &Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].peer_connected(&nodes[0].get_our_node_id(), &Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[0].peer_connected(&nodes[1].get_our_node_id(), &Init { features: nodes[1].init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].peer_connected(&nodes[0].get_our_node_id(), &Init { features: nodes[0].init_features(), remote_network_address: None }).unwrap();
|
||||
chan_a_disconnected = false;
|
||||
}
|
||||
},
|
||||
0x0f => {
|
||||
if chan_b_disconnected {
|
||||
nodes[1].peer_connected(&nodes[2].get_our_node_id(), &Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[2].peer_connected(&nodes[1].get_our_node_id(), &Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].peer_connected(&nodes[2].get_our_node_id(), &Init { features: nodes[2].init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[2].peer_connected(&nodes[1].get_our_node_id(), &Init { features: nodes[1].init_features(), remote_network_address: None }).unwrap();
|
||||
chan_b_disconnected = false;
|
||||
}
|
||||
},
|
||||
|
@ -1193,13 +1193,13 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
|
|||
|
||||
// Next, make sure peers are all connected to each other
|
||||
if chan_a_disconnected {
|
||||
nodes[0].peer_connected(&nodes[1].get_our_node_id(), &Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].peer_connected(&nodes[0].get_our_node_id(), &Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[0].peer_connected(&nodes[1].get_our_node_id(), &Init { features: nodes[1].init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].peer_connected(&nodes[0].get_our_node_id(), &Init { features: nodes[0].init_features(), remote_network_address: None }).unwrap();
|
||||
chan_a_disconnected = false;
|
||||
}
|
||||
if chan_b_disconnected {
|
||||
nodes[1].peer_connected(&nodes[2].get_our_node_id(), &Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[2].peer_connected(&nodes[1].get_our_node_id(), &Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].peer_connected(&nodes[2].get_our_node_id(), &Init { features: nodes[2].init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[2].peer_connected(&nodes[1].get_our_node_id(), &Init { features: nodes[1].init_features(), remote_network_address: None }).unwrap();
|
||||
chan_b_disconnected = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ use lightning::ln::msgs;
|
|||
use lightning::routing::gossip::{NetworkGraph, RoutingFees};
|
||||
use lightning::routing::router::{find_route, PaymentParameters, RouteHint, RouteHintHop, RouteParameters};
|
||||
use lightning::routing::scoring::FixedPenaltyScorer;
|
||||
use lightning::util::config::UserConfig;
|
||||
use lightning::util::ser::Readable;
|
||||
|
||||
use bitcoin::hashes::Hash;
|
||||
|
@ -210,7 +211,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
|
|||
channel_id: [0; 32],
|
||||
counterparty: ChannelCounterparty {
|
||||
node_id: *rnid,
|
||||
features: channelmanager::provided_init_features(),
|
||||
features: channelmanager::provided_init_features(&UserConfig::default()),
|
||||
unspendable_punishment_reserve: 0,
|
||||
forwarding_info: None,
|
||||
outbound_htlc_minimum_msat: None,
|
||||
|
|
|
@ -586,7 +586,7 @@ mod tests {
|
|||
use lightning::chain::keysinterface::{InMemorySigner, Recipient, EntropySource, KeysManager, NodeSigner};
|
||||
use lightning::chain::transaction::OutPoint;
|
||||
use lightning::get_event_msg;
|
||||
use lightning::ln::channelmanager::{self, BREAKDOWN_TIMEOUT, ChainParameters, ChannelManager, SimpleArcChannelManager};
|
||||
use lightning::ln::channelmanager::{BREAKDOWN_TIMEOUT, ChainParameters, ChannelManager, SimpleArcChannelManager};
|
||||
use lightning::ln::features::ChannelFeatures;
|
||||
use lightning::ln::msgs::{ChannelMessageHandler, Init};
|
||||
use lightning::ln::peer_handler::{PeerManager, MessageHandler, SocketDescriptor, IgnoringMessageHandler};
|
||||
|
@ -761,8 +761,8 @@ mod tests {
|
|||
|
||||
for i in 0..num_nodes {
|
||||
for j in (i+1)..num_nodes {
|
||||
nodes[i].node.peer_connected(&nodes[j].node.get_our_node_id(), &Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[j].node.peer_connected(&nodes[i].node.get_our_node_id(), &Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[i].node.peer_connected(&nodes[j].node.get_our_node_id(), &Init { features: nodes[j].node.init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[j].node.peer_connected(&nodes[i].node.get_our_node_id(), &Init { features: nodes[i].node.init_features(), remote_network_address: None }).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -783,8 +783,8 @@ mod tests {
|
|||
macro_rules! begin_open_channel {
|
||||
($node_a: expr, $node_b: expr, $channel_value: expr) => {{
|
||||
$node_a.node.create_channel($node_b.node.get_our_node_id(), $channel_value, 100, 42, None).unwrap();
|
||||
$node_b.node.handle_open_channel(&$node_a.node.get_our_node_id(), channelmanager::provided_init_features(), &get_event_msg!($node_a, MessageSendEvent::SendOpenChannel, $node_b.node.get_our_node_id()));
|
||||
$node_a.node.handle_accept_channel(&$node_b.node.get_our_node_id(), channelmanager::provided_init_features(), &get_event_msg!($node_b, MessageSendEvent::SendAcceptChannel, $node_a.node.get_our_node_id()));
|
||||
$node_b.node.handle_open_channel(&$node_a.node.get_our_node_id(), $node_a.node.init_features(), &get_event_msg!($node_a, MessageSendEvent::SendOpenChannel, $node_b.node.get_our_node_id()));
|
||||
$node_a.node.handle_accept_channel(&$node_b.node.get_our_node_id(), $node_b.node.init_features(), &get_event_msg!($node_b, MessageSendEvent::SendAcceptChannel, $node_a.node.get_our_node_id()));
|
||||
}}
|
||||
}
|
||||
|
||||
|
|
|
@ -734,7 +734,6 @@ mod tests {
|
|||
use crate::utils::create_invoice_from_channelmanager_and_duration_since_epoch;
|
||||
use bitcoin_hashes::sha256::Hash as Sha256;
|
||||
use lightning::ln::PaymentPreimage;
|
||||
use lightning::ln::channelmanager;
|
||||
use lightning::ln::features::{ChannelFeatures, NodeFeatures};
|
||||
use lightning::ln::functional_test_utils::*;
|
||||
use lightning::ln::msgs::{ChannelMessageHandler, ErrorAction, LightningError};
|
||||
|
@ -2046,24 +2045,24 @@ mod tests {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None, None]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 0);
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 0);
|
||||
let chans = nodes[0].node.list_usable_channels();
|
||||
let mut route = Route {
|
||||
paths: vec![
|
||||
vec![RouteHop {
|
||||
pubkey: nodes[1].node.get_our_node_id(),
|
||||
node_features: channelmanager::provided_node_features(),
|
||||
node_features: nodes[1].node.node_features(),
|
||||
short_channel_id: chans[0].short_channel_id.unwrap(),
|
||||
channel_features: channelmanager::provided_channel_features(),
|
||||
channel_features: nodes[1].node.channel_features(),
|
||||
fee_msat: 10_000,
|
||||
cltv_expiry_delta: 100,
|
||||
}],
|
||||
vec![RouteHop {
|
||||
pubkey: nodes[1].node.get_our_node_id(),
|
||||
node_features: channelmanager::provided_node_features(),
|
||||
node_features: nodes[1].node.node_features(),
|
||||
short_channel_id: chans[1].short_channel_id.unwrap(),
|
||||
channel_features: channelmanager::provided_channel_features(),
|
||||
channel_features: nodes[1].node.channel_features(),
|
||||
fee_msat: 100_000_001, // Our default max-HTLC-value is 10% of the channel value, which this is one more than
|
||||
cltv_expiry_delta: 100,
|
||||
}],
|
||||
|
@ -2097,16 +2096,16 @@ mod tests {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None, None]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 0);
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 0);
|
||||
let chans = nodes[0].node.list_usable_channels();
|
||||
let mut route = Route {
|
||||
paths: vec![
|
||||
vec![RouteHop {
|
||||
pubkey: nodes[1].node.get_our_node_id(),
|
||||
node_features: channelmanager::provided_node_features(),
|
||||
node_features: nodes[1].node.node_features(),
|
||||
short_channel_id: chans[0].short_channel_id.unwrap(),
|
||||
channel_features: channelmanager::provided_channel_features(),
|
||||
channel_features: nodes[1].node.channel_features(),
|
||||
fee_msat: 100_000_001, // Our default max-HTLC-value is 10% of the channel value, which this is one more than
|
||||
cltv_expiry_delta: 100,
|
||||
}],
|
||||
|
@ -2155,38 +2154,38 @@ mod tests {
|
|||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan_1_scid = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 10_000_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features()).0.contents.short_channel_id;
|
||||
let chan_2_scid = create_announced_chan_between_nodes_with_value(&nodes, 1, 2, 10_000_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features()).0.contents.short_channel_id;
|
||||
let chan_1_scid = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 10_000_000, 0).0.contents.short_channel_id;
|
||||
let chan_2_scid = create_announced_chan_between_nodes_with_value(&nodes, 1, 2, 10_000_000, 0).0.contents.short_channel_id;
|
||||
|
||||
let mut route = Route {
|
||||
paths: vec![
|
||||
vec![RouteHop {
|
||||
pubkey: nodes[1].node.get_our_node_id(),
|
||||
node_features: channelmanager::provided_node_features(),
|
||||
node_features: nodes[1].node.node_features(),
|
||||
short_channel_id: chan_1_scid,
|
||||
channel_features: channelmanager::provided_channel_features(),
|
||||
channel_features: nodes[1].node.channel_features(),
|
||||
fee_msat: 0,
|
||||
cltv_expiry_delta: 100,
|
||||
}, RouteHop {
|
||||
pubkey: nodes[2].node.get_our_node_id(),
|
||||
node_features: channelmanager::provided_node_features(),
|
||||
node_features: nodes[2].node.node_features(),
|
||||
short_channel_id: chan_2_scid,
|
||||
channel_features: channelmanager::provided_channel_features(),
|
||||
channel_features: nodes[2].node.channel_features(),
|
||||
fee_msat: 100_000_000,
|
||||
cltv_expiry_delta: 100,
|
||||
}],
|
||||
vec![RouteHop {
|
||||
pubkey: nodes[1].node.get_our_node_id(),
|
||||
node_features: channelmanager::provided_node_features(),
|
||||
node_features: nodes[1].node.node_features(),
|
||||
short_channel_id: chan_1_scid,
|
||||
channel_features: channelmanager::provided_channel_features(),
|
||||
channel_features: nodes[2].node.channel_features(),
|
||||
fee_msat: 0,
|
||||
cltv_expiry_delta: 100,
|
||||
}, RouteHop {
|
||||
pubkey: nodes[2].node.get_our_node_id(),
|
||||
node_features: channelmanager::provided_node_features(),
|
||||
node_features: nodes[2].node.node_features(),
|
||||
short_channel_id: chan_2_scid,
|
||||
channel_features: channelmanager::provided_channel_features(),
|
||||
channel_features: nodes[2].node.channel_features(),
|
||||
fee_msat: 100_000_000,
|
||||
cltv_expiry_delta: 100,
|
||||
}]
|
||||
|
|
|
@ -642,7 +642,7 @@ mod test {
|
|||
use bitcoin_hashes::sha256::Hash as Sha256;
|
||||
use lightning::chain::keysinterface::{EntropySource, PhantomKeysManager};
|
||||
use lightning::ln::{PaymentPreimage, PaymentHash};
|
||||
use lightning::ln::channelmanager::{self, PhantomRouteHints, MIN_FINAL_CLTV_EXPIRY, PaymentId};
|
||||
use lightning::ln::channelmanager::{PhantomRouteHints, MIN_FINAL_CLTV_EXPIRY, PaymentId};
|
||||
use lightning::ln::functional_test_utils::*;
|
||||
use lightning::ln::msgs::ChannelMessageHandler;
|
||||
use lightning::routing::router::{PaymentParameters, RouteParameters, find_route};
|
||||
|
@ -658,7 +658,7 @@ mod test {
|
|||
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
create_unannounced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_unannounced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 10001);
|
||||
let non_default_invoice_expiry_secs = 4200;
|
||||
let invoice = create_invoice_from_channelmanager_and_duration_since_epoch(
|
||||
&nodes[1].node, nodes[1].keys_manager, nodes[1].logger, Currency::BitcoinTestnet,
|
||||
|
@ -760,8 +760,8 @@ mod test {
|
|||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan_1_0 = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 0, 100000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_2_0 = create_unannounced_chan_between_nodes_with_value(&nodes, 2, 0, 100000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_1_0 = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 0, 100000, 10001);
|
||||
let chan_2_0 = create_unannounced_chan_between_nodes_with_value(&nodes, 2, 0, 100000, 10001);
|
||||
|
||||
let mut scid_aliases = HashSet::new();
|
||||
scid_aliases.insert(chan_1_0.0.short_channel_id_alias.unwrap());
|
||||
|
@ -776,9 +776,9 @@ mod test {
|
|||
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
let _chan_1_0_low_inbound_capacity = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 0, 100_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_1_0_high_inbound_capacity = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 0, 10_000_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let _chan_1_0_medium_inbound_capacity = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 0, 1_000_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let _chan_1_0_low_inbound_capacity = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 0, 100_000, 0);
|
||||
let chan_1_0_high_inbound_capacity = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 0, 10_000_000, 0);
|
||||
let _chan_1_0_medium_inbound_capacity = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 0, 1_000_000, 0);
|
||||
let mut scid_aliases = HashSet::new();
|
||||
scid_aliases.insert(chan_1_0_high_inbound_capacity.0.short_channel_id_alias.unwrap());
|
||||
match_invoice_routes(Some(5000), &nodes[0], scid_aliases);
|
||||
|
@ -790,9 +790,9 @@ mod test {
|
|||
let node_cfgs = create_node_cfgs(4, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(4, &node_cfgs, &[None, None, None, None]);
|
||||
let nodes = create_network(4, &node_cfgs, &node_chanmgrs);
|
||||
let chan_a = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 0, 10_000_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_b = create_unannounced_chan_between_nodes_with_value(&nodes, 2, 0, 10_000_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let _chan_c = create_unannounced_chan_between_nodes_with_value(&nodes, 3, 0, 1_000_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_a = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 0, 10_000_000, 0);
|
||||
let chan_b = create_unannounced_chan_between_nodes_with_value(&nodes, 2, 0, 10_000_000, 0);
|
||||
let _chan_c = create_unannounced_chan_between_nodes_with_value(&nodes, 3, 0, 1_000_000, 0);
|
||||
|
||||
// With all peers connected we should get all hints that have sufficient value
|
||||
let mut scid_aliases = HashSet::new();
|
||||
|
@ -819,7 +819,7 @@ mod test {
|
|||
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
let chan_1_0 = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 0, 100000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_1_0 = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 0, 100000, 10001);
|
||||
|
||||
// Create an unannonced channel between `nodes[2]` and `nodes[0]`, for which the
|
||||
// `msgs::ChannelUpdate` is never handled for the node(s). As the `msgs::ChannelUpdate`
|
||||
|
@ -828,9 +828,9 @@ mod test {
|
|||
private_chan_cfg.channel_handshake_config.announced_channel = false;
|
||||
let temporary_channel_id = nodes[2].node.create_channel(nodes[0].node.get_our_node_id(), 1_000_000, 500_000_000, 42, Some(private_chan_cfg)).unwrap();
|
||||
let open_channel = get_event_msg!(nodes[2], MessageSendEvent::SendOpenChannel, nodes[0].node.get_our_node_id());
|
||||
nodes[0].node.handle_open_channel(&nodes[2].node.get_our_node_id(), channelmanager::provided_init_features(), &open_channel);
|
||||
nodes[0].node.handle_open_channel(&nodes[2].node.get_our_node_id(), nodes[2].node.init_features(), &open_channel);
|
||||
let accept_channel = get_event_msg!(nodes[0], MessageSendEvent::SendAcceptChannel, nodes[2].node.get_our_node_id());
|
||||
nodes[2].node.handle_accept_channel(&nodes[0].node.get_our_node_id(), channelmanager::provided_init_features(), &accept_channel);
|
||||
nodes[2].node.handle_accept_channel(&nodes[0].node.get_our_node_id(), nodes[0].node.init_features(), &accept_channel);
|
||||
|
||||
let tx = sign_funding_transaction(&nodes[2], &nodes[0], 1_000_000, temporary_channel_id);
|
||||
|
||||
|
@ -861,9 +861,9 @@ mod test {
|
|||
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
let _chan_1_0 = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 0, 100000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let _chan_1_0 = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 0, 100000, 10001);
|
||||
|
||||
let chan_2_0 = create_announced_chan_between_nodes_with_value(&nodes, 2, 0, 100000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_2_0 = create_announced_chan_between_nodes_with_value(&nodes, 2, 0, 100000, 10001);
|
||||
nodes[2].node.handle_channel_update(&nodes[0].node.get_our_node_id(), &chan_2_0.1);
|
||||
nodes[0].node.handle_channel_update(&nodes[2].node.get_our_node_id(), &chan_2_0.0);
|
||||
|
||||
|
@ -879,11 +879,11 @@ mod test {
|
|||
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
let chan_1_0 = create_announced_chan_between_nodes_with_value(&nodes, 1, 0, 100000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_1_0 = create_announced_chan_between_nodes_with_value(&nodes, 1, 0, 100000, 10001);
|
||||
nodes[0].node.handle_channel_update(&nodes[1].node.get_our_node_id(), &chan_1_0.0);
|
||||
nodes[1].node.handle_channel_update(&nodes[0].node.get_our_node_id(), &chan_1_0.1);
|
||||
|
||||
let chan_2_0 = create_announced_chan_between_nodes_with_value(&nodes, 2, 0, 100000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_2_0 = create_announced_chan_between_nodes_with_value(&nodes, 2, 0, 100000, 10001);
|
||||
nodes[2].node.handle_channel_update(&nodes[0].node.get_our_node_id(), &chan_2_0.1);
|
||||
nodes[0].node.handle_channel_update(&nodes[2].node.get_our_node_id(), &chan_2_0.0);
|
||||
|
||||
|
@ -897,8 +897,8 @@ mod test {
|
|||
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
let chan_1_0 = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 0, 100_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_2_0 = create_unannounced_chan_between_nodes_with_value(&nodes, 2, 0, 1_000_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_1_0 = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 0, 100_000, 0);
|
||||
let chan_2_0 = create_unannounced_chan_between_nodes_with_value(&nodes, 2, 0, 1_000_000, 0);
|
||||
|
||||
// As the invoice amt is 1 msat above chan_1_0's inbound capacity, it shouldn't be included
|
||||
let mut scid_aliases_99_000_001_msat = HashSet::new();
|
||||
|
@ -964,10 +964,10 @@ mod test {
|
|||
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
let chan_0_1 = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_0_1 = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 10001);
|
||||
nodes[0].node.handle_channel_update(&nodes[1].node.get_our_node_id(), &chan_0_1.1);
|
||||
nodes[1].node.handle_channel_update(&nodes[0].node.get_our_node_id(), &chan_0_1.0);
|
||||
let chan_0_2 = create_announced_chan_between_nodes_with_value(&nodes, 0, 2, 100000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_0_2 = create_announced_chan_between_nodes_with_value(&nodes, 0, 2, 100000, 10001);
|
||||
nodes[0].node.handle_channel_update(&nodes[2].node.get_our_node_id(), &chan_0_2.1);
|
||||
nodes[2].node.handle_channel_update(&nodes[0].node.get_our_node_id(), &chan_0_2.0);
|
||||
|
||||
|
@ -1085,8 +1085,8 @@ mod test {
|
|||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
create_unannounced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_unannounced_chan_between_nodes_with_value(&nodes, 0, 2, 100000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_unannounced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 10001);
|
||||
create_unannounced_chan_between_nodes_with_value(&nodes, 0, 2, 100000, 10001);
|
||||
|
||||
let payment_amt = 20_000;
|
||||
let (payment_hash, _payment_secret) = nodes[1].node.create_inbound_payment(Some(payment_amt), 3600).unwrap();
|
||||
|
@ -1148,8 +1148,8 @@ mod test {
|
|||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan_0_1 = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_0_2 = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 2, 100000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_0_1 = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 10001);
|
||||
let chan_0_2 = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 2, 100000, 10001);
|
||||
|
||||
let mut scid_aliases = HashSet::new();
|
||||
scid_aliases.insert(chan_0_1.0.short_channel_id_alias.unwrap());
|
||||
|
@ -1177,9 +1177,9 @@ mod test {
|
|||
let node_chanmgrs = create_node_chanmgrs(4, &node_cfgs, &[None, None, None, None]);
|
||||
let nodes = create_network(4, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan_0_2 = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 2, 100000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_0_3 = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 3, 1000000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_1_3 = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 3, 3_000_000, 10005, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_0_2 = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 2, 100000, 10001);
|
||||
let chan_0_3 = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 3, 1000000, 10001);
|
||||
let chan_1_3 = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 3, 3_000_000, 10005);
|
||||
|
||||
let mut scid_aliases = HashSet::new();
|
||||
scid_aliases.insert(chan_0_2.0.short_channel_id_alias.unwrap());
|
||||
|
@ -1208,8 +1208,8 @@ mod test {
|
|||
let node_chanmgrs = create_node_chanmgrs(4, &node_cfgs, &[None, None, None, None]);
|
||||
let nodes = create_network(4, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan_0_2 = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 2, 100000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_0_3 = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 3, 1000000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_0_2 = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 2, 100000, 10001);
|
||||
let chan_0_3 = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 3, 1000000, 10001);
|
||||
|
||||
// Create an unannonced channel between `nodes[1]` and `nodes[3]`, for which the
|
||||
// `msgs::ChannelUpdate` is never handled for the node(s). As the `msgs::ChannelUpdate`
|
||||
|
@ -1218,9 +1218,9 @@ mod test {
|
|||
private_chan_cfg.channel_handshake_config.announced_channel = false;
|
||||
let temporary_channel_id = nodes[1].node.create_channel(nodes[3].node.get_our_node_id(), 1_000_000, 500_000_000, 42, Some(private_chan_cfg)).unwrap();
|
||||
let open_channel = get_event_msg!(nodes[1], MessageSendEvent::SendOpenChannel, nodes[3].node.get_our_node_id());
|
||||
nodes[3].node.handle_open_channel(&nodes[1].node.get_our_node_id(), channelmanager::provided_init_features(), &open_channel);
|
||||
nodes[3].node.handle_open_channel(&nodes[1].node.get_our_node_id(), nodes[1].node.init_features(), &open_channel);
|
||||
let accept_channel = get_event_msg!(nodes[3], MessageSendEvent::SendAcceptChannel, nodes[1].node.get_our_node_id());
|
||||
nodes[1].node.handle_accept_channel(&nodes[3].node.get_our_node_id(), channelmanager::provided_init_features(), &accept_channel);
|
||||
nodes[1].node.handle_accept_channel(&nodes[3].node.get_our_node_id(), nodes[3].node.init_features(), &accept_channel);
|
||||
|
||||
let tx = sign_funding_transaction(&nodes[1], &nodes[3], 1_000_000, temporary_channel_id);
|
||||
|
||||
|
@ -1266,9 +1266,9 @@ mod test {
|
|||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan_0_1 = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_0_1 = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 10001);
|
||||
|
||||
let chan_2_0 = create_announced_chan_between_nodes_with_value(&nodes, 2, 0, 100000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_2_0 = create_announced_chan_between_nodes_with_value(&nodes, 2, 0, 100000, 10001);
|
||||
nodes[2].node.handle_channel_update(&nodes[0].node.get_our_node_id(), &chan_2_0.1);
|
||||
nodes[0].node.handle_channel_update(&nodes[2].node.get_our_node_id(), &chan_2_0.0);
|
||||
|
||||
|
@ -1299,12 +1299,12 @@ mod test {
|
|||
let node_chanmgrs = create_node_chanmgrs(4, &node_cfgs, &[None, None, None, None]);
|
||||
let nodes = create_network(4, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan_0_2 = create_announced_chan_between_nodes_with_value(&nodes, 0, 2, 100000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_0_2 = create_announced_chan_between_nodes_with_value(&nodes, 0, 2, 100000, 10001);
|
||||
nodes[0].node.handle_channel_update(&nodes[2].node.get_our_node_id(), &chan_0_2.1);
|
||||
nodes[2].node.handle_channel_update(&nodes[0].node.get_our_node_id(), &chan_0_2.0);
|
||||
let _chan_1_2 = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 2, 100000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let _chan_1_2 = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 2, 100000, 10001);
|
||||
|
||||
let chan_0_3 = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 3, 100000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_0_3 = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 3, 100000, 10001);
|
||||
|
||||
// Hints should include `chan_0_3` from as `nodes[3]` only have private channels, and no
|
||||
// channels for `nodes[2]` as it contains a mix of public and private channels.
|
||||
|
@ -1333,10 +1333,10 @@ mod test {
|
|||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let _chan_0_1_low_inbound_capacity = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 1, 100_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_0_1_high_inbound_capacity = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 1, 10_000_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let _chan_0_1_medium_inbound_capacity = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_0_2 = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 2, 100000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let _chan_0_1_low_inbound_capacity = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 1, 100_000, 0);
|
||||
let chan_0_1_high_inbound_capacity = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 1, 10_000_000, 0);
|
||||
let _chan_0_1_medium_inbound_capacity = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 0);
|
||||
let chan_0_2 = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 2, 100000, 10001);
|
||||
|
||||
let mut scid_aliases = HashSet::new();
|
||||
scid_aliases.insert(chan_0_1_high_inbound_capacity.0.short_channel_id_alias.unwrap());
|
||||
|
@ -1364,9 +1364,9 @@ mod test {
|
|||
let node_chanmgrs = create_node_chanmgrs(4, &node_cfgs, &[None, None, None, None]);
|
||||
let nodes = create_network(4, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan_0_2 = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 2, 1_000_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_0_3 = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 3, 100_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_1_3 = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 3, 200_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_0_2 = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 2, 1_000_000, 0);
|
||||
let chan_0_3 = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 3, 100_000, 0);
|
||||
let chan_1_3 = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 3, 200_000, 0);
|
||||
|
||||
// Since the invoice 1 msat above chan_0_3's inbound capacity, it should be filtered out.
|
||||
let mut scid_aliases_99_000_001_msat = HashSet::new();
|
||||
|
|
|
@ -143,7 +143,6 @@ mod tests {
|
|||
use lightning::chain::chainmonitor::Persist;
|
||||
use lightning::chain::transaction::OutPoint;
|
||||
use lightning::{check_closed_broadcast, check_closed_event, check_added_monitors};
|
||||
use lightning::ln::channelmanager;
|
||||
use lightning::ln::functional_test_utils::*;
|
||||
use lightning::util::events::{ClosureReason, MessageSendEventsProvider};
|
||||
use lightning::util::test_utils;
|
||||
|
@ -228,7 +227,7 @@ mod tests {
|
|||
}
|
||||
|
||||
// Create some initial channel and check that a channel was persisted.
|
||||
let _ = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let _ = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
check_persisted_data!(0);
|
||||
|
||||
// Send a few payments and make sure the monitors are updated to the latest.
|
||||
|
@ -272,7 +271,7 @@ mod tests {
|
|||
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
let chan = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
nodes[1].node.force_close_broadcasting_latest_txn(&chan.2, &nodes[0].node.get_our_node_id()).unwrap();
|
||||
check_closed_event!(nodes[1], 1, ClosureReason::HolderForceClosed);
|
||||
let mut added_monitors = nodes[1].chain_monitor.added_monitors.lock().unwrap();
|
||||
|
@ -311,7 +310,7 @@ mod tests {
|
|||
let mut node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
let chan = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
nodes[1].node.force_close_broadcasting_latest_txn(&chan.2, &nodes[0].node.get_our_node_id()).unwrap();
|
||||
check_closed_event!(nodes[1], 1, ClosureReason::HolderForceClosed);
|
||||
let mut added_monitors = nodes[1].chain_monitor.added_monitors.lock().unwrap();
|
||||
|
|
|
@ -792,7 +792,7 @@ mod tests {
|
|||
use crate::{get_htlc_update_msgs, get_local_commitment_txn, get_revoke_commit_msgs, get_route_and_payment_hash, unwrap_send_err};
|
||||
use crate::chain::{ChannelMonitorUpdateStatus, Confirm, Watch};
|
||||
use crate::chain::channelmonitor::LATENCY_GRACE_PERIOD_BLOCKS;
|
||||
use crate::ln::channelmanager::{self, PaymentSendFailure, PaymentId};
|
||||
use crate::ln::channelmanager::{PaymentSendFailure, PaymentId};
|
||||
use crate::ln::functional_test_utils::*;
|
||||
use crate::ln::msgs::ChannelMessageHandler;
|
||||
use crate::util::errors::APIError;
|
||||
|
@ -807,7 +807,7 @@ mod tests {
|
|||
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
|
||||
// Route two payments to be claimed at the same time.
|
||||
let (payment_preimage_1, payment_hash_1, _) = route_payment(&nodes[0], &[&nodes[1]], 1_000_000);
|
||||
|
@ -897,8 +897,7 @@ mod tests {
|
|||
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
let channel = create_announced_chan_between_nodes(
|
||||
&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let channel = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
|
||||
// Get a route for later and rebalance the channel somewhat
|
||||
send_payment(&nodes[0], &[&nodes[1]], 10_000_000);
|
||||
|
@ -974,7 +973,7 @@ mod tests {
|
|||
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
|
||||
chanmon_cfgs[0].persister.chain_sync_monitor_persistences.lock().unwrap().clear();
|
||||
chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::PermanentFailure);
|
||||
|
|
|
@ -4021,7 +4021,7 @@ mod tests {
|
|||
use crate::ln::{PaymentPreimage, PaymentHash};
|
||||
use crate::ln::chan_utils;
|
||||
use crate::ln::chan_utils::{HTLCOutputInCommitment, ChannelPublicKeys, ChannelTransactionParameters, HolderCommitmentTransaction, CounterpartyChannelTransactionParameters};
|
||||
use crate::ln::channelmanager::{self, PaymentSendFailure, PaymentId};
|
||||
use crate::ln::channelmanager::{PaymentSendFailure, PaymentId};
|
||||
use crate::ln::functional_test_utils::*;
|
||||
use crate::ln::script::ShutdownScript;
|
||||
use crate::util::errors::APIError;
|
||||
|
@ -4049,10 +4049,8 @@ mod tests {
|
|||
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
let channel = create_announced_chan_between_nodes(
|
||||
&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes(
|
||||
&nodes, 1, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let channel = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
create_announced_chan_between_nodes(&nodes, 1, 2);
|
||||
|
||||
// Rebalance somewhat
|
||||
send_payment(&nodes[0], &[&nodes[1]], 10_000_000);
|
||||
|
|
|
@ -19,7 +19,7 @@ use bitcoin::network::constants::Network;
|
|||
use crate::chain::channelmonitor::{ANTI_REORG_DELAY, ChannelMonitor};
|
||||
use crate::chain::transaction::OutPoint;
|
||||
use crate::chain::{ChannelMonitorUpdateStatus, Listen, Watch};
|
||||
use crate::ln::channelmanager::{self, ChannelManager, RAACommitmentOrder, PaymentSendFailure, PaymentId};
|
||||
use crate::ln::channelmanager::{ChannelManager, RAACommitmentOrder, PaymentSendFailure, PaymentId};
|
||||
use crate::ln::channel::AnnouncementSigsState;
|
||||
use crate::ln::msgs;
|
||||
use crate::ln::msgs::{ChannelMessageHandler, RoutingMessageHandler};
|
||||
|
@ -46,7 +46,7 @@ fn test_simple_monitor_permanent_update_fail() {
|
|||
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
|
||||
let (route, payment_hash_1, _, payment_secret_1) = get_route_and_payment_hash!(&nodes[0], nodes[1], 1000000);
|
||||
chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::PermanentFailure);
|
||||
|
@ -84,7 +84,7 @@ fn test_monitor_and_persister_update_fail() {
|
|||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
// Create some initial channel
|
||||
let chan = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
let outpoint = OutPoint { txid: chan.3.txid(), index: 0 };
|
||||
|
||||
// Rebalance the network to generate htlc in the two directions
|
||||
|
@ -165,7 +165,7 @@ fn do_test_simple_monitor_temporary_update_fail(disconnect: bool) {
|
|||
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1).2;
|
||||
|
||||
let (route, payment_hash_1, payment_preimage_1, payment_secret_1) = get_route_and_payment_hash!(&nodes[0], nodes[1], 1000000);
|
||||
|
||||
|
@ -281,7 +281,7 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) {
|
|||
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1).2;
|
||||
|
||||
let (payment_preimage_1, payment_hash_1, _) = route_payment(&nodes[0], &[&nodes[1]], 1_000_000);
|
||||
|
||||
|
@ -351,10 +351,10 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) {
|
|||
nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id(), false);
|
||||
nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id(), false);
|
||||
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: nodes[1].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let reestablish_1 = get_chan_reestablish_msgs!(nodes[0], nodes[1]);
|
||||
assert_eq!(reestablish_1.len(), 1);
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: nodes[0].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let reestablish_2 = get_chan_reestablish_msgs!(nodes[1], nodes[0]);
|
||||
assert_eq!(reestablish_2.len(), 1);
|
||||
|
||||
|
@ -373,10 +373,10 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) {
|
|||
assert!(nodes[0].node.get_and_clear_pending_events().is_empty());
|
||||
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
|
||||
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: nodes[1].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let reestablish_1 = get_chan_reestablish_msgs!(nodes[0], nodes[1]);
|
||||
assert_eq!(reestablish_1.len(), 1);
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: nodes[0].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let reestablish_2 = get_chan_reestablish_msgs!(nodes[1], nodes[0]);
|
||||
assert_eq!(reestablish_2.len(), 1);
|
||||
|
||||
|
@ -625,7 +625,7 @@ fn test_monitor_update_fail_cs() {
|
|||
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1).2;
|
||||
|
||||
let (route, our_payment_hash, payment_preimage, our_payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[1], 1000000);
|
||||
{
|
||||
|
@ -717,7 +717,7 @@ fn test_monitor_update_fail_no_rebroadcast() {
|
|||
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1).2;
|
||||
|
||||
let (route, our_payment_hash, payment_preimage_1, payment_secret_1) = get_route_and_payment_hash!(nodes[0], nodes[1], 1000000);
|
||||
{
|
||||
|
@ -763,7 +763,7 @@ fn test_monitor_update_raa_while_paused() {
|
|||
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1).2;
|
||||
|
||||
send_payment(&nodes[0], &[&nodes[1]], 5000000);
|
||||
let (route, our_payment_hash_1, payment_preimage_1, our_payment_secret_1) = get_route_and_payment_hash!(nodes[0], nodes[1], 1000000);
|
||||
|
@ -834,8 +834,8 @@ fn do_test_monitor_update_fail_raa(test_ignore_second_cs: bool) {
|
|||
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_2 = create_announced_chan_between_nodes(&nodes, 1, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
let chan_2 = create_announced_chan_between_nodes(&nodes, 1, 2);
|
||||
|
||||
// Rebalance a bit so that we can send backwards from 2 to 1.
|
||||
send_payment(&nodes[0], &[&nodes[1], &nodes[2]], 5000000);
|
||||
|
@ -1105,8 +1105,8 @@ fn test_monitor_update_fail_reestablish() {
|
|||
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes(&nodes, 1, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
create_announced_chan_between_nodes(&nodes, 1, 2);
|
||||
|
||||
let (payment_preimage, payment_hash, _) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 1_000_000);
|
||||
|
||||
|
@ -1130,8 +1130,8 @@ fn test_monitor_update_fail_reestablish() {
|
|||
commitment_signed_dance!(nodes[1], nodes[2], updates.commitment_signed, false);
|
||||
|
||||
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: nodes[1].node.init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: nodes[0].node.init_features(), remote_network_address: None }).unwrap();
|
||||
|
||||
let as_reestablish = get_chan_reestablish_msgs!(nodes[0], nodes[1]).pop().unwrap();
|
||||
let bs_reestablish = get_chan_reestablish_msgs!(nodes[1], nodes[0]).pop().unwrap();
|
||||
|
@ -1149,8 +1149,8 @@ fn test_monitor_update_fail_reestablish() {
|
|||
nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id(), false);
|
||||
nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id(), false);
|
||||
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: nodes[1].node.init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: nodes[0].node.init_features(), remote_network_address: None }).unwrap();
|
||||
|
||||
assert_eq!(get_chan_reestablish_msgs!(nodes[0], nodes[1]).pop().unwrap(), as_reestablish);
|
||||
assert_eq!(get_chan_reestablish_msgs!(nodes[1], nodes[0]).pop().unwrap(), bs_reestablish);
|
||||
|
@ -1192,7 +1192,7 @@ fn raa_no_response_awaiting_raa_state() {
|
|||
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1).2;
|
||||
|
||||
let (route, payment_hash_1, payment_preimage_1, payment_secret_1) = get_route_and_payment_hash!(nodes[0], nodes[1], 1000000);
|
||||
let (payment_preimage_2, payment_hash_2, payment_secret_2) = get_payment_preimage_hash!(nodes[1]);
|
||||
|
@ -1310,7 +1310,7 @@ fn claim_while_disconnected_monitor_update_fail() {
|
|||
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1).2;
|
||||
|
||||
// Forward a payment for B to claim
|
||||
let (payment_preimage_1, payment_hash_1, _) = route_payment(&nodes[0], &[&nodes[1]], 1_000_000);
|
||||
|
@ -1322,8 +1322,8 @@ fn claim_while_disconnected_monitor_update_fail() {
|
|||
check_added_monitors!(nodes[1], 1);
|
||||
expect_payment_claimed!(nodes[1], payment_hash_1, 1_000_000);
|
||||
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: nodes[1].node.init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: nodes[0].node.init_features(), remote_network_address: None }).unwrap();
|
||||
|
||||
let as_reconnect = get_chan_reestablish_msgs!(nodes[0], nodes[1]).pop().unwrap();
|
||||
let bs_reconnect = get_chan_reestablish_msgs!(nodes[1], nodes[0]).pop().unwrap();
|
||||
|
@ -1422,7 +1422,7 @@ fn monitor_failed_no_reestablish_response() {
|
|||
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1).2;
|
||||
{
|
||||
let mut node_0_per_peer_lock;
|
||||
let mut node_0_peer_state_lock;
|
||||
|
@ -1454,8 +1454,8 @@ fn monitor_failed_no_reestablish_response() {
|
|||
nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id(), false);
|
||||
nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id(), false);
|
||||
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: nodes[1].node.init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: nodes[0].node.init_features(), remote_network_address: None }).unwrap();
|
||||
|
||||
let as_reconnect = get_chan_reestablish_msgs!(nodes[0], nodes[1]).pop().unwrap();
|
||||
let bs_reconnect = get_chan_reestablish_msgs!(nodes[1], nodes[0]).pop().unwrap();
|
||||
|
@ -1502,7 +1502,7 @@ fn first_message_on_recv_ordering() {
|
|||
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1).2;
|
||||
|
||||
// Route the first payment outbound, holding the last RAA for B until we are set up so that we
|
||||
// can deliver it and fail the monitor update.
|
||||
|
@ -1592,8 +1592,8 @@ fn test_monitor_update_fail_claim() {
|
|||
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes(&nodes, 1, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
create_announced_chan_between_nodes(&nodes, 1, 2);
|
||||
|
||||
// Rebalance a bit so that we can send backwards from 3 to 2.
|
||||
send_payment(&nodes[0], &[&nodes[1], &nodes[2]], 5000000);
|
||||
|
@ -1708,8 +1708,8 @@ fn test_monitor_update_on_pending_forwards() {
|
|||
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_2 = create_announced_chan_between_nodes(&nodes, 1, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
let chan_2 = create_announced_chan_between_nodes(&nodes, 1, 2);
|
||||
|
||||
// Rebalance a bit so that we can send backwards from 3 to 1.
|
||||
send_payment(&nodes[0], &[&nodes[1], &nodes[2]], 5000000);
|
||||
|
@ -1777,7 +1777,7 @@ fn monitor_update_claim_fail_no_response() {
|
|||
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1).2;
|
||||
|
||||
// Forward a payment for B to claim
|
||||
let (payment_preimage_1, payment_hash_1, _) = route_payment(&nodes[0], &[&nodes[1]], 1_000_000);
|
||||
|
@ -1832,8 +1832,8 @@ fn do_during_funding_monitor_fail(confirm_a_first: bool, restore_b_before_conf:
|
|||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 43, None).unwrap();
|
||||
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), channelmanager::provided_init_features(), &get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id()));
|
||||
nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), channelmanager::provided_init_features(), &get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id()));
|
||||
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), nodes[0].node.init_features(), &get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id()));
|
||||
nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), nodes[1].node.init_features(), &get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id()));
|
||||
|
||||
let (temporary_channel_id, funding_tx, funding_output) = create_funding_transaction(&nodes[0], &nodes[1].node.get_our_node_id(), 100000, 43);
|
||||
|
||||
|
@ -1951,10 +1951,10 @@ fn test_path_paused_mpp() {
|
|||
let node_chanmgrs = create_node_chanmgrs(4, &node_cfgs, &[None, None, None, None]);
|
||||
let mut nodes = create_network(4, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan_1_id = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).0.contents.short_channel_id;
|
||||
let (chan_2_ann, _, chan_2_id, _) = create_announced_chan_between_nodes(&nodes, 0, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_3_id = create_announced_chan_between_nodes(&nodes, 1, 3, channelmanager::provided_init_features(), channelmanager::provided_init_features()).0.contents.short_channel_id;
|
||||
let chan_4_id = create_announced_chan_between_nodes(&nodes, 2, 3, channelmanager::provided_init_features(), channelmanager::provided_init_features()).0.contents.short_channel_id;
|
||||
let chan_1_id = create_announced_chan_between_nodes(&nodes, 0, 1).0.contents.short_channel_id;
|
||||
let (chan_2_ann, _, chan_2_id, _) = create_announced_chan_between_nodes(&nodes, 0, 2);
|
||||
let chan_3_id = create_announced_chan_between_nodes(&nodes, 1, 3).0.contents.short_channel_id;
|
||||
let chan_4_id = create_announced_chan_between_nodes(&nodes, 2, 3).0.contents.short_channel_id;
|
||||
|
||||
let (mut route, payment_hash, payment_preimage, payment_secret) = get_route_and_payment_hash!(&nodes[0], nodes[3], 100000);
|
||||
|
||||
|
@ -2017,7 +2017,7 @@ fn test_pending_update_fee_ack_on_reconnect() {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
send_payment(&nodes[0], &[&nodes[1]], 100_000_00);
|
||||
|
||||
let (route, payment_hash, payment_preimage, payment_secret) = get_route_and_payment_hash!(&nodes[1], nodes[0], 1_000_000);
|
||||
|
@ -2044,9 +2044,9 @@ fn test_pending_update_fee_ack_on_reconnect() {
|
|||
nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id(), false);
|
||||
nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id(), false);
|
||||
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: nodes[1].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let as_connect_msg = get_chan_reestablish_msgs!(nodes[0], nodes[1]).pop().unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: nodes[0].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let bs_connect_msg = get_chan_reestablish_msgs!(nodes[1], nodes[0]).pop().unwrap();
|
||||
|
||||
nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &as_connect_msg);
|
||||
|
@ -2105,8 +2105,8 @@ fn test_fail_htlc_on_broadcast_after_claim() {
|
|||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_id_2 = create_announced_chan_between_nodes(&nodes, 1, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
let chan_id_2 = create_announced_chan_between_nodes(&nodes, 1, 2).2;
|
||||
|
||||
let (payment_preimage, payment_hash, _) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 2000);
|
||||
|
||||
|
@ -2145,7 +2145,7 @@ fn do_update_fee_resend_test(deliver_update: bool, parallel_updates: bool) {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
send_payment(&nodes[0], &[&nodes[1]], 1000);
|
||||
|
||||
{
|
||||
|
@ -2172,9 +2172,9 @@ fn do_update_fee_resend_test(deliver_update: bool, parallel_updates: bool) {
|
|||
nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id(), false);
|
||||
nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id(), false);
|
||||
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: nodes[1].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let as_connect_msg = get_chan_reestablish_msgs!(nodes[0], nodes[1]).pop().unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: nodes[0].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let bs_connect_msg = get_chan_reestablish_msgs!(nodes[1], nodes[0]).pop().unwrap();
|
||||
|
||||
nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &as_connect_msg);
|
||||
|
@ -2246,7 +2246,7 @@ fn do_channel_holding_cell_serialize(disconnect: bool, reload_a: bool) {
|
|||
let nodes_0_deserialized: ChannelManager<&test_utils::TestChainMonitor, &test_utils::TestBroadcaster, &test_utils::TestKeysInterface, &test_utils::TestKeysInterface, &test_utils::TestKeysInterface, &test_utils::TestFeeEstimator, &test_utils::TestRouter, &test_utils::TestLogger>;
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan_id = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 15_000_000, 7_000_000_000, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let chan_id = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 15_000_000, 7_000_000_000).2;
|
||||
let (route, payment_hash_1, payment_preimage_1, payment_secret_1) = get_route_and_payment_hash!(&nodes[0], nodes[1], 100000);
|
||||
let (payment_preimage_2, payment_hash_2, payment_secret_2) = get_payment_preimage_hash!(&nodes[1]);
|
||||
|
||||
|
@ -2308,10 +2308,10 @@ fn do_channel_holding_cell_serialize(disconnect: bool, reload_a: bool) {
|
|||
nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id(), false);
|
||||
|
||||
// Now reconnect the two
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: nodes[1].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let reestablish_1 = get_chan_reestablish_msgs!(nodes[0], nodes[1]);
|
||||
assert_eq!(reestablish_1.len(), 1);
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: nodes[0].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let reestablish_2 = get_chan_reestablish_msgs!(nodes[1], nodes[0]);
|
||||
assert_eq!(reestablish_2.len(), 1);
|
||||
|
||||
|
@ -2428,8 +2428,8 @@ fn do_test_reconnect_dup_htlc_claims(htlc_status: HTLCStatusAtDupClaim, second_f
|
|||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_id_2 = create_announced_chan_between_nodes(&nodes, 1, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
let chan_id_2 = create_announced_chan_between_nodes(&nodes, 1, 2).2;
|
||||
|
||||
let (payment_preimage, payment_hash, _) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 100_000);
|
||||
|
||||
|
@ -2541,16 +2541,16 @@ fn test_temporary_error_during_shutdown() {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(config), Some(config)]);
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let (_, _, channel_id, funding_tx) = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let (_, _, channel_id, funding_tx) = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
|
||||
chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
|
||||
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
|
||||
|
||||
nodes[0].node.close_channel(&channel_id, &nodes[1].node.get_our_node_id()).unwrap();
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &channelmanager::provided_init_features(), &get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[1].node.get_our_node_id()));
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &nodes[0].node.init_features(), &get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[1].node.get_our_node_id()));
|
||||
check_added_monitors!(nodes[1], 1);
|
||||
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &channelmanager::provided_init_features(), &get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id()));
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &nodes[1].node.init_features(), &get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id()));
|
||||
check_added_monitors!(nodes[0], 1);
|
||||
|
||||
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
|
||||
|
@ -2596,7 +2596,7 @@ fn test_permanent_error_during_sending_shutdown() {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(config), None]);
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1).2;
|
||||
chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::PermanentFailure);
|
||||
|
||||
assert!(nodes[0].node.close_channel(&channel_id, &nodes[1].node.get_our_node_id()).is_ok());
|
||||
|
@ -2617,12 +2617,12 @@ fn test_permanent_error_during_handling_shutdown() {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, Some(config)]);
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1).2;
|
||||
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::PermanentFailure);
|
||||
|
||||
assert!(nodes[0].node.close_channel(&channel_id, &nodes[1].node.get_our_node_id()).is_ok());
|
||||
let shutdown = get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[1].node.get_our_node_id());
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &channelmanager::provided_init_features(), &shutdown);
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &nodes[0].node.init_features(), &shutdown);
|
||||
check_closed_broadcast!(nodes[1], true);
|
||||
check_added_monitors!(nodes[1], 2);
|
||||
check_closed_event!(nodes[1], 1, ClosureReason::ProcessingError { err: "ChannelMonitor storage failure".to_string() });
|
||||
|
@ -2636,7 +2636,7 @@ fn double_temp_error() {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let (_, _, channel_id, _) = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let (_, _, channel_id, _) = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
|
||||
let (payment_preimage_1, payment_hash_1, _) = route_payment(&nodes[0], &[&nodes[1]], 1_000_000);
|
||||
let (payment_preimage_2, payment_hash_2, _) = route_payment(&nodes[0], &[&nodes[1]], 1_000_000);
|
||||
|
@ -2747,7 +2747,7 @@ fn do_test_outbound_reload_without_init_mon(use_0conf: bool) {
|
|||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 43, None).unwrap();
|
||||
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), channelmanager::provided_init_features(), &get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id()));
|
||||
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), nodes[0].node.init_features(), &get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id()));
|
||||
|
||||
let events = nodes[1].node.get_and_clear_pending_events();
|
||||
assert_eq!(events.len(), 1);
|
||||
|
@ -2762,7 +2762,7 @@ fn do_test_outbound_reload_without_init_mon(use_0conf: bool) {
|
|||
_ => panic!("Unexpected event"),
|
||||
};
|
||||
|
||||
nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), channelmanager::provided_init_features(), &get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id()));
|
||||
nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), nodes[1].node.init_features(), &get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id()));
|
||||
|
||||
let (temporary_channel_id, funding_tx, ..) = create_funding_transaction(&nodes[0], &nodes[1].node.get_our_node_id(), 100000, 43);
|
||||
|
||||
|
@ -2836,7 +2836,7 @@ fn do_test_inbound_reload_without_init_mon(use_0conf: bool, lock_commitment: boo
|
|||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 43, None).unwrap();
|
||||
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), channelmanager::provided_init_features(), &get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id()));
|
||||
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), nodes[0].node.init_features(), &get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id()));
|
||||
|
||||
let events = nodes[1].node.get_and_clear_pending_events();
|
||||
assert_eq!(events.len(), 1);
|
||||
|
@ -2851,7 +2851,7 @@ fn do_test_inbound_reload_without_init_mon(use_0conf: bool, lock_commitment: boo
|
|||
_ => panic!("Unexpected event"),
|
||||
};
|
||||
|
||||
nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), channelmanager::provided_init_features(), &get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id()));
|
||||
nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), nodes[1].node.init_features(), &get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id()));
|
||||
|
||||
let (temporary_channel_id, funding_tx, ..) = create_funding_transaction(&nodes[0], &nodes[1].node.get_our_node_id(), 100000, 43);
|
||||
|
||||
|
|
|
@ -2394,7 +2394,7 @@ impl<Signer: Sign> Channel<Signer> {
|
|||
/// Handles a channel_ready message from our peer. If we've already sent our channel_ready
|
||||
/// and the channel is now usable (and public), this may generate an announcement_signatures to
|
||||
/// reply with.
|
||||
pub fn channel_ready<L: Deref>(&mut self, msg: &msgs::ChannelReady, node_pk: PublicKey, genesis_block_hash: BlockHash, best_block: &BestBlock, logger: &L) -> Result<Option<msgs::AnnouncementSignatures>, ChannelError> where L::Target: Logger {
|
||||
pub fn channel_ready<L: Deref>(&mut self, msg: &msgs::ChannelReady, node_pk: PublicKey, genesis_block_hash: BlockHash, user_config: &UserConfig, best_block: &BestBlock, logger: &L) -> Result<Option<msgs::AnnouncementSignatures>, ChannelError> where L::Target: Logger {
|
||||
if self.channel_state & (ChannelState::PeerDisconnected as u32) == ChannelState::PeerDisconnected as u32 {
|
||||
self.workaround_lnd_bug_4006 = Some(msg.clone());
|
||||
return Err(ChannelError::Ignore("Peer sent channel_ready when we needed a channel_reestablish. The peer is likely lnd, see https://github.com/lightningnetwork/lnd/issues/4006".to_owned()));
|
||||
|
@ -2448,7 +2448,7 @@ impl<Signer: Sign> Channel<Signer> {
|
|||
|
||||
log_info!(logger, "Received channel_ready from peer for channel {}", log_bytes!(self.channel_id()));
|
||||
|
||||
Ok(self.get_announcement_sigs(node_pk, genesis_block_hash, best_block.height(), logger))
|
||||
Ok(self.get_announcement_sigs(node_pk, genesis_block_hash, user_config, best_block.height(), logger))
|
||||
}
|
||||
|
||||
/// Returns transaction if there is pending funding transaction that is yet to broadcast
|
||||
|
@ -3752,7 +3752,7 @@ impl<Signer: Sign> Channel<Signer> {
|
|||
/// Indicates that the latest ChannelMonitor update has been committed by the client
|
||||
/// successfully and we should restore normal operation. Returns messages which should be sent
|
||||
/// to the remote side.
|
||||
pub fn monitor_updating_restored<L: Deref>(&mut self, logger: &L, node_pk: PublicKey, genesis_block_hash: BlockHash, best_block_height: u32) -> MonitorRestoreUpdates where L::Target: Logger {
|
||||
pub fn monitor_updating_restored<L: Deref>(&mut self, logger: &L, node_pk: PublicKey, genesis_block_hash: BlockHash, user_config: &UserConfig, best_block_height: u32) -> MonitorRestoreUpdates where L::Target: Logger {
|
||||
assert_eq!(self.channel_state & ChannelState::MonitorUpdateInProgress as u32, ChannelState::MonitorUpdateInProgress as u32);
|
||||
self.channel_state &= !(ChannelState::MonitorUpdateInProgress as u32);
|
||||
|
||||
|
@ -3787,7 +3787,7 @@ impl<Signer: Sign> Channel<Signer> {
|
|||
})
|
||||
} else { None };
|
||||
|
||||
let announcement_sigs = self.get_announcement_sigs(node_pk, genesis_block_hash, best_block_height, logger);
|
||||
let announcement_sigs = self.get_announcement_sigs(node_pk, genesis_block_hash, user_config, best_block_height, logger);
|
||||
|
||||
let mut accepted_htlcs = Vec::new();
|
||||
mem::swap(&mut accepted_htlcs, &mut self.monitor_pending_forwards);
|
||||
|
@ -3940,7 +3940,7 @@ impl<Signer: Sign> Channel<Signer> {
|
|||
/// [`super::channelmanager::ChannelManager::force_close_without_broadcasting_txn`] and
|
||||
/// [`super::channelmanager::ChannelManager::force_close_all_channels_without_broadcasting_txn`].
|
||||
pub fn channel_reestablish<L: Deref>(&mut self, msg: &msgs::ChannelReestablish, logger: &L,
|
||||
node_pk: PublicKey, genesis_block_hash: BlockHash, best_block: &BestBlock)
|
||||
node_pk: PublicKey, genesis_block_hash: BlockHash, user_config: &UserConfig, best_block: &BestBlock)
|
||||
-> Result<ReestablishResponses, ChannelError> where L::Target: Logger {
|
||||
if self.channel_state & (ChannelState::PeerDisconnected as u32) == 0 {
|
||||
// While BOLT 2 doesn't indicate explicitly we should error this channel here, it
|
||||
|
@ -4005,7 +4005,7 @@ impl<Signer: Sign> Channel<Signer> {
|
|||
})
|
||||
} else { None };
|
||||
|
||||
let announcement_sigs = self.get_announcement_sigs(node_pk, genesis_block_hash, best_block.height(), logger);
|
||||
let announcement_sigs = self.get_announcement_sigs(node_pk, genesis_block_hash, user_config, best_block.height(), logger);
|
||||
|
||||
if self.channel_state & (ChannelState::FundingSent as u32) == ChannelState::FundingSent as u32 {
|
||||
// If we're waiting on a monitor update, we shouldn't re-send any channel_ready's.
|
||||
|
@ -4978,7 +4978,7 @@ impl<Signer: Sign> Channel<Signer> {
|
|||
/// In the first case, we store the confirmation height and calculating the short channel id.
|
||||
/// In the second, we simply return an Err indicating we need to be force-closed now.
|
||||
pub fn transactions_confirmed<L: Deref>(&mut self, block_hash: &BlockHash, height: u32,
|
||||
txdata: &TransactionData, genesis_block_hash: BlockHash, node_pk: PublicKey, logger: &L)
|
||||
txdata: &TransactionData, genesis_block_hash: BlockHash, node_pk: PublicKey, user_config: &UserConfig, logger: &L)
|
||||
-> Result<(Option<msgs::ChannelReady>, Option<msgs::AnnouncementSignatures>), ClosureReason> where L::Target: Logger {
|
||||
if let Some(funding_txo) = self.get_funding_txo() {
|
||||
for &(index_in_block, tx) in txdata.iter() {
|
||||
|
@ -5025,7 +5025,7 @@ impl<Signer: Sign> Channel<Signer> {
|
|||
// may have already happened for this block).
|
||||
if let Some(channel_ready) = self.check_get_channel_ready(height) {
|
||||
log_info!(logger, "Sending a channel_ready to our peer for channel {}", log_bytes!(self.channel_id));
|
||||
let announcement_sigs = self.get_announcement_sigs(node_pk, genesis_block_hash, height, logger);
|
||||
let announcement_sigs = self.get_announcement_sigs(node_pk, genesis_block_hash, user_config, height, logger);
|
||||
return Ok((Some(channel_ready), announcement_sigs));
|
||||
}
|
||||
}
|
||||
|
@ -5051,12 +5051,12 @@ impl<Signer: Sign> Channel<Signer> {
|
|||
///
|
||||
/// May return some HTLCs (and their payment_hash) which have timed out and should be failed
|
||||
/// back.
|
||||
pub fn best_block_updated<L: Deref>(&mut self, height: u32, highest_header_time: u32, genesis_block_hash: BlockHash, node_pk: PublicKey, logger: &L)
|
||||
pub fn best_block_updated<L: Deref>(&mut self, height: u32, highest_header_time: u32, genesis_block_hash: BlockHash, node_pk: PublicKey, user_config: UserConfig, logger: &L)
|
||||
-> Result<(Option<msgs::ChannelReady>, Vec<(HTLCSource, PaymentHash)>, Option<msgs::AnnouncementSignatures>), ClosureReason> where L::Target: Logger {
|
||||
self.do_best_block_updated(height, highest_header_time, Some((genesis_block_hash, node_pk)), logger)
|
||||
self.do_best_block_updated(height, highest_header_time, Some((genesis_block_hash, node_pk, user_config)), logger)
|
||||
}
|
||||
|
||||
fn do_best_block_updated<L: Deref>(&mut self, height: u32, highest_header_time: u32, genesis_node_pk: Option<(BlockHash, PublicKey)>, logger: &L)
|
||||
fn do_best_block_updated<L: Deref>(&mut self, height: u32, highest_header_time: u32, genesis_node_pk: Option<(BlockHash, PublicKey, UserConfig)>, logger: &L)
|
||||
-> Result<(Option<msgs::ChannelReady>, Vec<(HTLCSource, PaymentHash)>, Option<msgs::AnnouncementSignatures>), ClosureReason> where L::Target: Logger {
|
||||
let mut timed_out_htlcs = Vec::new();
|
||||
// This mirrors the check in ChannelManager::decode_update_add_htlc_onion, refusing to
|
||||
|
@ -5078,8 +5078,8 @@ impl<Signer: Sign> Channel<Signer> {
|
|||
self.update_time_counter = cmp::max(self.update_time_counter, highest_header_time);
|
||||
|
||||
if let Some(channel_ready) = self.check_get_channel_ready(height) {
|
||||
let announcement_sigs = if let Some((genesis_block_hash, node_pk)) = genesis_node_pk {
|
||||
self.get_announcement_sigs(node_pk, genesis_block_hash, height, logger)
|
||||
let announcement_sigs = if let Some((genesis_block_hash, node_pk, user_config)) = genesis_node_pk {
|
||||
self.get_announcement_sigs(node_pk, genesis_block_hash, &user_config, height, logger)
|
||||
} else { None };
|
||||
log_info!(logger, "Sending a channel_ready to our peer for channel {}", log_bytes!(self.channel_id));
|
||||
return Ok((Some(channel_ready), timed_out_htlcs, announcement_sigs));
|
||||
|
@ -5119,8 +5119,8 @@ impl<Signer: Sign> Channel<Signer> {
|
|||
return Err(ClosureReason::FundingTimedOut);
|
||||
}
|
||||
|
||||
let announcement_sigs = if let Some((genesis_block_hash, node_pk)) = genesis_node_pk {
|
||||
self.get_announcement_sigs(node_pk, genesis_block_hash, height, logger)
|
||||
let announcement_sigs = if let Some((genesis_block_hash, node_pk, user_config)) = genesis_node_pk {
|
||||
self.get_announcement_sigs(node_pk, genesis_block_hash, &user_config, height, logger)
|
||||
} else { None };
|
||||
Ok((None, timed_out_htlcs, announcement_sigs))
|
||||
}
|
||||
|
@ -5337,7 +5337,7 @@ impl<Signer: Sign> Channel<Signer> {
|
|||
/// closing).
|
||||
///
|
||||
/// This will only return ChannelError::Ignore upon failure.
|
||||
fn get_channel_announcement(&self, node_id: PublicKey, chain_hash: BlockHash) -> Result<msgs::UnsignedChannelAnnouncement, ChannelError> {
|
||||
fn get_channel_announcement(&self, node_id: PublicKey, chain_hash: BlockHash, user_config: &UserConfig) -> Result<msgs::UnsignedChannelAnnouncement, ChannelError> {
|
||||
if !self.config.announced_channel {
|
||||
return Err(ChannelError::Ignore("Channel is not available for public announcements".to_owned()));
|
||||
}
|
||||
|
@ -5348,7 +5348,7 @@ impl<Signer: Sign> Channel<Signer> {
|
|||
let were_node_one = node_id.serialize()[..] < self.counterparty_node_id.serialize()[..];
|
||||
|
||||
let msg = msgs::UnsignedChannelAnnouncement {
|
||||
features: channelmanager::provided_channel_features(),
|
||||
features: channelmanager::provided_channel_features(&user_config),
|
||||
chain_hash,
|
||||
short_channel_id: self.get_short_channel_id().unwrap(),
|
||||
node_id_1: if were_node_one { node_id } else { self.get_counterparty_node_id() },
|
||||
|
@ -5361,7 +5361,7 @@ impl<Signer: Sign> Channel<Signer> {
|
|||
Ok(msg)
|
||||
}
|
||||
|
||||
fn get_announcement_sigs<L: Deref>(&mut self, node_pk: PublicKey, genesis_block_hash: BlockHash, best_block_height: u32, logger: &L)
|
||||
fn get_announcement_sigs<L: Deref>(&mut self, node_pk: PublicKey, genesis_block_hash: BlockHash, user_config: &UserConfig, best_block_height: u32, logger: &L)
|
||||
-> Option<msgs::AnnouncementSignatures> where L::Target: Logger {
|
||||
if self.funding_tx_confirmation_height == 0 || self.funding_tx_confirmation_height + 5 > best_block_height {
|
||||
return None;
|
||||
|
@ -5381,7 +5381,7 @@ impl<Signer: Sign> Channel<Signer> {
|
|||
}
|
||||
|
||||
log_trace!(logger, "Creating an announcement_signatures message for channel {}", log_bytes!(self.channel_id()));
|
||||
let announcement = match self.get_channel_announcement(node_pk, genesis_block_hash) {
|
||||
let announcement = match self.get_channel_announcement(node_pk, genesis_block_hash, user_config) {
|
||||
Ok(a) => a,
|
||||
Err(_) => {
|
||||
log_trace!(logger, "Cannot create an announcement_signatures as channel is not public.");
|
||||
|
@ -5428,8 +5428,8 @@ impl<Signer: Sign> Channel<Signer> {
|
|||
/// Processes an incoming announcement_signatures message, providing a fully-signed
|
||||
/// channel_announcement message which we can broadcast and storing our counterparty's
|
||||
/// signatures for later reconstruction/rebroadcast of the channel_announcement.
|
||||
pub fn announcement_signatures(&mut self, our_node_id: PublicKey, chain_hash: BlockHash, best_block_height: u32, msg: &msgs::AnnouncementSignatures) -> Result<msgs::ChannelAnnouncement, ChannelError> {
|
||||
let announcement = self.get_channel_announcement(our_node_id.clone(), chain_hash)?;
|
||||
pub fn announcement_signatures(&mut self, our_node_id: PublicKey, chain_hash: BlockHash, best_block_height: u32, msg: &msgs::AnnouncementSignatures, user_config: &UserConfig) -> Result<msgs::ChannelAnnouncement, ChannelError> {
|
||||
let announcement = self.get_channel_announcement(our_node_id.clone(), chain_hash, user_config)?;
|
||||
|
||||
let msghash = hash_to_message!(&Sha256d::hash(&announcement.encode()[..])[..]);
|
||||
|
||||
|
@ -5455,11 +5455,11 @@ impl<Signer: Sign> Channel<Signer> {
|
|||
|
||||
/// Gets a signed channel_announcement for this channel, if we previously received an
|
||||
/// announcement_signatures from our counterparty.
|
||||
pub fn get_signed_channel_announcement(&self, our_node_id: PublicKey, chain_hash: BlockHash, best_block_height: u32) -> Option<msgs::ChannelAnnouncement> {
|
||||
pub fn get_signed_channel_announcement(&self, our_node_id: PublicKey, chain_hash: BlockHash, best_block_height: u32, user_config: &UserConfig) -> Option<msgs::ChannelAnnouncement> {
|
||||
if self.funding_tx_confirmation_height == 0 || self.funding_tx_confirmation_height + 5 > best_block_height {
|
||||
return None;
|
||||
}
|
||||
let announcement = match self.get_channel_announcement(our_node_id.clone(), chain_hash) {
|
||||
let announcement = match self.get_channel_announcement(our_node_id.clone(), chain_hash, user_config) {
|
||||
Ok(res) => res,
|
||||
Err(_) => return None,
|
||||
};
|
||||
|
@ -6910,7 +6910,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn upfront_shutdown_script_incompatibility() {
|
||||
let features = channelmanager::provided_init_features().clear_shutdown_anysegwit();
|
||||
let features = channelmanager::provided_init_features(&UserConfig::default()).clear_shutdown_anysegwit();
|
||||
let non_v0_segwit_shutdown_script =
|
||||
ShutdownScript::new_witness_program(WitnessVersion::V16, &[0, 40]).unwrap();
|
||||
|
||||
|
@ -6947,7 +6947,7 @@ mod tests {
|
|||
|
||||
let node_a_node_id = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap());
|
||||
let config = UserConfig::default();
|
||||
let node_a_chan = Channel::<EnforcingSigner>::new_outbound(&bounded_fee_estimator, &&keys_provider, &&keys_provider, node_a_node_id, &channelmanager::provided_init_features(), 10000000, 100000, 42, &config, 0, 42).unwrap();
|
||||
let node_a_chan = Channel::<EnforcingSigner>::new_outbound(&bounded_fee_estimator, &&keys_provider, &&keys_provider, node_a_node_id, &channelmanager::provided_init_features(&config), 10000000, 100000, 42, &config, 0, 42).unwrap();
|
||||
|
||||
// Now change the fee so we can check that the fee in the open_channel message is the
|
||||
// same as the old fee.
|
||||
|
@ -6973,18 +6973,18 @@ mod tests {
|
|||
// Create Node A's channel pointing to Node B's pubkey
|
||||
let node_b_node_id = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap());
|
||||
let config = UserConfig::default();
|
||||
let mut node_a_chan = Channel::<EnforcingSigner>::new_outbound(&feeest, &&keys_provider, &&keys_provider, node_b_node_id, &channelmanager::provided_init_features(), 10000000, 100000, 42, &config, 0, 42).unwrap();
|
||||
let mut node_a_chan = Channel::<EnforcingSigner>::new_outbound(&feeest, &&keys_provider, &&keys_provider, node_b_node_id, &channelmanager::provided_init_features(&config), 10000000, 100000, 42, &config, 0, 42).unwrap();
|
||||
|
||||
// Create Node B's channel by receiving Node A's open_channel message
|
||||
// Make sure A's dust limit is as we expect.
|
||||
let open_channel_msg = node_a_chan.get_open_channel(genesis_block(network).header.block_hash());
|
||||
let node_b_node_id = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[7; 32]).unwrap());
|
||||
let mut node_b_chan = Channel::<EnforcingSigner>::new_from_req(&feeest, &&keys_provider, &&keys_provider, node_b_node_id, &channelmanager::provided_init_features(), &open_channel_msg, 7, &config, 0, &&logger, 42).unwrap();
|
||||
let mut node_b_chan = Channel::<EnforcingSigner>::new_from_req(&feeest, &&keys_provider, &&keys_provider, node_b_node_id, &channelmanager::provided_init_features(&config), &open_channel_msg, 7, &config, 0, &&logger, 42).unwrap();
|
||||
|
||||
// Node B --> Node A: accept channel, explicitly setting B's dust limit.
|
||||
let mut accept_channel_msg = node_b_chan.accept_inbound_channel(0);
|
||||
accept_channel_msg.dust_limit_satoshis = 546;
|
||||
node_a_chan.accept_channel(&accept_channel_msg, &config.channel_handshake_limits, &channelmanager::provided_init_features()).unwrap();
|
||||
node_a_chan.accept_channel(&accept_channel_msg, &config.channel_handshake_limits, &channelmanager::provided_init_features(&config)).unwrap();
|
||||
node_a_chan.holder_dust_limit_satoshis = 1560;
|
||||
|
||||
// Put some inbound and outbound HTLCs in A's channel.
|
||||
|
@ -7043,7 +7043,7 @@ mod tests {
|
|||
|
||||
let node_id = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap());
|
||||
let config = UserConfig::default();
|
||||
let mut chan = Channel::<EnforcingSigner>::new_outbound(&fee_est, &&keys_provider, &&keys_provider, node_id, &channelmanager::provided_init_features(), 10000000, 100000, 42, &config, 0, 42).unwrap();
|
||||
let mut chan = Channel::<EnforcingSigner>::new_outbound(&fee_est, &&keys_provider, &&keys_provider, node_id, &channelmanager::provided_init_features(&config), 10000000, 100000, 42, &config, 0, 42).unwrap();
|
||||
|
||||
let commitment_tx_fee_0_htlcs = Channel::<EnforcingSigner>::commit_tx_fee_msat(chan.feerate_per_kw, 0, chan.opt_anchors());
|
||||
let commitment_tx_fee_1_htlc = Channel::<EnforcingSigner>::commit_tx_fee_msat(chan.feerate_per_kw, 1, chan.opt_anchors());
|
||||
|
@ -7092,16 +7092,16 @@ mod tests {
|
|||
// Create Node A's channel pointing to Node B's pubkey
|
||||
let node_b_node_id = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap());
|
||||
let config = UserConfig::default();
|
||||
let mut node_a_chan = Channel::<EnforcingSigner>::new_outbound(&feeest, &&keys_provider, &&keys_provider, node_b_node_id, &channelmanager::provided_init_features(), 10000000, 100000, 42, &config, 0, 42).unwrap();
|
||||
let mut node_a_chan = Channel::<EnforcingSigner>::new_outbound(&feeest, &&keys_provider, &&keys_provider, node_b_node_id, &channelmanager::provided_init_features(&config), 10000000, 100000, 42, &config, 0, 42).unwrap();
|
||||
|
||||
// Create Node B's channel by receiving Node A's open_channel message
|
||||
let open_channel_msg = node_a_chan.get_open_channel(chain_hash);
|
||||
let node_b_node_id = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[7; 32]).unwrap());
|
||||
let mut node_b_chan = Channel::<EnforcingSigner>::new_from_req(&feeest, &&keys_provider, &&keys_provider, node_b_node_id, &channelmanager::provided_init_features(), &open_channel_msg, 7, &config, 0, &&logger, 42).unwrap();
|
||||
let mut node_b_chan = Channel::<EnforcingSigner>::new_from_req(&feeest, &&keys_provider, &&keys_provider, node_b_node_id, &channelmanager::provided_init_features(&config), &open_channel_msg, 7, &config, 0, &&logger, 42).unwrap();
|
||||
|
||||
// Node B --> Node A: accept channel
|
||||
let accept_channel_msg = node_b_chan.accept_inbound_channel(0);
|
||||
node_a_chan.accept_channel(&accept_channel_msg, &config.channel_handshake_limits, &channelmanager::provided_init_features()).unwrap();
|
||||
node_a_chan.accept_channel(&accept_channel_msg, &config.channel_handshake_limits, &channelmanager::provided_init_features(&config)).unwrap();
|
||||
|
||||
// Node A --> Node B: funding created
|
||||
let output_script = node_a_chan.get_funding_redeemscript();
|
||||
|
@ -7165,12 +7165,12 @@ mod tests {
|
|||
// Test that `new_outbound` creates a channel with the correct value for
|
||||
// `holder_max_htlc_value_in_flight_msat`, when configured with a valid percentage value,
|
||||
// which is set to the lower bound + 1 (2%) of the `channel_value`.
|
||||
let chan_1 = Channel::<EnforcingSigner>::new_outbound(&feeest, &&keys_provider, &&keys_provider, outbound_node_id, &channelmanager::provided_init_features(), 10000000, 100000, 42, &config_2_percent, 0, 42).unwrap();
|
||||
let chan_1 = Channel::<EnforcingSigner>::new_outbound(&feeest, &&keys_provider, &&keys_provider, outbound_node_id, &channelmanager::provided_init_features(&config_2_percent), 10000000, 100000, 42, &config_2_percent, 0, 42).unwrap();
|
||||
let chan_1_value_msat = chan_1.channel_value_satoshis * 1000;
|
||||
assert_eq!(chan_1.holder_max_htlc_value_in_flight_msat, (chan_1_value_msat as f64 * 0.02) as u64);
|
||||
|
||||
// Test with the upper bound - 1 of valid values (99%).
|
||||
let chan_2 = Channel::<EnforcingSigner>::new_outbound(&feeest, &&keys_provider, &&keys_provider, outbound_node_id, &channelmanager::provided_init_features(), 10000000, 100000, 42, &config_99_percent, 0, 42).unwrap();
|
||||
let chan_2 = Channel::<EnforcingSigner>::new_outbound(&feeest, &&keys_provider, &&keys_provider, outbound_node_id, &channelmanager::provided_init_features(&config_99_percent), 10000000, 100000, 42, &config_99_percent, 0, 42).unwrap();
|
||||
let chan_2_value_msat = chan_2.channel_value_satoshis * 1000;
|
||||
assert_eq!(chan_2.holder_max_htlc_value_in_flight_msat, (chan_2_value_msat as f64 * 0.99) as u64);
|
||||
|
||||
|
@ -7179,38 +7179,38 @@ mod tests {
|
|||
// Test that `new_from_req` creates a channel with the correct value for
|
||||
// `holder_max_htlc_value_in_flight_msat`, when configured with a valid percentage value,
|
||||
// which is set to the lower bound - 1 (2%) of the `channel_value`.
|
||||
let chan_3 = Channel::<EnforcingSigner>::new_from_req(&feeest, &&keys_provider, &&keys_provider, inbound_node_id, &channelmanager::provided_init_features(), &chan_1_open_channel_msg, 7, &config_2_percent, 0, &&logger, 42).unwrap();
|
||||
let chan_3 = Channel::<EnforcingSigner>::new_from_req(&feeest, &&keys_provider, &&keys_provider, inbound_node_id, &channelmanager::provided_init_features(&config_2_percent), &chan_1_open_channel_msg, 7, &config_2_percent, 0, &&logger, 42).unwrap();
|
||||
let chan_3_value_msat = chan_3.channel_value_satoshis * 1000;
|
||||
assert_eq!(chan_3.holder_max_htlc_value_in_flight_msat, (chan_3_value_msat as f64 * 0.02) as u64);
|
||||
|
||||
// Test with the upper bound - 1 of valid values (99%).
|
||||
let chan_4 = Channel::<EnforcingSigner>::new_from_req(&feeest, &&keys_provider, &&keys_provider, inbound_node_id, &channelmanager::provided_init_features(), &chan_1_open_channel_msg, 7, &config_99_percent, 0, &&logger, 42).unwrap();
|
||||
let chan_4 = Channel::<EnforcingSigner>::new_from_req(&feeest, &&keys_provider, &&keys_provider, inbound_node_id, &channelmanager::provided_init_features(&config_99_percent), &chan_1_open_channel_msg, 7, &config_99_percent, 0, &&logger, 42).unwrap();
|
||||
let chan_4_value_msat = chan_4.channel_value_satoshis * 1000;
|
||||
assert_eq!(chan_4.holder_max_htlc_value_in_flight_msat, (chan_4_value_msat as f64 * 0.99) as u64);
|
||||
|
||||
// Test that `new_outbound` uses the lower bound of the configurable percentage values (1%)
|
||||
// if `max_inbound_htlc_value_in_flight_percent_of_channel` is set to a value less than 1.
|
||||
let chan_5 = Channel::<EnforcingSigner>::new_outbound(&feeest, &&keys_provider, &&keys_provider, outbound_node_id, &channelmanager::provided_init_features(), 10000000, 100000, 42, &config_0_percent, 0, 42).unwrap();
|
||||
let chan_5 = Channel::<EnforcingSigner>::new_outbound(&feeest, &&keys_provider, &&keys_provider, outbound_node_id, &channelmanager::provided_init_features(&config_0_percent), 10000000, 100000, 42, &config_0_percent, 0, 42).unwrap();
|
||||
let chan_5_value_msat = chan_5.channel_value_satoshis * 1000;
|
||||
assert_eq!(chan_5.holder_max_htlc_value_in_flight_msat, (chan_5_value_msat as f64 * 0.01) as u64);
|
||||
|
||||
// Test that `new_outbound` uses the upper bound of the configurable percentage values
|
||||
// (100%) if `max_inbound_htlc_value_in_flight_percent_of_channel` is set to a larger value
|
||||
// than 100.
|
||||
let chan_6 = Channel::<EnforcingSigner>::new_outbound(&feeest, &&keys_provider, &&keys_provider, outbound_node_id, &channelmanager::provided_init_features(), 10000000, 100000, 42, &config_101_percent, 0, 42).unwrap();
|
||||
let chan_6 = Channel::<EnforcingSigner>::new_outbound(&feeest, &&keys_provider, &&keys_provider, outbound_node_id, &channelmanager::provided_init_features(&config_101_percent), 10000000, 100000, 42, &config_101_percent, 0, 42).unwrap();
|
||||
let chan_6_value_msat = chan_6.channel_value_satoshis * 1000;
|
||||
assert_eq!(chan_6.holder_max_htlc_value_in_flight_msat, chan_6_value_msat);
|
||||
|
||||
// Test that `new_from_req` uses the lower bound of the configurable percentage values (1%)
|
||||
// if `max_inbound_htlc_value_in_flight_percent_of_channel` is set to a value less than 1.
|
||||
let chan_7 = Channel::<EnforcingSigner>::new_from_req(&feeest, &&keys_provider, &&keys_provider, inbound_node_id, &channelmanager::provided_init_features(), &chan_1_open_channel_msg, 7, &config_0_percent, 0, &&logger, 42).unwrap();
|
||||
let chan_7 = Channel::<EnforcingSigner>::new_from_req(&feeest, &&keys_provider, &&keys_provider, inbound_node_id, &channelmanager::provided_init_features(&config_0_percent), &chan_1_open_channel_msg, 7, &config_0_percent, 0, &&logger, 42).unwrap();
|
||||
let chan_7_value_msat = chan_7.channel_value_satoshis * 1000;
|
||||
assert_eq!(chan_7.holder_max_htlc_value_in_flight_msat, (chan_7_value_msat as f64 * 0.01) as u64);
|
||||
|
||||
// Test that `new_from_req` uses the upper bound of the configurable percentage values
|
||||
// (100%) if `max_inbound_htlc_value_in_flight_percent_of_channel` is set to a larger value
|
||||
// than 100.
|
||||
let chan_8 = Channel::<EnforcingSigner>::new_from_req(&feeest, &&keys_provider, &&keys_provider, inbound_node_id, &channelmanager::provided_init_features(), &chan_1_open_channel_msg, 7, &config_101_percent, 0, &&logger, 42).unwrap();
|
||||
let chan_8 = Channel::<EnforcingSigner>::new_from_req(&feeest, &&keys_provider, &&keys_provider, inbound_node_id, &channelmanager::provided_init_features(&config_101_percent), &chan_1_open_channel_msg, 7, &config_101_percent, 0, &&logger, 42).unwrap();
|
||||
let chan_8_value_msat = chan_8.channel_value_satoshis * 1000;
|
||||
assert_eq!(chan_8.holder_max_htlc_value_in_flight_msat, chan_8_value_msat);
|
||||
}
|
||||
|
@ -7250,7 +7250,7 @@ mod tests {
|
|||
|
||||
let mut outbound_node_config = UserConfig::default();
|
||||
outbound_node_config.channel_handshake_config.their_channel_reserve_proportional_millionths = (outbound_selected_channel_reserve_perc * 1_000_000.0) as u32;
|
||||
let chan = Channel::<EnforcingSigner>::new_outbound(&&fee_est, &&keys_provider, &&keys_provider, outbound_node_id, &channelmanager::provided_init_features(), channel_value_satoshis, 100_000, 42, &outbound_node_config, 0, 42).unwrap();
|
||||
let chan = Channel::<EnforcingSigner>::new_outbound(&&fee_est, &&keys_provider, &&keys_provider, outbound_node_id, &channelmanager::provided_init_features(&outbound_node_config), channel_value_satoshis, 100_000, 42, &outbound_node_config, 0, 42).unwrap();
|
||||
|
||||
let expected_outbound_selected_chan_reserve = cmp::max(MIN_THEIR_CHAN_RESERVE_SATOSHIS, (chan.channel_value_satoshis as f64 * outbound_selected_channel_reserve_perc) as u64);
|
||||
assert_eq!(chan.holder_selected_channel_reserve_satoshis, expected_outbound_selected_chan_reserve);
|
||||
|
@ -7260,7 +7260,7 @@ mod tests {
|
|||
inbound_node_config.channel_handshake_config.their_channel_reserve_proportional_millionths = (inbound_selected_channel_reserve_perc * 1_000_000.0) as u32;
|
||||
|
||||
if outbound_selected_channel_reserve_perc + inbound_selected_channel_reserve_perc < 1.0 {
|
||||
let chan_inbound_node = Channel::<EnforcingSigner>::new_from_req(&&fee_est, &&keys_provider, &&keys_provider, inbound_node_id, &channelmanager::provided_init_features(), &chan_open_channel_msg, 7, &inbound_node_config, 0, &&logger, 42).unwrap();
|
||||
let chan_inbound_node = Channel::<EnforcingSigner>::new_from_req(&&fee_est, &&keys_provider, &&keys_provider, inbound_node_id, &channelmanager::provided_init_features(&outbound_node_config), &chan_open_channel_msg, 7, &inbound_node_config, 0, &&logger, 42).unwrap();
|
||||
|
||||
let expected_inbound_selected_chan_reserve = cmp::max(MIN_THEIR_CHAN_RESERVE_SATOSHIS, (chan.channel_value_satoshis as f64 * inbound_selected_channel_reserve_perc) as u64);
|
||||
|
||||
|
@ -7268,7 +7268,7 @@ mod tests {
|
|||
assert_eq!(chan_inbound_node.counterparty_selected_channel_reserve_satoshis.unwrap(), expected_outbound_selected_chan_reserve);
|
||||
} else {
|
||||
// Channel Negotiations failed
|
||||
let result = Channel::<EnforcingSigner>::new_from_req(&&fee_est, &&keys_provider, &&keys_provider, inbound_node_id, &channelmanager::provided_init_features(), &chan_open_channel_msg, 7, &inbound_node_config, 0, &&logger, 42);
|
||||
let result = Channel::<EnforcingSigner>::new_from_req(&&fee_est, &&keys_provider, &&keys_provider, inbound_node_id, &channelmanager::provided_init_features(&outbound_node_config), &chan_open_channel_msg, 7, &inbound_node_config, 0, &&logger, 42);
|
||||
assert!(result.is_err());
|
||||
}
|
||||
}
|
||||
|
@ -7285,7 +7285,7 @@ mod tests {
|
|||
// Create a channel.
|
||||
let node_b_node_id = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap());
|
||||
let config = UserConfig::default();
|
||||
let mut node_a_chan = Channel::<EnforcingSigner>::new_outbound(&feeest, &&keys_provider, &&keys_provider, node_b_node_id, &channelmanager::provided_init_features(), 10000000, 100000, 42, &config, 0, 42).unwrap();
|
||||
let mut node_a_chan = Channel::<EnforcingSigner>::new_outbound(&feeest, &&keys_provider, &&keys_provider, node_b_node_id, &channelmanager::provided_init_features(&config), 10000000, 100000, 42, &config, 0, 42).unwrap();
|
||||
assert!(node_a_chan.counterparty_forwarding_info.is_none());
|
||||
assert_eq!(node_a_chan.holder_htlc_minimum_msat, 1); // the default
|
||||
assert!(node_a_chan.counterparty_forwarding_info().is_none());
|
||||
|
@ -7364,7 +7364,7 @@ mod tests {
|
|||
let counterparty_node_id = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap());
|
||||
let mut config = UserConfig::default();
|
||||
config.channel_handshake_config.announced_channel = false;
|
||||
let mut chan = Channel::<InMemorySigner>::new_outbound(&LowerBoundedFeeEstimator::new(&feeest), &&keys_provider, &&keys_provider, counterparty_node_id, &channelmanager::provided_init_features(), 10_000_000, 100000, 42, &config, 0, 42).unwrap(); // Nothing uses their network key in this test
|
||||
let mut chan = Channel::<InMemorySigner>::new_outbound(&LowerBoundedFeeEstimator::new(&feeest), &&keys_provider, &&keys_provider, counterparty_node_id, &channelmanager::provided_init_features(&config), 10_000_000, 100000, 42, &config, 0, 42).unwrap(); // Nothing uses their network key in this test
|
||||
chan.holder_dust_limit_satoshis = 546;
|
||||
chan.counterparty_selected_channel_reserve_satoshis = Some(0); // Filled in in accept_channel
|
||||
|
||||
|
@ -8079,7 +8079,7 @@ mod tests {
|
|||
let node_b_node_id = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap());
|
||||
let config = UserConfig::default();
|
||||
let node_a_chan = Channel::<EnforcingSigner>::new_outbound(&feeest, &&keys_provider, &&keys_provider,
|
||||
node_b_node_id, &channelmanager::provided_init_features(), 10000000, 100000, 42, &config, 0, 42).unwrap();
|
||||
node_b_node_id, &channelmanager::provided_init_features(&config), 10000000, 100000, 42, &config, 0, 42).unwrap();
|
||||
|
||||
let mut channel_type_features = ChannelTypeFeatures::only_static_remote_key();
|
||||
channel_type_features.set_zero_conf_required();
|
||||
|
@ -8088,7 +8088,7 @@ mod tests {
|
|||
open_channel_msg.channel_type = Some(channel_type_features);
|
||||
let node_b_node_id = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[7; 32]).unwrap());
|
||||
let res = Channel::<EnforcingSigner>::new_from_req(&feeest, &&keys_provider, &&keys_provider,
|
||||
node_b_node_id, &channelmanager::provided_init_features(), &open_channel_msg, 7, &config, 0, &&logger, 42);
|
||||
node_b_node_id, &channelmanager::provided_init_features(&config), &open_channel_msg, 7, &config, 0, &&logger, 42);
|
||||
assert!(res.is_ok());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4057,7 +4057,7 @@ where
|
|||
return;
|
||||
}
|
||||
|
||||
let updates = channel.get_mut().monitor_updating_restored(&self.logger, self.get_our_node_id(), self.genesis_hash, self.best_block.read().unwrap().height());
|
||||
let updates = channel.get_mut().monitor_updating_restored(&self.logger, self.get_our_node_id(), self.genesis_hash, &self.default_configuration, self.best_block.read().unwrap().height());
|
||||
let channel_update = if updates.channel_ready.is_some() && channel.get().is_usable() {
|
||||
// We only send a channel_update in the case where we are just now sending a
|
||||
// channel_ready and the channel is in a usable state. We may re-send a
|
||||
|
@ -4395,7 +4395,7 @@ where
|
|||
match peer_state.channel_by_id.entry(msg.channel_id) {
|
||||
hash_map::Entry::Occupied(mut chan) => {
|
||||
let announcement_sigs_opt = try_chan_entry!(self, chan.get_mut().channel_ready(&msg, self.get_our_node_id(),
|
||||
self.genesis_hash.clone(), &self.best_block.read().unwrap(), &self.logger), chan);
|
||||
self.genesis_hash.clone(), &self.default_configuration, &self.best_block.read().unwrap(), &self.logger), chan);
|
||||
if let Some(announcement_sigs) = announcement_sigs_opt {
|
||||
log_trace!(self.logger, "Sending announcement_signatures for channel {}", log_bytes!(chan.get().channel_id()));
|
||||
peer_state.pending_msg_events.push(events::MessageSendEvent::SendAnnouncementSignatures {
|
||||
|
@ -4876,7 +4876,9 @@ where
|
|||
|
||||
peer_state.pending_msg_events.push(events::MessageSendEvent::BroadcastChannelAnnouncement {
|
||||
msg: try_chan_entry!(self, chan.get_mut().announcement_signatures(
|
||||
self.get_our_node_id(), self.genesis_hash.clone(), self.best_block.read().unwrap().height(), msg), chan),
|
||||
self.get_our_node_id(), self.genesis_hash.clone(),
|
||||
self.best_block.read().unwrap().height(), msg, &self.default_configuration
|
||||
), chan),
|
||||
// Note that announcement_signatures fails if the channel cannot be announced,
|
||||
// so get_channel_update_for_broadcast will never fail by the time we get here.
|
||||
update_msg: self.get_channel_update_for_broadcast(chan.get()).unwrap(),
|
||||
|
@ -4947,7 +4949,7 @@ where
|
|||
// add-HTLCs on disconnect, we may be handed HTLCs to fail backwards here.
|
||||
let responses = try_chan_entry!(self, chan.get_mut().channel_reestablish(
|
||||
msg, &self.logger, self.our_network_pubkey.clone(), self.genesis_hash,
|
||||
&*self.best_block.read().unwrap()), chan);
|
||||
&self.default_configuration, &*self.best_block.read().unwrap()), chan);
|
||||
let mut channel_update = None;
|
||||
if let Some(msg) = responses.shutdown_msg {
|
||||
peer_state.pending_msg_events.push(events::MessageSendEvent::SendShutdown {
|
||||
|
@ -5625,7 +5627,7 @@ where
|
|||
*best_block = BestBlock::new(header.prev_blockhash, new_height)
|
||||
}
|
||||
|
||||
self.do_chain_event(Some(new_height), |channel| channel.best_block_updated(new_height, header.time, self.genesis_hash.clone(), self.get_our_node_id(), &self.logger));
|
||||
self.do_chain_event(Some(new_height), |channel| channel.best_block_updated(new_height, header.time, self.genesis_hash.clone(), self.get_our_node_id(), self.default_configuration.clone(), &self.logger));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5649,13 +5651,13 @@ where
|
|||
log_trace!(self.logger, "{} transactions included in block {} at height {} provided", txdata.len(), block_hash, height);
|
||||
|
||||
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
|
||||
self.do_chain_event(Some(height), |channel| channel.transactions_confirmed(&block_hash, height, txdata, self.genesis_hash.clone(), self.get_our_node_id(), &self.logger)
|
||||
self.do_chain_event(Some(height), |channel| channel.transactions_confirmed(&block_hash, height, txdata, self.genesis_hash.clone(), self.get_our_node_id(), &self.default_configuration, &self.logger)
|
||||
.map(|(a, b)| (a, Vec::new(), b)));
|
||||
|
||||
let last_best_block_height = self.best_block.read().unwrap().height();
|
||||
if height < last_best_block_height {
|
||||
let timestamp = self.highest_seen_timestamp.load(Ordering::Acquire);
|
||||
self.do_chain_event(Some(last_best_block_height), |channel| channel.best_block_updated(last_best_block_height, timestamp as u32, self.genesis_hash.clone(), self.get_our_node_id(), &self.logger));
|
||||
self.do_chain_event(Some(last_best_block_height), |channel| channel.best_block_updated(last_best_block_height, timestamp as u32, self.genesis_hash.clone(), self.get_our_node_id(), self.default_configuration.clone(), &self.logger));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5671,7 +5673,7 @@ where
|
|||
|
||||
*self.best_block.write().unwrap() = BestBlock::new(block_hash, height);
|
||||
|
||||
self.do_chain_event(Some(height), |channel| channel.best_block_updated(height, header.time, self.genesis_hash.clone(), self.get_our_node_id(), &self.logger));
|
||||
self.do_chain_event(Some(height), |channel| channel.best_block_updated(height, header.time, self.genesis_hash.clone(), self.get_our_node_id(), self.default_configuration.clone(), &self.logger));
|
||||
|
||||
macro_rules! max_time {
|
||||
($timestamp: expr) => {
|
||||
|
@ -5782,7 +5784,7 @@ where
|
|||
msg: announcement_sigs,
|
||||
});
|
||||
if let Some(height) = height_opt {
|
||||
if let Some(announcement) = channel.get_signed_channel_announcement(self.get_our_node_id(), self.genesis_hash, height) {
|
||||
if let Some(announcement) = channel.get_signed_channel_announcement(self.get_our_node_id(), self.genesis_hash, height, &self.default_configuration) {
|
||||
pending_msg_events.push(events::MessageSendEvent::BroadcastChannelAnnouncement {
|
||||
msg: announcement,
|
||||
// Note that announcement_signatures fails if the channel cannot be announced,
|
||||
|
@ -5926,6 +5928,40 @@ where
|
|||
pub fn current_best_block(&self) -> BestBlock {
|
||||
self.best_block.read().unwrap().clone()
|
||||
}
|
||||
|
||||
/// Fetches the set of [`NodeFeatures`] flags which are provided by or required by
|
||||
/// [`ChannelManager`].
|
||||
pub fn node_features(&self) -> NodeFeatures {
|
||||
provided_node_features(&self.default_configuration)
|
||||
}
|
||||
|
||||
/// Fetches the set of [`InvoiceFeatures`] flags which are provided by or required by
|
||||
/// [`ChannelManager`].
|
||||
///
|
||||
/// Note that the invoice feature flags can vary depending on if the invoice is a "phantom invoice"
|
||||
/// or not. Thus, this method is not public.
|
||||
#[cfg(any(feature = "_test_utils", test))]
|
||||
pub fn invoice_features(&self) -> InvoiceFeatures {
|
||||
provided_invoice_features(&self.default_configuration)
|
||||
}
|
||||
|
||||
/// Fetches the set of [`ChannelFeatures`] flags which are provided by or required by
|
||||
/// [`ChannelManager`].
|
||||
pub fn channel_features(&self) -> ChannelFeatures {
|
||||
provided_channel_features(&self.default_configuration)
|
||||
}
|
||||
|
||||
/// Fetches the set of [`ChannelTypeFeatures`] flags which are provided by or required by
|
||||
/// [`ChannelManager`].
|
||||
pub fn channel_type_features(&self) -> ChannelTypeFeatures {
|
||||
provided_channel_type_features(&self.default_configuration)
|
||||
}
|
||||
|
||||
/// Fetches the set of [`InitFeatures`] flags which are provided by or required by
|
||||
/// [`ChannelManager`].
|
||||
pub fn init_features(&self) -> InitFeatures {
|
||||
provided_init_features(&self.default_configuration)
|
||||
}
|
||||
}
|
||||
|
||||
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, L: Deref>
|
||||
|
@ -6138,7 +6174,7 @@ where
|
|||
}
|
||||
} else { true };
|
||||
if retain && chan.get_counterparty_node_id() != *counterparty_node_id {
|
||||
if let Some(msg) = chan.get_signed_channel_announcement(self.get_our_node_id(), self.genesis_hash.clone(), self.best_block.read().unwrap().height()) {
|
||||
if let Some(msg) = chan.get_signed_channel_announcement(self.get_our_node_id(), self.genesis_hash.clone(), self.best_block.read().unwrap().height(), &self.default_configuration) {
|
||||
if let Ok(update_msg) = self.get_channel_update_for_broadcast(chan) {
|
||||
pending_msg_events.push(events::MessageSendEvent::SendChannelAnnouncement {
|
||||
node_id: *counterparty_node_id,
|
||||
|
@ -6195,18 +6231,18 @@ where
|
|||
}
|
||||
|
||||
fn provided_node_features(&self) -> NodeFeatures {
|
||||
provided_node_features()
|
||||
provided_node_features(&self.default_configuration)
|
||||
}
|
||||
|
||||
fn provided_init_features(&self, _their_init_features: &PublicKey) -> InitFeatures {
|
||||
provided_init_features()
|
||||
provided_init_features(&self.default_configuration)
|
||||
}
|
||||
}
|
||||
|
||||
/// Fetches the set of [`NodeFeatures`] flags which are provided by or required by
|
||||
/// [`ChannelManager`].
|
||||
pub fn provided_node_features() -> NodeFeatures {
|
||||
provided_init_features().to_context()
|
||||
pub(crate) fn provided_node_features(config: &UserConfig) -> NodeFeatures {
|
||||
provided_init_features(config).to_context()
|
||||
}
|
||||
|
||||
/// Fetches the set of [`InvoiceFeatures`] flags which are provided by or required by
|
||||
|
@ -6215,19 +6251,25 @@ pub fn provided_node_features() -> NodeFeatures {
|
|||
/// Note that the invoice feature flags can vary depending on if the invoice is a "phantom invoice"
|
||||
/// or not. Thus, this method is not public.
|
||||
#[cfg(any(feature = "_test_utils", test))]
|
||||
pub fn provided_invoice_features() -> InvoiceFeatures {
|
||||
provided_init_features().to_context()
|
||||
pub(crate) fn provided_invoice_features(config: &UserConfig) -> InvoiceFeatures {
|
||||
provided_init_features(config).to_context()
|
||||
}
|
||||
|
||||
/// Fetches the set of [`ChannelFeatures`] flags which are provided by or required by
|
||||
/// [`ChannelManager`].
|
||||
pub fn provided_channel_features() -> ChannelFeatures {
|
||||
provided_init_features().to_context()
|
||||
pub(crate) fn provided_channel_features(config: &UserConfig) -> ChannelFeatures {
|
||||
provided_init_features(config).to_context()
|
||||
}
|
||||
|
||||
/// Fetches the set of [`ChannelTypeFeatures`] flags which are provided by or required by
|
||||
/// [`ChannelManager`].
|
||||
pub(crate) fn provided_channel_type_features(config: &UserConfig) -> ChannelTypeFeatures {
|
||||
ChannelTypeFeatures::from_counterparty_init(&provided_init_features(config))
|
||||
}
|
||||
|
||||
/// Fetches the set of [`InitFeatures`] flags which are provided by or required by
|
||||
/// [`ChannelManager`].
|
||||
pub fn provided_init_features() -> InitFeatures {
|
||||
pub fn provided_init_features(_config: &UserConfig) -> InitFeatures {
|
||||
// Note that if new features are added here which other peers may (eventually) require, we
|
||||
// should also add the corresponding (optional) bit to the ChannelMessageHandler impl for
|
||||
// ErroringMessageHandler.
|
||||
|
@ -7508,7 +7550,7 @@ mod tests {
|
|||
use core::time::Duration;
|
||||
use core::sync::atomic::Ordering;
|
||||
use crate::ln::{PaymentPreimage, PaymentHash, PaymentSecret};
|
||||
use crate::ln::channelmanager::{self, inbound_payment, PaymentId, PaymentSendFailure, InterceptId};
|
||||
use crate::ln::channelmanager::{inbound_payment, PaymentId, PaymentSendFailure, InterceptId};
|
||||
use crate::ln::functional_test_utils::*;
|
||||
use crate::ln::msgs;
|
||||
use crate::ln::msgs::{ChannelMessageHandler, OptionalField};
|
||||
|
@ -7534,7 +7576,7 @@ mod tests {
|
|||
assert!(nodes[1].node.await_persistable_update_timeout(Duration::from_millis(1)));
|
||||
assert!(nodes[2].node.await_persistable_update_timeout(Duration::from_millis(1)));
|
||||
|
||||
let mut chan = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let mut chan = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
|
||||
// We check that the channel info nodes have doesn't change too early, even though we try
|
||||
// to connect messages with new values
|
||||
|
@ -7605,7 +7647,7 @@ mod tests {
|
|||
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
|
||||
// First, send a partial MPP payment.
|
||||
let (route, our_payment_hash, payment_preimage, payment_secret) = get_route_and_payment_hash!(&nodes[0], nodes[1], 100_000);
|
||||
|
@ -7727,7 +7769,7 @@ mod tests {
|
|||
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
let scorer = test_utils::TestScorer::with_penalty(0);
|
||||
let random_seed_bytes = chanmon_cfgs[1].keys_manager.get_secure_random_bytes();
|
||||
|
||||
|
@ -7825,10 +7867,10 @@ mod tests {
|
|||
|
||||
let payer_pubkey = nodes[0].node.get_our_node_id();
|
||||
let payee_pubkey = nodes[1].node.get_our_node_id();
|
||||
nodes[0].node.peer_connected(&payee_pubkey, &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&payer_pubkey, &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[0].node.peer_connected(&payee_pubkey, &msgs::Init { features: nodes[1].node.init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&payer_pubkey, &msgs::Init { features: nodes[0].node.init_features(), remote_network_address: None }).unwrap();
|
||||
|
||||
let _chan = create_chan_between_nodes(&nodes[0], &nodes[1], channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let _chan = create_chan_between_nodes(&nodes[0], &nodes[1]);
|
||||
let route_params = RouteParameters {
|
||||
payment_params: PaymentParameters::for_keysend(payee_pubkey),
|
||||
final_value_msat: 10_000,
|
||||
|
@ -7870,10 +7912,10 @@ mod tests {
|
|||
|
||||
let payer_pubkey = nodes[0].node.get_our_node_id();
|
||||
let payee_pubkey = nodes[1].node.get_our_node_id();
|
||||
nodes[0].node.peer_connected(&payee_pubkey, &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&payer_pubkey, &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[0].node.peer_connected(&payee_pubkey, &msgs::Init { features: nodes[1].node.init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&payer_pubkey, &msgs::Init { features: nodes[0].node.init_features(), remote_network_address: None }).unwrap();
|
||||
|
||||
let _chan = create_chan_between_nodes(&nodes[0], &nodes[1], channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let _chan = create_chan_between_nodes(&nodes[0], &nodes[1]);
|
||||
let route_params = RouteParameters {
|
||||
payment_params: PaymentParameters::for_keysend(payee_pubkey),
|
||||
final_value_msat: 10_000,
|
||||
|
@ -7913,10 +7955,10 @@ mod tests {
|
|||
let node_chanmgrs = create_node_chanmgrs(4, &node_cfgs, &[None, None, None, None]);
|
||||
let nodes = create_network(4, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan_1_id = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).0.contents.short_channel_id;
|
||||
let chan_2_id = create_announced_chan_between_nodes(&nodes, 0, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features()).0.contents.short_channel_id;
|
||||
let chan_3_id = create_announced_chan_between_nodes(&nodes, 1, 3, channelmanager::provided_init_features(), channelmanager::provided_init_features()).0.contents.short_channel_id;
|
||||
let chan_4_id = create_announced_chan_between_nodes(&nodes, 2, 3, channelmanager::provided_init_features(), channelmanager::provided_init_features()).0.contents.short_channel_id;
|
||||
let chan_1_id = create_announced_chan_between_nodes(&nodes, 0, 1).0.contents.short_channel_id;
|
||||
let chan_2_id = create_announced_chan_between_nodes(&nodes, 0, 2).0.contents.short_channel_id;
|
||||
let chan_3_id = create_announced_chan_between_nodes(&nodes, 1, 3).0.contents.short_channel_id;
|
||||
let chan_4_id = create_announced_chan_between_nodes(&nodes, 2, 3).0.contents.short_channel_id;
|
||||
|
||||
// Marshall an MPP route.
|
||||
let (mut route, payment_hash, _, _) = get_route_and_payment_hash!(&nodes[0], nodes[3], 100000);
|
||||
|
@ -7977,9 +8019,9 @@ mod tests {
|
|||
|
||||
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 1_000_000, 500_000_000, 42, None).unwrap();
|
||||
let open_channel = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
|
||||
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), channelmanager::provided_init_features(), &open_channel);
|
||||
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), nodes[0].node.init_features(), &open_channel);
|
||||
let accept_channel = get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id());
|
||||
nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), channelmanager::provided_init_features(), &accept_channel);
|
||||
nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), nodes[1].node.init_features(), &accept_channel);
|
||||
|
||||
let (temporary_channel_id, tx, _funding_output) = create_funding_transaction(&nodes[0], &nodes[1].node.get_our_node_id(), 1_000_000, 42);
|
||||
let channel_id = &tx.txid().into_inner();
|
||||
|
@ -8024,9 +8066,9 @@ mod tests {
|
|||
update_nodes_with_chan_announce(&nodes, 0, 1, &announcement, &nodes_0_update, &nodes_1_update);
|
||||
|
||||
nodes[0].node.close_channel(channel_id, &nodes[1].node.get_our_node_id()).unwrap();
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &channelmanager::provided_init_features(), &get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[1].node.get_our_node_id()));
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &nodes[0].node.init_features(), &get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[1].node.get_our_node_id()));
|
||||
let nodes_1_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &channelmanager::provided_init_features(), &nodes_1_shutdown);
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &nodes[1].node.init_features(), &nodes_1_shutdown);
|
||||
|
||||
let closing_signed_node_0 = get_event_msg!(nodes[0], MessageSendEvent::SendClosingSigned, nodes[1].node.get_our_node_id());
|
||||
nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &closing_signed_node_0);
|
||||
|
@ -8112,7 +8154,7 @@ mod tests {
|
|||
// creating dummy ones.
|
||||
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 1_000_000, 500_000_000, 42, None).unwrap();
|
||||
let open_channel_msg = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
|
||||
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), channelmanager::provided_init_features(), &open_channel_msg);
|
||||
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), nodes[0].node.init_features(), &open_channel_msg);
|
||||
let accept_channel_msg = get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id());
|
||||
|
||||
// Dummy values
|
||||
|
@ -8221,9 +8263,9 @@ mod tests {
|
|||
// Test the API functions and message handlers.
|
||||
check_not_connected_to_peer_error(nodes[0].node.create_channel(unkown_public_key, 1_000_000, 500_000_000, 42, None), unkown_public_key);
|
||||
|
||||
nodes[1].node.handle_open_channel(&unkown_public_key, channelmanager::provided_init_features(), &open_channel_msg);
|
||||
nodes[1].node.handle_open_channel(&unkown_public_key, nodes[0].node.init_features(), &open_channel_msg);
|
||||
|
||||
nodes[0].node.handle_accept_channel(&unkown_public_key, channelmanager::provided_init_features(), &accept_channel_msg);
|
||||
nodes[0].node.handle_accept_channel(&unkown_public_key, nodes[1].node.init_features(), &accept_channel_msg);
|
||||
|
||||
check_unkown_peer_error(nodes[0].node.accept_inbound_channel(&open_channel_msg.temporary_channel_id, &unkown_public_key, 42), unkown_public_key);
|
||||
|
||||
|
@ -8245,7 +8287,7 @@ mod tests {
|
|||
|
||||
check_unkown_peer_error(nodes[0].node.update_channel_config(&unkown_public_key, &[channel_id], &ChannelConfig::default()), unkown_public_key);
|
||||
|
||||
nodes[0].node.handle_shutdown(&unkown_public_key, &channelmanager::provided_init_features(), &shutdown_msg);
|
||||
nodes[0].node.handle_shutdown(&unkown_public_key, &nodes[1].node.init_features(), &shutdown_msg);
|
||||
|
||||
nodes[1].node.handle_closing_signed(&unkown_public_key, &closing_signed_msg);
|
||||
|
||||
|
@ -8339,11 +8381,11 @@ pub mod bench {
|
|||
});
|
||||
let node_b_holder = NodeHolder { node: &node_b };
|
||||
|
||||
node_a.peer_connected(&node_b.get_our_node_id(), &Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
node_b.peer_connected(&node_a.get_our_node_id(), &Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
node_a.peer_connected(&node_b.get_our_node_id(), &Init { features: node_b.init_features(), remote_network_address: None }).unwrap();
|
||||
node_b.peer_connected(&node_a.get_our_node_id(), &Init { features: node_a.init_features(), remote_network_address: None }).unwrap();
|
||||
node_a.create_channel(node_b.get_our_node_id(), 8_000_000, 100_000_000, 42, None).unwrap();
|
||||
node_b.handle_open_channel(&node_a.get_our_node_id(), channelmanager::provided_init_features(), &get_event_msg!(node_a_holder, MessageSendEvent::SendOpenChannel, node_b.get_our_node_id()));
|
||||
node_a.handle_accept_channel(&node_b.get_our_node_id(), channelmanager::provided_init_features(), &get_event_msg!(node_b_holder, MessageSendEvent::SendAcceptChannel, node_a.get_our_node_id()));
|
||||
node_b.handle_open_channel(&node_a.get_our_node_id(), node_a.init_features(), &get_event_msg!(node_a_holder, MessageSendEvent::SendOpenChannel, node_b.get_our_node_id()));
|
||||
node_a.handle_accept_channel(&node_b.get_our_node_id(), node_b.init_features(), &get_event_msg!(node_b_holder, MessageSendEvent::SendAcceptChannel, node_a.get_our_node_id()));
|
||||
|
||||
let tx;
|
||||
if let Event::FundingGenerationReady { temporary_channel_id, output_script, .. } = get_event!(node_a_holder, Event::FundingGenerationReady) {
|
||||
|
@ -8405,7 +8447,7 @@ pub mod bench {
|
|||
($node_a: expr, $node_b: expr) => {
|
||||
let usable_channels = $node_a.list_usable_channels();
|
||||
let payment_params = PaymentParameters::from_node_id($node_b.get_our_node_id())
|
||||
.with_features(channelmanager::provided_invoice_features());
|
||||
.with_features($node_b.invoice_features());
|
||||
let scorer = test_utils::TestScorer::with_penalty(0);
|
||||
let seed = [3u8; 32];
|
||||
let keys_manager = KeysManager::new(&seed, 42, 42);
|
||||
|
|
|
@ -14,7 +14,7 @@ use crate::chain::{BestBlock, ChannelMonitorUpdateStatus, Confirm, Listen, Watch
|
|||
use crate::chain::channelmonitor::ChannelMonitor;
|
||||
use crate::chain::transaction::OutPoint;
|
||||
use crate::ln::{PaymentPreimage, PaymentHash, PaymentSecret};
|
||||
use crate::ln::channelmanager::{self, ChainParameters, ChannelManager, ChannelManagerReadArgs, RAACommitmentOrder, PaymentSendFailure, PaymentId, MIN_CLTV_EXPIRY_DELTA};
|
||||
use crate::ln::channelmanager::{ChainParameters, ChannelManager, ChannelManagerReadArgs, RAACommitmentOrder, PaymentSendFailure, PaymentId, MIN_CLTV_EXPIRY_DELTA};
|
||||
use crate::routing::gossip::{P2PGossipSync, NetworkGraph, NetworkUpdate};
|
||||
use crate::routing::router::{PaymentParameters, Route, get_route};
|
||||
use crate::ln::features::InitFeatures;
|
||||
|
@ -307,7 +307,7 @@ pub struct NodeCfg<'a> {
|
|||
pub logger: &'a test_utils::TestLogger,
|
||||
pub network_graph: Arc<NetworkGraph<&'a test_utils::TestLogger>>,
|
||||
pub node_seed: [u8; 32],
|
||||
pub features: InitFeatures,
|
||||
pub override_init_features: Rc<RefCell<Option<InitFeatures>>>,
|
||||
}
|
||||
|
||||
pub struct Node<'a, 'b: 'a, 'c: 'b> {
|
||||
|
@ -326,6 +326,7 @@ pub struct Node<'a, 'b: 'a, 'c: 'b> {
|
|||
pub logger: &'c test_utils::TestLogger,
|
||||
pub blocks: Arc<Mutex<Vec<(Block, u32)>>>,
|
||||
pub connect_style: Rc<RefCell<ConnectStyle>>,
|
||||
pub override_init_features: Rc<RefCell<Option<InitFeatures>>>,
|
||||
}
|
||||
impl<'a, 'b, 'c> Node<'a, 'b, 'c> {
|
||||
pub fn best_block_hash(&self) -> BlockHash {
|
||||
|
@ -446,12 +447,12 @@ impl<'a, 'b, 'c> Drop for Node<'a, 'b, 'c> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn create_chan_between_nodes<'a, 'b, 'c, 'd>(node_a: &'a Node<'b, 'c, 'd>, node_b: &'a Node<'b, 'c, 'd>, a_flags: InitFeatures, b_flags: InitFeatures) -> (msgs::ChannelAnnouncement, msgs::ChannelUpdate, msgs::ChannelUpdate, [u8; 32], Transaction) {
|
||||
create_chan_between_nodes_with_value(node_a, node_b, 100000, 10001, a_flags, b_flags)
|
||||
pub fn create_chan_between_nodes<'a, 'b, 'c, 'd>(node_a: &'a Node<'b, 'c, 'd>, node_b: &'a Node<'b, 'c, 'd>) -> (msgs::ChannelAnnouncement, msgs::ChannelUpdate, msgs::ChannelUpdate, [u8; 32], Transaction) {
|
||||
create_chan_between_nodes_with_value(node_a, node_b, 100000, 10001)
|
||||
}
|
||||
|
||||
pub fn create_chan_between_nodes_with_value<'a, 'b, 'c, 'd>(node_a: &'a Node<'b, 'c, 'd>, node_b: &'a Node<'b, 'c, 'd>, channel_value: u64, push_msat: u64, a_flags: InitFeatures, b_flags: InitFeatures) -> (msgs::ChannelAnnouncement, msgs::ChannelUpdate, msgs::ChannelUpdate, [u8; 32], Transaction) {
|
||||
let (channel_ready, channel_id, tx) = create_chan_between_nodes_with_value_a(node_a, node_b, channel_value, push_msat, a_flags, b_flags);
|
||||
pub fn create_chan_between_nodes_with_value<'a, 'b, 'c, 'd>(node_a: &'a Node<'b, 'c, 'd>, node_b: &'a Node<'b, 'c, 'd>, channel_value: u64, push_msat: u64) -> (msgs::ChannelAnnouncement, msgs::ChannelUpdate, msgs::ChannelUpdate, [u8; 32], Transaction) {
|
||||
let (channel_ready, channel_id, tx) = create_chan_between_nodes_with_value_a(node_a, node_b, channel_value, push_msat);
|
||||
let (announcement, as_update, bs_update) = create_chan_between_nodes_with_value_b(node_a, node_b, &channel_ready);
|
||||
(announcement, as_update, bs_update, channel_id, tx)
|
||||
}
|
||||
|
@ -867,7 +868,7 @@ pub fn open_zero_conf_channel<'a, 'b, 'c, 'd>(initiator: &'a Node<'b, 'c, 'd>, r
|
|||
initiator.node.create_channel(receiver.node.get_our_node_id(), 100_000, 10_001, 42, initiator_config).unwrap();
|
||||
let open_channel = get_event_msg!(initiator, MessageSendEvent::SendOpenChannel, receiver.node.get_our_node_id());
|
||||
|
||||
receiver.node.handle_open_channel(&initiator.node.get_our_node_id(), channelmanager::provided_init_features(), &open_channel);
|
||||
receiver.node.handle_open_channel(&initiator.node.get_our_node_id(), initiator.node.init_features(), &open_channel);
|
||||
let events = receiver.node.get_and_clear_pending_events();
|
||||
assert_eq!(events.len(), 1);
|
||||
match events[0] {
|
||||
|
@ -879,7 +880,7 @@ pub fn open_zero_conf_channel<'a, 'b, 'c, 'd>(initiator: &'a Node<'b, 'c, 'd>, r
|
|||
|
||||
let accept_channel = get_event_msg!(receiver, MessageSendEvent::SendAcceptChannel, initiator.node.get_our_node_id());
|
||||
assert_eq!(accept_channel.minimum_depth, 0);
|
||||
initiator.node.handle_accept_channel(&receiver.node.get_our_node_id(), channelmanager::provided_init_features(), &accept_channel);
|
||||
initiator.node.handle_accept_channel(&receiver.node.get_our_node_id(), receiver.node.init_features(), &accept_channel);
|
||||
|
||||
let (temporary_channel_id, tx, _) = create_funding_transaction(&initiator, &receiver.node.get_our_node_id(), 100_000, 42);
|
||||
initiator.node.funding_transaction_generated(&temporary_channel_id, &receiver.node.get_our_node_id(), tx.clone()).unwrap();
|
||||
|
@ -928,11 +929,13 @@ pub fn open_zero_conf_channel<'a, 'b, 'c, 'd>(initiator: &'a Node<'b, 'c, 'd>, r
|
|||
(tx, as_channel_ready.channel_id)
|
||||
}
|
||||
|
||||
pub fn create_chan_between_nodes_with_value_init<'a, 'b, 'c>(node_a: &Node<'a, 'b, 'c>, node_b: &Node<'a, 'b, 'c>, channel_value: u64, push_msat: u64, a_flags: InitFeatures, b_flags: InitFeatures) -> Transaction {
|
||||
pub fn create_chan_between_nodes_with_value_init<'a, 'b, 'c>(node_a: &Node<'a, 'b, 'c>, node_b: &Node<'a, 'b, 'c>, channel_value: u64, push_msat: u64) -> Transaction {
|
||||
let create_chan_id = node_a.node.create_channel(node_b.node.get_our_node_id(), channel_value, push_msat, 42, None).unwrap();
|
||||
let open_channel_msg = get_event_msg!(node_a, MessageSendEvent::SendOpenChannel, node_b.node.get_our_node_id());
|
||||
assert_eq!(open_channel_msg.temporary_channel_id, create_chan_id);
|
||||
assert_eq!(node_a.node.list_channels().iter().find(|channel| channel.channel_id == create_chan_id).unwrap().user_channel_id, 42);
|
||||
let a_flags = node_a.override_init_features.borrow().clone().unwrap_or_else(|| node_a.node.init_features());
|
||||
let b_flags = node_b.override_init_features.borrow().clone().unwrap_or_else(|| node_b.node.init_features());
|
||||
node_b.node.handle_open_channel(&node_a.node.get_our_node_id(), a_flags, &open_channel_msg);
|
||||
let accept_channel_msg = get_event_msg!(node_b, MessageSendEvent::SendAcceptChannel, node_a.node.get_our_node_id());
|
||||
assert_eq!(accept_channel_msg.temporary_channel_id, create_chan_id);
|
||||
|
@ -984,8 +987,8 @@ pub fn create_chan_between_nodes_with_value_confirm<'a, 'b, 'c, 'd>(node_a: &'a
|
|||
create_chan_between_nodes_with_value_confirm_second(node_b, node_a)
|
||||
}
|
||||
|
||||
pub fn create_chan_between_nodes_with_value_a<'a, 'b, 'c, 'd>(node_a: &'a Node<'b, 'c, 'd>, node_b: &'a Node<'b, 'c, 'd>, channel_value: u64, push_msat: u64, a_flags: InitFeatures, b_flags: InitFeatures) -> ((msgs::ChannelReady, msgs::AnnouncementSignatures), [u8; 32], Transaction) {
|
||||
let tx = create_chan_between_nodes_with_value_init(node_a, node_b, channel_value, push_msat, a_flags, b_flags);
|
||||
pub fn create_chan_between_nodes_with_value_a<'a, 'b, 'c, 'd>(node_a: &'a Node<'b, 'c, 'd>, node_b: &'a Node<'b, 'c, 'd>, channel_value: u64, push_msat: u64) -> ((msgs::ChannelReady, msgs::AnnouncementSignatures), [u8; 32], Transaction) {
|
||||
let tx = create_chan_between_nodes_with_value_init(node_a, node_b, channel_value, push_msat);
|
||||
let (msgs, chan_id) = create_chan_between_nodes_with_value_confirm(node_a, node_b, &tx);
|
||||
(msgs, chan_id, tx)
|
||||
}
|
||||
|
@ -1023,21 +1026,23 @@ pub fn create_chan_between_nodes_with_value_b<'a, 'b, 'c>(node_a: &Node<'a, 'b,
|
|||
((*announcement).clone(), (*as_update).clone(), (*bs_update).clone())
|
||||
}
|
||||
|
||||
pub fn create_announced_chan_between_nodes<'a, 'b, 'c, 'd>(nodes: &'a Vec<Node<'b, 'c, 'd>>, a: usize, b: usize, a_flags: InitFeatures, b_flags: InitFeatures) -> (msgs::ChannelUpdate, msgs::ChannelUpdate, [u8; 32], Transaction) {
|
||||
create_announced_chan_between_nodes_with_value(nodes, a, b, 100000, 10001, a_flags, b_flags)
|
||||
pub fn create_announced_chan_between_nodes<'a, 'b, 'c, 'd>(nodes: &'a Vec<Node<'b, 'c, 'd>>, a: usize, b: usize) -> (msgs::ChannelUpdate, msgs::ChannelUpdate, [u8; 32], Transaction) {
|
||||
create_announced_chan_between_nodes_with_value(nodes, a, b, 100000, 10001)
|
||||
}
|
||||
|
||||
pub fn create_announced_chan_between_nodes_with_value<'a, 'b, 'c, 'd>(nodes: &'a Vec<Node<'b, 'c, 'd>>, a: usize, b: usize, channel_value: u64, push_msat: u64, a_flags: InitFeatures, b_flags: InitFeatures) -> (msgs::ChannelUpdate, msgs::ChannelUpdate, [u8; 32], Transaction) {
|
||||
let chan_announcement = create_chan_between_nodes_with_value(&nodes[a], &nodes[b], channel_value, push_msat, a_flags, b_flags);
|
||||
pub fn create_announced_chan_between_nodes_with_value<'a, 'b, 'c, 'd>(nodes: &'a Vec<Node<'b, 'c, 'd>>, a: usize, b: usize, channel_value: u64, push_msat: u64) -> (msgs::ChannelUpdate, msgs::ChannelUpdate, [u8; 32], Transaction) {
|
||||
let chan_announcement = create_chan_between_nodes_with_value(&nodes[a], &nodes[b], channel_value, push_msat);
|
||||
update_nodes_with_chan_announce(nodes, a, b, &chan_announcement.0, &chan_announcement.1, &chan_announcement.2);
|
||||
(chan_announcement.1, chan_announcement.2, chan_announcement.3, chan_announcement.4)
|
||||
}
|
||||
|
||||
pub fn create_unannounced_chan_between_nodes_with_value<'a, 'b, 'c, 'd>(nodes: &'a Vec<Node<'b, 'c, 'd>>, a: usize, b: usize, channel_value: u64, push_msat: u64, a_flags: InitFeatures, b_flags: InitFeatures) -> (msgs::ChannelReady, Transaction) {
|
||||
pub fn create_unannounced_chan_between_nodes_with_value<'a, 'b, 'c, 'd>(nodes: &'a Vec<Node<'b, 'c, 'd>>, a: usize, b: usize, channel_value: u64, push_msat: u64) -> (msgs::ChannelReady, Transaction) {
|
||||
let mut no_announce_cfg = test_default_channel_config();
|
||||
no_announce_cfg.channel_handshake_config.announced_channel = false;
|
||||
nodes[a].node.create_channel(nodes[b].node.get_our_node_id(), channel_value, push_msat, 42, Some(no_announce_cfg)).unwrap();
|
||||
let open_channel = get_event_msg!(nodes[a], MessageSendEvent::SendOpenChannel, nodes[b].node.get_our_node_id());
|
||||
let a_flags = nodes[a].override_init_features.borrow().clone().unwrap_or_else(|| nodes[a].node.init_features());
|
||||
let b_flags = nodes[b].override_init_features.borrow().clone().unwrap_or_else(|| nodes[b].node.init_features());
|
||||
nodes[b].node.handle_open_channel(&nodes[a].node.get_our_node_id(), a_flags, &open_channel);
|
||||
let accept_channel = get_event_msg!(nodes[b], MessageSendEvent::SendAcceptChannel, nodes[a].node.get_our_node_id());
|
||||
nodes[a].node.handle_accept_channel(&nodes[b].node.get_our_node_id(), b_flags, &accept_channel);
|
||||
|
@ -1241,7 +1246,7 @@ pub fn close_channel<'a, 'b, 'c>(outbound_node: &Node<'a, 'b, 'c>, inbound_node:
|
|||
let (tx_a, tx_b);
|
||||
|
||||
node_a.close_channel(channel_id, &node_b.get_our_node_id()).unwrap();
|
||||
node_b.handle_shutdown(&node_a.get_our_node_id(), &channelmanager::provided_init_features(), &get_event_msg!(struct_a, MessageSendEvent::SendShutdown, node_b.get_our_node_id()));
|
||||
node_b.handle_shutdown(&node_a.get_our_node_id(), &node_a.init_features(), &get_event_msg!(struct_a, MessageSendEvent::SendShutdown, node_b.get_our_node_id()));
|
||||
|
||||
let events_1 = node_b.get_and_clear_pending_msg_events();
|
||||
assert!(events_1.len() >= 1);
|
||||
|
@ -1266,7 +1271,7 @@ pub fn close_channel<'a, 'b, 'c>(outbound_node: &Node<'a, 'b, 'c>, inbound_node:
|
|||
})
|
||||
};
|
||||
|
||||
node_a.handle_shutdown(&node_b.get_our_node_id(), &channelmanager::provided_init_features(), &shutdown_b);
|
||||
node_a.handle_shutdown(&node_b.get_our_node_id(), &node_b.init_features(), &shutdown_b);
|
||||
let (as_update, bs_update) = if close_inbound_first {
|
||||
assert!(node_a.get_and_clear_pending_msg_events().is_empty());
|
||||
node_a.handle_closing_signed(&node_b.get_our_node_id(), &closing_signed_b.unwrap());
|
||||
|
@ -1469,7 +1474,7 @@ macro_rules! get_route {
|
|||
macro_rules! get_route_and_payment_hash {
|
||||
($send_node: expr, $recv_node: expr, $recv_value: expr) => {{
|
||||
let payment_params = $crate::routing::router::PaymentParameters::from_node_id($recv_node.node.get_our_node_id())
|
||||
.with_features($crate::ln::channelmanager::provided_invoice_features());
|
||||
.with_features($recv_node.node.invoice_features());
|
||||
$crate::get_route_and_payment_hash!($send_node, $recv_node, payment_params, $recv_value, TEST_FINAL_CLTV)
|
||||
}};
|
||||
($send_node: expr, $recv_node: expr, $payment_params: expr, $recv_value: expr, $cltv: expr) => {{
|
||||
|
@ -2081,7 +2086,7 @@ pub const TEST_FINAL_CLTV: u32 = 70;
|
|||
|
||||
pub fn route_payment<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_route: &[&Node<'a, 'b, 'c>], recv_value: u64) -> (PaymentPreimage, PaymentHash, PaymentSecret) {
|
||||
let payment_params = PaymentParameters::from_node_id(expected_route.last().unwrap().node.get_our_node_id())
|
||||
.with_features(channelmanager::provided_invoice_features());
|
||||
.with_features(expected_route.last().unwrap().node.invoice_features());
|
||||
let route = get_route!(origin_node, payment_params, recv_value, TEST_FINAL_CLTV).unwrap();
|
||||
assert_eq!(route.paths.len(), 1);
|
||||
assert_eq!(route.paths[0].len(), expected_route.len());
|
||||
|
@ -2095,7 +2100,7 @@ pub fn route_payment<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_route:
|
|||
|
||||
pub fn route_over_limit<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_route: &[&Node<'a, 'b, 'c>], recv_value: u64) {
|
||||
let payment_params = PaymentParameters::from_node_id(expected_route.last().unwrap().node.get_our_node_id())
|
||||
.with_features(channelmanager::provided_invoice_features());
|
||||
.with_features(expected_route.last().unwrap().node.invoice_features());
|
||||
let network_graph = origin_node.network_graph.read_only();
|
||||
let scorer = test_utils::TestScorer::with_penalty(0);
|
||||
let seed = [0u8; 32];
|
||||
|
@ -2285,8 +2290,8 @@ pub fn create_node_cfgs<'a>(node_count: usize, chanmon_cfgs: &'a Vec<TestChanMon
|
|||
chain_monitor,
|
||||
keys_manager: &chanmon_cfgs[i].keys_manager,
|
||||
node_seed: seed,
|
||||
features: channelmanager::provided_init_features(),
|
||||
network_graph,
|
||||
override_init_features: Rc::new(RefCell::new(None)),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -2342,13 +2347,14 @@ pub fn create_network<'a, 'b: 'a, 'c: 'b>(node_count: usize, cfgs: &'b Vec<NodeC
|
|||
network_payment_count: payment_count.clone(), logger: cfgs[i].logger,
|
||||
blocks: Arc::clone(&cfgs[i].tx_broadcaster.blocks),
|
||||
connect_style: Rc::clone(&connect_style),
|
||||
override_init_features: Rc::clone(&cfgs[i].override_init_features),
|
||||
})
|
||||
}
|
||||
|
||||
for i in 0..node_count {
|
||||
for j in (i+1)..node_count {
|
||||
nodes[i].node.peer_connected(&nodes[j].node.get_our_node_id(), &msgs::Init { features: cfgs[j].features.clone(), remote_network_address: None }).unwrap();
|
||||
nodes[j].node.peer_connected(&nodes[i].node.get_our_node_id(), &msgs::Init { features: cfgs[i].features.clone(), remote_network_address: None }).unwrap();
|
||||
nodes[i].node.peer_connected(&nodes[j].node.get_our_node_id(), &msgs::Init { features: nodes[j].override_init_features.borrow().clone().unwrap_or_else(|| nodes[j].node.init_features()), remote_network_address: None }).unwrap();
|
||||
nodes[j].node.peer_connected(&nodes[i].node.get_our_node_id(), &msgs::Init { features: nodes[i].override_init_features.borrow().clone().unwrap_or_else(|| nodes[i].node.init_features()), remote_network_address: None }).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2631,9 +2637,9 @@ macro_rules! handle_chan_reestablish_msgs {
|
|||
/// pending_htlc_adds includes both the holding cell and in-flight update_add_htlcs, whereas
|
||||
/// for claims/fails they are separated out.
|
||||
pub fn reconnect_nodes<'a, 'b, 'c>(node_a: &Node<'a, 'b, 'c>, node_b: &Node<'a, 'b, 'c>, send_channel_ready: (bool, bool), pending_htlc_adds: (i64, i64), pending_htlc_claims: (usize, usize), pending_htlc_fails: (usize, usize), pending_cell_htlc_claims: (usize, usize), pending_cell_htlc_fails: (usize, usize), pending_raa: (bool, bool)) {
|
||||
node_a.node.peer_connected(&node_b.node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
node_a.node.peer_connected(&node_b.node.get_our_node_id(), &msgs::Init { features: node_b.node.init_features(), remote_network_address: None }).unwrap();
|
||||
let reestablish_1 = get_chan_reestablish_msgs!(node_a, node_b);
|
||||
node_b.node.peer_connected(&node_a.node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
node_b.node.peer_connected(&node_a.node.get_our_node_id(), &msgs::Init { features: node_a.node.init_features(), remote_network_address: None }).unwrap();
|
||||
let reestablish_2 = get_chan_reestablish_msgs!(node_b, node_a);
|
||||
|
||||
if send_channel_ready.0 {
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -13,7 +13,7 @@ use crate::chain::channelmonitor::{ANTI_REORG_DELAY, Balance};
|
|||
use crate::chain::transaction::OutPoint;
|
||||
use crate::chain::chaininterface::LowerBoundedFeeEstimator;
|
||||
use crate::ln::channel;
|
||||
use crate::ln::channelmanager::{self, BREAKDOWN_TIMEOUT, PaymentId};
|
||||
use crate::ln::channelmanager::{BREAKDOWN_TIMEOUT, PaymentId};
|
||||
use crate::ln::msgs::ChannelMessageHandler;
|
||||
use crate::util::events::{Event, MessageSendEvent, MessageSendEventsProvider, ClosureReason, HTLCDestination};
|
||||
|
||||
|
@ -48,8 +48,8 @@ fn chanmon_fail_from_stale_commitment() {
|
|||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let (update_a, _, chan_id_2, _) = create_announced_chan_between_nodes(&nodes, 1, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
let (update_a, _, chan_id_2, _) = create_announced_chan_between_nodes(&nodes, 1, 2);
|
||||
|
||||
let (route, payment_hash, _, payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[2], 1_000_000);
|
||||
nodes[0].node.send_payment(&route, payment_hash, &Some(payment_secret), PaymentId(payment_hash.0)).unwrap();
|
||||
|
@ -105,7 +105,7 @@ fn revoked_output_htlc_resolution_timing() {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 500_000_000, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 500_000_000);
|
||||
|
||||
let payment_hash_1 = route_payment(&nodes[1], &[&nodes[0]], 1_000_000).1;
|
||||
|
||||
|
@ -154,7 +154,7 @@ fn chanmon_claim_value_coop_close() {
|
|||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let (_, _, chan_id, funding_tx) =
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 1_000_000, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 1_000_000);
|
||||
let funding_outpoint = OutPoint { txid: funding_tx.txid(), index: 0 };
|
||||
assert_eq!(funding_outpoint.to_channel_id(), chan_id);
|
||||
|
||||
|
@ -170,9 +170,9 @@ fn chanmon_claim_value_coop_close() {
|
|||
|
||||
nodes[0].node.close_channel(&chan_id, &nodes[1].node.get_our_node_id()).unwrap();
|
||||
let node_0_shutdown = get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[1].node.get_our_node_id());
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_0_shutdown);
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &nodes[0].node.init_features(), &node_0_shutdown);
|
||||
let node_1_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_1_shutdown);
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &nodes[1].node.init_features(), &node_1_shutdown);
|
||||
|
||||
let node_0_closing_signed = get_event_msg!(nodes[0], MessageSendEvent::SendClosingSigned, nodes[1].node.get_our_node_id());
|
||||
nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_closing_signed);
|
||||
|
@ -255,7 +255,7 @@ fn do_test_claim_value_force_close(prev_commitment_tx: bool) {
|
|||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let (_, _, chan_id, funding_tx) =
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 1_000_000, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 1_000_000);
|
||||
let funding_outpoint = OutPoint { txid: funding_tx.txid(), index: 0 };
|
||||
assert_eq!(funding_outpoint.to_channel_id(), chan_id);
|
||||
|
||||
|
@ -594,7 +594,7 @@ fn test_balances_on_local_commitment_htlcs() {
|
|||
|
||||
// Create a single channel with two pending HTLCs from nodes[0] to nodes[1], one which nodes[1]
|
||||
// knows the preimage for, one which it does not.
|
||||
let (_, _, chan_id, funding_tx) = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let (_, _, chan_id, funding_tx) = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 0);
|
||||
let funding_outpoint = OutPoint { txid: funding_tx.txid(), index: 0 };
|
||||
|
||||
let (route, payment_hash, _, payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[1], 10_000_000);
|
||||
|
@ -768,7 +768,7 @@ fn test_no_preimage_inbound_htlc_balances() {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let (_, _, chan_id, funding_tx) = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 500_000_000, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let (_, _, chan_id, funding_tx) = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 500_000_000);
|
||||
let funding_outpoint = OutPoint { txid: funding_tx.txid(), index: 0 };
|
||||
|
||||
// Send two HTLCs, one from A to B, and one from B to A.
|
||||
|
@ -1021,7 +1021,7 @@ fn do_test_revoked_counterparty_commitment_balances(confirm_htlc_spend_first: bo
|
|||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let (_, _, chan_id, funding_tx) =
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 100_000_000, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 100_000_000);
|
||||
let funding_outpoint = OutPoint { txid: funding_tx.txid(), index: 0 };
|
||||
assert_eq!(funding_outpoint.to_channel_id(), chan_id);
|
||||
|
||||
|
@ -1273,7 +1273,7 @@ fn test_revoked_counterparty_htlc_tx_balances() {
|
|||
|
||||
// Create some initial channels
|
||||
let (_, _, chan_id, funding_tx) =
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 11_000_000, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 11_000_000);
|
||||
let funding_outpoint = OutPoint { txid: funding_tx.txid(), index: 0 };
|
||||
assert_eq!(funding_outpoint.to_channel_id(), chan_id);
|
||||
|
||||
|
@ -1483,7 +1483,7 @@ fn test_revoked_counterparty_aggregated_claims() {
|
|||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let (_, _, chan_id, funding_tx) =
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 100_000_000, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 100_000_000);
|
||||
let funding_outpoint = OutPoint { txid: funding_tx.txid(), index: 0 };
|
||||
assert_eq!(funding_outpoint.to_channel_id(), chan_id);
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ use crate::chain::channelmonitor::{CLTV_CLAIM_BUFFER, LATENCY_GRACE_PERIOD_BLOCK
|
|||
use crate::chain::keysinterface::{EntropySource, NodeSigner, Recipient};
|
||||
use crate::ln::{PaymentHash, PaymentSecret};
|
||||
use crate::ln::channel::EXPIRE_PREV_CONFIG_TICKS;
|
||||
use crate::ln::channelmanager::{self, HTLCForwardInfo, CLTV_FAR_FAR_AWAY, MIN_CLTV_EXPIRY_DELTA, PendingAddHTLCInfo, PendingHTLCInfo, PendingHTLCRouting, PaymentId};
|
||||
use crate::ln::channelmanager::{HTLCForwardInfo, CLTV_FAR_FAR_AWAY, MIN_CLTV_EXPIRY_DELTA, PendingAddHTLCInfo, PendingHTLCInfo, PendingHTLCRouting, PaymentId};
|
||||
use crate::ln::onion_utils;
|
||||
use crate::routing::gossip::{NetworkUpdate, RoutingFees};
|
||||
use crate::routing::router::{get_route, PaymentParameters, Route, RouteHint, RouteHintHop};
|
||||
|
@ -281,7 +281,7 @@ fn test_fee_failures() {
|
|||
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[Some(config), Some(config), Some(config)]);
|
||||
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
let channels = [create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()), create_announced_chan_between_nodes(&nodes, 1, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features())];
|
||||
let channels = [create_announced_chan_between_nodes(&nodes, 0, 1), create_announced_chan_between_nodes(&nodes, 1, 2)];
|
||||
|
||||
// positive case
|
||||
let (route, payment_hash_success, payment_preimage_success, payment_secret_success) = get_route_and_payment_hash!(nodes[0], nodes[2], 40_000);
|
||||
|
@ -333,7 +333,7 @@ fn test_onion_failure() {
|
|||
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[Some(config), Some(config), Some(node_2_cfg)]);
|
||||
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
let channels = [create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()), create_announced_chan_between_nodes(&nodes, 1, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features())];
|
||||
let channels = [create_announced_chan_between_nodes(&nodes, 0, 1), create_announced_chan_between_nodes(&nodes, 1, 2)];
|
||||
for node in nodes.iter() {
|
||||
*node.keys_manager.override_random_bytes.lock().unwrap() = Some([3; 32]);
|
||||
}
|
||||
|
@ -623,16 +623,16 @@ fn do_test_onion_failure_stale_channel_update(announced_channel: bool) {
|
|||
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let other_channel = create_chan_between_nodes(
|
||||
&nodes[0], &nodes[1], channelmanager::provided_init_features(), channelmanager::provided_init_features(),
|
||||
&nodes[0], &nodes[1],
|
||||
);
|
||||
let channel_to_update = if announced_channel {
|
||||
let channel = create_announced_chan_between_nodes(
|
||||
&nodes, 1, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features(),
|
||||
&nodes, 1, 2,
|
||||
);
|
||||
(channel.2, channel.0.contents.short_channel_id)
|
||||
} else {
|
||||
let channel = create_unannounced_chan_between_nodes_with_value(
|
||||
&nodes, 1, 2, 100000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features(),
|
||||
&nodes, 1, 2, 100000, 10001,
|
||||
);
|
||||
(channel.0.channel_id, channel.0.short_channel_id_alias.unwrap())
|
||||
};
|
||||
|
@ -657,7 +657,7 @@ fn do_test_onion_failure_stale_channel_update(announced_channel: bool) {
|
|||
htlc_minimum_msat: None,
|
||||
}])];
|
||||
let payment_params = PaymentParameters::from_node_id(*channel_to_update_counterparty)
|
||||
.with_features(channelmanager::provided_invoice_features())
|
||||
.with_features(nodes[2].node.invoice_features())
|
||||
.with_route_hints(hop_hints);
|
||||
get_route_and_payment_hash!(nodes[0], nodes[2], payment_params, PAYMENT_AMT, TEST_FINAL_CLTV)
|
||||
};
|
||||
|
@ -791,18 +791,17 @@ fn test_always_create_tlv_format_onion_payloads() {
|
|||
let chanmon_cfgs = create_chanmon_cfgs(3);
|
||||
let mut node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
|
||||
|
||||
// Set `node[1]`'s config features to features which return `false` for
|
||||
// Set `node[1]`'s init features to features which return `false` for
|
||||
// `supports_variable_length_onion()`
|
||||
let mut no_variable_length_onion_features = InitFeatures::empty();
|
||||
no_variable_length_onion_features.set_static_remote_key_required();
|
||||
let mut node_1_cfg = &mut node_cfgs[1];
|
||||
node_1_cfg.features = no_variable_length_onion_features;
|
||||
*node_cfgs[1].override_init_features.borrow_mut() = Some(no_variable_length_onion_features);
|
||||
|
||||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::empty(), InitFeatures::empty());
|
||||
create_announced_chan_between_nodes(&nodes, 1, 2, InitFeatures::empty(), InitFeatures::empty());
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
create_announced_chan_between_nodes(&nodes, 1, 2);
|
||||
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[2].node.get_our_node_id())
|
||||
.with_features(InvoiceFeatures::empty());
|
||||
|
@ -840,7 +839,7 @@ macro_rules! get_phantom_route {
|
|||
let phantom_pubkey = PublicKey::from_secret_key(&secp_ctx, &phantom_secret);
|
||||
let phantom_route_hint = $nodes[1].node.get_phantom_route_hints();
|
||||
let payment_params = PaymentParameters::from_node_id(phantom_pubkey)
|
||||
.with_features(channelmanager::provided_invoice_features())
|
||||
.with_features($nodes[1].node.invoice_features())
|
||||
.with_route_hints(vec![RouteHint(vec![
|
||||
RouteHintHop {
|
||||
src_node_id: $nodes[0].node.get_our_node_id(),
|
||||
|
@ -882,7 +881,7 @@ fn test_phantom_onion_hmac_failure() {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let channel = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let channel = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
|
||||
// Get the route.
|
||||
let recv_value_msat = 10_000;
|
||||
|
@ -941,7 +940,7 @@ fn test_phantom_invalid_onion_payload() {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let channel = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let channel = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
|
||||
// Get the route.
|
||||
let recv_value_msat = 10_000;
|
||||
|
@ -1014,7 +1013,7 @@ fn test_phantom_final_incorrect_cltv_expiry() {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let channel = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let channel = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
|
||||
// Get the route.
|
||||
let recv_value_msat = 10_000;
|
||||
|
@ -1070,7 +1069,7 @@ fn test_phantom_failure_too_low_cltv() {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let channel = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let channel = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
|
||||
// Get the route.
|
||||
let recv_value_msat = 10_000;
|
||||
|
@ -1120,7 +1119,7 @@ fn test_phantom_failure_modified_cltv() {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let channel = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let channel = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
|
||||
// Get the route.
|
||||
let recv_value_msat = 10_000;
|
||||
|
@ -1161,7 +1160,7 @@ fn test_phantom_failure_expires_too_soon() {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let channel = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let channel = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
|
||||
// Get the route.
|
||||
let recv_value_msat = 10_000;
|
||||
|
@ -1198,7 +1197,7 @@ fn test_phantom_failure_too_low_recv_amt() {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let channel = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let channel = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
|
||||
// Get the route with a too-low amount.
|
||||
let recv_amt_msat = 10_000;
|
||||
|
@ -1250,7 +1249,7 @@ fn test_phantom_dust_exposure_failure() {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, Some(receiver_config)]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let channel = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let channel = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
|
||||
// Get the route with an amount exceeding the dust exposure threshold of nodes[1].
|
||||
let (_, payment_hash, payment_secret) = get_payment_preimage_hash!(nodes[1], Some(max_dust_exposure + 1));
|
||||
|
@ -1292,7 +1291,7 @@ fn test_phantom_failure_reject_payment() {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let channel = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let channel = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
|
||||
// Get the route with a too-low amount.
|
||||
let recv_amt_msat = 10_000;
|
||||
|
|
|
@ -16,7 +16,7 @@ use crate::chain::channelmonitor::{ANTI_REORG_DELAY, LATENCY_GRACE_PERIOD_BLOCKS
|
|||
use crate::chain::keysinterface::EntropySource;
|
||||
use crate::chain::transaction::OutPoint;
|
||||
use crate::ln::channel::EXPIRE_PREV_CONFIG_TICKS;
|
||||
use crate::ln::channelmanager::{self, BREAKDOWN_TIMEOUT, ChannelManager, MPP_TIMEOUT_TICKS, MIN_CLTV_EXPIRY_DELTA, PaymentId, PaymentSendFailure, IDEMPOTENCY_TIMEOUT_TICKS};
|
||||
use crate::ln::channelmanager::{BREAKDOWN_TIMEOUT, ChannelManager, MPP_TIMEOUT_TICKS, MIN_CLTV_EXPIRY_DELTA, PaymentId, PaymentSendFailure, IDEMPOTENCY_TIMEOUT_TICKS};
|
||||
use crate::ln::msgs;
|
||||
use crate::ln::msgs::ChannelMessageHandler;
|
||||
use crate::routing::gossip::RoutingFees;
|
||||
|
@ -42,8 +42,8 @@ fn retry_single_path_payment() {
|
|||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let _chan_0 = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_1 = create_announced_chan_between_nodes(&nodes, 2, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let _chan_0 = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
let chan_1 = create_announced_chan_between_nodes(&nodes, 2, 1);
|
||||
// Rebalance to find a route
|
||||
send_payment(&nodes[2], &vec!(&nodes[1])[..], 3_000_000);
|
||||
|
||||
|
@ -96,10 +96,10 @@ fn mpp_failure() {
|
|||
let node_chanmgrs = create_node_chanmgrs(4, &node_cfgs, &[None, None, None, None]);
|
||||
let nodes = create_network(4, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan_1_id = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).0.contents.short_channel_id;
|
||||
let chan_2_id = create_announced_chan_between_nodes(&nodes, 0, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features()).0.contents.short_channel_id;
|
||||
let chan_3_id = create_announced_chan_between_nodes(&nodes, 1, 3, channelmanager::provided_init_features(), channelmanager::provided_init_features()).0.contents.short_channel_id;
|
||||
let chan_4_id = create_announced_chan_between_nodes(&nodes, 2, 3, channelmanager::provided_init_features(), channelmanager::provided_init_features()).0.contents.short_channel_id;
|
||||
let chan_1_id = create_announced_chan_between_nodes(&nodes, 0, 1).0.contents.short_channel_id;
|
||||
let chan_2_id = create_announced_chan_between_nodes(&nodes, 0, 2).0.contents.short_channel_id;
|
||||
let chan_3_id = create_announced_chan_between_nodes(&nodes, 1, 3).0.contents.short_channel_id;
|
||||
let chan_4_id = create_announced_chan_between_nodes(&nodes, 2, 3).0.contents.short_channel_id;
|
||||
|
||||
let (mut route, payment_hash, _, payment_secret) = get_route_and_payment_hash!(&nodes[0], nodes[3], 100000);
|
||||
let path = route.paths[0].clone();
|
||||
|
@ -121,10 +121,10 @@ fn mpp_retry() {
|
|||
let node_chanmgrs = create_node_chanmgrs(4, &node_cfgs, &[None, None, None, None]);
|
||||
let nodes = create_network(4, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let (chan_1_update, _, _, _) = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let (chan_2_update, _, _, _) = create_announced_chan_between_nodes(&nodes, 0, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let (chan_3_update, _, _, _) = create_announced_chan_between_nodes(&nodes, 1, 3, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let (chan_4_update, _, chan_4_id, _) = create_announced_chan_between_nodes(&nodes, 3, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let (chan_1_update, _, _, _) = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
let (chan_2_update, _, _, _) = create_announced_chan_between_nodes(&nodes, 0, 2);
|
||||
let (chan_3_update, _, _, _) = create_announced_chan_between_nodes(&nodes, 1, 3);
|
||||
let (chan_4_update, _, chan_4_id, _) = create_announced_chan_between_nodes(&nodes, 3, 2);
|
||||
// Rebalance
|
||||
send_payment(&nodes[3], &vec!(&nodes[2])[..], 1_500_000);
|
||||
|
||||
|
@ -208,10 +208,10 @@ fn do_mpp_receive_timeout(send_partial_mpp: bool) {
|
|||
let node_chanmgrs = create_node_chanmgrs(4, &node_cfgs, &[None, None, None, None]);
|
||||
let nodes = create_network(4, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let (chan_1_update, _, _, _) = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let (chan_2_update, _, _, _) = create_announced_chan_between_nodes(&nodes, 0, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let (chan_3_update, _, chan_3_id, _) = create_announced_chan_between_nodes(&nodes, 1, 3, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let (chan_4_update, _, _, _) = create_announced_chan_between_nodes(&nodes, 2, 3, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let (chan_1_update, _, _, _) = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
let (chan_2_update, _, _, _) = create_announced_chan_between_nodes(&nodes, 0, 2);
|
||||
let (chan_3_update, _, chan_3_id, _) = create_announced_chan_between_nodes(&nodes, 1, 3);
|
||||
let (chan_4_update, _, _, _) = create_announced_chan_between_nodes(&nodes, 2, 3);
|
||||
|
||||
let (mut route, payment_hash, payment_preimage, payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[3], 100_000);
|
||||
let path = route.paths[0].clone();
|
||||
|
@ -283,8 +283,8 @@ fn retry_expired_payment() {
|
|||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let _chan_0 = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_1 = create_announced_chan_between_nodes(&nodes, 2, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let _chan_0 = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
let chan_1 = create_announced_chan_between_nodes(&nodes, 2, 1);
|
||||
// Rebalance to find a route
|
||||
send_payment(&nodes[2], &vec!(&nodes[1])[..], 3_000_000);
|
||||
|
||||
|
@ -338,7 +338,7 @@ fn no_pending_leak_on_initial_send_failure() {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
|
||||
let (route, payment_hash, _, payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[1], 100_000);
|
||||
|
||||
|
@ -372,8 +372,8 @@ fn do_retry_with_no_persist(confirm_before_reload: bool) {
|
|||
let nodes_0_deserialized: ChannelManager<&test_utils::TestChainMonitor, &test_utils::TestBroadcaster, &test_utils::TestKeysInterface, &test_utils::TestKeysInterface, &test_utils::TestKeysInterface, &test_utils::TestFeeEstimator, &test_utils::TestRouter, &test_utils::TestLogger>;
|
||||
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan_id = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let (_, _, chan_id_2, _) = create_announced_chan_between_nodes(&nodes, 1, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_id = create_announced_chan_between_nodes(&nodes, 0, 1).2;
|
||||
let (_, _, chan_id_2, _) = create_announced_chan_between_nodes(&nodes, 1, 2);
|
||||
|
||||
// Serialize the ChannelManager prior to sending payments
|
||||
let nodes_0_serialized = nodes[0].node.encode();
|
||||
|
@ -424,12 +424,12 @@ fn do_retry_with_no_persist(confirm_before_reload: bool) {
|
|||
assert_eq!(as_broadcasted_txn[0], as_commitment_tx);
|
||||
|
||||
nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id(), false);
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: nodes[1].node.init_features(), remote_network_address: None }).unwrap();
|
||||
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
|
||||
|
||||
// Now nodes[1] should send a channel reestablish, which nodes[0] will respond to with an
|
||||
// error, as the channel has hit the chain.
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: nodes[0].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let bs_reestablish = get_chan_reestablish_msgs!(nodes[1], nodes[0]).pop().unwrap();
|
||||
nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &bs_reestablish);
|
||||
let as_err = nodes[0].node.get_and_clear_pending_msg_events();
|
||||
|
@ -466,7 +466,7 @@ fn do_retry_with_no_persist(confirm_before_reload: bool) {
|
|||
// Create a new channel on which to retry the payment before we fail the payment via the
|
||||
// HTLC-Timeout transaction. This avoids ChannelManager timing out the payment due to us
|
||||
// connecting several blocks while creating the channel (implying time has passed).
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
assert_eq!(nodes[0].node.list_usable_channels().len(), 1);
|
||||
|
||||
mine_transaction(&nodes[1], &as_commitment_tx);
|
||||
|
@ -566,7 +566,7 @@ fn do_test_completed_payment_not_retryable_on_reload(use_dust: bool) {
|
|||
// Ignore the announcement_signatures messages
|
||||
nodes[0].node.get_and_clear_pending_msg_events();
|
||||
nodes[1].node.get_and_clear_pending_msg_events();
|
||||
let chan_id_2 = create_announced_chan_between_nodes(&nodes, 1, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let chan_id_2 = create_announced_chan_between_nodes(&nodes, 1, 2).2;
|
||||
|
||||
// Serialize the ChannelManager prior to sending payments
|
||||
let mut nodes_0_serialized = nodes[0].node.encode();
|
||||
|
@ -588,12 +588,12 @@ fn do_test_completed_payment_not_retryable_on_reload(use_dust: bool) {
|
|||
assert!(nodes[0].node.has_pending_payments());
|
||||
assert_eq!(nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0).len(), 1);
|
||||
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: nodes[1].node.init_features(), remote_network_address: None }).unwrap();
|
||||
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
|
||||
|
||||
// Now nodes[1] should send a channel reestablish, which nodes[0] will respond to with an
|
||||
// error, as the channel has hit the chain.
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: nodes[0].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let bs_reestablish = get_chan_reestablish_msgs!(nodes[1], nodes[0]).pop().unwrap();
|
||||
nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &bs_reestablish);
|
||||
let as_err = nodes[0].node.get_and_clear_pending_msg_events();
|
||||
|
@ -723,7 +723,7 @@ fn do_test_dup_htlc_onchain_fails_on_reload(persist_manager_post_event: bool, co
|
|||
let nodes_0_deserialized: ChannelManager<&test_utils::TestChainMonitor, &test_utils::TestBroadcaster, &test_utils::TestKeysInterface, &test_utils::TestKeysInterface, &test_utils::TestKeysInterface, &test_utils::TestFeeEstimator, &test_utils::TestRouter, &test_utils::TestLogger>;
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let (_, _, chan_id, funding_tx) = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let (_, _, chan_id, funding_tx) = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
|
||||
// Route a payment, but force-close the channel before the HTLC fulfill message arrives at
|
||||
// nodes[0].
|
||||
|
@ -866,7 +866,7 @@ fn test_fulfill_restart_failure() {
|
|||
let nodes_1_deserialized: ChannelManager<&test_utils::TestChainMonitor, &test_utils::TestBroadcaster, &test_utils::TestKeysInterface, &test_utils::TestKeysInterface, &test_utils::TestKeysInterface, &test_utils::TestFeeEstimator, &test_utils::TestRouter, &test_utils::TestLogger>;
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan_id = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let chan_id = create_announced_chan_between_nodes(&nodes, 0, 1).2;
|
||||
let (payment_preimage, payment_hash, _) = route_payment(&nodes[0], &[&nodes[1]], 100_000);
|
||||
|
||||
// The simplest way to get a failure after a fulfill is to reload nodes[1] from a state
|
||||
|
@ -906,14 +906,14 @@ fn get_ldk_payment_preimage() {
|
|||
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
|
||||
let amt_msat = 60_000;
|
||||
let expiry_secs = 60 * 60;
|
||||
let (payment_hash, payment_secret) = nodes[1].node.create_inbound_payment(Some(amt_msat), expiry_secs).unwrap();
|
||||
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[1].node.get_our_node_id())
|
||||
.with_features(channelmanager::provided_invoice_features());
|
||||
.with_features(nodes[1].node.invoice_features());
|
||||
let scorer = test_utils::TestScorer::with_penalty(0);
|
||||
let keys_manager = test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
|
||||
let random_seed_bytes = keys_manager.get_secure_random_bytes();
|
||||
|
@ -939,8 +939,8 @@ fn sent_probe_is_probe_of_sending_node() {
|
|||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None, None]);
|
||||
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes(&nodes, 1, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
create_announced_chan_between_nodes(&nodes, 1, 2);
|
||||
|
||||
// First check we refuse to build a single-hop probe
|
||||
let (route, _, _, _) = get_route_and_payment_hash!(&nodes[0], nodes[1], 100_000);
|
||||
|
@ -969,8 +969,8 @@ fn successful_probe_yields_event() {
|
|||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None, None]);
|
||||
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes(&nodes, 1, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
create_announced_chan_between_nodes(&nodes, 1, 2);
|
||||
|
||||
let (route, _, _, _) = get_route_and_payment_hash!(&nodes[0], nodes[2], 100_000);
|
||||
|
||||
|
@ -1023,8 +1023,8 @@ fn failed_probe_yields_event() {
|
|||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None, None]);
|
||||
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 1, 2, 100000, 90000000, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 1, 2, 100000, 90000000);
|
||||
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[2].node.get_our_node_id());
|
||||
|
||||
|
@ -1070,8 +1070,8 @@ fn onchain_failed_probe_yields_event() {
|
|||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan_id = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
create_announced_chan_between_nodes(&nodes, 1, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_id = create_announced_chan_between_nodes(&nodes, 0, 1).2;
|
||||
create_announced_chan_between_nodes(&nodes, 1, 2);
|
||||
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[2].node.get_our_node_id());
|
||||
|
||||
|
@ -1123,7 +1123,7 @@ fn claimed_send_payment_idempotent() {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1).2;
|
||||
|
||||
let (route, second_payment_hash, second_payment_preimage, second_payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[1], 100_000);
|
||||
let (first_payment_preimage, _, _, payment_id) = send_along_route(&nodes[0], route.clone(), &[&nodes[1]], 100_000);
|
||||
|
@ -1195,7 +1195,7 @@ fn abandoned_send_payment_idempotent() {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1).2;
|
||||
|
||||
let (route, second_payment_hash, second_payment_preimage, second_payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[1], 100_000);
|
||||
let (_, first_payment_hash, _, payment_id) = send_along_route(&nodes[0], route.clone(), &[&nodes[1]], 100_000);
|
||||
|
@ -1263,8 +1263,8 @@ fn test_trivial_inflight_htlc_tracking(){
|
|||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let (_, _, chan_1_id, _) = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let (_, _, chan_2_id, _) = create_announced_chan_between_nodes(&nodes, 1, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let (_, _, chan_1_id, _) = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
let (_, _, chan_2_id, _) = create_announced_chan_between_nodes(&nodes, 1, 2);
|
||||
|
||||
// Send and claim the payment. Inflight HTLCs should be empty.
|
||||
send_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 500000);
|
||||
|
@ -1355,7 +1355,7 @@ fn test_holding_cell_inflight_htlcs() {
|
|||
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1).2;
|
||||
|
||||
let (route, payment_hash_1, _, payment_secret_1) = get_route_and_payment_hash!(nodes[0], nodes[1], 1000000);
|
||||
let (_, payment_hash_2, payment_secret_2) = get_payment_preimage_hash!(nodes[1]);
|
||||
|
@ -1414,7 +1414,7 @@ fn do_test_intercepted_payment(test: InterceptTest) {
|
|||
let scorer = test_utils::TestScorer::with_penalty(0);
|
||||
let random_seed_bytes = chanmon_cfgs[0].keys_manager.get_secure_random_bytes();
|
||||
|
||||
let _ = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let _ = create_announced_chan_between_nodes(&nodes, 0, 1).2;
|
||||
|
||||
let amt_msat = 100_000;
|
||||
let intercept_scid = nodes[1].node.get_intercept_scid();
|
||||
|
@ -1432,7 +1432,7 @@ fn do_test_intercepted_payment(test: InterceptTest) {
|
|||
htlc_maximum_msat: None,
|
||||
}])
|
||||
])
|
||||
.with_features(channelmanager::provided_invoice_features());
|
||||
.with_features(nodes[2].node.invoice_features());
|
||||
let route_params = RouteParameters {
|
||||
payment_params,
|
||||
final_value_msat: amt_msat,
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
use crate::chain::ChannelMonitorUpdateStatus;
|
||||
use crate::chain::keysinterface::{Recipient, NodeSigner};
|
||||
use crate::ln::channelmanager::{self, ChannelManager, MIN_CLTV_EXPIRY_DELTA, PaymentId};
|
||||
use crate::ln::channelmanager::{ChannelManager, MIN_CLTV_EXPIRY_DELTA, PaymentId};
|
||||
use crate::routing::gossip::RoutingFees;
|
||||
use crate::routing::router::{PaymentParameters, RouteHint, RouteHintHop};
|
||||
use crate::ln::features::ChannelTypeFeatures;
|
||||
|
@ -51,8 +51,8 @@ fn test_priv_forwarding_rejection() {
|
|||
let nodes_1_deserialized: ChannelManager<&test_utils::TestChainMonitor, &test_utils::TestBroadcaster, &test_utils::TestKeysInterface, &test_utils::TestKeysInterface, &test_utils::TestKeysInterface, &test_utils::TestFeeEstimator, &test_utils::TestRouter, &test_utils::TestLogger>;
|
||||
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan_id_1 = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 500_000_000, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let chan_id_2 = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 2, 1_000_000, 500_000_000, channelmanager::provided_init_features(), channelmanager::provided_init_features()).0.channel_id;
|
||||
let chan_id_1 = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 500_000_000).2;
|
||||
let chan_id_2 = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 2, 1_000_000, 500_000_000).0.channel_id;
|
||||
|
||||
// We should always be able to forward through nodes[1] as long as its out through a public
|
||||
// channel:
|
||||
|
@ -70,7 +70,7 @@ fn test_priv_forwarding_rejection() {
|
|||
}]);
|
||||
let last_hops = vec![route_hint];
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[2].node.get_our_node_id())
|
||||
.with_features(channelmanager::provided_invoice_features())
|
||||
.with_features(nodes[2].node.invoice_features())
|
||||
.with_route_hints(last_hops);
|
||||
let (route, our_payment_hash, our_payment_preimage, our_payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[2], payment_params, 10_000, TEST_FINAL_CLTV);
|
||||
|
||||
|
@ -103,8 +103,8 @@ fn test_priv_forwarding_rejection() {
|
|||
no_announce_cfg.accept_forwards_to_priv_channels = true;
|
||||
reload_node!(nodes[1], no_announce_cfg, &nodes_1_serialized, &[&monitor_a_serialized, &monitor_b_serialized], persister, new_chain_monitor, nodes_1_deserialized);
|
||||
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: nodes[1].node.init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: nodes[0].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let as_reestablish = get_chan_reestablish_msgs!(nodes[0], nodes[1]).pop().unwrap();
|
||||
let bs_reestablish = get_chan_reestablish_msgs!(nodes[1], nodes[0]).pop().unwrap();
|
||||
nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &as_reestablish);
|
||||
|
@ -112,8 +112,8 @@ fn test_priv_forwarding_rejection() {
|
|||
get_event_msg!(nodes[0], MessageSendEvent::SendChannelUpdate, nodes[1].node.get_our_node_id());
|
||||
get_event_msg!(nodes[1], MessageSendEvent::SendChannelUpdate, nodes[0].node.get_our_node_id());
|
||||
|
||||
nodes[1].node.peer_connected(&nodes[2].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[2].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[2].node.get_our_node_id(), &msgs::Init { features: nodes[2].node.init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[2].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: nodes[1].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let bs_reestablish = get_chan_reestablish_msgs!(nodes[1], nodes[2]).pop().unwrap();
|
||||
let cs_reestablish = get_chan_reestablish_msgs!(nodes[2], nodes[1]).pop().unwrap();
|
||||
nodes[2].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &bs_reestablish);
|
||||
|
@ -144,7 +144,7 @@ fn do_test_1_conf_open(connect_style: ConnectStyle) {
|
|||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
*nodes[0].connect_style.borrow_mut() = connect_style;
|
||||
|
||||
let tx = create_chan_between_nodes_with_value_init(&nodes[0], &nodes[1], 100000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let tx = create_chan_between_nodes_with_value_init(&nodes[0], &nodes[1], 100000, 10001);
|
||||
mine_transaction(&nodes[1], &tx);
|
||||
nodes[0].node.handle_channel_ready(&nodes[1].node.get_our_node_id(), &get_event_msg!(nodes[1], MessageSendEvent::SendChannelReady, nodes[0].node.get_our_node_id()));
|
||||
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
|
||||
|
@ -221,8 +221,8 @@ fn test_routed_scid_alias() {
|
|||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, Some(no_announce_cfg), None]);
|
||||
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 500_000_000, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let mut as_channel_ready = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 2, 1_000_000, 500_000_000, channelmanager::provided_init_features(), channelmanager::provided_init_features()).0;
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 500_000_000).2;
|
||||
let mut as_channel_ready = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 2, 1_000_000, 500_000_000).0;
|
||||
|
||||
let last_hop = nodes[2].node.list_usable_channels();
|
||||
let hop_hints = vec![RouteHint(vec![RouteHintHop {
|
||||
|
@ -237,7 +237,7 @@ fn test_routed_scid_alias() {
|
|||
htlc_minimum_msat: None,
|
||||
}])];
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[2].node.get_our_node_id())
|
||||
.with_features(channelmanager::provided_invoice_features())
|
||||
.with_features(nodes[2].node.invoice_features())
|
||||
.with_route_hints(hop_hints);
|
||||
let (route, payment_hash, payment_preimage, payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[2], payment_params, 100_000, 42);
|
||||
assert_eq!(route.paths[0][1].short_channel_id, last_hop[0].inbound_scid_alias.unwrap());
|
||||
|
@ -280,7 +280,7 @@ fn test_scid_privacy_on_pub_channel() {
|
|||
open_channel.channel_type.as_mut().unwrap().set_scid_privacy_required();
|
||||
assert_eq!(open_channel.channel_flags & 1, 1); // The `announce_channel` bit is set.
|
||||
|
||||
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), channelmanager::provided_init_features(), &open_channel);
|
||||
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), nodes[0].node.init_features(), &open_channel);
|
||||
let err = get_err_msg!(nodes[1], nodes[0].node.get_our_node_id());
|
||||
assert_eq!(err.data, "SCID Alias/Privacy Channel Type cannot be set on a public channel");
|
||||
}
|
||||
|
@ -313,8 +313,8 @@ fn test_scid_privacy_negotiation() {
|
|||
|
||||
let second_open_channel = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
|
||||
assert!(!second_open_channel.channel_type.as_ref().unwrap().supports_scid_privacy());
|
||||
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), channelmanager::provided_init_features(), &second_open_channel);
|
||||
nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), channelmanager::provided_init_features(), &get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id()));
|
||||
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), nodes[0].node.init_features(), &second_open_channel);
|
||||
nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), nodes[1].node.init_features(), &get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id()));
|
||||
|
||||
let events = nodes[0].node.get_and_clear_pending_events();
|
||||
assert_eq!(events.len(), 1);
|
||||
|
@ -338,7 +338,7 @@ fn test_inbound_scid_privacy() {
|
|||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, Some(accept_forward_cfg), None]);
|
||||
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 0);
|
||||
|
||||
let mut no_announce_cfg = test_default_channel_config();
|
||||
no_announce_cfg.channel_handshake_config.announced_channel = false;
|
||||
|
@ -348,9 +348,9 @@ fn test_inbound_scid_privacy() {
|
|||
|
||||
assert!(open_channel.channel_type.as_ref().unwrap().requires_scid_privacy());
|
||||
|
||||
nodes[2].node.handle_open_channel(&nodes[1].node.get_our_node_id(), channelmanager::provided_init_features(), &open_channel);
|
||||
nodes[2].node.handle_open_channel(&nodes[1].node.get_our_node_id(), nodes[1].node.init_features(), &open_channel);
|
||||
let accept_channel = get_event_msg!(nodes[2], MessageSendEvent::SendAcceptChannel, nodes[1].node.get_our_node_id());
|
||||
nodes[1].node.handle_accept_channel(&nodes[2].node.get_our_node_id(), channelmanager::provided_init_features(), &accept_channel);
|
||||
nodes[1].node.handle_accept_channel(&nodes[2].node.get_our_node_id(), nodes[2].node.init_features(), &accept_channel);
|
||||
|
||||
let (temporary_channel_id, tx, _) = create_funding_transaction(&nodes[1], &nodes[2].node.get_our_node_id(), 100_000, 42);
|
||||
nodes[1].node.funding_transaction_generated(&temporary_channel_id, &nodes[2].node.get_our_node_id(), tx.clone()).unwrap();
|
||||
|
@ -392,7 +392,7 @@ fn test_inbound_scid_privacy() {
|
|||
htlc_minimum_msat: None,
|
||||
}])];
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[2].node.get_our_node_id())
|
||||
.with_features(channelmanager::provided_invoice_features())
|
||||
.with_features(nodes[2].node.invoice_features())
|
||||
.with_route_hints(hop_hints.clone());
|
||||
let (route, payment_hash, payment_preimage, payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[2], payment_params, 100_000, 42);
|
||||
assert_eq!(route.paths[0][1].short_channel_id, last_hop[0].inbound_scid_alias.unwrap());
|
||||
|
@ -407,7 +407,7 @@ fn test_inbound_scid_privacy() {
|
|||
hop_hints[0].0[0].short_channel_id = last_hop[0].short_channel_id.unwrap();
|
||||
|
||||
let payment_params_2 = PaymentParameters::from_node_id(nodes[2].node.get_our_node_id())
|
||||
.with_features(channelmanager::provided_invoice_features())
|
||||
.with_features(nodes[2].node.invoice_features())
|
||||
.with_route_hints(hop_hints);
|
||||
let (route_2, payment_hash_2, _, payment_secret_2) = get_route_and_payment_hash!(nodes[0], nodes[2], payment_params_2, 100_000, 42);
|
||||
assert_eq!(route_2.paths[0][1].short_channel_id, last_hop[0].short_channel_id.unwrap());
|
||||
|
@ -442,8 +442,8 @@ fn test_scid_alias_returned() {
|
|||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, Some(accept_forward_cfg), None]);
|
||||
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 10_000_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 2, 10_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 10_000_000, 0);
|
||||
let chan = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 2, 10_000, 0);
|
||||
|
||||
let last_hop = nodes[2].node.list_usable_channels();
|
||||
let mut hop_hints = vec![RouteHint(vec![RouteHintHop {
|
||||
|
@ -458,7 +458,7 @@ fn test_scid_alias_returned() {
|
|||
htlc_minimum_msat: None,
|
||||
}])];
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[2].node.get_our_node_id())
|
||||
.with_features(channelmanager::provided_invoice_features())
|
||||
.with_features(nodes[2].node.invoice_features())
|
||||
.with_route_hints(hop_hints);
|
||||
let (mut route, payment_hash, _, payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[2], payment_params, 10_000, 42);
|
||||
assert_eq!(route.paths[0][1].short_channel_id, nodes[2].node.list_usable_channels()[0].inbound_scid_alias.unwrap());
|
||||
|
@ -565,13 +565,13 @@ fn test_0conf_channel_with_async_monitor() {
|
|||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, Some(chan_config), None]);
|
||||
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 1, 2, 1_000_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 1, 2, 1_000_000, 0);
|
||||
|
||||
chan_config.channel_handshake_config.announced_channel = false;
|
||||
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 42, Some(chan_config)).unwrap();
|
||||
let open_channel = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
|
||||
|
||||
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), channelmanager::provided_init_features(), &open_channel);
|
||||
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), nodes[0].node.init_features(), &open_channel);
|
||||
let events = nodes[1].node.get_and_clear_pending_events();
|
||||
assert_eq!(events.len(), 1);
|
||||
match events[0] {
|
||||
|
@ -583,7 +583,7 @@ fn test_0conf_channel_with_async_monitor() {
|
|||
|
||||
let mut accept_channel = get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id());
|
||||
assert_eq!(accept_channel.minimum_depth, 0);
|
||||
nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), channelmanager::provided_init_features(), &accept_channel);
|
||||
nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), nodes[1].node.init_features(), &accept_channel);
|
||||
|
||||
let (temporary_channel_id, tx, funding_output) = create_funding_transaction(&nodes[0], &nodes[1].node.get_our_node_id(), 100000, 42);
|
||||
nodes[0].node.funding_transaction_generated(&temporary_channel_id, &nodes[1].node.get_our_node_id(), tx.clone()).unwrap();
|
||||
|
@ -844,7 +844,7 @@ fn test_zero_conf_accept_reject() {
|
|||
|
||||
open_channel_msg.channel_type = Some(channel_type_features.clone());
|
||||
|
||||
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), channelmanager::provided_init_features(), &open_channel_msg);
|
||||
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), nodes[0].node.init_features(), &open_channel_msg);
|
||||
|
||||
let msg_events = nodes[1].node.get_and_clear_pending_msg_events();
|
||||
match msg_events[0] {
|
||||
|
@ -872,7 +872,7 @@ fn test_zero_conf_accept_reject() {
|
|||
|
||||
open_channel_msg.channel_type = Some(channel_type_features.clone());
|
||||
|
||||
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), channelmanager::provided_init_features(),
|
||||
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), nodes[0].node.init_features(),
|
||||
&open_channel_msg);
|
||||
|
||||
// Assert that `nodes[1]` has no `MessageSendEvent::SendAcceptChannel` in the `msg_events`.
|
||||
|
@ -905,7 +905,7 @@ fn test_zero_conf_accept_reject() {
|
|||
|
||||
open_channel_msg.channel_type = Some(channel_type_features);
|
||||
|
||||
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), channelmanager::provided_init_features(),
|
||||
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), nodes[0].node.init_features(),
|
||||
&open_channel_msg);
|
||||
|
||||
let events = nodes[1].node.get_and_clear_pending_events();
|
||||
|
@ -944,7 +944,7 @@ fn test_connect_before_funding() {
|
|||
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100_000, 10_001, 42, None).unwrap();
|
||||
let open_channel = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
|
||||
|
||||
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), channelmanager::provided_init_features(), &open_channel);
|
||||
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), nodes[0].node.init_features(), &open_channel);
|
||||
let events = nodes[1].node.get_and_clear_pending_events();
|
||||
assert_eq!(events.len(), 1);
|
||||
match events[0] {
|
||||
|
@ -956,7 +956,7 @@ fn test_connect_before_funding() {
|
|||
|
||||
let mut accept_channel = get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id());
|
||||
assert_eq!(accept_channel.minimum_depth, 0);
|
||||
nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), channelmanager::provided_init_features(), &accept_channel);
|
||||
nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), nodes[1].node.init_features(), &accept_channel);
|
||||
|
||||
let events = nodes[0].node.get_and_clear_pending_events();
|
||||
assert_eq!(events.len(), 1);
|
||||
|
|
|
@ -14,7 +14,7 @@ use crate::chain::chaininterface::LowerBoundedFeeEstimator;
|
|||
use crate::chain::channelmonitor::ChannelMonitor;
|
||||
use crate::chain::keysinterface::EntropySource;
|
||||
use crate::chain::transaction::OutPoint;
|
||||
use crate::ln::channelmanager::{self, ChannelManager, ChannelManagerReadArgs, PaymentId};
|
||||
use crate::ln::channelmanager::{ChannelManager, ChannelManagerReadArgs, PaymentId};
|
||||
use crate::ln::msgs;
|
||||
use crate::ln::msgs::{ChannelMessageHandler, RoutingMessageHandler, ErrorAction};
|
||||
use crate::util::enforcing_trait_impls::EnforcingSigner;
|
||||
|
@ -42,7 +42,7 @@ fn test_funding_peer_disconnect() {
|
|||
let new_chain_monitor: test_utils::TestChainMonitor;
|
||||
let nodes_0_deserialized: ChannelManager<&test_utils::TestChainMonitor, &test_utils::TestBroadcaster, &test_utils::TestKeysInterface, &test_utils::TestKeysInterface, &test_utils::TestKeysInterface, &test_utils::TestFeeEstimator, &test_utils::TestRouter, &test_utils::TestLogger>;
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
let tx = create_chan_between_nodes_with_value_init(&nodes[0], &nodes[1], 100000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let tx = create_chan_between_nodes_with_value_init(&nodes[0], &nodes[1], 100000, 10001);
|
||||
|
||||
nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id(), false);
|
||||
nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id(), false);
|
||||
|
@ -60,9 +60,9 @@ fn test_funding_peer_disconnect() {
|
|||
let events_2 = nodes[1].node.get_and_clear_pending_msg_events();
|
||||
assert!(events_2.is_empty());
|
||||
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: nodes[1].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let as_reestablish = get_chan_reestablish_msgs!(nodes[0], nodes[1]).pop().unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: nodes[0].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let bs_reestablish = get_chan_reestablish_msgs!(nodes[1], nodes[0]).pop().unwrap();
|
||||
|
||||
// nodes[0] hasn't yet received a channel_ready, so it only sends that on reconnect.
|
||||
|
@ -188,7 +188,7 @@ fn test_no_txn_manager_serialize_deserialize() {
|
|||
let nodes_0_deserialized: ChannelManager<&test_utils::TestChainMonitor, &test_utils::TestBroadcaster, &test_utils::TestKeysInterface, &test_utils::TestKeysInterface, &test_utils::TestKeysInterface, &test_utils::TestFeeEstimator, &test_utils::TestRouter, &test_utils::TestLogger>;
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let tx = create_chan_between_nodes_with_value_init(&nodes[0], &nodes[1], 100000, 10001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let tx = create_chan_between_nodes_with_value_init(&nodes[0], &nodes[1], 100000, 10001);
|
||||
|
||||
nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id(), false);
|
||||
|
||||
|
@ -196,9 +196,9 @@ fn test_no_txn_manager_serialize_deserialize() {
|
|||
get_monitor!(nodes[0], OutPoint { txid: tx.txid(), index: 0 }.to_channel_id()).encode();
|
||||
reload_node!(nodes[0], nodes[0].node.encode(), &[&chan_0_monitor_serialized], persister, new_chain_monitor, nodes_0_deserialized);
|
||||
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: nodes[1].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let reestablish_1 = get_chan_reestablish_msgs!(nodes[0], nodes[1]);
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: nodes[0].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let reestablish_2 = get_chan_reestablish_msgs!(nodes[1], nodes[0]);
|
||||
|
||||
nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &reestablish_1[0]);
|
||||
|
@ -231,10 +231,10 @@ fn test_manager_serialize_deserialize_events() {
|
|||
// Start creating a channel, but stop right before broadcasting the funding transaction
|
||||
let channel_value = 100000;
|
||||
let push_msat = 10001;
|
||||
let a_flags = channelmanager::provided_init_features();
|
||||
let b_flags = channelmanager::provided_init_features();
|
||||
let node_a = nodes.remove(0);
|
||||
let node_b = nodes.remove(0);
|
||||
let a_flags = node_a.node.init_features();
|
||||
let b_flags = node_b.node.init_features();
|
||||
node_a.node.create_channel(node_b.node.get_our_node_id(), channel_value, push_msat, 42, None).unwrap();
|
||||
node_b.node.handle_open_channel(&node_a.node.get_our_node_id(), a_flags, &get_event_msg!(node_a, MessageSendEvent::SendOpenChannel, node_b.node.get_our_node_id()));
|
||||
node_a.node.handle_accept_channel(&node_b.node.get_our_node_id(), b_flags, &get_event_msg!(node_b, MessageSendEvent::SendAcceptChannel, node_a.node.get_our_node_id()));
|
||||
|
@ -280,9 +280,9 @@ fn test_manager_serialize_deserialize_events() {
|
|||
// Make sure the channel is functioning as though the de/serialization never happened
|
||||
assert_eq!(nodes[0].node.list_channels().len(), 1);
|
||||
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: nodes[1].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let reestablish_1 = get_chan_reestablish_msgs!(nodes[0], nodes[1]);
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: nodes[0].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let reestablish_2 = get_chan_reestablish_msgs!(nodes[1], nodes[0]);
|
||||
|
||||
nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &reestablish_1[0]);
|
||||
|
@ -310,7 +310,7 @@ fn test_simple_manager_serialize_deserialize() {
|
|||
let new_chain_monitor: test_utils::TestChainMonitor;
|
||||
let nodes_0_deserialized: ChannelManager<&test_utils::TestChainMonitor, &test_utils::TestBroadcaster, &test_utils::TestKeysInterface, &test_utils::TestKeysInterface, &test_utils::TestKeysInterface, &test_utils::TestFeeEstimator, &test_utils::TestRouter, &test_utils::TestLogger>;
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
let chan_id = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let chan_id = create_announced_chan_between_nodes(&nodes, 0, 1).2;
|
||||
|
||||
let (our_payment_preimage, _, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
|
||||
let (_, our_payment_hash, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
|
||||
|
@ -338,9 +338,9 @@ fn test_manager_serialize_deserialize_inconsistent_monitor() {
|
|||
let new_chain_monitor: test_utils::TestChainMonitor;
|
||||
let nodes_0_deserialized: ChannelManager<&test_utils::TestChainMonitor, &test_utils::TestBroadcaster, &test_utils::TestKeysInterface, &test_utils::TestKeysInterface, &test_utils::TestKeysInterface, &test_utils::TestFeeEstimator, &test_utils::TestRouter, &test_utils::TestLogger>;
|
||||
let mut nodes = create_network(4, &node_cfgs, &node_chanmgrs);
|
||||
let chan_id_1 = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let chan_id_2 = create_announced_chan_between_nodes(&nodes, 2, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let (_, _, channel_id, funding_tx) = create_announced_chan_between_nodes(&nodes, 0, 3, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_id_1 = create_announced_chan_between_nodes(&nodes, 0, 1).2;
|
||||
let chan_id_2 = create_announced_chan_between_nodes(&nodes, 2, 0).2;
|
||||
let (_, _, channel_id, funding_tx) = create_announced_chan_between_nodes(&nodes, 0, 3);
|
||||
|
||||
let mut node_0_stale_monitors_serialized = Vec::new();
|
||||
for chan_id_iter in &[chan_id_1, chan_id_2, channel_id] {
|
||||
|
@ -445,9 +445,9 @@ fn test_manager_serialize_deserialize_inconsistent_monitor() {
|
|||
//... and we can even still claim the payment!
|
||||
claim_payment(&nodes[2], &[&nodes[0], &nodes[1]], our_payment_preimage);
|
||||
|
||||
nodes[3].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[3].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: nodes[0].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let reestablish = get_chan_reestablish_msgs!(nodes[3], nodes[0]).pop().unwrap();
|
||||
nodes[0].node.peer_connected(&nodes[3].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[0].node.peer_connected(&nodes[3].node.get_our_node_id(), &msgs::Init { features: nodes[3].node.init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[0].node.handle_channel_reestablish(&nodes[3].node.get_our_node_id(), &reestablish);
|
||||
let mut found_err = false;
|
||||
for msg_event in nodes[0].node.get_and_clear_pending_msg_events() {
|
||||
|
@ -481,7 +481,7 @@ fn do_test_data_loss_protect(reconnect_panicing: bool) {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1000000, 1000000, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1000000, 1000000);
|
||||
|
||||
// Cache node A state before any channel update
|
||||
let previous_node_state = nodes[0].node.encode();
|
||||
|
@ -496,8 +496,8 @@ fn do_test_data_loss_protect(reconnect_panicing: bool) {
|
|||
reload_node!(nodes[0], previous_node_state, &[&previous_chain_monitor_state], persister, new_chain_monitor, nodes_0_deserialized);
|
||||
|
||||
if reconnect_panicing {
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: nodes[1].node.init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: nodes[0].node.init_features(), remote_network_address: None }).unwrap();
|
||||
|
||||
let reestablish_1 = get_chan_reestablish_msgs!(nodes[0], nodes[1]);
|
||||
|
||||
|
@ -545,8 +545,8 @@ fn do_test_data_loss_protect(reconnect_panicing: bool) {
|
|||
// after the warning message sent by B, we should not able to
|
||||
// use the channel, or reconnect with success to the channel.
|
||||
assert!(nodes[0].node.list_usable_channels().is_empty());
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: nodes[1].node.init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: nodes[0].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let retry_reestablish = get_chan_reestablish_msgs!(nodes[1], nodes[0]);
|
||||
|
||||
nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &retry_reestablish[0]);
|
||||
|
@ -597,8 +597,8 @@ fn test_forwardable_regen() {
|
|||
let new_chain_monitor: test_utils::TestChainMonitor;
|
||||
let nodes_1_deserialized: ChannelManager<&test_utils::TestChainMonitor, &test_utils::TestBroadcaster, &test_utils::TestKeysInterface, &test_utils::TestKeysInterface, &test_utils::TestKeysInterface, &test_utils::TestFeeEstimator, &test_utils::TestRouter, &test_utils::TestLogger>;
|
||||
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
let chan_id_1 = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let chan_id_2 = create_announced_chan_between_nodes(&nodes, 1, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let chan_id_1 = create_announced_chan_between_nodes(&nodes, 0, 1).2;
|
||||
let chan_id_2 = create_announced_chan_between_nodes(&nodes, 1, 2).2;
|
||||
|
||||
// First send a payment to nodes[1]
|
||||
let (route, payment_hash, payment_preimage, payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[1], 100_000);
|
||||
|
@ -683,10 +683,10 @@ fn do_test_partial_claim_before_restart(persist_both_monitors: bool) {
|
|||
|
||||
let mut nodes = create_network(4, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 2, 100_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_id_persisted = create_announced_chan_between_nodes_with_value(&nodes, 1, 3, 100_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let chan_id_not_persisted = create_announced_chan_between_nodes_with_value(&nodes, 2, 3, 100_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100_000, 0);
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 2, 100_000, 0);
|
||||
let chan_id_persisted = create_announced_chan_between_nodes_with_value(&nodes, 1, 3, 100_000, 0).2;
|
||||
let chan_id_not_persisted = create_announced_chan_between_nodes_with_value(&nodes, 2, 3, 100_000, 0).2;
|
||||
|
||||
// Create an MPP route for 15k sats, more than the default htlc-max of 10%
|
||||
let (mut route, payment_hash, payment_preimage, payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[3], 15_000_000);
|
||||
|
@ -781,9 +781,9 @@ fn do_test_partial_claim_before_restart(persist_both_monitors: bool) {
|
|||
if !persist_both_monitors {
|
||||
// If one of the two channels is still live, reveal the payment preimage over it.
|
||||
|
||||
nodes[3].node.peer_connected(&nodes[2].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[3].node.peer_connected(&nodes[2].node.get_our_node_id(), &msgs::Init { features: nodes[2].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let reestablish_1 = get_chan_reestablish_msgs!(nodes[3], nodes[2]);
|
||||
nodes[2].node.peer_connected(&nodes[3].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[2].node.peer_connected(&nodes[3].node.get_our_node_id(), &msgs::Init { features: nodes[3].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let reestablish_2 = get_chan_reestablish_msgs!(nodes[2], nodes[3]);
|
||||
|
||||
nodes[2].node.handle_channel_reestablish(&nodes[3].node.get_our_node_id(), &reestablish_1[0]);
|
||||
|
@ -841,8 +841,8 @@ fn do_forwarded_payment_no_manager_persistence(use_cs_commitment: bool, claim_ht
|
|||
|
||||
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan_id_1 = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let chan_id_2 = create_announced_chan_between_nodes(&nodes, 1, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let chan_id_1 = create_announced_chan_between_nodes(&nodes, 0, 1).2;
|
||||
let chan_id_2 = create_announced_chan_between_nodes(&nodes, 1, 2).2;
|
||||
|
||||
let intercept_scid = nodes[1].node.get_intercept_scid();
|
||||
|
||||
|
@ -1006,8 +1006,8 @@ fn removed_payment_no_manager_persistence() {
|
|||
|
||||
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan_id_1 = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let chan_id_2 = create_announced_chan_between_nodes(&nodes, 1, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let chan_id_1 = create_announced_chan_between_nodes(&nodes, 0, 1).2;
|
||||
let chan_id_2 = create_announced_chan_between_nodes(&nodes, 1, 2).2;
|
||||
|
||||
let (_, payment_hash, _) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 1_000_000);
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
use crate::chain::channelmonitor::ANTI_REORG_DELAY;
|
||||
use crate::chain::transaction::OutPoint;
|
||||
use crate::chain::Confirm;
|
||||
use crate::ln::channelmanager::{self, ChannelManager};
|
||||
use crate::ln::channelmanager::ChannelManager;
|
||||
use crate::ln::msgs::ChannelMessageHandler;
|
||||
use crate::util::events::{Event, MessageSendEvent, MessageSendEventsProvider, ClosureReason, HTLCDestination};
|
||||
use crate::util::test_utils;
|
||||
|
@ -50,8 +50,8 @@ fn do_test_onchain_htlc_reorg(local_commitment: bool, claim: bool) {
|
|||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_2 = create_announced_chan_between_nodes(&nodes, 1, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
let chan_2 = create_announced_chan_between_nodes(&nodes, 1, 2);
|
||||
|
||||
// Make sure all nodes are at the same starting height
|
||||
connect_blocks(&nodes[0], 2*CHAN_CONFIRM_DEPTH + 1 - nodes[0].best_block_info().1);
|
||||
|
@ -190,7 +190,7 @@ fn test_counterparty_revoked_reorg() {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 500_000_000, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 500_000_000);
|
||||
|
||||
// Get the initial commitment transaction for broadcast, before any HTLCs are added at all.
|
||||
let revoked_local_txn = get_local_commitment_txn!(nodes[0], chan.2);
|
||||
|
@ -264,7 +264,7 @@ fn do_test_unconf_chan(reload_node: bool, reorg_after_reload: bool, use_funding_
|
|||
*nodes[0].connect_style.borrow_mut() = connect_style;
|
||||
|
||||
let chan_conf_height = core::cmp::max(nodes[0].best_block_info().1 + 1, nodes[1].best_block_info().1 + 1);
|
||||
let chan = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
|
||||
{
|
||||
let per_peer_state = nodes[0].node.per_peer_state.read().unwrap();
|
||||
|
@ -374,7 +374,7 @@ fn do_test_unconf_chan(reload_node: bool, reorg_after_reload: bool, use_funding_
|
|||
nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().clear();
|
||||
|
||||
// Now check that we can create a new channel
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
send_payment(&nodes[0], &[&nodes[1]], 8000000);
|
||||
}
|
||||
|
||||
|
@ -427,7 +427,7 @@ fn test_set_outpoints_partial_claiming() {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1000000, 59000000, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1000000, 59000000);
|
||||
let (payment_preimage_1, payment_hash_1, _) = route_payment(&nodes[1], &[&nodes[0]], 3_000_000);
|
||||
let (payment_preimage_2, payment_hash_2, _) = route_payment(&nodes[1], &[&nodes[0]], 3_000_000);
|
||||
|
||||
|
@ -529,7 +529,7 @@ fn do_test_to_remote_after_local_detection(style: ConnectStyle) {
|
|||
*nodes[1].connect_style.borrow_mut() = style;
|
||||
|
||||
let (_, _, chan_id, funding_tx) =
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 100_000_000, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 100_000_000);
|
||||
let funding_outpoint = OutPoint { txid: funding_tx.txid(), index: 0 };
|
||||
assert_eq!(funding_outpoint.to_channel_id(), chan_id);
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ impl TryFrom<Script> for ShutdownScript {
|
|||
type Error = InvalidShutdownScript;
|
||||
|
||||
fn try_from(script: Script) -> Result<Self, Self::Error> {
|
||||
Self::try_from((script, &channelmanager::provided_init_features()))
|
||||
Self::try_from((script, &channelmanager::provided_init_features(&crate::util::config::UserConfig::default())))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,15 +41,15 @@ fn pre_funding_lock_shutdown_test() {
|
|||
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
let tx = create_chan_between_nodes_with_value_init(&nodes[0], &nodes[1], 8000000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let tx = create_chan_between_nodes_with_value_init(&nodes[0], &nodes[1], 8000000, 0);
|
||||
mine_transaction(&nodes[0], &tx);
|
||||
mine_transaction(&nodes[1], &tx);
|
||||
|
||||
nodes[0].node.close_channel(&OutPoint { txid: tx.txid(), index: 0 }.to_channel_id(), &nodes[1].node.get_our_node_id()).unwrap();
|
||||
let node_0_shutdown = get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[1].node.get_our_node_id());
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_0_shutdown);
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &nodes[0].node.init_features(), &node_0_shutdown);
|
||||
let node_1_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_1_shutdown);
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &nodes[1].node.init_features(), &node_1_shutdown);
|
||||
|
||||
let node_0_closing_signed = get_event_msg!(nodes[0], MessageSendEvent::SendClosingSigned, nodes[1].node.get_our_node_id());
|
||||
nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_closing_signed);
|
||||
|
@ -73,8 +73,8 @@ fn updates_shutdown_wait() {
|
|||
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_2 = create_announced_chan_between_nodes(&nodes, 1, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
let chan_2 = create_announced_chan_between_nodes(&nodes, 1, 2);
|
||||
let logger = test_utils::TestLogger::new();
|
||||
let scorer = test_utils::TestScorer::with_penalty(0);
|
||||
let keys_manager = test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
|
||||
|
@ -84,18 +84,18 @@ fn updates_shutdown_wait() {
|
|||
|
||||
nodes[0].node.close_channel(&chan_1.2, &nodes[1].node.get_our_node_id()).unwrap();
|
||||
let node_0_shutdown = get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[1].node.get_our_node_id());
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_0_shutdown);
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &nodes[0].node.init_features(), &node_0_shutdown);
|
||||
let node_1_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_1_shutdown);
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &nodes[1].node.init_features(), &node_1_shutdown);
|
||||
|
||||
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
|
||||
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
|
||||
|
||||
let (_, payment_hash, payment_secret) = get_payment_preimage_hash!(nodes[0]);
|
||||
|
||||
let payment_params_1 = PaymentParameters::from_node_id(nodes[1].node.get_our_node_id()).with_features(channelmanager::provided_invoice_features());
|
||||
let payment_params_1 = PaymentParameters::from_node_id(nodes[1].node.get_our_node_id()).with_features(nodes[1].node.invoice_features());
|
||||
let route_1 = get_route(&nodes[0].node.get_our_node_id(), &payment_params_1, &nodes[0].network_graph.read_only(), None, 100000, TEST_FINAL_CLTV, &logger, &scorer, &random_seed_bytes).unwrap();
|
||||
let payment_params_2 = PaymentParameters::from_node_id(nodes[0].node.get_our_node_id()).with_features(channelmanager::provided_invoice_features());
|
||||
let payment_params_2 = PaymentParameters::from_node_id(nodes[0].node.get_our_node_id()).with_features(nodes[0].node.invoice_features());
|
||||
let route_2 = get_route(&nodes[1].node.get_our_node_id(), &payment_params_2, &nodes[1].network_graph.read_only(), None, 100000, TEST_FINAL_CLTV, &logger, &scorer, &random_seed_bytes).unwrap();
|
||||
unwrap_send_err!(nodes[0].node.send_payment(&route_1, payment_hash, &Some(payment_secret), PaymentId(payment_hash.0)), true, APIError::ChannelUnavailable {..}, {});
|
||||
unwrap_send_err!(nodes[1].node.send_payment(&route_2, payment_hash, &Some(payment_secret), PaymentId(payment_hash.0)), true, APIError::ChannelUnavailable {..}, {});
|
||||
|
@ -154,8 +154,8 @@ fn htlc_fail_async_shutdown() {
|
|||
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_2 = create_announced_chan_between_nodes(&nodes, 1, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
let chan_2 = create_announced_chan_between_nodes(&nodes, 1, 2);
|
||||
|
||||
let (route, our_payment_hash, _, our_payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[2], 100000);
|
||||
nodes[0].node.send_payment(&route, our_payment_hash, &Some(our_payment_secret), PaymentId(our_payment_hash.0)).unwrap();
|
||||
|
@ -169,13 +169,13 @@ fn htlc_fail_async_shutdown() {
|
|||
|
||||
nodes[1].node.close_channel(&chan_1.2, &nodes[0].node.get_our_node_id()).unwrap();
|
||||
let node_1_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_1_shutdown);
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &nodes[1].node.init_features(), &node_1_shutdown);
|
||||
let node_0_shutdown = get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[1].node.get_our_node_id());
|
||||
|
||||
nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
|
||||
nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &updates.commitment_signed);
|
||||
check_added_monitors!(nodes[1], 1);
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_0_shutdown);
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &nodes[0].node.init_features(), &node_0_shutdown);
|
||||
commitment_signed_dance!(nodes[1], nodes[0], (), false, true, false);
|
||||
|
||||
let updates_2 = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
|
||||
|
@ -228,27 +228,27 @@ fn do_test_shutdown_rebroadcast(recv_count: u8) {
|
|||
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
|
||||
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_2 = create_announced_chan_between_nodes(&nodes, 1, 2, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
let chan_2 = create_announced_chan_between_nodes(&nodes, 1, 2);
|
||||
|
||||
let (payment_preimage, payment_hash, _) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 100_000);
|
||||
|
||||
nodes[1].node.close_channel(&chan_1.2, &nodes[0].node.get_our_node_id()).unwrap();
|
||||
let node_1_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());
|
||||
if recv_count > 0 {
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_1_shutdown);
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &nodes[1].node.init_features(), &node_1_shutdown);
|
||||
let node_0_shutdown = get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[1].node.get_our_node_id());
|
||||
if recv_count > 1 {
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_0_shutdown);
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &nodes[0].node.init_features(), &node_0_shutdown);
|
||||
}
|
||||
}
|
||||
|
||||
nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id(), false);
|
||||
nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id(), false);
|
||||
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: nodes[1].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let node_0_reestablish = get_chan_reestablish_msgs!(nodes[0], nodes[1]).pop().unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: nodes[0].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let node_1_reestablish = get_chan_reestablish_msgs!(nodes[1], nodes[0]).pop().unwrap();
|
||||
|
||||
nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &node_0_reestablish);
|
||||
|
@ -258,15 +258,15 @@ fn do_test_shutdown_rebroadcast(recv_count: u8) {
|
|||
nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &node_1_reestablish);
|
||||
let node_0_2nd_shutdown = if recv_count > 0 {
|
||||
let node_0_2nd_shutdown = get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[1].node.get_our_node_id());
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_1_2nd_shutdown);
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &nodes[1].node.init_features(), &node_1_2nd_shutdown);
|
||||
node_0_2nd_shutdown
|
||||
} else {
|
||||
let node_0_chan_update = get_event_msg!(nodes[0], MessageSendEvent::SendChannelUpdate, nodes[1].node.get_our_node_id());
|
||||
assert_eq!(node_0_chan_update.contents.flags & 2, 0); // "disabled" flag must not be set as we just reconnected.
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_1_2nd_shutdown);
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &nodes[1].node.init_features(), &node_1_2nd_shutdown);
|
||||
get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[1].node.get_our_node_id())
|
||||
};
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_0_2nd_shutdown);
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &nodes[0].node.init_features(), &node_0_2nd_shutdown);
|
||||
|
||||
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
|
||||
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
|
||||
|
@ -308,9 +308,9 @@ fn do_test_shutdown_rebroadcast(recv_count: u8) {
|
|||
nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id(), false);
|
||||
nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id(), false);
|
||||
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: nodes[0].node.init_features(), remote_network_address: None }).unwrap();
|
||||
let node_1_2nd_reestablish = get_chan_reestablish_msgs!(nodes[1], nodes[0]).pop().unwrap();
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
|
||||
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: nodes[1].node.init_features(), remote_network_address: None }).unwrap();
|
||||
if recv_count == 0 {
|
||||
// If all closing_signeds weren't delivered we can just resume where we left off...
|
||||
let node_0_2nd_reestablish = get_chan_reestablish_msgs!(nodes[0], nodes[1]).pop().unwrap();
|
||||
|
@ -339,10 +339,10 @@ fn do_test_shutdown_rebroadcast(recv_count: u8) {
|
|||
let node_1_3rd_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());
|
||||
assert!(node_1_3rd_shutdown == node_1_2nd_shutdown);
|
||||
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_0_3rd_shutdown);
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &nodes[0].node.init_features(), &node_0_3rd_shutdown);
|
||||
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
|
||||
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_1_3rd_shutdown);
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &nodes[1].node.init_features(), &node_1_3rd_shutdown);
|
||||
|
||||
nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed);
|
||||
let node_1_closing_signed = get_event_msg!(nodes[1], MessageSendEvent::SendClosingSigned, nodes[0].node.get_our_node_id());
|
||||
|
@ -415,30 +415,29 @@ fn test_upfront_shutdown_script() {
|
|||
let chanmon_cfgs = create_chanmon_cfgs(3);
|
||||
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &user_cfgs);
|
||||
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
// We test that in case of peer committing upfront to a script, if it changes at closing, we refuse to sign
|
||||
let flags = channelmanager::provided_init_features();
|
||||
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 2, 1000000, 1000000, flags.clone(), flags.clone());
|
||||
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 2, 1000000, 1000000);
|
||||
nodes[0].node.close_channel(&OutPoint { txid: chan.3.txid(), index: 0 }.to_channel_id(), &nodes[2].node.get_our_node_id()).unwrap();
|
||||
let node_0_orig_shutdown = get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[2].node.get_our_node_id());
|
||||
let mut node_0_shutdown = node_0_orig_shutdown.clone();
|
||||
node_0_shutdown.scriptpubkey = Builder::new().push_opcode(opcodes::all::OP_RETURN).into_script().to_p2sh();
|
||||
// Test we enforce upfront_scriptpbukey if by providing a different one at closing that we warn
|
||||
// the peer and ignore the message.
|
||||
nodes[2].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_0_shutdown);
|
||||
nodes[2].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &nodes[0].node.init_features(), &node_0_shutdown);
|
||||
assert!(regex::Regex::new(r"Got shutdown request with a scriptpubkey \([A-Fa-f0-9]+\) which did not match their previous scriptpubkey.")
|
||||
.unwrap().is_match(&check_warn_msg!(nodes[2], nodes[0].node.get_our_node_id(), chan.2)));
|
||||
// This allows nodes[2] to retry the shutdown message, which should get a response:
|
||||
nodes[2].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_0_orig_shutdown);
|
||||
nodes[2].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &nodes[0].node.init_features(), &node_0_orig_shutdown);
|
||||
get_event_msg!(nodes[2], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());
|
||||
|
||||
// We test that in case of peer committing upfront to a script, if it doesn't change at closing, we sign
|
||||
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 2, 1000000, 1000000, flags.clone(), flags.clone());
|
||||
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 2, 1000000, 1000000);
|
||||
nodes[0].node.close_channel(&OutPoint { txid: chan.3.txid(), index: 0 }.to_channel_id(), &nodes[2].node.get_our_node_id()).unwrap();
|
||||
let node_0_shutdown = get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[2].node.get_our_node_id());
|
||||
// We test that in case of peer committing upfront to a script, if it oesn't change at closing, we sign
|
||||
nodes[2].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_0_shutdown);
|
||||
nodes[2].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &nodes[0].node.init_features(), &node_0_shutdown);
|
||||
let events = nodes[2].node.get_and_clear_pending_msg_events();
|
||||
assert_eq!(events.len(), 1);
|
||||
match events[0] {
|
||||
|
@ -447,11 +446,11 @@ fn test_upfront_shutdown_script() {
|
|||
}
|
||||
|
||||
// We test that if case of peer non-signaling we don't enforce committed script at channel opening
|
||||
let flags_no = channelmanager::provided_init_features().clear_upfront_shutdown_script();
|
||||
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1000000, 1000000, flags_no, flags.clone());
|
||||
*nodes[0].override_init_features.borrow_mut() = Some(nodes[0].node.init_features().clear_upfront_shutdown_script());
|
||||
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1000000, 1000000);
|
||||
nodes[0].node.close_channel(&OutPoint { txid: chan.3.txid(), index: 0 }.to_channel_id(), &nodes[1].node.get_our_node_id()).unwrap();
|
||||
let node_1_shutdown = get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[1].node.get_our_node_id());
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_1_shutdown);
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &nodes[0].node.init_features(), &node_1_shutdown);
|
||||
check_added_monitors!(nodes[1], 1);
|
||||
let events = nodes[1].node.get_and_clear_pending_msg_events();
|
||||
assert_eq!(events.len(), 1);
|
||||
|
@ -462,11 +461,12 @@ fn test_upfront_shutdown_script() {
|
|||
|
||||
// We test that if user opt-out, we provide a zero-length script at channel opening and we are able to close
|
||||
// channel smoothly, opt-out is from channel initiator here
|
||||
let chan = create_announced_chan_between_nodes_with_value(&nodes, 1, 0, 1000000, 1000000, flags.clone(), flags.clone());
|
||||
*nodes[0].override_init_features.borrow_mut() = None;
|
||||
let chan = create_announced_chan_between_nodes_with_value(&nodes, 1, 0, 1000000, 1000000);
|
||||
nodes[1].node.close_channel(&OutPoint { txid: chan.3.txid(), index: 0 }.to_channel_id(), &nodes[0].node.get_our_node_id()).unwrap();
|
||||
check_added_monitors!(nodes[1], 1);
|
||||
let node_0_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_0_shutdown);
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &nodes[1].node.init_features(), &node_0_shutdown);
|
||||
let events = nodes[0].node.get_and_clear_pending_msg_events();
|
||||
assert_eq!(events.len(), 1);
|
||||
match events[0] {
|
||||
|
@ -476,11 +476,11 @@ fn test_upfront_shutdown_script() {
|
|||
|
||||
//// We test that if user opt-out, we provide a zero-length script at channel opening and we are able to close
|
||||
//// channel smoothly
|
||||
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1000000, 1000000, flags.clone(), flags.clone());
|
||||
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1000000, 1000000);
|
||||
nodes[1].node.close_channel(&OutPoint { txid: chan.3.txid(), index: 0 }.to_channel_id(), &nodes[0].node.get_our_node_id()).unwrap();
|
||||
check_added_monitors!(nodes[1], 1);
|
||||
let node_0_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_0_shutdown);
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &nodes[1].node.init_features(), &node_0_shutdown);
|
||||
let events = nodes[0].node.get_and_clear_pending_msg_events();
|
||||
assert_eq!(events.len(), 2);
|
||||
match events[0] {
|
||||
|
@ -501,7 +501,7 @@ fn test_unsupported_anysegwit_upfront_shutdown_script() {
|
|||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
// Use a non-v0 segwit script supported by option_shutdown_anysegwit
|
||||
let node_features = channelmanager::provided_init_features().clear_shutdown_anysegwit();
|
||||
let node_features = nodes[0].node.init_features().clear_shutdown_anysegwit();
|
||||
let anysegwit_shutdown_script = Builder::new()
|
||||
.push_int(16)
|
||||
.push_slice(&[0, 40])
|
||||
|
@ -526,7 +526,7 @@ fn test_unsupported_anysegwit_upfront_shutdown_script() {
|
|||
// Check script when handling an accept_channel message
|
||||
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 42, None).unwrap();
|
||||
let open_channel = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
|
||||
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), channelmanager::provided_init_features(), &open_channel);
|
||||
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), nodes[0].node.init_features(), &open_channel);
|
||||
let mut accept_channel = get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id());
|
||||
accept_channel.shutdown_scriptpubkey = Present(anysegwit_shutdown_script.clone());
|
||||
nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), node_features, &accept_channel);
|
||||
|
@ -557,7 +557,7 @@ fn test_invalid_upfront_shutdown_script() {
|
|||
open_channel.shutdown_scriptpubkey = Present(Builder::new().push_int(0)
|
||||
.push_slice(&[0, 0])
|
||||
.into_script());
|
||||
nodes[0].node.handle_open_channel(&nodes[1].node.get_our_node_id(), channelmanager::provided_init_features(), &open_channel);
|
||||
nodes[0].node.handle_open_channel(&nodes[1].node.get_our_node_id(), nodes[1].node.init_features(), &open_channel);
|
||||
|
||||
let events = nodes[0].node.get_and_clear_pending_msg_events();
|
||||
assert_eq!(events.len(), 1);
|
||||
|
@ -582,7 +582,7 @@ fn test_segwit_v0_shutdown_script() {
|
|||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &user_cfgs);
|
||||
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
nodes[1].node.close_channel(&OutPoint { txid: chan.3.txid(), index: 0 }.to_channel_id(), &nodes[0].node.get_our_node_id()).unwrap();
|
||||
check_added_monitors!(nodes[1], 1);
|
||||
|
||||
|
@ -591,7 +591,7 @@ fn test_segwit_v0_shutdown_script() {
|
|||
node_0_shutdown.scriptpubkey = Builder::new().push_int(0)
|
||||
.push_slice(&[0; 20])
|
||||
.into_script();
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_0_shutdown);
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &nodes[1].node.init_features(), &node_0_shutdown);
|
||||
|
||||
let events = nodes[0].node.get_and_clear_pending_msg_events();
|
||||
assert_eq!(events.len(), 2);
|
||||
|
@ -617,7 +617,7 @@ fn test_anysegwit_shutdown_script() {
|
|||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &user_cfgs);
|
||||
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
nodes[1].node.close_channel(&OutPoint { txid: chan.3.txid(), index: 0 }.to_channel_id(), &nodes[0].node.get_our_node_id()).unwrap();
|
||||
check_added_monitors!(nodes[1], 1);
|
||||
|
||||
|
@ -626,7 +626,7 @@ fn test_anysegwit_shutdown_script() {
|
|||
node_0_shutdown.scriptpubkey = Builder::new().push_int(16)
|
||||
.push_slice(&[0, 0])
|
||||
.into_script();
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_0_shutdown);
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &nodes[1].node.init_features(), &node_0_shutdown);
|
||||
|
||||
let events = nodes[0].node.get_and_clear_pending_msg_events();
|
||||
assert_eq!(events.len(), 2);
|
||||
|
@ -649,8 +649,8 @@ fn test_unsupported_anysegwit_shutdown_script() {
|
|||
let user_cfgs = [None, Some(config), None];
|
||||
let chanmon_cfgs = create_chanmon_cfgs(3);
|
||||
let mut node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
|
||||
node_cfgs[0].features = channelmanager::provided_init_features().clear_shutdown_anysegwit();
|
||||
node_cfgs[1].features = channelmanager::provided_init_features().clear_shutdown_anysegwit();
|
||||
*node_cfgs[0].override_init_features.borrow_mut() = Some(channelmanager::provided_init_features(&config).clear_shutdown_anysegwit());
|
||||
*node_cfgs[1].override_init_features.borrow_mut() = Some(channelmanager::provided_init_features(&config).clear_shutdown_anysegwit());
|
||||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &user_cfgs);
|
||||
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
|
@ -662,7 +662,7 @@ fn test_unsupported_anysegwit_shutdown_script() {
|
|||
.expect(OnGetShutdownScriptpubkey { returns: unsupported_shutdown_script.clone() })
|
||||
.expect(OnGetShutdownScriptpubkey { returns: supported_shutdown_script });
|
||||
|
||||
let chan = create_announced_chan_between_nodes(&nodes, 0, 1, node_cfgs[0].features.clone(), node_cfgs[1].features.clone());
|
||||
let chan = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
match nodes[1].node.close_channel(&OutPoint { txid: chan.3.txid(), index: 0 }.to_channel_id(), &nodes[0].node.get_our_node_id()) {
|
||||
Err(APIError::IncompatibleShutdownScript { script }) => {
|
||||
assert_eq!(script.into_inner(), unsupported_shutdown_script.clone().into_inner());
|
||||
|
@ -676,7 +676,7 @@ fn test_unsupported_anysegwit_shutdown_script() {
|
|||
// Use a non-v0 segwit script unsupported without option_shutdown_anysegwit
|
||||
let mut node_0_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());
|
||||
node_0_shutdown.scriptpubkey = unsupported_shutdown_script.into_inner();
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &node_cfgs[1].features, &node_0_shutdown);
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &nodes[1].override_init_features.borrow().as_ref().unwrap(), &node_0_shutdown);
|
||||
|
||||
assert_eq!(&check_warn_msg!(nodes[0], nodes[1].node.get_our_node_id(), chan.2),
|
||||
"Got a nonstandard scriptpubkey (60020028) from remote peer");
|
||||
|
@ -694,7 +694,7 @@ fn test_invalid_shutdown_script() {
|
|||
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &user_cfgs);
|
||||
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
nodes[1].node.close_channel(&OutPoint { txid: chan.3.txid(), index: 0 }.to_channel_id(), &nodes[0].node.get_our_node_id()).unwrap();
|
||||
check_added_monitors!(nodes[1], 1);
|
||||
|
||||
|
@ -703,7 +703,7 @@ fn test_invalid_shutdown_script() {
|
|||
node_0_shutdown.scriptpubkey = Builder::new().push_int(0)
|
||||
.push_slice(&[0, 0])
|
||||
.into_script();
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_0_shutdown);
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &nodes[1].node.init_features(), &node_0_shutdown);
|
||||
|
||||
assert_eq!(&check_warn_msg!(nodes[0], nodes[1].node.get_our_node_id(), chan.2),
|
||||
"Got a nonstandard scriptpubkey (00020000) from remote peer");
|
||||
|
@ -729,15 +729,15 @@ fn do_test_closing_signed_reinit_timeout(timeout_step: TimeoutStep) {
|
|||
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
|
||||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
let chan_id = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
|
||||
let chan_id = create_announced_chan_between_nodes(&nodes, 0, 1).2;
|
||||
|
||||
send_payment(&nodes[0], &[&nodes[1]], 8_000_000);
|
||||
|
||||
nodes[0].node.close_channel(&chan_id, &nodes[1].node.get_our_node_id()).unwrap();
|
||||
let node_0_shutdown = get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[1].node.get_our_node_id());
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_0_shutdown);
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &nodes[0].node.init_features(), &node_0_shutdown);
|
||||
let node_1_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_1_shutdown);
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &nodes[1].node.init_features(), &node_1_shutdown);
|
||||
|
||||
{
|
||||
// Now we set nodes[1] to require a relatively high feerate for closing. This should result
|
||||
|
@ -826,7 +826,7 @@ fn do_simple_legacy_shutdown_test(high_initiator_fee: bool) {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
|
||||
if high_initiator_fee {
|
||||
// If high_initiator_fee is set, set nodes[0]'s feerate significantly higher. This
|
||||
|
@ -837,9 +837,9 @@ fn do_simple_legacy_shutdown_test(high_initiator_fee: bool) {
|
|||
|
||||
nodes[0].node.close_channel(&OutPoint { txid: chan.3.txid(), index: 0 }.to_channel_id(), &nodes[1].node.get_our_node_id()).unwrap();
|
||||
let node_0_shutdown = get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[1].node.get_our_node_id());
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_0_shutdown);
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &nodes[0].node.init_features(), &node_0_shutdown);
|
||||
let node_1_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_1_shutdown);
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &nodes[1].node.init_features(), &node_1_shutdown);
|
||||
|
||||
let mut node_0_closing_signed = get_event_msg!(nodes[0], MessageSendEvent::SendClosingSigned, nodes[1].node.get_our_node_id());
|
||||
node_0_closing_signed.fee_range = None;
|
||||
|
@ -874,7 +874,7 @@ fn simple_target_feerate_shutdown() {
|
|||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
|
||||
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
|
||||
let chan = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
|
||||
let chan = create_announced_chan_between_nodes(&nodes, 0, 1);
|
||||
let chan_id = OutPoint { txid: chan.3.txid(), index: 0 }.to_channel_id();
|
||||
|
||||
nodes[0].node.close_channel_with_target_feerate(&chan_id, &nodes[1].node.get_our_node_id(), 253 * 10).unwrap();
|
||||
|
@ -882,8 +882,8 @@ fn simple_target_feerate_shutdown() {
|
|||
nodes[1].node.close_channel_with_target_feerate(&chan_id, &nodes[0].node.get_our_node_id(), 253 * 5).unwrap();
|
||||
let node_1_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());
|
||||
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_0_shutdown);
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &channelmanager::provided_init_features(), &node_1_shutdown);
|
||||
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &nodes[0].node.init_features(), &node_0_shutdown);
|
||||
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &nodes[1].node.init_features(), &node_1_shutdown);
|
||||
|
||||
let node_0_closing_signed = get_event_msg!(nodes[0], MessageSendEvent::SendClosingSigned, nodes[1].node.get_our_node_id());
|
||||
nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_closing_signed);
|
||||
|
|
|
@ -1940,6 +1940,7 @@ mod tests {
|
|||
use crate::ln::msgs::{RoutingMessageHandler, UnsignedNodeAnnouncement, NodeAnnouncement,
|
||||
UnsignedChannelAnnouncement, ChannelAnnouncement, UnsignedChannelUpdate, ChannelUpdate,
|
||||
ReplyChannelRange, QueryChannelRange, QueryShortChannelIds, MAX_VALUE_MSAT};
|
||||
use crate::util::config::UserConfig;
|
||||
use crate::util::test_utils;
|
||||
use crate::util::ser::{ReadableArgs, Writeable};
|
||||
use crate::util::events::{MessageSendEvent, MessageSendEventsProvider};
|
||||
|
@ -1999,7 +2000,7 @@ mod tests {
|
|||
fn get_signed_node_announcement<F: Fn(&mut UnsignedNodeAnnouncement)>(f: F, node_key: &SecretKey, secp_ctx: &Secp256k1<secp256k1::All>) -> NodeAnnouncement {
|
||||
let node_id = PublicKey::from_secret_key(&secp_ctx, node_key);
|
||||
let mut unsigned_announcement = UnsignedNodeAnnouncement {
|
||||
features: channelmanager::provided_node_features(),
|
||||
features: channelmanager::provided_node_features(&UserConfig::default()),
|
||||
timestamp: 100,
|
||||
node_id: node_id,
|
||||
rgb: [0; 3],
|
||||
|
@ -2023,7 +2024,7 @@ mod tests {
|
|||
let node_2_btckey = &SecretKey::from_slice(&[39; 32]).unwrap();
|
||||
|
||||
let mut unsigned_announcement = UnsignedChannelAnnouncement {
|
||||
features: channelmanager::provided_channel_features(),
|
||||
features: channelmanager::provided_channel_features(&UserConfig::default()),
|
||||
chain_hash: genesis_block(Network::Testnet).header.block_hash(),
|
||||
short_channel_id: 0,
|
||||
node_id_1,
|
||||
|
@ -3157,6 +3158,7 @@ mod tests {
|
|||
let node_cfgs = crate::ln::functional_test_utils::create_node_cfgs(2, &chanmon_cfgs);
|
||||
let node_chanmgrs = crate::ln::functional_test_utils::create_node_chanmgrs(2, &node_cfgs, &[None, None, None, None]);
|
||||
let nodes = crate::ln::functional_test_utils::create_network(2, &node_cfgs, &node_chanmgrs);
|
||||
let config = crate::ln::functional_test_utils::test_default_channel_config();
|
||||
|
||||
// 1. Test encoding/decoding of ChannelUpdateInfo
|
||||
let chan_update_info = ChannelUpdateInfo {
|
||||
|
@ -3193,7 +3195,7 @@ mod tests {
|
|||
// 2. Test encoding/decoding of ChannelInfo
|
||||
// Check we can encode/decode ChannelInfo without ChannelUpdateInfo fields present.
|
||||
let chan_info_none_updates = ChannelInfo {
|
||||
features: channelmanager::provided_channel_features(),
|
||||
features: channelmanager::provided_channel_features(&config),
|
||||
node_one: NodeId::from_pubkey(&nodes[0].node.get_our_node_id()),
|
||||
one_to_two: None,
|
||||
node_two: NodeId::from_pubkey(&nodes[1].node.get_our_node_id()),
|
||||
|
@ -3211,7 +3213,7 @@ mod tests {
|
|||
|
||||
// Check we can encode/decode ChannelInfo with ChannelUpdateInfo fields present.
|
||||
let chan_info_some_updates = ChannelInfo {
|
||||
features: channelmanager::provided_channel_features(),
|
||||
features: channelmanager::provided_channel_features(&config),
|
||||
node_one: NodeId::from_pubkey(&nodes[0].node.get_our_node_id()),
|
||||
one_to_two: Some(chan_update_info.clone()),
|
||||
node_two: NodeId::from_pubkey(&nodes[1].node.get_our_node_id()),
|
||||
|
@ -3253,7 +3255,7 @@ mod tests {
|
|||
// 1. Check we can read a valid NodeAnnouncementInfo and fail on an invalid one
|
||||
let valid_netaddr = crate::ln::msgs::NetAddress::Hostname { hostname: crate::util::ser::Hostname::try_from("A".to_string()).unwrap(), port: 1234 };
|
||||
let valid_node_ann_info = NodeAnnouncementInfo {
|
||||
features: channelmanager::provided_node_features(),
|
||||
features: channelmanager::provided_node_features(&UserConfig::default()),
|
||||
last_update: 0,
|
||||
rgb: [0u8; 3],
|
||||
alias: NodeAlias([0u8; 32]),
|
||||
|
|
|
@ -2143,6 +2143,7 @@ mod tests {
|
|||
use crate::ln::features::{ChannelFeatures, InitFeatures, NodeFeatures};
|
||||
use crate::ln::msgs::{ErrorAction, LightningError, UnsignedChannelUpdate, MAX_VALUE_MSAT};
|
||||
use crate::ln::channelmanager;
|
||||
use crate::util::config::UserConfig;
|
||||
use crate::util::test_utils as ln_test_utils;
|
||||
use crate::util::chacha20::ChaCha20;
|
||||
#[cfg(c_bindings)]
|
||||
|
@ -2386,7 +2387,8 @@ mod tests {
|
|||
fn htlc_minimum_overpay_test() {
|
||||
let (secp_ctx, network_graph, gossip_sync, _, logger) = build_graph();
|
||||
let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[2]).with_features(channelmanager::provided_invoice_features());
|
||||
let config = UserConfig::default();
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[2]).with_features(channelmanager::provided_invoice_features(&config));
|
||||
let scorer = ln_test_utils::TestScorer::with_penalty(0);
|
||||
let keys_manager = ln_test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
|
||||
let random_seed_bytes = keys_manager.get_secure_random_bytes();
|
||||
|
@ -3359,7 +3361,8 @@ mod tests {
|
|||
let scorer = ln_test_utils::TestScorer::with_penalty(0);
|
||||
let keys_manager = ln_test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
|
||||
let random_seed_bytes = keys_manager.get_secure_random_bytes();
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[2]).with_features(channelmanager::provided_invoice_features());
|
||||
let config = UserConfig::default();
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[2]).with_features(channelmanager::provided_invoice_features(&config));
|
||||
|
||||
// We will use a simple single-path route from
|
||||
// our node to node2 via node0: channels {1, 3}.
|
||||
|
@ -3633,7 +3636,8 @@ mod tests {
|
|||
let scorer = ln_test_utils::TestScorer::with_penalty(0);
|
||||
let keys_manager = ln_test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
|
||||
let random_seed_bytes = keys_manager.get_secure_random_bytes();
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[3]).with_features(channelmanager::provided_invoice_features());
|
||||
let config = UserConfig::default();
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[3]).with_features(channelmanager::provided_invoice_features(&config));
|
||||
|
||||
// Path via {node7, node2, node4} is channels {12, 13, 6, 11}.
|
||||
// {12, 13, 11} have the capacities of 100, {6} has a capacity of 50.
|
||||
|
@ -3806,8 +3810,9 @@ mod tests {
|
|||
let scorer = ln_test_utils::TestScorer::with_penalty(0);
|
||||
let keys_manager = ln_test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
|
||||
let random_seed_bytes = keys_manager.get_secure_random_bytes();
|
||||
let config = UserConfig::default();
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[2])
|
||||
.with_features(channelmanager::provided_invoice_features());
|
||||
.with_features(channelmanager::provided_invoice_features(&config));
|
||||
|
||||
// We need a route consisting of 3 paths:
|
||||
// From our node to node2 via node0, node7, node1 (three paths one hop each).
|
||||
|
@ -3965,7 +3970,8 @@ mod tests {
|
|||
let scorer = ln_test_utils::TestScorer::with_penalty(0);
|
||||
let keys_manager = ln_test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
|
||||
let random_seed_bytes = keys_manager.get_secure_random_bytes();
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[3]).with_features(channelmanager::provided_invoice_features());
|
||||
let config = UserConfig::default();
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[3]).with_features(channelmanager::provided_invoice_features(&config));
|
||||
|
||||
// We need a route consisting of 3 paths:
|
||||
// From our node to node3 via {node0, node2}, {node7, node2, node4} and {node7, node2}.
|
||||
|
@ -4129,7 +4135,8 @@ mod tests {
|
|||
let scorer = ln_test_utils::TestScorer::with_penalty(0);
|
||||
let keys_manager = ln_test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
|
||||
let random_seed_bytes = keys_manager.get_secure_random_bytes();
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[3]).with_features(channelmanager::provided_invoice_features());
|
||||
let config = UserConfig::default();
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[3]).with_features(channelmanager::provided_invoice_features(&config));
|
||||
|
||||
// This test checks that if we have two cheaper paths and one more expensive path,
|
||||
// so that liquidity-wise any 2 of 3 combination is sufficient,
|
||||
|
@ -4298,7 +4305,8 @@ mod tests {
|
|||
let scorer = ln_test_utils::TestScorer::with_penalty(0);
|
||||
let keys_manager = ln_test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
|
||||
let random_seed_bytes = keys_manager.get_secure_random_bytes();
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[3]).with_features(channelmanager::provided_invoice_features());
|
||||
let config = UserConfig::default();
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[3]).with_features(channelmanager::provided_invoice_features(&config));
|
||||
|
||||
// We need a route consisting of 2 paths:
|
||||
// From our node to node3 via {node0, node2} and {node7, node2, node4}.
|
||||
|
@ -4479,7 +4487,8 @@ mod tests {
|
|||
let scorer = ln_test_utils::TestScorer::with_penalty(0);
|
||||
let keys_manager = ln_test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
|
||||
let random_seed_bytes = keys_manager.get_secure_random_bytes();
|
||||
let payment_params = PaymentParameters::from_node_id(PublicKey::from_slice(&[02; 33]).unwrap()).with_features(channelmanager::provided_invoice_features())
|
||||
let config = UserConfig::default();
|
||||
let payment_params = PaymentParameters::from_node_id(PublicKey::from_slice(&[02; 33]).unwrap()).with_features(channelmanager::provided_invoice_features(&config))
|
||||
.with_route_hints(vec![RouteHint(vec![RouteHintHop {
|
||||
src_node_id: nodes[2],
|
||||
short_channel_id: 42,
|
||||
|
@ -4570,7 +4579,8 @@ mod tests {
|
|||
let scorer = ln_test_utils::TestScorer::with_penalty(0);
|
||||
let keys_manager = ln_test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
|
||||
let random_seed_bytes = keys_manager.get_secure_random_bytes();
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[2]).with_features(channelmanager::provided_invoice_features())
|
||||
let config = UserConfig::default();
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[2]).with_features(channelmanager::provided_invoice_features(&config))
|
||||
.with_max_channel_saturation_power_of_half(0);
|
||||
|
||||
// We need a route consisting of 3 paths:
|
||||
|
@ -4926,7 +4936,8 @@ mod tests {
|
|||
let scorer = ln_test_utils::TestScorer::with_penalty(0);
|
||||
let keys_manager = ln_test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
|
||||
let random_seed_bytes = keys_manager.get_secure_random_bytes();
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[2]).with_features(channelmanager::provided_invoice_features());
|
||||
let config = UserConfig::default();
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[2]).with_features(channelmanager::provided_invoice_features(&config));
|
||||
|
||||
// We modify the graph to set the htlc_minimum of channel 2 and 4 as needed - channel 2
|
||||
// gets an htlc_maximum_msat of 80_000 and channel 4 an htlc_minimum_msat of 90_000. We
|
||||
|
@ -4975,7 +4986,7 @@ mod tests {
|
|||
assert_eq!(route.paths[0][1].short_channel_id, 13);
|
||||
assert_eq!(route.paths[0][1].fee_msat, 90_000);
|
||||
assert_eq!(route.paths[0][1].cltv_expiry_delta, 42);
|
||||
assert_eq!(route.paths[0][1].node_features.le_flags(), channelmanager::provided_invoice_features().le_flags());
|
||||
assert_eq!(route.paths[0][1].node_features.le_flags(), channelmanager::provided_invoice_features(&config).le_flags());
|
||||
assert_eq!(route.paths[0][1].channel_features.le_flags(), &id_to_feature_flags(13));
|
||||
}
|
||||
}
|
||||
|
@ -4994,14 +5005,15 @@ mod tests {
|
|||
let logger = Arc::new(ln_test_utils::TestLogger::new());
|
||||
let network_graph = NetworkGraph::new(genesis_hash, Arc::clone(&logger));
|
||||
let scorer = ln_test_utils::TestScorer::with_penalty(0);
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[0]).with_features(channelmanager::provided_invoice_features());
|
||||
let config = UserConfig::default();
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[0]).with_features(channelmanager::provided_invoice_features(&config));
|
||||
let keys_manager = ln_test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
|
||||
let random_seed_bytes = keys_manager.get_secure_random_bytes();
|
||||
|
||||
{
|
||||
let route = get_route(&our_id, &payment_params, &network_graph.read_only(), Some(&[
|
||||
&get_channel_details(Some(3), nodes[0], channelmanager::provided_init_features(), 200_000),
|
||||
&get_channel_details(Some(2), nodes[0], channelmanager::provided_init_features(), 10_000),
|
||||
&get_channel_details(Some(3), nodes[0], channelmanager::provided_init_features(&config), 200_000),
|
||||
&get_channel_details(Some(2), nodes[0], channelmanager::provided_init_features(&config), 10_000),
|
||||
]), 100_000, 42, Arc::clone(&logger), &scorer, &random_seed_bytes).unwrap();
|
||||
assert_eq!(route.paths.len(), 1);
|
||||
assert_eq!(route.paths[0].len(), 1);
|
||||
|
@ -5012,8 +5024,8 @@ mod tests {
|
|||
}
|
||||
{
|
||||
let route = get_route(&our_id, &payment_params, &network_graph.read_only(), Some(&[
|
||||
&get_channel_details(Some(3), nodes[0], channelmanager::provided_init_features(), 50_000),
|
||||
&get_channel_details(Some(2), nodes[0], channelmanager::provided_init_features(), 50_000),
|
||||
&get_channel_details(Some(3), nodes[0], channelmanager::provided_init_features(&config), 50_000),
|
||||
&get_channel_details(Some(2), nodes[0], channelmanager::provided_init_features(&config), 50_000),
|
||||
]), 100_000, 42, Arc::clone(&logger), &scorer, &random_seed_bytes).unwrap();
|
||||
assert_eq!(route.paths.len(), 2);
|
||||
assert_eq!(route.paths[0].len(), 1);
|
||||
|
@ -5038,14 +5050,14 @@ mod tests {
|
|||
// smallest of them, avoiding further fragmenting our available outbound balance to
|
||||
// this node.
|
||||
let route = get_route(&our_id, &payment_params, &network_graph.read_only(), Some(&[
|
||||
&get_channel_details(Some(2), nodes[0], channelmanager::provided_init_features(), 50_000),
|
||||
&get_channel_details(Some(3), nodes[0], channelmanager::provided_init_features(), 50_000),
|
||||
&get_channel_details(Some(5), nodes[0], channelmanager::provided_init_features(), 50_000),
|
||||
&get_channel_details(Some(6), nodes[0], channelmanager::provided_init_features(), 300_000),
|
||||
&get_channel_details(Some(7), nodes[0], channelmanager::provided_init_features(), 50_000),
|
||||
&get_channel_details(Some(8), nodes[0], channelmanager::provided_init_features(), 50_000),
|
||||
&get_channel_details(Some(9), nodes[0], channelmanager::provided_init_features(), 50_000),
|
||||
&get_channel_details(Some(4), nodes[0], channelmanager::provided_init_features(), 1_000_000),
|
||||
&get_channel_details(Some(2), nodes[0], channelmanager::provided_init_features(&config), 50_000),
|
||||
&get_channel_details(Some(3), nodes[0], channelmanager::provided_init_features(&config), 50_000),
|
||||
&get_channel_details(Some(5), nodes[0], channelmanager::provided_init_features(&config), 50_000),
|
||||
&get_channel_details(Some(6), nodes[0], channelmanager::provided_init_features(&config), 300_000),
|
||||
&get_channel_details(Some(7), nodes[0], channelmanager::provided_init_features(&config), 50_000),
|
||||
&get_channel_details(Some(8), nodes[0], channelmanager::provided_init_features(&config), 50_000),
|
||||
&get_channel_details(Some(9), nodes[0], channelmanager::provided_init_features(&config), 50_000),
|
||||
&get_channel_details(Some(4), nodes[0], channelmanager::provided_init_features(&config), 1_000_000),
|
||||
]), 100_000, 42, Arc::clone(&logger), &scorer, &random_seed_bytes).unwrap();
|
||||
assert_eq!(route.paths.len(), 1);
|
||||
assert_eq!(route.paths[0].len(), 1);
|
||||
|
@ -5487,7 +5499,8 @@ mod tests {
|
|||
excess_data: Vec::new()
|
||||
});
|
||||
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[2]).with_features(channelmanager::provided_invoice_features());
|
||||
let config = UserConfig::default();
|
||||
let payment_params = PaymentParameters::from_node_id(nodes[2]).with_features(channelmanager::provided_invoice_features(&config));
|
||||
let keys_manager = ln_test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
|
||||
let random_seed_bytes = keys_manager.get_secure_random_bytes();
|
||||
// 100,000 sats is less than the available liquidity on each channel, set above.
|
||||
|
@ -5561,6 +5574,7 @@ mod tests {
|
|||
let graph = NetworkGraph::read(&mut d, &logger).unwrap();
|
||||
let keys_manager = ln_test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet);
|
||||
let random_seed_bytes = keys_manager.get_secure_random_bytes();
|
||||
let config = UserConfig::default();
|
||||
|
||||
// First, get 100 (source, destination) pairs for which route-getting actually succeeds...
|
||||
let mut seed = random_init_seed() as usize;
|
||||
|
@ -5571,7 +5585,7 @@ mod tests {
|
|||
let src = &PublicKey::from_slice(nodes.keys().skip(seed % nodes.len()).next().unwrap().as_slice()).unwrap();
|
||||
seed = seed.overflowing_mul(0xdeadbeef).0;
|
||||
let dst = PublicKey::from_slice(nodes.keys().skip(seed % nodes.len()).next().unwrap().as_slice()).unwrap();
|
||||
let payment_params = PaymentParameters::from_node_id(dst).with_features(channelmanager::provided_invoice_features());
|
||||
let payment_params = PaymentParameters::from_node_id(dst).with_features(channelmanager::provided_invoice_features(&config));
|
||||
let amt = seed as u64 % 200_000_000;
|
||||
let params = ProbabilisticScoringParameters::default();
|
||||
let scorer = ProbabilisticScorer::new(params, &graph, &logger);
|
||||
|
@ -5658,6 +5672,7 @@ mod benches {
|
|||
use crate::ln::features::InvoiceFeatures;
|
||||
use crate::routing::gossip::NetworkGraph;
|
||||
use crate::routing::scoring::{FixedPenaltyScorer, ProbabilisticScorer, ProbabilisticScoringParameters};
|
||||
use crate::util::config::UserConfig;
|
||||
use crate::util::logger::{Logger, Record};
|
||||
use crate::util::ser::ReadableArgs;
|
||||
|
||||
|
@ -5683,7 +5698,7 @@ mod benches {
|
|||
ChannelDetails {
|
||||
channel_id: [0; 32],
|
||||
counterparty: ChannelCounterparty {
|
||||
features: channelmanager::provided_init_features(),
|
||||
features: channelmanager::provided_init_features(&UserConfig::default()),
|
||||
node_id,
|
||||
unspendable_punishment_reserve: 0,
|
||||
forwarding_info: None,
|
||||
|
@ -5730,7 +5745,7 @@ mod benches {
|
|||
let logger = DummyLogger {};
|
||||
let network_graph = read_network_graph(&logger);
|
||||
let scorer = FixedPenaltyScorer::with_penalty(0);
|
||||
generate_routes(bench, &network_graph, scorer, channelmanager::provided_invoice_features());
|
||||
generate_routes(bench, &network_graph, scorer, channelmanager::provided_invoice_features(&UserConfig::default()));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
|
@ -5748,7 +5763,7 @@ mod benches {
|
|||
let network_graph = read_network_graph(&logger);
|
||||
let params = ProbabilisticScoringParameters::default();
|
||||
let scorer = ProbabilisticScorer::new(params, &network_graph, &logger);
|
||||
generate_routes(bench, &network_graph, scorer, channelmanager::provided_invoice_features());
|
||||
generate_routes(bench, &network_graph, scorer, channelmanager::provided_invoice_features(&UserConfig::default()));
|
||||
}
|
||||
|
||||
fn generate_routes<S: Score>(
|
||||
|
|
|
@ -1602,6 +1602,7 @@ impl<T: Time> Readable for ChannelLiquidity<T> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{ChannelLiquidity, HistoricalBucketRangeTracker, ProbabilisticScoringParameters, ProbabilisticScorerUsingTime};
|
||||
use crate::util::config::UserConfig;
|
||||
use crate::util::time::Time;
|
||||
use crate::util::time::tests::SinceEpoch;
|
||||
|
||||
|
@ -1696,7 +1697,7 @@ mod tests {
|
|||
let node_2_secret = &SecretKey::from_slice(&[40; 32]).unwrap();
|
||||
let secp_ctx = Secp256k1::new();
|
||||
let unsigned_announcement = UnsignedChannelAnnouncement {
|
||||
features: channelmanager::provided_channel_features(),
|
||||
features: channelmanager::provided_channel_features(&UserConfig::default()),
|
||||
chain_hash: genesis_hash,
|
||||
short_channel_id,
|
||||
node_id_1: PublicKey::from_secret_key(&secp_ctx, &node_1_key),
|
||||
|
@ -1747,11 +1748,12 @@ mod tests {
|
|||
}
|
||||
|
||||
fn path_hop(pubkey: PublicKey, short_channel_id: u64, fee_msat: u64) -> RouteHop {
|
||||
let config = UserConfig::default();
|
||||
RouteHop {
|
||||
pubkey,
|
||||
node_features: channelmanager::provided_node_features(),
|
||||
node_features: channelmanager::provided_node_features(&config),
|
||||
short_channel_id,
|
||||
channel_features: channelmanager::provided_channel_features(),
|
||||
channel_features: channelmanager::provided_channel_features(&config),
|
||||
fee_msat,
|
||||
cltv_expiry_delta: 18,
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ use crate::ln::script::ShutdownScript;
|
|||
use crate::routing::gossip::NetworkGraph;
|
||||
use crate::routing::router::{find_route, InFlightHtlcs, Route, RouteHop, RouteParameters, Router, ScorerAccountingForInFlightHtlcs};
|
||||
use crate::routing::scoring::FixedPenaltyScorer;
|
||||
use crate::util::config::UserConfig;
|
||||
use crate::util::enforcing_trait_impls::{EnforcingSigner, EnforcementState};
|
||||
use crate::util::events;
|
||||
use crate::util::logger::{Logger, Level, Record};
|
||||
|
@ -397,10 +398,10 @@ impl msgs::ChannelMessageHandler for TestChannelMessageHandler {
|
|||
self.received_msg(wire::Message::Error(msg.clone()));
|
||||
}
|
||||
fn provided_node_features(&self) -> NodeFeatures {
|
||||
channelmanager::provided_node_features()
|
||||
channelmanager::provided_node_features(&UserConfig::default())
|
||||
}
|
||||
fn provided_init_features(&self, _their_init_features: &PublicKey) -> InitFeatures {
|
||||
channelmanager::provided_init_features()
|
||||
channelmanager::provided_init_features(&UserConfig::default())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue