networks: None,
remote_network_address: None,
};
- $source.peer_connected(&$dest.get_our_node_id(), &init_dest, true).unwrap();
+ $source.peer_connected($dest.get_our_node_id(), &init_dest, true).unwrap();
let init_src = Init {
features: $source.init_features(),
networks: None,
remote_network_address: None,
};
- $dest.peer_connected(&$source.get_our_node_id(), &init_src, false).unwrap();
+ $dest.peer_connected($source.get_our_node_id(), &init_src, false).unwrap();
$source.create_channel($dest.get_our_node_id(), 100_000, 42, 0, None, None).unwrap();
let open_channel = {
}
};
- $dest.handle_open_channel(&$source.get_our_node_id(), &open_channel);
+ $dest.handle_open_channel($source.get_our_node_id(), &open_channel);
let accept_channel = {
if anchors {
let events = $dest.get_and_clear_pending_events();
}
};
- $source.handle_accept_channel(&$dest.get_our_node_id(), &accept_channel);
+ $source.handle_accept_channel($dest.get_our_node_id(), &accept_channel);
let funding_output;
{
let mut events = $source.get_and_clear_pending_events();
panic!("Wrong event type");
}
};
- $dest.handle_funding_created(&$source.get_our_node_id(), &funding_created);
+ $dest.handle_funding_created($source.get_our_node_id(), &funding_created);
let funding_signed = {
let events = $dest.get_and_clear_pending_msg_events();
panic!("Wrong event type");
}
- $source.handle_funding_signed(&$dest.get_our_node_id(), &funding_signed);
+ $source.handle_funding_signed($dest.get_our_node_id(), &funding_signed);
let events = $source.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
if let events::Event::ChannelPending { ref counterparty_node_id, .. } = events[0] {
{
for node in $nodes.iter() {
if node.get_our_node_id() == *node_id {
- node.handle_channel_ready(&$nodes[idx].get_our_node_id(), msg);
+ node.handle_channel_ready($nodes[idx].get_our_node_id(), msg);
}
}
} else {
for update_add in update_add_htlcs.iter() {
out.locked_write(format!("Delivering update_add_htlc to node {}.\n", idx).as_bytes());
if !$corrupt_forward {
- dest.handle_update_add_htlc(&nodes[$node].get_our_node_id(), update_add);
+ dest.handle_update_add_htlc(nodes[$node].get_our_node_id(), update_add);
} else {
// Corrupt the update_add_htlc message so that its HMAC
// check will fail and we generate a
let mut msg_ser = update_add.encode();
msg_ser[1000] ^= 0xff;
let new_msg = UpdateAddHTLC::read(&mut Cursor::new(&msg_ser)).unwrap();
- dest.handle_update_add_htlc(&nodes[$node].get_our_node_id(), &new_msg);
+ dest.handle_update_add_htlc(nodes[$node].get_our_node_id(), &new_msg);
}
}
for update_fulfill in update_fulfill_htlcs.iter() {
out.locked_write(format!("Delivering update_fulfill_htlc to node {}.\n", idx).as_bytes());
- dest.handle_update_fulfill_htlc(&nodes[$node].get_our_node_id(), update_fulfill);
+ dest.handle_update_fulfill_htlc(nodes[$node].get_our_node_id(), update_fulfill);
}
for update_fail in update_fail_htlcs.iter() {
out.locked_write(format!("Delivering update_fail_htlc to node {}.\n", idx).as_bytes());
- dest.handle_update_fail_htlc(&nodes[$node].get_our_node_id(), update_fail);
+ dest.handle_update_fail_htlc(nodes[$node].get_our_node_id(), update_fail);
}
for update_fail_malformed in update_fail_malformed_htlcs.iter() {
out.locked_write(format!("Delivering update_fail_malformed_htlc to node {}.\n", idx).as_bytes());
- dest.handle_update_fail_malformed_htlc(&nodes[$node].get_our_node_id(), update_fail_malformed);
+ dest.handle_update_fail_malformed_htlc(nodes[$node].get_our_node_id(), update_fail_malformed);
}
if let Some(msg) = update_fee {
out.locked_write(format!("Delivering update_fee to node {}.\n", idx).as_bytes());
- dest.handle_update_fee(&nodes[$node].get_our_node_id(), &msg);
+ dest.handle_update_fee(nodes[$node].get_our_node_id(), &msg);
}
let processed_change = !update_add_htlcs.is_empty() || !update_fulfill_htlcs.is_empty() ||
!update_fail_htlcs.is_empty() || !update_fail_malformed_htlcs.is_empty();
break;
}
out.locked_write(format!("Delivering commitment_signed to node {}.\n", idx).as_bytes());
- dest.handle_commitment_signed(&nodes[$node].get_our_node_id(), &commitment_signed);
+ dest.handle_commitment_signed(nodes[$node].get_our_node_id(), &commitment_signed);
break;
}
}
for (idx, dest) in nodes.iter().enumerate() {
if dest.get_our_node_id() == *node_id {
out.locked_write(format!("Delivering revoke_and_ack to node {}.\n", idx).as_bytes());
- dest.handle_revoke_and_ack(&nodes[$node].get_our_node_id(), msg);
+ dest.handle_revoke_and_ack(nodes[$node].get_our_node_id(), msg);
}
}
},
for (idx, dest) in nodes.iter().enumerate() {
if dest.get_our_node_id() == *node_id {
out.locked_write(format!("Delivering channel_reestablish to node {}.\n", idx).as_bytes());
- dest.handle_channel_reestablish(&nodes[$node].get_our_node_id(), msg);
+ dest.handle_channel_reestablish(nodes[$node].get_our_node_id(), msg);
}
}
},
0x0c => {
if !chan_a_disconnected {
- nodes[0].peer_disconnected(&nodes[1].get_our_node_id());
- nodes[1].peer_disconnected(&nodes[0].get_our_node_id());
+ nodes[0].peer_disconnected(nodes[1].get_our_node_id());
+ nodes[1].peer_disconnected(nodes[0].get_our_node_id());
chan_a_disconnected = true;
drain_msg_events_on_disconnect!(0);
}
},
0x0d => {
if !chan_b_disconnected {
- nodes[1].peer_disconnected(&nodes[2].get_our_node_id());
- nodes[2].peer_disconnected(&nodes[1].get_our_node_id());
+ nodes[1].peer_disconnected(nodes[2].get_our_node_id());
+ nodes[2].peer_disconnected(nodes[1].get_our_node_id());
chan_b_disconnected = true;
drain_msg_events_on_disconnect!(2);
}
networks: None,
remote_network_address: None,
};
- nodes[0].peer_connected(&nodes[1].get_our_node_id(), &init_1, true).unwrap();
+ nodes[0].peer_connected(nodes[1].get_our_node_id(), &init_1, true).unwrap();
let init_0 = Init {
features: nodes[0].init_features(),
networks: None,
remote_network_address: None,
};
- nodes[1].peer_connected(&nodes[0].get_our_node_id(), &init_0, false).unwrap();
+ nodes[1].peer_connected(nodes[0].get_our_node_id(), &init_0, false).unwrap();
chan_a_disconnected = false;
}
},
networks: None,
remote_network_address: None,
};
- nodes[1].peer_connected(&nodes[2].get_our_node_id(), &init_2, true).unwrap();
+ nodes[1].peer_connected(nodes[2].get_our_node_id(), &init_2, true).unwrap();
let init_1 = Init {
features: nodes[1].init_features(),
networks: None,
remote_network_address: None,
};
- nodes[2].peer_connected(&nodes[1].get_our_node_id(), &init_1, false).unwrap();
+ nodes[2].peer_connected(nodes[1].get_our_node_id(), &init_1, false).unwrap();
chan_b_disconnected = false;
}
},
0x2c => {
if !chan_a_disconnected {
- nodes[1].peer_disconnected(&nodes[0].get_our_node_id());
+ nodes[1].peer_disconnected(nodes[0].get_our_node_id());
chan_a_disconnected = true;
push_excess_b_events!(
nodes[1].get_and_clear_pending_msg_events().drain(..),
},
0x2d => {
if !chan_a_disconnected {
- nodes[0].peer_disconnected(&nodes[1].get_our_node_id());
+ nodes[0].peer_disconnected(nodes[1].get_our_node_id());
chan_a_disconnected = true;
nodes[0].get_and_clear_pending_msg_events();
ab_events.clear();
ba_events.clear();
}
if !chan_b_disconnected {
- nodes[2].peer_disconnected(&nodes[1].get_our_node_id());
+ nodes[2].peer_disconnected(nodes[1].get_our_node_id());
chan_b_disconnected = true;
nodes[2].get_and_clear_pending_msg_events();
bc_events.clear();
},
0x2e => {
if !chan_b_disconnected {
- nodes[1].peer_disconnected(&nodes[2].get_our_node_id());
+ nodes[1].peer_disconnected(nodes[2].get_our_node_id());
chan_b_disconnected = true;
push_excess_b_events!(
nodes[1].get_and_clear_pending_msg_events().drain(..),
networks: None,
remote_network_address: None,
};
- nodes[0].peer_connected(&nodes[1].get_our_node_id(), &init_1, true).unwrap();
+ nodes[0].peer_connected(nodes[1].get_our_node_id(), &init_1, true).unwrap();
let init_0 = Init {
features: nodes[0].init_features(),
networks: None,
remote_network_address: None,
};
- nodes[1].peer_connected(&nodes[0].get_our_node_id(), &init_0, false).unwrap();
+ nodes[1].peer_connected(nodes[0].get_our_node_id(), &init_0, false).unwrap();
chan_a_disconnected = false;
}
if chan_b_disconnected {
networks: None,
remote_network_address: None,
};
- nodes[1].peer_connected(&nodes[2].get_our_node_id(), &init_2, true).unwrap();
+ nodes[1].peer_connected(nodes[2].get_our_node_id(), &init_2, true).unwrap();
let init_1 = Init {
features: nodes[1].init_features(),
networks: None,
remote_network_address: None,
};
- nodes[2].peer_connected(&nodes[1].get_our_node_id(), &init_1, false).unwrap();
+ nodes[2].peer_connected(nodes[1].get_our_node_id(), &init_1, false).unwrap();
chan_b_disconnected = false;
}
features.set_onion_messages_optional();
let init = msgs::Init { features, networks: None, remote_network_address: None };
- onion_messenger.peer_connected(&peer_node_id, &init, false).unwrap();
- onion_messenger.handle_onion_message(&peer_node_id, &msg);
+ onion_messenger.peer_connected(peer_node_id, &init, false).unwrap();
+ onion_messenger.handle_onion_message(peer_node_id, &msg);
}
}
};
nodes[i]
.node
- .peer_connected(&nodes[j].node.get_our_node_id(), &init_i, true)
+ .peer_connected(nodes[j].node.get_our_node_id(), &init_i, true)
.unwrap();
let init_j = Init {
features: nodes[i].node.init_features(),
};
nodes[j]
.node
- .peer_connected(&nodes[i].node.get_our_node_id(), &init_j, false)
+ .peer_connected(nodes[i].node.get_our_node_id(), &init_j, false)
.unwrap();
}
}
MessageSendEvent::SendFundingCreated,
$node_b.node.get_our_node_id()
);
- $node_b.node.handle_funding_created(&$node_a.node.get_our_node_id(), &msg_a);
+ $node_b.node.handle_funding_created($node_a.node.get_our_node_id(), &msg_a);
get_event!($node_b, Event::ChannelPending);
let msg_b = get_event_msg!(
$node_b,
MessageSendEvent::SendFundingSigned,
$node_a.node.get_our_node_id()
);
- $node_a.node.handle_funding_signed(&$node_b.node.get_our_node_id(), &msg_b);
+ $node_a.node.handle_funding_signed($node_b.node.get_our_node_id(), &msg_b);
get_event!($node_a, Event::ChannelPending);
tx
}};
MessageSendEvent::SendOpenChannel,
$node_b.node.get_our_node_id()
);
- $node_b.node.handle_open_channel(&$node_a.node.get_our_node_id(), &msg_a);
+ $node_b.node.handle_open_channel($node_a.node.get_our_node_id(), &msg_a);
let msg_b = get_event_msg!(
$node_b,
MessageSendEvent::SendAcceptChannel,
$node_a.node.get_our_node_id()
);
- $node_a.node.handle_accept_channel(&$node_b.node.get_our_node_id(), &msg_b);
+ $node_a.node.handle_accept_channel($node_b.node.get_our_node_id(), &msg_b);
}};
}
.funding_transaction_generated(temporary_channel_id, node_1_id, funding_tx.clone())
.unwrap();
let msg_0 = get_event_msg!(nodes[0], MessageSendEvent::SendFundingCreated, node_1_id);
- nodes[1].node.handle_funding_created(&node_0_id, &msg_0);
+ nodes[1].node.handle_funding_created(node_0_id, &msg_0);
get_event!(nodes[1], Event::ChannelPending);
let msg_1 = get_event_msg!(nodes[1], MessageSendEvent::SendFundingSigned, node_0_id);
- nodes[0].node.handle_funding_signed(&node_1_id, &msg_1);
+ nodes[0].node.handle_funding_signed(node_1_id, &msg_1);
let _ = channel_pending_recv
.recv_timeout(Duration::from_secs(EVENT_DEADLINE))
.expect("ChannelPending not handled within deadline");
let as_funding = get_event_msg!(nodes[0], MessageSendEvent::SendChannelReady, node_1_id);
confirm_transaction(&mut nodes[1], &funding_tx);
let bs_funding = get_event_msg!(nodes[1], MessageSendEvent::SendChannelReady, node_0_id);
- nodes[0].node.handle_channel_ready(&node_1_id, &bs_funding);
+ nodes[0].node.handle_channel_ready(node_1_id, &bs_funding);
let _as_channel_update =
get_event_msg!(nodes[0], MessageSendEvent::SendChannelUpdate, node_1_id);
- nodes[1].node.handle_channel_ready(&node_0_id, &as_funding);
+ nodes[1].node.handle_channel_ready(node_0_id, &as_funding);
let _bs_channel_update =
get_event_msg!(nodes[1], MessageSendEvent::SendChannelUpdate, node_0_id);
let broadcast_funding =
//! impl CustomMessageHandler for FooHandler {
//! // ...
//! # fn handle_custom_message(
-//! # &self, _msg: Self::CustomMessage, _sender_node_id: &PublicKey
+//! # &self, _msg: Self::CustomMessage, _sender_node_id: PublicKey
//! # ) -> Result<(), LightningError> {
//! # unimplemented!()
//! # }
//! # fn get_and_clear_pending_msg(&self) -> Vec<(PublicKey, Self::CustomMessage)> {
//! # unimplemented!()
//! # }
-//! # fn peer_disconnected(&self, _their_node_id: &PublicKey) {
+//! # fn peer_disconnected(&self, _their_node_id: PublicKey) {
//! # unimplemented!()
//! # }
-//! # fn peer_connected(&self, _their_node_id: &PublicKey, _msg: &Init, _inbound: bool) -> Result<(), ()> {
+//! # fn peer_connected(&self, _their_node_id: PublicKey, _msg: &Init, _inbound: bool) -> Result<(), ()> {
//! # unimplemented!()
//! # }
//! # fn provided_node_features(&self) -> NodeFeatures {
//! # unimplemented!()
//! # }
-//! # fn provided_init_features(&self, _their_node_id: &PublicKey) -> InitFeatures {
+//! # fn provided_init_features(&self, _their_node_id: PublicKey) -> InitFeatures {
//! # unimplemented!()
//! # }
//! }
//! impl CustomMessageHandler for BarHandler {
//! // ...
//! # fn handle_custom_message(
-//! # &self, _msg: Self::CustomMessage, _sender_node_id: &PublicKey
+//! # &self, _msg: Self::CustomMessage, _sender_node_id: PublicKey
//! # ) -> Result<(), LightningError> {
//! # unimplemented!()
//! # }
//! # fn get_and_clear_pending_msg(&self) -> Vec<(PublicKey, Self::CustomMessage)> {
//! # unimplemented!()
//! # }
-//! # fn peer_disconnected(&self, _their_node_id: &PublicKey) {
+//! # fn peer_disconnected(&self, _their_node_id: PublicKey) {
//! # unimplemented!()
//! # }
-//! # fn peer_connected(&self, _their_node_id: &PublicKey, _msg: &Init, _inbound: bool) -> Result<(), ()> {
+//! # fn peer_connected(&self, _their_node_id: PublicKey, _msg: &Init, _inbound: bool) -> Result<(), ()> {
//! # unimplemented!()
//! # }
//! # fn provided_node_features(&self) -> NodeFeatures {
//! # unimplemented!()
//! # }
-//! # fn provided_init_features(&self, _their_node_id: &PublicKey) -> InitFeatures {
+//! # fn provided_init_features(&self, _their_node_id: PublicKey) -> InitFeatures {
//! # unimplemented!()
//! # }
//! }
//! impl CustomMessageHandler for BazHandler {
//! // ...
//! # fn handle_custom_message(
-//! # &self, _msg: Self::CustomMessage, _sender_node_id: &PublicKey
+//! # &self, _msg: Self::CustomMessage, _sender_node_id: PublicKey
//! # ) -> Result<(), LightningError> {
//! # unimplemented!()
//! # }
//! # fn get_and_clear_pending_msg(&self) -> Vec<(PublicKey, Self::CustomMessage)> {
//! # unimplemented!()
//! # }
-//! # fn peer_disconnected(&self, _their_node_id: &PublicKey) {
+//! # fn peer_disconnected(&self, _their_node_id: PublicKey) {
//! # unimplemented!()
//! # }
-//! # fn peer_connected(&self, _their_node_id: &PublicKey, _msg: &Init, _inbound: bool) -> Result<(), ()> {
+//! # fn peer_connected(&self, _their_node_id: PublicKey, _msg: &Init, _inbound: bool) -> Result<(), ()> {
//! # unimplemented!()
//! # }
//! # fn provided_node_features(&self) -> NodeFeatures {
//! # unimplemented!()
//! # }
-//! # fn provided_init_features(&self, _their_node_id: &PublicKey) -> InitFeatures {
+//! # fn provided_init_features(&self, _their_node_id: PublicKey) -> InitFeatures {
//! # unimplemented!()
//! # }
//! }
impl $crate::lightning::ln::peer_handler::CustomMessageHandler for $handler {
fn handle_custom_message(
- &self, msg: Self::CustomMessage, sender_node_id: &$crate::bitcoin::secp256k1::PublicKey
+ &self, msg: Self::CustomMessage, sender_node_id: $crate::bitcoin::secp256k1::PublicKey
) -> Result<(), $crate::lightning::ln::msgs::LightningError> {
match msg {
$(
.collect()
}
- fn peer_disconnected(&self, their_node_id: &$crate::bitcoin::secp256k1::PublicKey) {
+ fn peer_disconnected(&self, their_node_id: $crate::bitcoin::secp256k1::PublicKey) {
$(
self.$field.peer_disconnected(their_node_id);
)*
}
- fn peer_connected(&self, their_node_id: &$crate::bitcoin::secp256k1::PublicKey, msg: &$crate::lightning::ln::msgs::Init, inbound: bool) -> Result<(), ()> {
+ fn peer_connected(&self, their_node_id: $crate::bitcoin::secp256k1::PublicKey, msg: &$crate::lightning::ln::msgs::Init, inbound: bool) -> Result<(), ()> {
let mut result = Ok(());
$(
if let Err(e) = self.$field.peer_connected(their_node_id, msg, inbound) {
}
fn provided_init_features(
- &self, their_node_id: &$crate::bitcoin::secp256k1::PublicKey
+ &self, their_node_id: $crate::bitcoin::secp256k1::PublicKey
) -> $crate::lightning::ln::features::InitFeatures {
$crate::lightning::ln::features::InitFeatures::empty()
$(
}
impl RoutingMessageHandler for MsgHandler {
fn handle_node_announcement(
- &self, _their_node_id: Option<&PublicKey>, _msg: &NodeAnnouncement,
+ &self, _their_node_id: Option<PublicKey>, _msg: &NodeAnnouncement,
) -> Result<bool, LightningError> {
Ok(false)
}
fn handle_channel_announcement(
- &self, _their_node_id: Option<&PublicKey>, _msg: &ChannelAnnouncement,
+ &self, _their_node_id: Option<PublicKey>, _msg: &ChannelAnnouncement,
) -> Result<bool, LightningError> {
Ok(false)
}
fn handle_channel_update(
- &self, _their_node_id: Option<&PublicKey>, _msg: &ChannelUpdate,
+ &self, _their_node_id: Option<PublicKey>, _msg: &ChannelUpdate,
) -> Result<bool, LightningError> {
Ok(false)
}
None
}
fn peer_connected(
- &self, _their_node_id: &PublicKey, _init_msg: &Init, _inbound: bool,
+ &self, _their_node_id: PublicKey, _init_msg: &Init, _inbound: bool,
) -> Result<(), ()> {
Ok(())
}
fn handle_reply_channel_range(
- &self, _their_node_id: &PublicKey, _msg: ReplyChannelRange,
+ &self, _their_node_id: PublicKey, _msg: ReplyChannelRange,
) -> Result<(), LightningError> {
Ok(())
}
fn handle_reply_short_channel_ids_end(
- &self, _their_node_id: &PublicKey, _msg: ReplyShortChannelIdsEnd,
+ &self, _their_node_id: PublicKey, _msg: ReplyShortChannelIdsEnd,
) -> Result<(), LightningError> {
Ok(())
}
fn handle_query_channel_range(
- &self, _their_node_id: &PublicKey, _msg: QueryChannelRange,
+ &self, _their_node_id: PublicKey, _msg: QueryChannelRange,
) -> Result<(), LightningError> {
Ok(())
}
fn handle_query_short_channel_ids(
- &self, _their_node_id: &PublicKey, _msg: QueryShortChannelIds,
+ &self, _their_node_id: PublicKey, _msg: QueryShortChannelIds,
) -> Result<(), LightningError> {
Ok(())
}
fn provided_node_features(&self) -> NodeFeatures {
NodeFeatures::empty()
}
- fn provided_init_features(&self, _their_node_id: &PublicKey) -> InitFeatures {
+ fn provided_init_features(&self, _their_node_id: PublicKey) -> InitFeatures {
InitFeatures::empty()
}
fn processing_queue_high(&self) -> bool {
}
}
impl ChannelMessageHandler for MsgHandler {
- fn handle_open_channel(&self, _their_node_id: &PublicKey, _msg: &OpenChannel) {}
- fn handle_accept_channel(&self, _their_node_id: &PublicKey, _msg: &AcceptChannel) {}
- fn handle_funding_created(&self, _their_node_id: &PublicKey, _msg: &FundingCreated) {}
- fn handle_funding_signed(&self, _their_node_id: &PublicKey, _msg: &FundingSigned) {}
- fn handle_channel_ready(&self, _their_node_id: &PublicKey, _msg: &ChannelReady) {}
- fn handle_shutdown(&self, _their_node_id: &PublicKey, _msg: &Shutdown) {}
- fn handle_closing_signed(&self, _their_node_id: &PublicKey, _msg: &ClosingSigned) {}
- fn handle_update_add_htlc(&self, _their_node_id: &PublicKey, _msg: &UpdateAddHTLC) {}
- fn handle_update_fulfill_htlc(&self, _their_node_id: &PublicKey, _msg: &UpdateFulfillHTLC) {
- }
- fn handle_update_fail_htlc(&self, _their_node_id: &PublicKey, _msg: &UpdateFailHTLC) {}
+ fn handle_open_channel(&self, _their_node_id: PublicKey, _msg: &OpenChannel) {}
+ fn handle_accept_channel(&self, _their_node_id: PublicKey, _msg: &AcceptChannel) {}
+ fn handle_funding_created(&self, _their_node_id: PublicKey, _msg: &FundingCreated) {}
+ fn handle_funding_signed(&self, _their_node_id: PublicKey, _msg: &FundingSigned) {}
+ fn handle_channel_ready(&self, _their_node_id: PublicKey, _msg: &ChannelReady) {}
+ fn handle_shutdown(&self, _their_node_id: PublicKey, _msg: &Shutdown) {}
+ fn handle_closing_signed(&self, _their_node_id: PublicKey, _msg: &ClosingSigned) {}
+ fn handle_update_add_htlc(&self, _their_node_id: PublicKey, _msg: &UpdateAddHTLC) {}
+ fn handle_update_fulfill_htlc(&self, _their_node_id: PublicKey, _msg: &UpdateFulfillHTLC) {}
+ fn handle_update_fail_htlc(&self, _their_node_id: PublicKey, _msg: &UpdateFailHTLC) {}
fn handle_update_fail_malformed_htlc(
- &self, _their_node_id: &PublicKey, _msg: &UpdateFailMalformedHTLC,
+ &self, _their_node_id: PublicKey, _msg: &UpdateFailMalformedHTLC,
) {
}
- fn handle_commitment_signed(&self, _their_node_id: &PublicKey, _msg: &CommitmentSigned) {}
- fn handle_revoke_and_ack(&self, _their_node_id: &PublicKey, _msg: &RevokeAndACK) {}
- fn handle_update_fee(&self, _their_node_id: &PublicKey, _msg: &UpdateFee) {}
+ fn handle_commitment_signed(&self, _their_node_id: PublicKey, _msg: &CommitmentSigned) {}
+ fn handle_revoke_and_ack(&self, _their_node_id: PublicKey, _msg: &RevokeAndACK) {}
+ fn handle_update_fee(&self, _their_node_id: PublicKey, _msg: &UpdateFee) {}
fn handle_announcement_signatures(
- &self, _their_node_id: &PublicKey, _msg: &AnnouncementSignatures,
+ &self, _their_node_id: PublicKey, _msg: &AnnouncementSignatures,
) {
}
- fn handle_channel_update(&self, _their_node_id: &PublicKey, _msg: &ChannelUpdate) {}
- fn handle_open_channel_v2(&self, _their_node_id: &PublicKey, _msg: &OpenChannelV2) {}
- fn handle_accept_channel_v2(&self, _their_node_id: &PublicKey, _msg: &AcceptChannelV2) {}
- fn handle_stfu(&self, _their_node_id: &PublicKey, _msg: &Stfu) {}
+ fn handle_channel_update(&self, _their_node_id: PublicKey, _msg: &ChannelUpdate) {}
+ fn handle_open_channel_v2(&self, _their_node_id: PublicKey, _msg: &OpenChannelV2) {}
+ fn handle_accept_channel_v2(&self, _their_node_id: PublicKey, _msg: &AcceptChannelV2) {}
+ fn handle_stfu(&self, _their_node_id: PublicKey, _msg: &Stfu) {}
#[cfg(splicing)]
- fn handle_splice_init(&self, _their_node_id: &PublicKey, _msg: &SpliceInit) {}
+ fn handle_splice_init(&self, _their_node_id: PublicKey, _msg: &SpliceInit) {}
#[cfg(splicing)]
- fn handle_splice_ack(&self, _their_node_id: &PublicKey, _msg: &SpliceAck) {}
+ fn handle_splice_ack(&self, _their_node_id: PublicKey, _msg: &SpliceAck) {}
#[cfg(splicing)]
- fn handle_splice_locked(&self, _their_node_id: &PublicKey, _msg: &SpliceLocked) {}
- fn handle_tx_add_input(&self, _their_node_id: &PublicKey, _msg: &TxAddInput) {}
- fn handle_tx_add_output(&self, _their_node_id: &PublicKey, _msg: &TxAddOutput) {}
- fn handle_tx_remove_input(&self, _their_node_id: &PublicKey, _msg: &TxRemoveInput) {}
- fn handle_tx_remove_output(&self, _their_node_id: &PublicKey, _msg: &TxRemoveOutput) {}
- fn handle_tx_complete(&self, _their_node_id: &PublicKey, _msg: &TxComplete) {}
- fn handle_tx_signatures(&self, _their_node_id: &PublicKey, _msg: &TxSignatures) {}
- fn handle_tx_init_rbf(&self, _their_node_id: &PublicKey, _msg: &TxInitRbf) {}
- fn handle_tx_ack_rbf(&self, _their_node_id: &PublicKey, _msg: &TxAckRbf) {}
- fn handle_tx_abort(&self, _their_node_id: &PublicKey, _msg: &TxAbort) {}
- fn peer_disconnected(&self, their_node_id: &PublicKey) {
- if *their_node_id == self.expected_pubkey {
+ fn handle_splice_locked(&self, _their_node_id: PublicKey, _msg: &SpliceLocked) {}
+ fn handle_tx_add_input(&self, _their_node_id: PublicKey, _msg: &TxAddInput) {}
+ fn handle_tx_add_output(&self, _their_node_id: PublicKey, _msg: &TxAddOutput) {}
+ fn handle_tx_remove_input(&self, _their_node_id: PublicKey, _msg: &TxRemoveInput) {}
+ fn handle_tx_remove_output(&self, _their_node_id: PublicKey, _msg: &TxRemoveOutput) {}
+ fn handle_tx_complete(&self, _their_node_id: PublicKey, _msg: &TxComplete) {}
+ fn handle_tx_signatures(&self, _their_node_id: PublicKey, _msg: &TxSignatures) {}
+ fn handle_tx_init_rbf(&self, _their_node_id: PublicKey, _msg: &TxInitRbf) {}
+ fn handle_tx_ack_rbf(&self, _their_node_id: PublicKey, _msg: &TxAckRbf) {}
+ fn handle_tx_abort(&self, _their_node_id: PublicKey, _msg: &TxAbort) {}
+ fn peer_disconnected(&self, their_node_id: PublicKey) {
+ if their_node_id == self.expected_pubkey {
self.disconnected_flag.store(true, Ordering::SeqCst);
self.pubkey_disconnected.clone().try_send(()).unwrap();
}
}
fn peer_connected(
- &self, their_node_id: &PublicKey, _init_msg: &Init, _inbound: bool,
+ &self, their_node_id: PublicKey, _init_msg: &Init, _inbound: bool,
) -> Result<(), ()> {
- if *their_node_id == self.expected_pubkey {
+ if their_node_id == self.expected_pubkey {
self.pubkey_connected.clone().try_send(()).unwrap();
}
Ok(())
}
- fn handle_channel_reestablish(
- &self, _their_node_id: &PublicKey, _msg: &ChannelReestablish,
- ) {
+ fn handle_channel_reestablish(&self, _their_node_id: PublicKey, _msg: &ChannelReestablish) {
}
- fn handle_error(&self, _their_node_id: &PublicKey, _msg: &ErrorMessage) {}
+ fn handle_error(&self, _their_node_id: PublicKey, _msg: &ErrorMessage) {}
fn provided_node_features(&self) -> NodeFeatures {
NodeFeatures::empty()
}
- fn provided_init_features(&self, _their_node_id: &PublicKey) -> InitFeatures {
+ fn provided_init_features(&self, _their_node_id: PublicKey) -> InitFeatures {
InitFeatures::empty()
}
fn get_chain_hashes(&self) -> Option<Vec<ChainHash>> {
// back-to-back it doesn't fit into the neat walk commitment_signed_dance does.
let updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
expect_payment_sent(&nodes[0], payment_preimage_1, None, false, false);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &updates.commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &updates.commitment_signed);
check_added_monitors!(nodes[0], 1);
let (as_first_raa, as_first_update) = get_revoke_commit_msgs!(nodes[0], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_first_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_first_raa);
check_added_monitors!(nodes[1], 1);
let bs_second_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_first_update);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_first_update);
check_added_monitors!(nodes[1], 1);
let bs_first_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &bs_second_updates.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &bs_second_updates.update_fulfill_htlcs[0]);
expect_payment_sent(&nodes[0], payment_preimage_2, None, false, false);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_second_updates.commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_second_updates.commitment_signed);
check_added_monitors!(nodes[0], 1);
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_first_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_first_raa);
expect_payment_path_successful!(nodes[0]);
check_added_monitors!(nodes[0], 1);
let (as_second_raa, as_second_update) = get_revoke_commit_msgs!(nodes[0], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_second_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_second_raa);
check_added_monitors!(nodes[1], 1);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_second_update);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_second_update);
check_added_monitors!(nodes[1], 1);
let bs_second_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_second_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_second_raa);
expect_payment_path_successful!(nodes[0]);
check_added_monitors!(nodes[0], 1);
}
// nodes[0] --- open_channel --> nodes[1]
let mut open_chan_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(), &open_chan_msg);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_chan_msg);
// nodes[0] <-- accept_channel --- nodes[1]
- nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), &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(), &get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id()));
// nodes[0] --- funding_created --> nodes[1]
//
nodes[0].node.signer_unblocked(Some((nodes[1].node.get_our_node_id(), chan_id)));
let mut funding_created_msg = get_event_msg!(nodes[0], MessageSendEvent::SendFundingCreated, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &funding_created_msg);
+ nodes[1].node.handle_funding_created(nodes[0].node.get_our_node_id(), &funding_created_msg);
check_added_monitors(&nodes[1], 1);
expect_channel_pending_event(&nodes[1], &nodes[0].node.get_our_node_id());
// nodes[0] <-- funding_signed --- nodes[1]
let funding_signed_msg = get_event_msg!(nodes[1], MessageSendEvent::SendFundingSigned, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_funding_signed(&nodes[1].node.get_our_node_id(), &funding_signed_msg);
+ nodes[0].node.handle_funding_signed(nodes[1].node.get_our_node_id(), &funding_signed_msg);
check_added_monitors(&nodes[0], 1);
expect_channel_pending_event(&nodes[0], &nodes[1].node.get_our_node_id());
}
// nodes[0] --- open_channel --> nodes[1]
let mut open_chan_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(), &open_chan_msg);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_chan_msg);
// nodes[0] <-- accept_channel --- nodes[1]
- nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), &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(), &get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id()));
// nodes[0] --- funding_created --> nodes[1]
let (temporary_channel_id, tx, _) = create_funding_transaction(&nodes[0], &nodes[1].node.get_our_node_id(), 100000, 42);
// Now let's make node[1]'s signer be unavailable while handling the `funding_created`. It should
// *not* broadcast a `funding_signed`...
nodes[1].disable_channel_signer_op(&nodes[0].node.get_our_node_id(), &temporary_channel_id, SignerOp::SignCounterpartyCommitment);
- nodes[1].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &funding_created_msg);
+ nodes[1].node.handle_funding_created(nodes[0].node.get_our_node_id(), &funding_created_msg);
check_added_monitors(&nodes[1], 1);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
// nodes[0] <-- funding_signed --- nodes[1]
let funding_signed_msg = get_event_msg!(nodes[1], MessageSendEvent::SendFundingSigned, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_funding_signed(&nodes[1].node.get_our_node_id(), &funding_signed_msg);
+ nodes[0].node.handle_funding_signed(nodes[1].node.get_our_node_id(), &funding_signed_msg);
check_added_monitors(&nodes[0], 1);
expect_channel_pending_event(&nodes[0], &nodes[1].node.get_our_node_id());
}
assert_eq!(payment_event.node_id, dst.node.get_our_node_id());
assert_eq!(payment_event.msgs.len(), 1);
- dst.node.handle_update_add_htlc(&src.node.get_our_node_id(), &payment_event.msgs[0]);
+ dst.node.handle_update_add_htlc(src.node.get_our_node_id(), &payment_event.msgs[0]);
// Mark dst's signer as unavailable and handle src's commitment_signed: while dst won't yet have a
// `commitment_signed` of its own to offer, it should publish a `revoke_and_ack`.
dst.disable_channel_signer_op(&src.node.get_our_node_id(), &chan_id, SignerOp::GetPerCommitmentPoint);
dst.disable_channel_signer_op(&src.node.get_our_node_id(), &chan_id, SignerOp::ReleaseCommitmentSecret);
dst.disable_channel_signer_op(&src.node.get_our_node_id(), &chan_id, SignerOp::SignCounterpartyCommitment);
- dst.node.handle_commitment_signed(&src.node.get_our_node_id(), &payment_event.commitment_msg);
+ dst.node.handle_commitment_signed(src.node.get_our_node_id(), &payment_event.commitment_msg);
check_added_monitors(dst, 1);
let mut enabled_signer_ops = HashSet::new();
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 42, None, 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(), &open_channel);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel);
{
let events = nodes[1].node.get_and_clear_pending_events();
// nodes[0] <-- accept_channel --- nodes[1]
let accept_channel = get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id());
assert_eq!(accept_channel.common_fields.minimum_depth, 0, "Expected minimum depth of 0");
- nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), &accept_channel);
+ nodes[0].node.handle_accept_channel(nodes[1].node.get_our_node_id(), &accept_channel);
// nodes[0] --- funding_created --> nodes[1]
let (temporary_channel_id, tx, _) = create_funding_transaction(&nodes[0], &nodes[1].node.get_our_node_id(), 100000, 42);
// Now let's make node[1]'s signer be unavailable while handling the `funding_created`. It should
// *not* broadcast a `funding_signed`...
nodes[1].disable_channel_signer_op(&nodes[0].node.get_our_node_id(), &temporary_channel_id, SignerOp::SignCounterpartyCommitment);
- nodes[1].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &funding_created_msg);
+ nodes[1].node.handle_funding_created(nodes[0].node.get_our_node_id(), &funding_created_msg);
check_added_monitors(&nodes[1], 1);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
(funding_signed, channel_ready)
};
- nodes[0].node.handle_funding_signed(&nodes[1].node.get_our_node_id(), &funding_signed);
+ nodes[0].node.handle_funding_signed(nodes[1].node.get_our_node_id(), &funding_signed);
expect_channel_pending_event(&nodes[0], &nodes[1].node.get_our_node_id());
expect_channel_pending_event(&nodes[1], &nodes[0].node.get_our_node_id());
check_added_monitors(&nodes[0], 1);
let channel_ready_0 = get_event_msg!(nodes[0], MessageSendEvent::SendChannelReady, nodes[1].node.get_our_node_id());
- nodes[0].node.handle_channel_ready(&nodes[1].node.get_our_node_id(), &channel_ready_1);
+ nodes[0].node.handle_channel_ready(nodes[1].node.get_our_node_id(), &channel_ready_1);
expect_channel_ready_event(&nodes[0], &nodes[1].node.get_our_node_id());
- nodes[1].node.handle_channel_ready(&nodes[0].node.get_our_node_id(), &channel_ready_0);
+ nodes[1].node.handle_channel_ready(nodes[0].node.get_our_node_id(), &channel_ready_0);
expect_channel_ready_event(&nodes[1], &nodes[0].node.get_our_node_id());
let channel_update_0 = get_event_msg!(nodes[0], MessageSendEvent::SendChannelUpdate, nodes[1].node.get_our_node_id());
let channel_update_1 = get_event_msg!(nodes[1], MessageSendEvent::SendChannelUpdate, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_channel_update(&nodes[1].node.get_our_node_id(), &channel_update_1);
- nodes[1].node.handle_channel_update(&nodes[0].node.get_our_node_id(), &channel_update_0);
+ nodes[0].node.handle_channel_update(nodes[1].node.get_our_node_id(), &channel_update_1);
+ nodes[1].node.handle_channel_update(nodes[0].node.get_our_node_id(), &channel_update_0);
assert_eq!(nodes[0].node.list_usable_channels().len(), 1);
assert_eq!(nodes[1].node.list_usable_channels().len(), 1);
assert_eq!(payment_event.node_id, dst.node.get_our_node_id());
assert_eq!(payment_event.msgs.len(), 1);
- dst.node.handle_update_add_htlc(&src.node.get_our_node_id(), &payment_event.msgs[0]);
+ dst.node.handle_update_add_htlc(src.node.get_our_node_id(), &payment_event.msgs[0]);
if test_case == UnblockSignerAcrossDisconnectCase::BeforeMonitorRestored {
// Fail to persist the monitor update when handling the commitment_signed.
// Mark dst's signer as unavailable and handle src's commitment_signed: while dst won't yet have a
// `commitment_signed` of its own to offer, it should publish a `revoke_and_ack`.
dst.disable_channel_signer_op(&src.node.get_our_node_id(), &chan_id, block_raa_signer_op);
- dst.node.handle_commitment_signed(&src.node.get_our_node_id(), &payment_event.commitment_msg);
+ dst.node.handle_commitment_signed(src.node.get_our_node_id(), &payment_event.commitment_msg);
check_added_monitors(dst, 1);
let events = dst.node.get_and_clear_pending_msg_events();
assert!(events.is_empty(), "expected no message, got {}", events.len());
// Now disconnect and reconnect the peers.
- src.node.peer_disconnected(&dst.node.get_our_node_id());
- dst.node.peer_disconnected(&src.node.get_our_node_id());
+ src.node.peer_disconnected(dst.node.get_our_node_id());
+ dst.node.peer_disconnected(src.node.get_our_node_id());
// do reestablish stuff
- src.node.peer_connected(&dst.node.get_our_node_id(), &msgs::Init {
+ src.node.peer_connected(dst.node.get_our_node_id(), &msgs::Init {
features: dst.node.init_features(), networks: None, remote_network_address: None
}, true).unwrap();
let reestablish_1 = get_chan_reestablish_msgs!(src, dst);
assert_eq!(reestablish_1.len(), 1);
- dst.node.peer_connected(&src.node.get_our_node_id(), &msgs::Init {
+ dst.node.peer_connected(src.node.get_our_node_id(), &msgs::Init {
features: src.node.init_features(), networks: None, remote_network_address: None
}, false).unwrap();
let reestablish_2 = get_chan_reestablish_msgs!(dst, src);
dst.enable_channel_signer_op(&src.node.get_our_node_id(), &chan_id, block_raa_signer_op);
}
- dst.node.handle_channel_reestablish(&src.node.get_our_node_id(), &reestablish_1[0]);
+ dst.node.handle_channel_reestablish(src.node.get_our_node_id(), &reestablish_1[0]);
if test_case == UnblockSignerAcrossDisconnectCase::BeforeMonitorRestored {
dst.enable_channel_signer_op(&src.node.get_our_node_id(), &chan_id, block_raa_signer_op);
assert_eq!(payment_event.node_id, dst.node.get_our_node_id());
assert_eq!(payment_event.msgs.len(), 1);
- dst.node.handle_update_add_htlc(&src.node.get_our_node_id(), &payment_event.msgs[0]);
+ dst.node.handle_update_add_htlc(src.node.get_our_node_id(), &payment_event.msgs[0]);
if test_case == UnblockSignerAcrossDisconnectCase::BeforeMonitorRestored {
// Fail to persist the monitor update when handling the commitment_signed.
// Mark dst's signer as unavailable and handle src's commitment_signed: while dst won't yet have a
// `commitment_signed` of its own to offer, it should publish a `revoke_and_ack`.
dst.disable_channel_signer_op(&src.node.get_our_node_id(), &chan_id, SignerOp::SignCounterpartyCommitment);
- dst.node.handle_commitment_signed(&src.node.get_our_node_id(), &payment_event.commitment_msg);
+ dst.node.handle_commitment_signed(src.node.get_our_node_id(), &payment_event.commitment_msg);
check_added_monitors(dst, 1);
if test_case != UnblockSignerAcrossDisconnectCase::BeforeMonitorRestored {
}
// Now disconnect and reconnect the peers.
- src.node.peer_disconnected(&dst.node.get_our_node_id());
- dst.node.peer_disconnected(&src.node.get_our_node_id());
+ src.node.peer_disconnected(dst.node.get_our_node_id());
+ dst.node.peer_disconnected(src.node.get_our_node_id());
// do reestablish stuff
- src.node.peer_connected(&dst.node.get_our_node_id(), &msgs::Init {
+ src.node.peer_connected(dst.node.get_our_node_id(), &msgs::Init {
features: dst.node.init_features(), networks: None, remote_network_address: None
}, true).unwrap();
let reestablish_1 = get_chan_reestablish_msgs!(src, dst);
assert_eq!(reestablish_1.len(), 1);
- dst.node.peer_connected(&src.node.get_our_node_id(), &msgs::Init {
+ dst.node.peer_connected(src.node.get_our_node_id(), &msgs::Init {
features: src.node.init_features(), networks: None, remote_network_address: None
}, false).unwrap();
let reestablish_2 = get_chan_reestablish_msgs!(dst, src);
dst.enable_channel_signer_op(&src.node.get_our_node_id(), &chan_id, SignerOp::SignCounterpartyCommitment);
}
- dst.node.handle_channel_reestablish(&src.node.get_our_node_id(), &reestablish_1[0]);
+ dst.node.handle_channel_reestablish(src.node.get_our_node_id(), &reestablish_1[0]);
if test_case == UnblockSignerAcrossDisconnectCase::BeforeMonitorRestored {
dst.enable_channel_signer_op(&src.node.get_our_node_id(), &chan_id, SignerOp::SignCounterpartyCommitment);
assert_eq!(events_2.len(), 1);
match events_2[0] {
MessageSendEvent::UpdateHTLCs { node_id: _, updates: msgs::CommitmentUpdate { ref update_fulfill_htlcs, ref commitment_signed, .. } } => {
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &update_fulfill_htlcs[0]);
expect_payment_sent(&nodes[0], payment_preimage_1, None, false, false);
if monitor_update_failure {
chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
}
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), commitment_signed);
if monitor_update_failure {
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
} else {
// Disconnect and reconnect the peers so that nodes[0] will
// need to re-send the commitment update *and then* revoke_and_ack.
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
- nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init {
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).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 {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, false).unwrap();
let reestablish_2 = get_chan_reestablish_msgs!(nodes[1], nodes[0]);
// and then revoke_and_ack. With commitment_signed disabled, since
// our ordering is CS then RAA, we should make sure we don't send the RAA.
nodes[0].disable_channel_signer_op(&nodes[1].node.get_our_node_id(), &chan_id, SignerOp::SignCounterpartyCommitment);
- nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &reestablish_2[0]);
+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &reestablish_2[0]);
let as_resp = handle_chan_reestablish_msgs!(nodes[0], nodes[1]);
assert!(as_resp.0.is_none());
assert!(as_resp.1.is_none());
nodes[0].node.signer_unblocked(Some((nodes[1].node.get_our_node_id(), chan_id)));
let as_resp = handle_chan_reestablish_msgs!(nodes[0], nodes[1]);
- nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &reestablish_1[0]);
+ nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), &reestablish_1[0]);
let bs_resp = handle_chan_reestablish_msgs!(nodes[1], nodes[0]);
assert!(as_resp.0.is_none());
assert!(as_resp.3 == RAACommitmentOrder::CommitmentFirst);
// Now that everything is restored, get the CS + RAA and handle them.
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &as_resp.2.as_ref().unwrap().update_add_htlcs[0]);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_resp.2.as_ref().unwrap().commitment_signed);
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), as_resp.1.as_ref().unwrap());
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &as_resp.2.as_ref().unwrap().update_add_htlcs[0]);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_resp.2.as_ref().unwrap().commitment_signed);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), as_resp.1.as_ref().unwrap());
let (bs_revoke_and_ack, bs_second_commitment_signed) = get_revoke_commit_msgs(&nodes[1], &nodes[0].node.get_our_node_id());
check_added_monitors!(nodes[1], 2);
// The rest of this is boilerplate for resolving the previous state.
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_revoke_and_ack);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_revoke_and_ack);
let as_commitment_signed = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
check_added_monitors!(nodes[0], 1);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_second_commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_second_commitment_signed);
let as_revoke_and_ack = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
// No commitment_signed so get_event_msg's assert(len == 1) passes
check_added_monitors!(nodes[0], 1);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_commitment_signed.commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_commitment_signed.commitment_signed);
let bs_second_revoke_and_ack = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
// No commitment_signed so get_event_msg's assert(len == 1) passes
check_added_monitors!(nodes[1], 1);
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_revoke_and_ack);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_revoke_and_ack);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[1], 1);
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_second_revoke_and_ack);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_second_revoke_and_ack);
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[0], 1);
expect_channel_shutdown_state!(nodes[1], chan_1.2, ChannelShutdownState::NotShuttingDown);
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(), &node_0_shutdown);
+ nodes[1].node.handle_shutdown(nodes[0].node.get_our_node_id(), &node_0_shutdown);
expect_channel_shutdown_state!(nodes[0], chan_1.2, ChannelShutdownState::ShutdownInitiated);
expect_channel_shutdown_state!(nodes[1], chan_1.2, ChannelShutdownState::NegotiatingClosingFee);
let node_1_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());
nodes[0].disable_channel_signer_op(&nodes[1].node.get_our_node_id(), &chan_1.2, SignerOp::SignClosingTransaction);
- nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &node_1_shutdown);
+ nodes[0].node.handle_shutdown(nodes[1].node.get_our_node_id(), &node_1_shutdown);
expect_channel_shutdown_state!(nodes[0], chan_1.2, ChannelShutdownState::NegotiatingClosingFee);
expect_channel_shutdown_state!(nodes[1], chan_1.2, ChannelShutdownState::NegotiatingClosingFee);
let node_0_closing_signed = get_event_msg!(nodes[0], MessageSendEvent::SendClosingSigned, nodes[1].node.get_our_node_id());
nodes[1].disable_channel_signer_op(&nodes[0].node.get_our_node_id(), &chan_1.2, SignerOp::SignClosingTransaction);
- nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_closing_signed);
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &node_0_closing_signed);
let events = nodes[1].node.get_and_clear_pending_msg_events();
assert!(events.is_empty(), "Expected no events, got {:?}", events);
let node_1_closing_signed = get_event_msg!(nodes[1], MessageSendEvent::SendClosingSigned, nodes[0].node.get_our_node_id());
nodes[0].disable_channel_signer_op(&nodes[1].node.get_our_node_id(), &chan_1.2, SignerOp::SignClosingTransaction);
- nodes[0].node.handle_closing_signed(&nodes[1].node.get_our_node_id(), &node_1_closing_signed);
+ nodes[0].node.handle_closing_signed(nodes[1].node.get_our_node_id(), &node_1_closing_signed);
let events = nodes[0].node.get_and_clear_pending_msg_events();
assert!(events.is_empty(), "Expected no events, got {:?}", events);
nodes[0].enable_channel_signer_op(&nodes[1].node.get_our_node_id(), &chan_1.2, SignerOp::SignClosingTransaction);
node_1_closing_signed_2.signature = signature;
node_1_closing_signed_2
};
- nodes[0].node.handle_closing_signed(&nodes[1].node.get_our_node_id(), &node_1_closing_signed_2_bad);
+ nodes[0].node.handle_closing_signed(nodes[1].node.get_our_node_id(), &node_1_closing_signed_2_bad);
let events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
}
if reconnect {
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
*nodes[0].fee_estimator.sat_per_kw.lock().unwrap() *= 8;
*nodes[1].fee_estimator.sat_per_kw.lock().unwrap() *= 8;
connect_nodes(&nodes[0], &nodes[1]);
let node_0_reestablish = get_chan_reestablish_msgs!(nodes[0], nodes[1]).pop().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);
- nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &node_1_reestablish);
+ nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), &node_0_reestablish);
+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &node_1_reestablish);
let node_0_msgs = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(node_0_msgs.len(), 2);
};
let node_1_2nd_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(), &node_0_2nd_shutdown);
+ nodes[1].node.handle_shutdown(nodes[0].node.get_our_node_id(), &node_0_2nd_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(), &node_1_2nd_shutdown);
- nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed);
+ nodes[0].node.handle_shutdown(nodes[1].node.get_our_node_id(), &node_1_2nd_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());
- nodes[0].node.handle_closing_signed(&nodes[1].node.get_our_node_id(), &node_1_closing_signed);
+ nodes[0].node.handle_closing_signed(nodes[1].node.get_our_node_id(), &node_1_closing_signed);
}
nodes[0].node.signer_unblocked(None);
let (_, node_0_2nd_closing_signed) = get_closing_signed_broadcast!(nodes[0].node, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed.unwrap());
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed.unwrap());
let (_, node_1_closing_signed) = get_closing_signed_broadcast!(nodes[1].node, nodes[0].node.get_our_node_id());
assert!(node_1_closing_signed.is_none());
},
ForwardCheckFail::OutboundChannelCheck => {
// The intro node will see that the next-hop peer is disconnected and fail the HTLC backwards.
- nodes[$src_node_idx].node.peer_disconnected(&nodes[$target_node_idx].node.get_our_node_id());
+ nodes[$src_node_idx].node.peer_disconnected(nodes[$target_node_idx].node.get_our_node_id());
}
}
}
cause_error!(1, 2, update_add);
}
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &update_add);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add);
check_added_monitors!(nodes[1], 0);
do_commitment_signed_dance(&nodes[1], &nodes[0], &updates_0_1.commitment_signed, true, true);
if intro_fails {
let mut updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
do_commitment_signed_dance(&nodes[0], &nodes[1], &updates.commitment_signed, false, false);
expect_payment_failed_conditions(&nodes[0], payment_hash, false,
PaymentFailedConditions::new().expected_htlc_error_data(INVALID_ONION_BLINDING, &[0; 32]));
cause_error!(2, 3, update_add);
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &update_add);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &update_add);
check_added_monitors!(nodes[2], 0);
do_commitment_signed_dance(&nodes[2], &nodes[1], &updates_1_2.commitment_signed, true, true);
// Ensure the intro node will properly blind the error if its downstream node failed to do so.
update_malformed.sha256_of_onion = [1; 32];
update_malformed.failure_code = INVALID_ONION_BLINDING ^ 1;
- nodes[1].node.handle_update_fail_malformed_htlc(&nodes[2].node.get_our_node_id(), update_malformed);
+ nodes[1].node.handle_update_fail_malformed_htlc(nodes[2].node.get_our_node_id(), update_malformed);
do_commitment_signed_dance(&nodes[1], &nodes[2], &updates.commitment_signed, true, false);
let mut updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
do_commitment_signed_dance(&nodes[0], &nodes[1], &updates.commitment_signed, false, false);
expect_payment_failed_conditions(&nodes[0], payment_hash, false,
PaymentFailedConditions::new().expected_htlc_error_data(INVALID_ONION_BLINDING, &[0; 32]));
let ev = remove_first_msg_event_to_node(&nodes[1].node.get_our_node_id(), &mut events);
let mut payment_event = SendEvent::from_event(ev);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
check_added_monitors!(nodes[1], 0);
do_commitment_signed_dance(&nodes[1], &nodes[0], &payment_event.commitment_msg, false, false);
expect_pending_htlcs_forwardable!(nodes[1]);
// Ensure the final node fails to handle the HTLC.
payment_event.msgs[0].onion_routing_packet.hop_data[0] ^= 1;
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &payment_event.msgs[0]);
check_added_monitors!(nodes[2], 0);
do_commitment_signed_dance(&nodes[2], &nodes[1], &payment_event.commitment_msg, true, true);
nodes[2].node.process_pending_htlc_forwards();
// Modify such the final hop does not correctly blind their error so we can ensure the intro node
// converts it to the correct error.
update_malformed.sha256_of_onion = [1; 32];
- nodes[1].node.handle_update_fail_malformed_htlc(&nodes[2].node.get_our_node_id(), update_malformed);
+ nodes[1].node.handle_update_fail_malformed_htlc(nodes[2].node.get_our_node_id(), update_malformed);
do_commitment_signed_dance(&nodes[1], &nodes[2], &updates.commitment_signed, true, false);
let mut updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
do_commitment_signed_dance(&nodes[0], &nodes[1], &updates.commitment_signed, false, false);
expect_payment_failed_conditions(&nodes[0], payment_hash, false,
PaymentFailedConditions::new().expected_htlc_error_data(INVALID_ONION_BLINDING, &[0; 32]));
let ev = remove_first_msg_event_to_node(&nodes[1].node.get_our_node_id(), &mut events);
let mut payment_event = SendEvent::from_event(ev);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
check_added_monitors!(nodes[1], 0);
do_commitment_signed_dance(&nodes[1], &nodes[0], &payment_event.commitment_msg, false, false);
ProcessPendingHTLCsCheck::FwdPeerDisconnected => {
// Disconnect the next-hop peer so when we go to forward in process_pending_htlc_forwards, the
// intro node will error backwards.
- $curr_node.node.peer_disconnected(&$next_node.node.get_our_node_id());
+ $curr_node.node.peer_disconnected($next_node.node.get_our_node_id());
expect_pending_htlcs_forwardable!($curr_node);
expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore!($curr_node,
vec![HTLCDestination::NextHopChannel { node_id: Some($next_node.node.get_our_node_id()), channel_id: $failed_chan_id }]);
if intro_fails {
cause_error!(nodes[0], nodes[1], nodes[2], chan_id_1_2, chan_upd_1_2.short_channel_id);
let mut updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
check_added_monitors!(nodes[1], 1);
do_commitment_signed_dance(&nodes[0], &nodes[1], &updates.commitment_signed, false, false);
let mut updates_1_2 = get_htlc_update_msgs!(nodes[1], nodes[2].node.get_our_node_id());
let mut update_add = &mut updates_1_2.update_add_htlcs[0];
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &update_add);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &update_add);
check_added_monitors!(nodes[2], 0);
do_commitment_signed_dance(&nodes[2], &nodes[1], &updates_1_2.commitment_signed, true, true);
// Ensure the intro node will properly blind the error if its downstream node failed to do so.
update_malformed.sha256_of_onion = [1; 32];
update_malformed.failure_code = INVALID_ONION_BLINDING ^ 1;
- nodes[1].node.handle_update_fail_malformed_htlc(&nodes[2].node.get_our_node_id(), update_malformed);
+ nodes[1].node.handle_update_fail_malformed_htlc(nodes[2].node.get_our_node_id(), update_malformed);
do_commitment_signed_dance(&nodes[1], &nodes[2], &updates.commitment_signed, true, false);
let mut updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
do_commitment_signed_dance(&nodes[0], &nodes[1], &updates.commitment_signed, false, false);
expect_payment_failed_conditions(&nodes[0], payment_hash, false,
PaymentFailedConditions::new().expected_htlc_error_data(INVALID_ONION_BLINDING, &[0; 32]));
assert_eq!(events.len(), 1);
SendEvent::from_event(events.remove(0))
};
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], &payment_event.commitment_msg, false, true);
let events = nodes[1].node.get_and_clear_pending_events();
check_added_monitors!(&nodes[1], 1);
assert!(update_fail.update_fail_htlcs.len() == 1);
let fail_msg = update_fail.update_fail_htlcs[0].clone();
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &fail_msg);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &fail_msg);
commitment_signed_dance!(nodes[0], nodes[1], update_fail.commitment_signed, false);
expect_payment_failed_conditions(&nodes[0], payment_hash, false,
PaymentFailedConditions::new().expected_htlc_error_data(INVALID_ONION_BLINDING, &[0; 32]));
assert_eq!(events.len(), 1);
SendEvent::from_event(events.remove(0))
};
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[2], nodes[1], &payment_event.commitment_msg, false, true);
expect_pending_htlcs_forwardable!(nodes[2]);
let update_malformed = &updates_3_2.update_fail_malformed_htlcs[0];
assert_eq!(update_malformed.sha256_of_onion, [0; 32]);
assert_eq!(update_malformed.failure_code, INVALID_ONION_BLINDING);
- nodes[2].node.handle_update_fail_malformed_htlc(&nodes[3].node.get_our_node_id(), update_malformed);
+ nodes[2].node.handle_update_fail_malformed_htlc(nodes[3].node.get_our_node_id(), update_malformed);
do_commitment_signed_dance(&nodes[2], &nodes[3], &updates_3_2.commitment_signed, true, false);
let updates_2_1 = get_htlc_update_msgs!(nodes[2], nodes[1].node.get_our_node_id());
let update_malformed = &updates_2_1.update_fail_malformed_htlcs[0];
assert_eq!(update_malformed.sha256_of_onion, [0; 32]);
assert_eq!(update_malformed.failure_code, INVALID_ONION_BLINDING);
- nodes[1].node.handle_update_fail_malformed_htlc(&nodes[2].node.get_our_node_id(), update_malformed);
+ nodes[1].node.handle_update_fail_malformed_htlc(nodes[2].node.get_our_node_id(), update_malformed);
do_commitment_signed_dance(&nodes[1], &nodes[2], &updates_2_1.commitment_signed, true, false);
let updates_1_0 = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
assert_eq!(updates_1_0.update_fail_htlcs.len(), 1);
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &updates_1_0.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &updates_1_0.update_fail_htlcs[0]);
do_commitment_signed_dance(&nodes[0], &nodes[1], &updates_1_0.commitment_signed, false, false);
expect_payment_failed_conditions(&nodes[0], payment_hash, false,
PaymentFailedConditions::new().expected_htlc_error_data(INVALID_ONION_BLINDING, &[0; 32]));
let ev = remove_first_msg_event_to_node(&nodes[1].node.get_our_node_id(), &mut events);
SendEvent::from_event(ev)
};
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event_0_1.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event_0_1.msgs[0]);
check_added_monitors!(nodes[1], 0);
do_commitment_signed_dance(&nodes[1], &nodes[0], &payment_event_0_1.commitment_msg, false, false);
expect_pending_htlcs_forwardable!(nodes[1]);
match check {
ReceiveCheckFail::RecipientFail => {
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &payment_event_1_2.msgs[0]);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &payment_event_1_2.msgs[0]);
check_added_monitors!(nodes[2], 0);
do_commitment_signed_dance(&nodes[2], &nodes[1], &payment_event_1_2.commitment_msg, true, true);
expect_pending_htlcs_forwardable!(nodes[2]);
vec![onion_payloads.pop().unwrap()], vec![onion_keys.pop().unwrap()], [0; 32],
&payment_hash
).unwrap();
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), update_add);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), update_add);
check_added_monitors!(nodes[2], 0);
do_commitment_signed_dance(&nodes[2], &nodes[1], &payment_event_1_2.commitment_msg, true, true);
},
ReceiveCheckFail::ReceiveRequirements => {
let update_add = &mut payment_event_1_2.msgs[0];
update_add.amount_msat -= 1;
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), update_add);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), update_add);
check_added_monitors!(nodes[2], 0);
do_commitment_signed_dance(&nodes[2], &nodes[1], &payment_event_1_2.commitment_msg, true, true);
},
ReceiveCheckFail::ChannelCheck => {
nodes[2].node.close_channel(&chan_id_1_2, &nodes[1].node.get_our_node_id()).unwrap();
let node_2_shutdown = get_event_msg!(nodes[2], MessageSendEvent::SendShutdown, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_shutdown(&nodes[2].node.get_our_node_id(), &node_2_shutdown);
+ nodes[1].node.handle_shutdown(nodes[2].node.get_our_node_id(), &node_2_shutdown);
let node_1_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[2].node.get_our_node_id());
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &payment_event_1_2.msgs[0]);
- nodes[2].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &payment_event_1_2.commitment_msg);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &payment_event_1_2.msgs[0]);
+ nodes[2].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &payment_event_1_2.commitment_msg);
check_added_monitors!(nodes[2], 1);
- nodes[2].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &node_1_shutdown);
+ nodes[2].node.handle_shutdown(nodes[1].node.get_our_node_id(), &node_1_shutdown);
commitment_signed_dance!(nodes[2], nodes[1], (), false, true, false, false);
},
ReceiveCheckFail::ProcessPendingHTLCsCheck => {
assert_eq!(payment_event_1_2.msgs[0].cltv_expiry, nodes[0].best_block_info().1 + 1 + excess_final_cltv_delta_opt.unwrap() as u32 + TEST_FINAL_CLTV);
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &payment_event_1_2.msgs[0]);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &payment_event_1_2.msgs[0]);
check_added_monitors!(nodes[2], 0);
do_commitment_signed_dance(&nodes[2], &nodes[1], &payment_event_1_2.commitment_msg, true, true);
expect_pending_htlcs_forwardable!(nodes[2]);
check_added_monitors!(nodes[2], 1);
},
ReceiveCheckFail::PaymentConstraints => {
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &payment_event_1_2.msgs[0]);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &payment_event_1_2.msgs[0]);
check_added_monitors!(nodes[2], 0);
do_commitment_signed_dance(&nodes[2], &nodes[1], &payment_event_1_2.commitment_msg, true, true);
}
let update_malformed = &updates_2_1.update_fail_malformed_htlcs[0];
assert_eq!(update_malformed.sha256_of_onion, [0; 32]);
assert_eq!(update_malformed.failure_code, INVALID_ONION_BLINDING);
- nodes[1].node.handle_update_fail_malformed_htlc(&nodes[2].node.get_our_node_id(), update_malformed);
+ nodes[1].node.handle_update_fail_malformed_htlc(nodes[2].node.get_our_node_id(), update_malformed);
do_commitment_signed_dance(&nodes[1], &nodes[2], &updates_2_1.commitment_signed, true, false);
let updates_1_0 = if check == ReceiveCheckFail::ChannelCheck {
}).unwrap()
} else { get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id()) };
assert_eq!(updates_1_0.update_fail_htlcs.len(), 1);
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &updates_1_0.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &updates_1_0.update_fail_htlcs[0]);
do_commitment_signed_dance(&nodes[0], &nodes[1], &updates_1_0.commitment_signed, false, false);
expect_payment_failed_conditions(&nodes[0], payment_hash, false,
PaymentFailedConditions::new().expected_htlc_error_data(INVALID_ONION_BLINDING, &[0; 32]));
let update_malformed = &updates.update_fail_malformed_htlcs[0];
assert_eq!(update_malformed.sha256_of_onion, [0; 32]);
assert_eq!(update_malformed.failure_code, INVALID_ONION_BLINDING);
- $intro_node.node.handle_update_fail_malformed_htlc(&nodes[3].node.get_our_node_id(), update_malformed);
+ $intro_node.node.handle_update_fail_malformed_htlc(nodes[3].node.get_our_node_id(), update_malformed);
do_commitment_signed_dance(&$intro_node, &nodes[3], &updates.commitment_signed, true, false);
let updates = get_htlc_update_msgs!($intro_node, nodes[0].node.get_our_node_id());
assert_eq!(updates.update_fail_htlcs.len(), 1);
- nodes[0].node.handle_update_fail_htlc(&$intro_node.node.get_our_node_id(), &updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc($intro_node.node.get_our_node_id(), &updates.update_fail_htlcs[0]);
do_commitment_signed_dance(&nodes[0], &$intro_node, &updates.commitment_signed, false, false);
let mut events = nodes[0].node.get_and_clear_pending_events();
let ev = remove_first_msg_event_to_node(&nodes[1].node.get_our_node_id(), &mut events);
SendEvent::from_event(ev)
};
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event_0_1.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event_0_1.msgs[0]);
check_added_monitors!(nodes[1], 0);
do_commitment_signed_dance(&nodes[1], &nodes[0], &payment_event_0_1.commitment_msg, true, true);
let mut updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
do_commitment_signed_dance(&nodes[0], &nodes[1], &updates.commitment_signed, false, false);
expect_payment_failed_conditions(&nodes[0], payment_hash, false,
PaymentFailedConditions::new().expected_htlc_error_data(INVALID_ONION_BLINDING, &[0; 32]));
.unwrap();
check_added_monitors(&nodes[0], 1);
let send_event = SendEvent::from_node(&nodes[0]);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], &send_event.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[1]);
let updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
assert_eq!(updates.update_fulfill_htlcs.len(), 1);
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
{
let mut node_0_per_peer_lock;
assert_eq!(nodes[0].node.list_channels().len(), 1);
if disconnect {
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
let mut reconnect_args = ReconnectArgs::new(&nodes[0], &nodes[1]);
reconnect_args.send_channel_ready = (true, true);
reconnect_nodes(reconnect_args);
assert_eq!(events_2.len(), 1);
let payment_event = SendEvent::from_event(events_2.pop().unwrap());
assert_eq!(payment_event.node_id, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[1]);
assert_eq!(nodes[0].node.list_channels().len(), 1);
if disconnect {
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[1]));
}
assert!(update_fee.is_none());
if (disconnect_count & 16) == 0 {
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &update_fulfill_htlcs[0]);
let events_3 = nodes[0].node.get_and_clear_pending_events();
assert_eq!(events_3.len(), 1);
match events_3[0] {
_ => panic!("Unexpected event"),
}
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), commitment_signed);
check_added_monitors!(nodes[0], 1);
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
}
};
if disconnect_count & !disconnect_flags > 0 {
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
}
// Now fix monitor updating...
check_added_monitors!(nodes[0], 0);
macro_rules! disconnect_reconnect_peers { () => { {
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
- nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init {
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).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 {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, false).unwrap();
let reestablish_2 = get_chan_reestablish_msgs!(nodes[1], nodes[0]);
assert_eq!(reestablish_2.len(), 1);
- nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &reestablish_2[0]);
+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &reestablish_2[0]);
let as_resp = handle_chan_reestablish_msgs!(nodes[0], nodes[1]);
- nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &reestablish_1[0]);
+ nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), &reestablish_1[0]);
let bs_resp = handle_chan_reestablish_msgs!(nodes[1], nodes[0]);
assert!(as_resp.0.is_none());
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 {
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).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 {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, false).unwrap();
let reestablish_2 = get_chan_reestablish_msgs!(nodes[1], nodes[0]);
assert_eq!(reestablish_2.len(), 1);
- nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &reestablish_2[0]);
+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &reestablish_2[0]);
check_added_monitors!(nodes[0], 0);
let mut as_resp = handle_chan_reestablish_msgs!(nodes[0], nodes[1]);
- nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &reestablish_1[0]);
+ nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), &reestablish_1[0]);
check_added_monitors!(nodes[1], 0);
let mut bs_resp = handle_chan_reestablish_msgs!(nodes[1], nodes[0]);
assert!(as_resp.1.is_none());
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &bs_resp.2.as_ref().unwrap().update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &bs_resp.2.as_ref().unwrap().update_fulfill_htlcs[0]);
let events_3 = nodes[0].node.get_and_clear_pending_events();
assert_eq!(events_3.len(), 1);
match events_3[0] {
_ => panic!("Unexpected event"),
}
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_resp.2.as_ref().unwrap().commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_resp.2.as_ref().unwrap().commitment_signed);
let as_resp_raa = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
// No commitment_signed so get_event_msg's assert(len == 1) passes
check_added_monitors!(nodes[0], 1);
assert_eq!(payment_event.node_id, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &payment_event.commitment_msg);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &payment_event.commitment_msg);
let bs_revoke_and_ack = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
// nodes[1] is awaiting an RAA from nodes[0] still so get_event_msg's assert(len == 1) passes
check_added_monitors!(nodes[1], 1);
let bs_second_commitment_update;
macro_rules! handle_bs_raa { () => {
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_revoke_and_ack);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_revoke_and_ack);
as_commitment_update = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
assert!(as_commitment_update.update_add_htlcs.is_empty());
assert!(as_commitment_update.update_fulfill_htlcs.is_empty());
} }
macro_rules! handle_initial_raa { () => {
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &initial_revoke_and_ack);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &initial_revoke_and_ack);
bs_second_commitment_update = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
assert!(bs_second_commitment_update.update_add_htlcs.is_empty());
assert!(bs_second_commitment_update.update_fulfill_htlcs.is_empty());
}
}
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_second_commitment_update.commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_second_commitment_update.commitment_signed);
let as_revoke_and_ack = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
// No commitment_signed so get_event_msg's assert(len == 1) passes
check_added_monitors!(nodes[0], 1);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_commitment_update.commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_commitment_update.commitment_signed);
let bs_second_revoke_and_ack = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
// No commitment_signed so get_event_msg's assert(len == 1) passes
check_added_monitors!(nodes[1], 1);
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_revoke_and_ack);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_revoke_and_ack);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[1], 1);
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_second_revoke_and_ack);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_second_revoke_and_ack);
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[0], 1);
expect_payment_path_successful!(nodes[0]);
}
let send_event = SendEvent::from_event(nodes[0].node.get_and_clear_pending_msg_events().remove(0));
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &send_event.commitment_msg);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &send_event.commitment_msg);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[1], 1);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
match responses[0] {
MessageSendEvent::SendRevokeAndACK { ref msg, ref node_id } => {
assert_eq!(*node_id, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &msg);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &msg);
check_added_monitors!(nodes[0], 1);
},
_ => panic!("Unexpected event"),
assert_eq!(*node_id, nodes[0].node.get_our_node_id());
chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &updates.commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &updates.commitment_signed);
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[0], 1);
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[0], 0);
let final_raa = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &final_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &final_raa);
check_added_monitors!(nodes[1], 1);
expect_pending_htlcs_forwardable!(nodes[1]);
}
let send_event = SendEvent::from_event(nodes[0].node.get_and_clear_pending_msg_events().remove(0));
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
let bs_raa = commitment_signed_dance!(nodes[1], nodes[0], send_event.commitment_msg, false, true, false, true);
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &bs_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &bs_raa);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
assert!(nodes[1].node.get_and_clear_pending_events().is_empty());
}
let send_event_2 = SendEvent::from_event(nodes[1].node.get_and_clear_pending_msg_events().remove(0));
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &send_event_1.msgs[0]);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &send_event_1.commitment_msg);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &send_event_1.msgs[0]);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &send_event_1.commitment_msg);
check_added_monitors!(nodes[1], 1);
let bs_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
- nodes[0].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &send_event_2.msgs[0]);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &send_event_2.commitment_msg);
+ nodes[0].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &send_event_2.msgs[0]);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &send_event_2.commitment_msg);
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[0], 1);
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_raa);
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[0], 1);
check_added_monitors!(nodes[0], 0);
let as_update_raa = get_revoke_commit_msgs!(nodes[0], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_update_raa.0);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_update_raa.0);
check_added_monitors!(nodes[1], 1);
let bs_cs = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_update_raa.1);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_update_raa.1);
check_added_monitors!(nodes[1], 1);
let bs_second_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_cs.commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_cs.commitment_signed);
check_added_monitors!(nodes[0], 1);
let as_second_raa = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_second_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_second_raa);
check_added_monitors!(nodes[0], 1);
expect_pending_htlcs_forwardable!(nodes[0]);
expect_payment_claimable!(nodes[0], our_payment_hash_2, our_payment_secret_2, 1000000);
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_second_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_second_raa);
check_added_monitors!(nodes[1], 1);
expect_pending_htlcs_forwardable!(nodes[1]);
expect_payment_claimable!(nodes[1], our_payment_hash_1, our_payment_secret_1, 1000000);
assert_eq!(updates.update_fail_htlcs.len(), 1);
assert!(updates.update_fail_malformed_htlcs.is_empty());
assert!(updates.update_fee.is_none());
- nodes[1].node.handle_update_fail_htlc(&nodes[2].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
+ nodes[1].node.handle_update_fail_htlc(nodes[2].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
let bs_revoke_and_ack = commitment_signed_dance!(nodes[1], nodes[2], updates.commitment_signed, false, true, false, true);
check_added_monitors!(nodes[0], 0);
}
let mut send_event = SendEvent::from_event(nodes[0].node.get_and_clear_pending_msg_events().remove(0));
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], send_event.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[1]);
// Now fail monitor updating.
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
- nodes[1].node.handle_revoke_and_ack(&nodes[2].node.get_our_node_id(), &bs_revoke_and_ack);
+ nodes[1].node.handle_revoke_and_ack(nodes[2].node.get_our_node_id(), &bs_revoke_and_ack);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
assert!(nodes[1].node.get_and_clear_pending_events().is_empty());
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::Completed); // We succeed in updating the monitor for the first channel
send_event = SendEvent::from_event(nodes[0].node.get_and_clear_pending_msg_events().remove(0));
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], send_event.commitment_msg, false, true);
check_added_monitors!(nodes[1], 0);
check_added_monitors!(nodes[2], 1);
send_event = SendEvent::from_event(nodes[2].node.get_and_clear_pending_msg_events().remove(0));
- nodes[1].node.handle_update_add_htlc(&nodes[2].node.get_our_node_id(), &send_event.msgs[0]);
- nodes[1].node.handle_commitment_signed(&nodes[2].node.get_our_node_id(), &send_event.commitment_msg);
+ nodes[1].node.handle_update_add_htlc(nodes[2].node.get_our_node_id(), &send_event.msgs[0]);
+ nodes[1].node.handle_commitment_signed(nodes[2].node.get_our_node_id(), &send_event.commitment_msg);
check_added_monitors!(nodes[1], 1);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
(Some(payment_preimage_4), Some(payment_hash_4))
// Now deliver the new messages...
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &messages_a.0);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &messages_a.0);
commitment_signed_dance!(nodes[0], nodes[1], messages_a.1, false);
expect_payment_failed!(nodes[0], payment_hash_1, true);
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &send_event_b.msgs[0]);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &send_event_b.msgs[0]);
let as_cs;
if test_ignore_second_cs {
- nodes[2].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &send_event_b.commitment_msg);
+ nodes[2].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &send_event_b.commitment_msg);
check_added_monitors!(nodes[2], 1);
let bs_revoke_and_ack = get_event_msg!(nodes[2], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
- nodes[2].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &raa.unwrap());
+ nodes[2].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &raa.unwrap());
check_added_monitors!(nodes[2], 1);
let bs_cs = get_htlc_update_msgs!(nodes[2], nodes[1].node.get_our_node_id());
assert!(bs_cs.update_add_htlcs.is_empty());
assert!(bs_cs.update_fulfill_htlcs.is_empty());
assert!(bs_cs.update_fee.is_none());
- nodes[1].node.handle_revoke_and_ack(&nodes[2].node.get_our_node_id(), &bs_revoke_and_ack);
+ nodes[1].node.handle_revoke_and_ack(nodes[2].node.get_our_node_id(), &bs_revoke_and_ack);
check_added_monitors!(nodes[1], 1);
as_cs = get_htlc_update_msgs!(nodes[1], nodes[2].node.get_our_node_id());
- nodes[1].node.handle_commitment_signed(&nodes[2].node.get_our_node_id(), &bs_cs.commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[2].node.get_our_node_id(), &bs_cs.commitment_signed);
check_added_monitors!(nodes[1], 1);
} else {
- nodes[2].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &send_event_b.commitment_msg);
+ nodes[2].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &send_event_b.commitment_msg);
check_added_monitors!(nodes[2], 1);
let bs_revoke_and_commit = nodes[2].node.get_and_clear_pending_msg_events();
match bs_revoke_and_commit[0] {
MessageSendEvent::SendRevokeAndACK { ref node_id, ref msg } => {
assert_eq!(*node_id, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[2].node.get_our_node_id(), &msg);
+ nodes[1].node.handle_revoke_and_ack(nodes[2].node.get_our_node_id(), &msg);
check_added_monitors!(nodes[1], 1);
},
_ => panic!("Unexpected event"),
assert!(updates.update_fail_malformed_htlcs.is_empty());
assert!(updates.update_fulfill_htlcs.is_empty());
assert!(updates.update_fee.is_none());
- nodes[1].node.handle_commitment_signed(&nodes[2].node.get_our_node_id(), &updates.commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[2].node.get_our_node_id(), &updates.commitment_signed);
check_added_monitors!(nodes[1], 1);
},
_ => panic!("Unexpected event"),
let as_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[2].node.get_our_node_id());
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &as_cs.update_add_htlcs[0]);
- nodes[2].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &as_cs.commitment_signed);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &as_cs.update_add_htlcs[0]);
+ nodes[2].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &as_cs.commitment_signed);
check_added_monitors!(nodes[2], 1);
let bs_second_raa = get_event_msg!(nodes[2], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
- nodes[2].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &as_raa);
+ nodes[2].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &as_raa);
check_added_monitors!(nodes[2], 1);
let bs_second_cs = get_htlc_update_msgs!(nodes[2], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[2].node.get_our_node_id(), &bs_second_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[2].node.get_our_node_id(), &bs_second_raa);
check_added_monitors!(nodes[1], 1);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
- nodes[1].node.handle_commitment_signed(&nodes[2].node.get_our_node_id(), &bs_second_cs.commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[2].node.get_our_node_id(), &bs_second_cs.commitment_signed);
check_added_monitors!(nodes[1], 1);
let as_second_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[2].node.get_our_node_id());
- nodes[2].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &as_second_raa);
+ nodes[2].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &as_second_raa);
check_added_monitors!(nodes[2], 1);
assert!(nodes[2].node.get_and_clear_pending_msg_events().is_empty());
send_event = SendEvent::from_node(&nodes[1]);
assert_eq!(send_event.node_id, nodes[0].node.get_our_node_id());
assert_eq!(send_event.msgs.len(), 1);
- nodes[0].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &send_event.msgs[0]);
+ nodes[0].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &send_event.msgs[0]);
commitment_signed_dance!(nodes[0], nodes[1], send_event.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[0]);
let (payment_preimage, payment_hash, ..) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 1_000_000);
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
nodes[2].node.claim_funds(payment_preimage);
check_added_monitors!(nodes[2], 1);
assert!(updates.update_fail_malformed_htlcs.is_empty());
assert!(updates.update_fee.is_none());
assert_eq!(updates.update_fulfill_htlcs.len(), 1);
- nodes[1].node.handle_update_fulfill_htlc(&nodes[2].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
+ nodes[1].node.handle_update_fulfill_htlc(nodes[2].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], Some(1000), false, false);
check_added_monitors!(nodes[1], 1);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
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 {
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).unwrap();
- nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, false).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[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &bs_reestablish);
+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &bs_reestablish);
- nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &as_reestablish);
+ nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), &as_reestablish);
assert_eq!(
get_event_msg!(nodes[0], MessageSendEvent::SendChannelUpdate, nodes[1].node.get_our_node_id())
.contents.channel_flags & 2, 0); // The "disabled" bit should be unset as we just reconnected
nodes[1].node.get_and_clear_pending_msg_events(); // Free the holding cell
check_added_monitors!(nodes[1], 1);
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
- nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init {
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).unwrap();
- nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, false).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);
- nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &bs_reestablish);
+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &bs_reestablish);
assert_eq!(
get_event_msg!(nodes[0], MessageSendEvent::SendChannelUpdate, nodes[1].node.get_our_node_id())
.contents.channel_flags & 2, 0); // The "disabled" bit should be unset as we just reconnected
- nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &as_reestablish);
+ nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), &as_reestablish);
check_added_monitors!(nodes[1], 0);
assert_eq!(
get_event_msg!(nodes[1], MessageSendEvent::SendChannelUpdate, nodes[0].node.get_our_node_id())
assert!(updates.update_fail_malformed_htlcs.is_empty());
assert!(updates.update_fee.is_none());
assert_eq!(updates.update_fulfill_htlcs.len(), 1);
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], updates.commitment_signed, false);
expect_payment_sent!(nodes[0], payment_preimage);
}
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
let payment_event = SendEvent::from_event(events.pop().unwrap());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &payment_event.commitment_msg);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &payment_event.commitment_msg);
check_added_monitors!(nodes[1], 1);
let bs_responses = get_revoke_commit_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_responses.0);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_responses.0);
check_added_monitors!(nodes[0], 1);
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
let payment_event = SendEvent::from_event(events.pop().unwrap());
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_responses.1);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_responses.1);
check_added_monitors!(nodes[0], 1);
let as_raa = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
// then restore channel monitor updates.
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &payment_event.commitment_msg);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &payment_event.commitment_msg);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[1], 1);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_raa);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[1], 1);
check_added_monitors!(nodes[0], 0);
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
}
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_responses.0);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_responses.0);
check_added_monitors!(nodes[0], 1);
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
let payment_event = SendEvent::from_event(events.pop().unwrap());
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_responses.1);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_responses.1);
check_added_monitors!(nodes[0], 1);
let as_raa = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &payment_event.commitment_msg);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &payment_event.commitment_msg);
check_added_monitors!(nodes[1], 1);
let bs_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
// Finally deliver the RAA to nodes[1] which results in a CS response to the last update
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_raa);
check_added_monitors!(nodes[1], 1);
expect_pending_htlcs_forwardable!(nodes[1]);
expect_payment_claimable!(nodes[1], payment_hash_2, payment_secret_2, 1000000);
let bs_update = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_raa);
check_added_monitors!(nodes[0], 1);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_update.commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_update.commitment_signed);
check_added_monitors!(nodes[0], 1);
let as_raa = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_raa);
check_added_monitors!(nodes[1], 1);
expect_pending_htlcs_forwardable!(nodes[1]);
expect_payment_claimable!(nodes[1], payment_hash_3, payment_secret_3, 1000000);
// Forward a payment for B to claim
let (payment_preimage_1, payment_hash_1, ..) = route_payment(&nodes[0], &[&nodes[1]], 1_000_000);
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
nodes[1].node.claim_funds(payment_preimage_1);
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 {
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).unwrap();
- nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, false).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();
- nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &bs_reconnect);
+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &bs_reconnect);
let _as_channel_update = get_event_msg!(nodes[0], MessageSendEvent::SendChannelUpdate, nodes[1].node.get_our_node_id());
// Now deliver a's reestablish, freeing the claim from the holding cell, but fail the monitor
// update.
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
- nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &as_reconnect);
+ nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), &as_reconnect);
let _bs_channel_update = get_event_msg!(nodes[1], MessageSendEvent::SendChannelUpdate, nodes[0].node.get_our_node_id());
check_added_monitors!(nodes[1], 1);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
}
let as_updates = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &as_updates.update_add_htlcs[0]);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_updates.commitment_signed);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &as_updates.update_add_htlcs[0]);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_updates.commitment_signed);
check_added_monitors!(nodes[1], 1);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
// Note that nodes[1] not updating monitor here is OK - it wont take action on the new HTLC
match bs_msgs[0] {
MessageSendEvent::UpdateHTLCs { ref node_id, ref updates } => {
assert_eq!(*node_id, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
expect_payment_sent(&nodes[0], payment_preimage_1, None, false, false);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &updates.commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &updates.commitment_signed);
check_added_monitors!(nodes[0], 1);
let as_raa = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_raa);
check_added_monitors!(nodes[1], 1);
},
_ => panic!("Unexpected event"),
match bs_msgs[1] {
MessageSendEvent::SendRevokeAndACK { ref node_id, ref msg } => {
assert_eq!(*node_id, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), msg);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), msg);
check_added_monitors!(nodes[0], 1);
},
_ => panic!("Unexpected event"),
let as_commitment = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
let bs_commitment = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_commitment.commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_commitment.commitment_signed);
check_added_monitors!(nodes[0], 1);
let as_raa = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_commitment.commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_commitment.commitment_signed);
check_added_monitors!(nodes[1], 1);
let bs_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_raa);
check_added_monitors!(nodes[1], 1);
expect_pending_htlcs_forwardable!(nodes[1]);
expect_payment_claimable!(nodes[1], payment_hash_2, payment_secret_2, 1000000);
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_raa);
check_added_monitors!(nodes[0], 1);
expect_payment_path_successful!(nodes[0]);
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
let payment_event = SendEvent::from_event(events.pop().unwrap());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &payment_event.commitment_msg);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &payment_event.commitment_msg);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[1], 1);
// Now disconnect and immediately reconnect, delivering the channel_reestablish while nodes[1]
// is still failing to update monitors.
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
- nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init {
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).unwrap();
- nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, false).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();
- nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &as_reconnect);
+ nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), &as_reconnect);
let _bs_channel_update = get_event_msg!(nodes[1], MessageSendEvent::SendChannelUpdate, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &bs_reconnect);
+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &bs_reconnect);
let _as_channel_update = get_event_msg!(nodes[0], MessageSendEvent::SendChannelUpdate, nodes[1].node.get_our_node_id());
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::Completed);
check_added_monitors!(nodes[1], 0);
let bs_responses = get_revoke_commit_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_responses.0);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_responses.0);
check_added_monitors!(nodes[0], 1);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_responses.1);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_responses.1);
check_added_monitors!(nodes[0], 1);
let as_raa = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_raa);
check_added_monitors!(nodes[1], 1);
expect_pending_htlcs_forwardable!(nodes[1]);
assert_eq!(events.len(), 1);
let payment_event = SendEvent::from_event(events.pop().unwrap());
assert_eq!(payment_event.node_id, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &payment_event.commitment_msg);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &payment_event.commitment_msg);
check_added_monitors!(nodes[1], 1);
let bs_responses = get_revoke_commit_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_responses.0);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_responses.0);
check_added_monitors!(nodes[0], 1);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_responses.1);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_responses.1);
check_added_monitors!(nodes[0], 1);
let as_raa = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
// Deliver the final RAA for the first payment, which does not require a response. RAAs
// generally require a commitment_signed, so the fact that we're expecting an opposite response
// to the next message also tests resetting the delivery order.
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_raa);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[1], 1);
// Now deliver the update_add_htlc/commitment_signed for the second payment, which does need an
// RAA/CS response, which should be generated when we call channel_monitor_update (with the
// appropriate HTLC acceptance).
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &payment_event.commitment_msg);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &payment_event.commitment_msg);
check_added_monitors!(nodes[1], 1);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
expect_payment_claimable!(nodes[1], payment_hash_1, payment_secret_1, 1000000);
let bs_responses = get_revoke_commit_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_responses.0);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_responses.0);
check_added_monitors!(nodes[0], 1);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_responses.1);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_responses.1);
check_added_monitors!(nodes[0], 1);
let as_raa = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_raa);
check_added_monitors!(nodes[1], 1);
expect_pending_htlcs_forwardable!(nodes[1]);
let mut events = nodes[2].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
let payment_event = SendEvent::from_event(events.pop().unwrap());
- nodes[1].node.handle_update_add_htlc(&nodes[2].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[2].node.get_our_node_id(), &payment_event.msgs[0]);
let events = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 0);
commitment_signed_dance!(nodes[1], nodes[2], payment_event.commitment_msg, false, true);
let mut events = nodes[2].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
let payment_event = SendEvent::from_event(events.pop().unwrap());
- nodes[1].node.handle_update_add_htlc(&nodes[2].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[2].node.get_our_node_id(), &payment_event.msgs[0]);
let events = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 0);
commitment_signed_dance!(nodes[1], nodes[2], payment_event.commitment_msg, false, true);
check_added_monitors!(nodes[1], 0);
let bs_fulfill_update = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &bs_fulfill_update.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &bs_fulfill_update.update_fulfill_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], bs_fulfill_update.commitment_signed, false);
expect_payment_sent!(nodes[0], payment_preimage_1);
nodes[1].node.process_pending_htlc_forwards();
check_added_monitors!(nodes[1], 1);
let bs_forward_update = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &bs_forward_update.update_add_htlcs[0]);
- nodes[0].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &bs_forward_update.update_add_htlcs[1]);
+ nodes[0].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &bs_forward_update.update_add_htlcs[0]);
+ nodes[0].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &bs_forward_update.update_add_htlcs[1]);
commitment_signed_dance!(nodes[0], nodes[1], bs_forward_update.commitment_signed, false);
expect_pending_htlcs_forwardable!(nodes[0]);
check_added_monitors!(nodes[2], 1);
let cs_fail_update = get_htlc_update_msgs!(nodes[2], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_update_fail_htlc(&nodes[2].node.get_our_node_id(), &cs_fail_update.update_fail_htlcs[0]);
+ nodes[1].node.handle_update_fail_htlc(nodes[2].node.get_our_node_id(), &cs_fail_update.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[1], nodes[2], cs_fail_update.commitment_signed, true, true);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
let mut events = nodes[2].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
let payment_event = SendEvent::from_event(events.pop().unwrap());
- nodes[1].node.handle_update_add_htlc(&nodes[2].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[2].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[2], payment_event.commitment_msg, false);
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
check_added_monitors!(nodes[1], 0);
let bs_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &bs_updates.update_fail_htlcs[0]);
- nodes[0].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &bs_updates.update_add_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &bs_updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &bs_updates.update_add_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], bs_updates.commitment_signed, false, true);
let events = nodes[0].node.get_and_clear_pending_events();
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
let payment_event = SendEvent::from_event(events.pop().unwrap());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
let as_raa = commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false, true, false, true);
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
check_added_monitors!(nodes[1], 0);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_raa);
check_added_monitors!(nodes[1], 1);
expect_pending_htlcs_forwardable!(nodes[1]);
expect_payment_claimable!(nodes[1], payment_hash_2, payment_secret_2, 1000000);
let bs_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &bs_updates.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &bs_updates.update_fulfill_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], bs_updates.commitment_signed, false);
expect_payment_sent!(nodes[0], payment_preimage_1);
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, None).unwrap();
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &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(), &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(), &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(), &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);
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
let funding_created_msg = get_event_msg!(nodes[0], MessageSendEvent::SendFundingCreated, nodes[1].node.get_our_node_id());
let channel_id = ChannelId::v1_from_funding_outpoint(OutPoint { txid: funding_created_msg.funding_txid, index: funding_created_msg.funding_output_index });
- nodes[1].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &funding_created_msg);
+ nodes[1].node.handle_funding_created(nodes[0].node.get_our_node_id(), &funding_created_msg);
check_added_monitors!(nodes[1], 1);
chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
- nodes[0].node.handle_funding_signed(&nodes[1].node.get_our_node_id(), &get_event_msg!(nodes[1], MessageSendEvent::SendFundingSigned, nodes[0].node.get_our_node_id()));
+ nodes[0].node.handle_funding_signed(nodes[1].node.get_our_node_id(), &get_event_msg!(nodes[1], MessageSendEvent::SendFundingSigned, 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());
assert!(nodes[0].node.get_and_clear_pending_events().is_empty());
if confirm_a_first {
confirm_transaction(&nodes[0], &funding_tx);
- nodes[1].node.handle_channel_ready(&nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendChannelReady, nodes[1].node.get_our_node_id()));
+ nodes[1].node.handle_channel_ready(nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendChannelReady, nodes[1].node.get_our_node_id()));
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
assert!(nodes[1].node.get_and_clear_pending_events().is_empty());
} else {
}
// Make sure nodes[1] isn't stupid enough to re-send the ChannelReady on reconnect
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
let mut reconnect_args = ReconnectArgs::new(&nodes[0], &nodes[1]);
reconnect_args.send_channel_ready.1 = confirm_a_first;
reconnect_nodes(reconnect_args);
}
if !confirm_a_first && !restore_b_before_lock {
confirm_transaction(&nodes[0], &funding_tx);
- nodes[1].node.handle_channel_ready(&nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendChannelReady, nodes[1].node.get_our_node_id()));
+ nodes[1].node.handle_channel_ready(nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendChannelReady, nodes[1].node.get_our_node_id()));
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
assert!(nodes[1].node.get_and_clear_pending_events().is_empty());
}
let (channel_ready, channel_id) = create_chan_between_nodes_with_value_confirm_second(&nodes[0], &nodes[1]);
(channel_id, create_chan_between_nodes_with_value_b(&nodes[1], &nodes[0], &channel_ready))
} else {
- 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()));
+ 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()));
confirm_transaction(&nodes[0], &funding_tx);
let (channel_ready, channel_id) = create_chan_between_nodes_with_value_confirm_second(&nodes[1], &nodes[0]);
(channel_id, create_chan_between_nodes_with_value_b(&nodes[0], &nodes[1], &channel_ready))
};
for (i, node) in nodes.iter().enumerate() {
let counterparty_node_id = nodes[(i + 1) % 2].node.get_our_node_id();
- assert!(node.gossip_sync.handle_channel_announcement(Some(&counterparty_node_id), &announcement).unwrap());
- node.gossip_sync.handle_channel_update(Some(&counterparty_node_id), &as_update).unwrap();
- node.gossip_sync.handle_channel_update(Some(&counterparty_node_id), &bs_update).unwrap();
+ assert!(node.gossip_sync.handle_channel_announcement(Some(counterparty_node_id), &announcement).unwrap());
+ node.gossip_sync.handle_channel_update(Some(counterparty_node_id), &as_update).unwrap();
+ node.gossip_sync.handle_channel_update(Some(counterparty_node_id), &bs_update).unwrap();
}
if !restore_b_before_lock {
let as_update_fee_msgs = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
assert!(as_update_fee_msgs.update_fee.is_some());
- nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), as_update_fee_msgs.update_fee.as_ref().unwrap());
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_update_fee_msgs.commitment_signed);
+ nodes[1].node.handle_update_fee(nodes[0].node.get_our_node_id(), as_update_fee_msgs.update_fee.as_ref().unwrap());
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_update_fee_msgs.commitment_signed);
check_added_monitors!(nodes[1], 1);
let bs_first_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
// bs_first_raa is not delivered until it is re-generated after reconnect
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
- nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init {
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).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 {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, false).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);
+ nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), &as_connect_msg);
let bs_resend_msgs = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(bs_resend_msgs.len(), 3);
if let MessageSendEvent::UpdateHTLCs { ref updates, .. } = bs_resend_msgs[0] {
} else { panic!(); }
if let MessageSendEvent::SendChannelUpdate { .. } = bs_resend_msgs[2] { } else { panic!(); }
- nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &bs_connect_msg);
+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &bs_connect_msg);
get_event_msg!(nodes[0], MessageSendEvent::SendChannelUpdate, nodes[1].node.get_our_node_id());
- nodes[0].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &bs_initial_send_msgs.update_add_htlcs[0]);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_initial_send_msgs.commitment_signed);
+ nodes[0].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &bs_initial_send_msgs.update_add_htlcs[0]);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_initial_send_msgs.commitment_signed);
check_added_monitors!(nodes[0], 1);
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id()));
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id()));
check_added_monitors!(nodes[1], 1);
let bs_second_cs = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id()).commitment_signed;
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_first_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_first_raa);
check_added_monitors!(nodes[0], 1);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id()).commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id()).commitment_signed);
check_added_monitors!(nodes[1], 1);
let bs_third_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_second_cs);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_second_cs);
check_added_monitors!(nodes[0], 1);
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_third_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_third_raa);
check_added_monitors!(nodes[0], 1);
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id()));
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id()));
check_added_monitors!(nodes[1], 1);
expect_pending_htlcs_forwardable!(nodes[0]);
expect_payment_claimed!(nodes[2], payment_hash, 2000);
let cs_updates = get_htlc_update_msgs!(nodes[2], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_update_fulfill_htlc(&nodes[2].node.get_our_node_id(), &cs_updates.update_fulfill_htlcs[0]);
+ nodes[1].node.handle_update_fulfill_htlc(nodes[2].node.get_our_node_id(), &cs_updates.update_fulfill_htlcs[0]);
let bs_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
check_added_monitors!(nodes[1], 1);
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], Some(1000), false, false);
check_added_monitors!(nodes[1], 1);
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], vec![HTLCDestination::NextHopChannel { node_id: Some(nodes[2].node.get_our_node_id()), channel_id: chan_id_2 }]);
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &bs_updates.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &bs_updates.update_fulfill_htlcs[0]);
expect_payment_sent(&nodes[0], payment_preimage, None, false, false);
commitment_signed_dance!(nodes[0], nodes[1], bs_updates.commitment_signed, true, true);
expect_payment_path_successful!(nodes[0]);
let update_msgs = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
assert!(update_msgs.update_fee.is_some());
if deliver_update {
- nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), update_msgs.update_fee.as_ref().unwrap());
+ nodes[1].node.handle_update_fee(nodes[0].node.get_our_node_id(), update_msgs.update_fee.as_ref().unwrap());
}
if parallel_updates {
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
}
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
- nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init {
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).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 {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, false).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);
+ nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), &as_connect_msg);
get_event_msg!(nodes[1], MessageSendEvent::SendChannelUpdate, nodes[0].node.get_our_node_id());
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
- nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &bs_connect_msg);
+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &bs_connect_msg);
let mut as_reconnect_msgs = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(as_reconnect_msgs.len(), 2);
if let MessageSendEvent::SendChannelUpdate { .. } = as_reconnect_msgs.pop().unwrap() {} else { panic!(); }
let update_msgs = if let MessageSendEvent::UpdateHTLCs { updates, .. } = as_reconnect_msgs.pop().unwrap()
{ updates } else { panic!(); };
assert!(update_msgs.update_fee.is_some());
- nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), update_msgs.update_fee.as_ref().unwrap());
+ nodes[1].node.handle_update_fee(nodes[0].node.get_our_node_id(), update_msgs.update_fee.as_ref().unwrap());
if parallel_updates {
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &update_msgs.commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &update_msgs.commitment_signed);
check_added_monitors!(nodes[1], 1);
let (bs_first_raa, bs_first_cs) = get_revoke_commit_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_first_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_first_raa);
check_added_monitors!(nodes[0], 1);
let as_second_update = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_first_cs);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_first_cs);
check_added_monitors!(nodes[0], 1);
let as_first_raa = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), as_second_update.update_fee.as_ref().unwrap());
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_second_update.commitment_signed);
+ nodes[1].node.handle_update_fee(nodes[0].node.get_our_node_id(), as_second_update.update_fee.as_ref().unwrap());
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_second_update.commitment_signed);
check_added_monitors!(nodes[1], 1);
let bs_second_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_first_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_first_raa);
let bs_second_cs = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
check_added_monitors!(nodes[1], 1);
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_second_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_second_raa);
check_added_monitors!(nodes[0], 1);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_second_cs.commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_second_cs.commitment_signed);
check_added_monitors!(nodes[0], 1);
let as_second_raa = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_second_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_second_raa);
check_added_monitors!(nodes[1], 1);
} else {
commitment_signed_dance!(nodes[1], nodes[0], update_msgs.commitment_signed, false);
nodes[0].node.claim_funds(payment_preimage_0);
check_added_monitors!(nodes[0], 1);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &send.msgs[0]);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &send.commitment_msg);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &send.msgs[0]);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &send.commitment_msg);
check_added_monitors!(nodes[1], 1);
let (raa, cs) = get_revoke_commit_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &raa);
check_added_monitors!(nodes[0], 1);
if disconnect {
persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
} else {
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
}
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
// Now reconnect the two
- nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init {
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).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 {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, false).unwrap();
let reestablish_2 = get_chan_reestablish_msgs!(nodes[1], nodes[0]);
assert_eq!(reestablish_2.len(), 1);
- nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &reestablish_1[0]);
+ nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), &reestablish_1[0]);
let resp_1 = handle_chan_reestablish_msgs!(nodes[1], nodes[0]);
check_added_monitors!(nodes[1], 0);
- nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &reestablish_2[0]);
+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &reestablish_2[0]);
let resp_0 = handle_chan_reestablish_msgs!(nodes[0], nodes[1]);
assert!(resp_0.0.is_none());
assert_eq!(events.len(), 1);
// Deliver the pending in-flight CS
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &cs);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &cs);
check_added_monitors!(nodes[0], 1);
let commitment_msg = match events.pop().unwrap() {
assert!(updates.update_fail_malformed_htlcs.is_empty());
assert!(updates.update_fee.is_none());
assert_eq!(updates.update_fulfill_htlcs.len(), 1);
- nodes[1].node.handle_update_fulfill_htlc(&nodes[0].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
+ nodes[1].node.handle_update_fulfill_htlc(nodes[0].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
expect_payment_sent(&nodes[1], payment_preimage_0, None, false, false);
assert_eq!(updates.update_add_htlcs.len(), 1);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
updates.commitment_signed
},
_ => panic!("Unexpected event type!"),
};
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &commitment_msg);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &commitment_msg);
check_added_monitors!(nodes[1], 1);
let as_revoke_and_ack = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_revoke_and_ack);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_revoke_and_ack);
expect_pending_htlcs_forwardable!(nodes[1]);
expect_payment_claimable!(nodes[1], payment_hash_1, payment_secret_1, 100000);
check_added_monitors!(nodes[1], 1);
check_added_monitors!(nodes[0], 1);
let send_event = SendEvent::from_event(nodes[0].node.get_and_clear_pending_msg_events().remove(0));
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &send_event.commitment_msg);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &send_event.commitment_msg);
check_added_monitors!(nodes[1], 1);
let (bs_raa, bs_cs) = get_revoke_commit_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_raa);
check_added_monitors!(nodes[0], 1);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_cs);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_cs);
check_added_monitors!(nodes[0], 1);
as_raa = Some(get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id()));
// Check that the message we're about to deliver matches the one generated:
assert_eq!(fulfill_msg, cs_updates.update_fulfill_htlcs[0]);
}
- nodes[1].node.handle_update_fulfill_htlc(&nodes[2].node.get_our_node_id(), &fulfill_msg);
+ nodes[1].node.handle_update_fulfill_htlc(nodes[2].node.get_our_node_id(), &fulfill_msg);
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], Some(1000), false, false);
check_added_monitors!(nodes[1], 1);
if htlc_status != HTLCStatusAtDupClaim::HoldingCell {
bs_updates = Some(get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id()));
assert_eq!(bs_updates.as_ref().unwrap().update_fulfill_htlcs.len(), 1);
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &bs_updates.as_ref().unwrap().update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &bs_updates.as_ref().unwrap().update_fulfill_htlcs[0]);
expect_payment_sent(&nodes[0], payment_preimage, None, false, false);
if htlc_status == HTLCStatusAtDupClaim::Cleared {
commitment_signed_dance!(nodes[0], nodes[1], &bs_updates.as_ref().unwrap().commitment_signed, false);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
}
- nodes[1].node.peer_disconnected(&nodes[2].node.get_our_node_id());
- nodes[2].node.peer_disconnected(&nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[2].node.get_our_node_id());
+ nodes[2].node.peer_disconnected(nodes[1].node.get_our_node_id());
if second_fails {
let mut reconnect_args = ReconnectArgs::new(&nodes[1], &nodes[2]);
}
if htlc_status == HTLCStatusAtDupClaim::HoldingCell {
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_raa.unwrap());
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_raa.unwrap());
check_added_monitors!(nodes[1], 1);
expect_pending_htlcs_forwardable_ignore!(nodes[1]); // We finally receive the second payment, but don't claim it
bs_updates = Some(get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id()));
assert_eq!(bs_updates.as_ref().unwrap().update_fulfill_htlcs.len(), 1);
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &bs_updates.as_ref().unwrap().update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &bs_updates.as_ref().unwrap().update_fulfill_htlcs[0]);
expect_payment_sent(&nodes[0], payment_preimage, None, false, false);
}
if htlc_status != HTLCStatusAtDupClaim::Cleared {
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(), &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(), &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(), &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(), &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());
let (outpoint, latest_update, _) = nodes[0].chain_monitor.latest_monitor_update_id.lock().unwrap().get(&channel_id).unwrap().clone();
nodes[0].chain_monitor.chain_monitor.force_channel_monitor_updated(outpoint, latest_update);
- nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &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(), &get_event_msg!(nodes[0], MessageSendEvent::SendClosingSigned, nodes[1].node.get_our_node_id()));
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
let (outpoint, latest_update, _) = nodes[1].chain_monitor.latest_monitor_update_id.lock().unwrap().get(&channel_id).unwrap().clone();
nodes[1].chain_monitor.chain_monitor.force_channel_monitor_updated(outpoint, latest_update);
- nodes[0].node.handle_closing_signed(&nodes[1].node.get_our_node_id(), &get_event_msg!(nodes[1], MessageSendEvent::SendClosingSigned, nodes[0].node.get_our_node_id()));
+ nodes[0].node.handle_closing_signed(nodes[1].node.get_our_node_id(), &get_event_msg!(nodes[1], MessageSendEvent::SendClosingSigned, nodes[0].node.get_our_node_id()));
let (_, closing_signed_a) = get_closing_signed_broadcast!(nodes[0].node, nodes[1].node.get_our_node_id());
let txn_a = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0);
- nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &closing_signed_a.unwrap());
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &closing_signed_a.unwrap());
let (_, none_b) = get_closing_signed_broadcast!(nodes[1].node, nodes[0].node.get_our_node_id());
assert!(none_b.is_none());
let txn_b = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0);
}
};
assert_eq!(node_id, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &update_fulfill_1);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &update_fulfill_1);
check_added_monitors!(nodes[0], 0);
expect_payment_sent(&nodes[0], payment_preimage_1, None, false, false);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &commitment_signed_b1);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &commitment_signed_b1);
check_added_monitors!(nodes[0], 1);
nodes[0].node.process_pending_htlc_forwards();
let (raa_a1, commitment_signed_a1) = get_revoke_commit_msgs!(nodes[0], nodes[1].node.get_our_node_id());
check_added_monitors!(nodes[1], 0);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &raa_a1);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &raa_a1);
check_added_monitors!(nodes[1], 1);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &commitment_signed_a1);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &commitment_signed_a1);
check_added_monitors!(nodes[1], 1);
// Complete the second HTLC.
_ => panic!("Unexpected event"),
})
};
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &raa_b2);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &raa_b2);
check_added_monitors!(nodes[0], 1);
expect_payment_path_successful!(nodes[0]);
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &update_fulfill_2);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &update_fulfill_2);
check_added_monitors!(nodes[0], 0);
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
commitment_signed_dance!(nodes[0], nodes[1], commitment_signed_b2, false);
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, None).unwrap();
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &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(), &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);
_ => panic!("Unexpected event"),
};
- nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), &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(), &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);
check_added_monitors!(nodes[0], 0);
let funding_created_msg = get_event_msg!(nodes[0], MessageSendEvent::SendFundingCreated, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &funding_created_msg);
+ nodes[1].node.handle_funding_created(nodes[0].node.get_our_node_id(), &funding_created_msg);
check_added_monitors!(nodes[1], 1);
expect_channel_pending_event(&nodes[1], &nodes[0].node.get_our_node_id());
MessageSendEvent::SendFundingSigned { msg, .. } => {
chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
- nodes[0].node.handle_funding_signed(&nodes[1].node.get_our_node_id(), &msg);
+ nodes[0].node.handle_funding_signed(nodes[1].node.get_our_node_id(), &msg);
check_added_monitors!(nodes[0], 1);
}
_ => panic!("Unexpected event"),
if use_0conf {
match &bs_signed_locked[1] {
MessageSendEvent::SendChannelReady { msg, .. } => {
- nodes[0].node.handle_channel_ready(&nodes[1].node.get_our_node_id(), &msg);
+ nodes[0].node.handle_channel_ready(nodes[1].node.get_our_node_id(), &msg);
}
_ => panic!("Unexpected event"),
}
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, None).unwrap();
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &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(), &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);
_ => panic!("Unexpected event"),
};
- nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), &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(), &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);
let funding_created_msg = get_event_msg!(nodes[0], MessageSendEvent::SendFundingCreated, nodes[1].node.get_our_node_id());
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
- nodes[1].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &funding_created_msg);
+ nodes[1].node.handle_funding_created(nodes[0].node.get_our_node_id(), &funding_created_msg);
check_added_monitors!(nodes[1], 1);
// nodes[1] happily sends its funding_signed even though its awaiting the persistence of the
// transaction is confirmed.
let funding_signed_msg = get_event_msg!(nodes[1], MessageSendEvent::SendFundingSigned, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_funding_signed(&nodes[1].node.get_our_node_id(), &funding_signed_msg);
+ nodes[0].node.handle_funding_signed(nodes[1].node.get_our_node_id(), &funding_signed_msg);
check_added_monitors!(nodes[0], 1);
expect_channel_pending_event(&nodes[0], &nodes[1].node.get_our_node_id());
}
if use_0conf || lock_commitment {
let as_ready = get_event_msg!(nodes[0], MessageSendEvent::SendChannelReady, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_channel_ready(&nodes[0].node.get_our_node_id(), &as_ready);
+ nodes[1].node.handle_channel_ready(nodes[0].node.get_our_node_id(), &as_ready);
}
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
expect_payment_claimed!(nodes[2], payment_hash_1, 1_000_000);
let cs_htlc_fulfill_updates = get_htlc_update_msgs!(nodes[2], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_update_fulfill_htlc(&nodes[2].node.get_our_node_id(), &cs_htlc_fulfill_updates.update_fulfill_htlcs[0]);
+ nodes[1].node.handle_update_fulfill_htlc(nodes[2].node.get_our_node_id(), &cs_htlc_fulfill_updates.update_fulfill_htlcs[0]);
do_commitment_signed_dance(&nodes[1], &nodes[2], &cs_htlc_fulfill_updates.commitment_signed, false, false);
check_added_monitors(&nodes[1], 0);
expect_payment_claimed!(nodes[0], payment_hash_2, 1_000_000);
let as_htlc_fulfill_updates = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_update_fulfill_htlc(&nodes[0].node.get_our_node_id(), &as_htlc_fulfill_updates.update_fulfill_htlcs[0]);
+ nodes[1].node.handle_update_fulfill_htlc(nodes[0].node.get_our_node_id(), &as_htlc_fulfill_updates.update_fulfill_htlcs[0]);
check_added_monitors(&nodes[1], 1); // We generate only a preimage monitor update
assert!(get_monitor!(nodes[1], chan_id_2).get_stored_preimages().contains_key(&payment_hash_2));
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
// Finish the CS dance between nodes[0] and nodes[1]. Note that until the event handling, the
// update_fulfill_htlc + CS is held, even though the preimage is already on disk for the
// channel.
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_htlc_fulfill_updates.commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_htlc_fulfill_updates.commitment_signed);
check_added_monitors(&nodes[1], 1);
let (a, raa) = do_main_commitment_signed_dance(&nodes[1], &nodes[0], false);
assert!(a.is_none());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &raa);
check_added_monitors(&nodes[1], 0);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
let bs_htlc_fulfill_updates = get_htlc_update_msgs!(nodes[1], nodes[2].node.get_our_node_id());
check_added_monitors(&nodes[1], 1);
- nodes[2].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &bs_htlc_fulfill_updates.update_fulfill_htlcs[0]);
+ nodes[2].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &bs_htlc_fulfill_updates.update_fulfill_htlcs[0]);
do_commitment_signed_dance(&nodes[2], &nodes[1], &bs_htlc_fulfill_updates.commitment_signed, false, false);
expect_payment_sent(&nodes[2], payment_preimage_2, None, true, true);
}
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
let cs_updates = get_htlc_update_msgs(&nodes[2], &nodes[1].node.get_our_node_id());
- nodes[1].node.handle_update_fulfill_htlc(&nodes[2].node.get_our_node_id(), &cs_updates.update_fulfill_htlcs[0]);
+ nodes[1].node.handle_update_fulfill_htlc(nodes[2].node.get_our_node_id(), &cs_updates.update_fulfill_htlcs[0]);
// B generates a new monitor update for the A <-> B channel, but doesn't send the new messages
// for it since the monitor update is marked in-progress.
// Now step the Commitment Signed Dance between B and C forward a bit (or fully), ensuring we
// won't get the preimage when the nodes reconnect and we have to get it from the
// ChannelMonitor.
- nodes[1].node.handle_commitment_signed(&nodes[2].node.get_our_node_id(), &cs_updates.commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[2].node.get_our_node_id(), &cs_updates.commitment_signed);
check_added_monitors(&nodes[1], 1);
if complete_bc_commitment_dance {
let (bs_revoke_and_ack, bs_commitment_signed) = get_revoke_commit_msgs!(nodes[1], nodes[2].node.get_our_node_id());
- nodes[2].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_revoke_and_ack);
+ nodes[2].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_revoke_and_ack);
check_added_monitors(&nodes[2], 1);
- nodes[2].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_commitment_signed);
+ nodes[2].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_commitment_signed);
check_added_monitors(&nodes[2], 1);
let cs_raa = get_event_msg!(nodes[2], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
// At this point node B still hasn't persisted the `ChannelMonitorUpdate` with the
// preimage in the A <-> B channel, which will prevent it from persisting the
// `ChannelMonitorUpdate` for the B<->C channel here to avoid "losing" the preimage.
- nodes[1].node.handle_revoke_and_ack(&nodes[2].node.get_our_node_id(), &cs_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[2].node.get_our_node_id(), &cs_raa);
check_added_monitors(&nodes[1], 0);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
}
let mon_bc = get_monitor!(nodes[1], chan_id_bc).encode();
reload_node!(nodes[1], &manager_b, &[&mon_ab, &mon_bc], persister, new_chain_monitor, nodes_1_deserialized);
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[2].node.peer_disconnected(&nodes[1].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[2].node.peer_disconnected(nodes[1].node.get_our_node_id());
if with_latest_manager {
// If we used the latest ChannelManager to reload from, we should have both channels still
let bs_updates = get_htlc_update_msgs(&nodes[1], &nodes[0].node.get_our_node_id());
check_added_monitors(&nodes[1], 1);
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &bs_updates.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &bs_updates.update_fulfill_htlcs[0]);
do_commitment_signed_dance(&nodes[0], &nodes[1], &bs_updates.commitment_signed, false, false);
expect_payment_forwarded!(nodes[1], &nodes[0], &nodes[2], Some(1_000), false, !with_latest_manager);
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
let cs_updates = get_htlc_update_msgs(&nodes[2], &nodes[1].node.get_our_node_id());
- nodes[1].node.handle_update_fulfill_htlc(&nodes[2].node.get_our_node_id(), &cs_updates.update_fulfill_htlcs[0]);
+ nodes[1].node.handle_update_fulfill_htlc(nodes[2].node.get_our_node_id(), &cs_updates.update_fulfill_htlcs[0]);
// B generates a new monitor update for the A <-> B channel, but doesn't send the new messages
// for it since the monitor update is marked in-progress.
// Now step the Commitment Signed Dance between B and C forward a bit, ensuring we won't get
// the preimage when the nodes reconnect, at which point we have to ensure we get it from the
// ChannelMonitor.
- nodes[1].node.handle_commitment_signed(&nodes[2].node.get_our_node_id(), &cs_updates.commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[2].node.get_our_node_id(), &cs_updates.commitment_signed);
check_added_monitors(&nodes[1], 1);
let _ = get_revoke_commit_msgs!(nodes[1], nodes[2].node.get_our_node_id());
let manager_b = nodes[1].node.encode();
reload_node!(nodes[1], &manager_b, &[&mon_ab, &mon_bc], persister, new_chain_monitor, nodes_1_deserialized);
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[2].node.peer_disconnected(&nodes[1].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[2].node.peer_disconnected(nodes[1].node.get_our_node_id());
if close_chans_before_reload {
// If the channels were already closed, B will rebroadcast its closing transactions here.
expect_payment_claimed!(nodes[1], payment_hash_1, 1_000_000);
let bs_updates = get_htlc_update_msgs(&nodes[1], &nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &bs_updates.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &bs_updates.update_fulfill_htlcs[0]);
expect_payment_sent(&nodes[0], payment_preimage_1, None, false, false);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_updates.commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_updates.commitment_signed);
check_added_monitors(&nodes[0], 1);
let (as_raa, as_cs) = get_revoke_commit_msgs!(nodes[0], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_raa);
check_added_monitors(&nodes[1], 1);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_cs);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_cs);
check_added_monitors(&nodes[1], 1);
let bs_final_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_final_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_final_raa);
check_added_monitors(&nodes[0], 1);
// Immediately complete the monitor update, but before the ChannelManager has a chance to see
expect_payment_claimed!(nodes[1], payment_hash_2, 1_000_000);
let bs_updates = get_htlc_update_msgs(&nodes[1], &nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &bs_updates.update_fulfill_htlcs[0]);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_updates.commitment_signed);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &bs_updates.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_updates.commitment_signed);
check_added_monitors(&nodes[0], 1);
// At this point, we have completed an extra `ChannelMonitorUpdate` but the `ChannelManager`
} else { panic!(); }
// Finally, complete the claiming of the second payment
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_raa);
check_added_monitors(&nodes[1], 1);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_cs);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_cs);
check_added_monitors(&nodes[1], 1);
let bs_final_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_final_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_final_raa);
check_added_monitors(&nodes[0], 1);
expect_payment_path_successful!(nodes[0]);
}
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
let cs_updates = get_htlc_update_msgs(&nodes[2], &nodes[1].node.get_our_node_id());
- nodes[1].node.handle_update_fulfill_htlc(&nodes[2].node.get_our_node_id(), &cs_updates.update_fulfill_htlcs[0]);
+ nodes[1].node.handle_update_fulfill_htlc(nodes[2].node.get_our_node_id(), &cs_updates.update_fulfill_htlcs[0]);
// B generates a new monitor update for the A <-> B channel, but doesn't send the new messages
// for it since the monitor update is marked in-progress.
// Now step the Commitment Signed Dance between B and C and check that after the final RAA B
// doesn't let the preimage-removing monitor update fly.
- nodes[1].node.handle_commitment_signed(&nodes[2].node.get_our_node_id(), &cs_updates.commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[2].node.get_our_node_id(), &cs_updates.commitment_signed);
check_added_monitors(&nodes[1], 1);
let (bs_raa, bs_cs) = get_revoke_commit_msgs!(nodes[1], nodes[2].node.get_our_node_id());
- nodes[2].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_raa);
+ nodes[2].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_raa);
check_added_monitors(&nodes[2], 1);
- nodes[2].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_cs);
+ nodes[2].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_cs);
check_added_monitors(&nodes[2], 1);
let cs_final_raa = get_event_msg!(nodes[2], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[2].node.get_our_node_id(), &cs_final_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[2].node.get_our_node_id(), &cs_final_raa);
check_added_monitors(&nodes[1], 0);
// Finally, reload node B and check that after we call `process_pending_events` once we realize
// Finally, check that there's nothing left to do on B<->C reconnect and the channel operates
// fine.
- nodes[2].node.peer_disconnected(&nodes[1].node.get_our_node_id());
+ nodes[2].node.peer_disconnected(nodes[1].node.get_our_node_id());
reconnect_nodes(ReconnectArgs::new(&nodes[1], &nodes[2]));
send_payment(&nodes[1], &[&nodes[2]], 100_000);
}
// The first update will be on the A <-> B channel, which we allow to complete.
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
}
- nodes[1].node.handle_update_fulfill_htlc(&nodes[2].node.get_our_node_id(), &cs_updates.update_fulfill_htlcs[0]);
+ nodes[1].node.handle_update_fulfill_htlc(nodes[2].node.get_our_node_id(), &cs_updates.update_fulfill_htlcs[0]);
check_added_monitors(&nodes[1], 1);
if !hold_chan_a {
let bs_updates = get_htlc_update_msgs(&nodes[1], &nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &bs_updates.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &bs_updates.update_fulfill_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], bs_updates.commitment_signed, false);
expect_payment_sent!(&nodes[0], payment_preimage);
}
- nodes[1].node.peer_disconnected(&nodes[2].node.get_our_node_id());
- nodes[2].node.peer_disconnected(&nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[2].node.get_our_node_id());
+ nodes[2].node.peer_disconnected(nodes[1].node.get_our_node_id());
let mut reconnect = ReconnectArgs::new(&nodes[1], &nodes[2]);
reconnect.pending_htlc_claims = (1, 0);
expect_payment_claimed!(&nodes[3], payment_hash, 200_000);
let updates = get_htlc_update_msgs(&nodes[3], &nodes[1].node.get_our_node_id());
- nodes[1].node.handle_update_fulfill_htlc(&nodes[3].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
+ nodes[1].node.handle_update_fulfill_htlc(nodes[3].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
check_added_monitors(&nodes[1], 1);
expect_payment_forwarded!(nodes[1], nodes[0], nodes[3], Some(1000), false, false);
let _bs_updates_for_a = get_htlc_update_msgs(&nodes[1], &nodes[0].node.get_our_node_id());
- nodes[1].node.handle_commitment_signed(&nodes[3].node.get_our_node_id(), &updates.commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[3].node.get_our_node_id(), &updates.commitment_signed);
check_added_monitors(&nodes[1], 1);
let (bs_raa, bs_cs) = get_revoke_commit_msgs(&nodes[1], &nodes[3].node.get_our_node_id());
- nodes[3].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_raa);
+ nodes[3].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_raa);
check_added_monitors(&nodes[3], 0);
- nodes[3].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_cs);
+ nodes[3].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_cs);
check_added_monitors(&nodes[3], 0);
assert!(nodes[3].node.get_and_clear_pending_msg_events().is_empty());
match remove_first_msg_event_to_node(&nodes[1].node.get_our_node_id(), &mut ds_msgs) {
MessageSendEvent::SendRevokeAndACK { msg, .. } => {
- nodes[1].node.handle_revoke_and_ack(&nodes[3].node.get_our_node_id(), &msg);
+ nodes[1].node.handle_revoke_and_ack(nodes[3].node.get_our_node_id(), &msg);
check_added_monitors(&nodes[1], 1);
}
_ => panic!(),
match remove_first_msg_event_to_node(&nodes[2].node.get_our_node_id(), &mut ds_msgs) {
MessageSendEvent::UpdateHTLCs { updates, .. } => {
- nodes[2].node.handle_update_fulfill_htlc(&nodes[3].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
+ nodes[2].node.handle_update_fulfill_htlc(nodes[3].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
check_added_monitors(&nodes[2], 1);
expect_payment_forwarded!(nodes[2], nodes[0], nodes[3], Some(1000), false, false);
let _cs_updates_for_a = get_htlc_update_msgs(&nodes[2], &nodes[0].node.get_our_node_id());
- nodes[2].node.handle_commitment_signed(&nodes[3].node.get_our_node_id(), &updates.commitment_signed);
+ nodes[2].node.handle_commitment_signed(nodes[3].node.get_our_node_id(), &updates.commitment_signed);
check_added_monitors(&nodes[2], 1);
},
_ => panic!(),
let (cs_raa, cs_cs) = get_revoke_commit_msgs(&nodes[2], &nodes[3].node.get_our_node_id());
- nodes[3].node.handle_revoke_and_ack(&nodes[2].node.get_our_node_id(), &cs_raa);
+ nodes[3].node.handle_revoke_and_ack(nodes[2].node.get_our_node_id(), &cs_raa);
check_added_monitors(&nodes[3], 1);
- nodes[3].node.handle_commitment_signed(&nodes[2].node.get_our_node_id(), &cs_cs);
+ nodes[3].node.handle_commitment_signed(nodes[2].node.get_our_node_id(), &cs_cs);
check_added_monitors(&nodes[3], 1);
let ds_raa = get_event_msg!(nodes[3], MessageSendEvent::SendRevokeAndACK, nodes[2].node.get_our_node_id());
- nodes[2].node.handle_revoke_and_ack(&nodes[3].node.get_our_node_id(), &ds_raa);
+ nodes[2].node.handle_revoke_and_ack(nodes[3].node.get_our_node_id(), &ds_raa);
check_added_monitors(&nodes[2], 1);
// Our current `ChannelMonitor`s store preimages one RAA longer than they need to. That's nice
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
log_debug!(self.logger,
"Force-closing channel, The error message sent to the peer : {}", error_message);
- match self.force_close_channel_with_peer(channel_id, counterparty_node_id, None, broadcast) {
+ match self.force_close_channel_with_peer(channel_id, &counterparty_node_id, None, broadcast) {
Ok(counterparty_node_id) => {
let per_peer_state = self.per_peer_state.read().unwrap();
if let Some(peer_state_mutex) = per_peer_state.get(&counterparty_node_id) {
R::Target: Router,
L::Target: Logger,
{
- fn handle_open_channel(&self, counterparty_node_id: &PublicKey, msg: &msgs::OpenChannel) {
+ fn handle_open_channel(&self, counterparty_node_id: PublicKey, msg: &msgs::OpenChannel) {
// Note that we never need to persist the updated ChannelManager for an inbound
// open_channel message - pre-funded channels are never written so there should be no
// change to the contents.
let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
- let res = self.internal_open_channel(counterparty_node_id, msg);
+ let res = self.internal_open_channel(&counterparty_node_id, msg);
let persist = match &res {
Err(e) if e.closes_channel() => {
debug_assert!(false, "We shouldn't close a new channel");
},
_ => NotifyOption::SkipPersistHandleEvents,
};
- let _ = handle_error!(self, res, *counterparty_node_id);
+ let _ = handle_error!(self, res, counterparty_node_id);
persist
});
}
- fn handle_open_channel_v2(&self, counterparty_node_id: &PublicKey, msg: &msgs::OpenChannelV2) {
+ fn handle_open_channel_v2(&self, counterparty_node_id: PublicKey, msg: &msgs::OpenChannelV2) {
let _: Result<(), _> = handle_error!(self, Err(MsgHandleErrInternal::send_err_msg_no_close(
"Dual-funded channels not supported".to_owned(),
- msg.common_fields.temporary_channel_id.clone())), *counterparty_node_id);
+ msg.common_fields.temporary_channel_id.clone())), counterparty_node_id);
}
- fn handle_accept_channel(&self, counterparty_node_id: &PublicKey, msg: &msgs::AcceptChannel) {
+ fn handle_accept_channel(&self, counterparty_node_id: PublicKey, msg: &msgs::AcceptChannel) {
// Note that we never need to persist the updated ChannelManager for an inbound
// accept_channel message - pre-funded channels are never written so there should be no
// change to the contents.
let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
- let _ = handle_error!(self, self.internal_accept_channel(counterparty_node_id, msg), *counterparty_node_id);
+ let _ = handle_error!(self, self.internal_accept_channel(&counterparty_node_id, msg), counterparty_node_id);
NotifyOption::SkipPersistHandleEvents
});
}
- fn handle_accept_channel_v2(&self, counterparty_node_id: &PublicKey, msg: &msgs::AcceptChannelV2) {
+ fn handle_accept_channel_v2(&self, counterparty_node_id: PublicKey, msg: &msgs::AcceptChannelV2) {
let _: Result<(), _> = handle_error!(self, Err(MsgHandleErrInternal::send_err_msg_no_close(
"Dual-funded channels not supported".to_owned(),
- msg.common_fields.temporary_channel_id.clone())), *counterparty_node_id);
+ msg.common_fields.temporary_channel_id.clone())), counterparty_node_id);
}
- fn handle_funding_created(&self, counterparty_node_id: &PublicKey, msg: &msgs::FundingCreated) {
+ fn handle_funding_created(&self, counterparty_node_id: PublicKey, msg: &msgs::FundingCreated) {
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
- let _ = handle_error!(self, self.internal_funding_created(counterparty_node_id, msg), *counterparty_node_id);
+ let _ = handle_error!(self, self.internal_funding_created(&counterparty_node_id, msg), counterparty_node_id);
}
- fn handle_funding_signed(&self, counterparty_node_id: &PublicKey, msg: &msgs::FundingSigned) {
+ fn handle_funding_signed(&self, counterparty_node_id: PublicKey, msg: &msgs::FundingSigned) {
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
- let _ = handle_error!(self, self.internal_funding_signed(counterparty_node_id, msg), *counterparty_node_id);
+ let _ = handle_error!(self, self.internal_funding_signed(&counterparty_node_id, msg), counterparty_node_id);
}
- fn handle_channel_ready(&self, counterparty_node_id: &PublicKey, msg: &msgs::ChannelReady) {
+ fn handle_channel_ready(&self, counterparty_node_id: PublicKey, msg: &msgs::ChannelReady) {
// Note that we never need to persist the updated ChannelManager for an inbound
// channel_ready message - while the channel's state will change, any channel_ready message
// will ultimately be re-sent on startup and the `ChannelMonitor` won't be updated so we
// will not force-close the channel on startup.
let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
- let res = self.internal_channel_ready(counterparty_node_id, msg);
+ let res = self.internal_channel_ready(&counterparty_node_id, msg);
let persist = match &res {
Err(e) if e.closes_channel() => NotifyOption::DoPersist,
_ => NotifyOption::SkipPersistHandleEvents,
};
- let _ = handle_error!(self, res, *counterparty_node_id);
+ let _ = handle_error!(self, res, counterparty_node_id);
persist
});
}
- fn handle_stfu(&self, counterparty_node_id: &PublicKey, msg: &msgs::Stfu) {
+ fn handle_stfu(&self, counterparty_node_id: PublicKey, msg: &msgs::Stfu) {
let _: Result<(), _> = handle_error!(self, Err(MsgHandleErrInternal::send_err_msg_no_close(
"Quiescence not supported".to_owned(),
- msg.channel_id.clone())), *counterparty_node_id);
+ msg.channel_id.clone())), counterparty_node_id);
}
#[cfg(splicing)]
- fn handle_splice_init(&self, counterparty_node_id: &PublicKey, msg: &msgs::SpliceInit) {
+ fn handle_splice_init(&self, counterparty_node_id: PublicKey, msg: &msgs::SpliceInit) {
let _: Result<(), _> = handle_error!(self, Err(MsgHandleErrInternal::send_err_msg_no_close(
"Splicing not supported".to_owned(),
- msg.channel_id.clone())), *counterparty_node_id);
+ msg.channel_id.clone())), counterparty_node_id);
}
#[cfg(splicing)]
- fn handle_splice_ack(&self, counterparty_node_id: &PublicKey, msg: &msgs::SpliceAck) {
+ fn handle_splice_ack(&self, counterparty_node_id: PublicKey, msg: &msgs::SpliceAck) {
let _: Result<(), _> = handle_error!(self, Err(MsgHandleErrInternal::send_err_msg_no_close(
"Splicing not supported (splice_ack)".to_owned(),
- msg.channel_id.clone())), *counterparty_node_id);
+ msg.channel_id.clone())), counterparty_node_id);
}
#[cfg(splicing)]
- fn handle_splice_locked(&self, counterparty_node_id: &PublicKey, msg: &msgs::SpliceLocked) {
+ fn handle_splice_locked(&self, counterparty_node_id: PublicKey, msg: &msgs::SpliceLocked) {
let _: Result<(), _> = handle_error!(self, Err(MsgHandleErrInternal::send_err_msg_no_close(
"Splicing not supported (splice_locked)".to_owned(),
- msg.channel_id.clone())), *counterparty_node_id);
+ msg.channel_id.clone())), counterparty_node_id);
}
- fn handle_shutdown(&self, counterparty_node_id: &PublicKey, msg: &msgs::Shutdown) {
+ fn handle_shutdown(&self, counterparty_node_id: PublicKey, msg: &msgs::Shutdown) {
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
- let _ = handle_error!(self, self.internal_shutdown(counterparty_node_id, msg), *counterparty_node_id);
+ let _ = handle_error!(self, self.internal_shutdown(&counterparty_node_id, msg), counterparty_node_id);
}
- fn handle_closing_signed(&self, counterparty_node_id: &PublicKey, msg: &msgs::ClosingSigned) {
+ fn handle_closing_signed(&self, counterparty_node_id: PublicKey, msg: &msgs::ClosingSigned) {
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
- let _ = handle_error!(self, self.internal_closing_signed(counterparty_node_id, msg), *counterparty_node_id);
+ let _ = handle_error!(self, self.internal_closing_signed(&counterparty_node_id, msg), counterparty_node_id);
}
- fn handle_update_add_htlc(&self, counterparty_node_id: &PublicKey, msg: &msgs::UpdateAddHTLC) {
+ fn handle_update_add_htlc(&self, counterparty_node_id: PublicKey, msg: &msgs::UpdateAddHTLC) {
// Note that we never need to persist the updated ChannelManager for an inbound
// update_add_htlc message - the message itself doesn't change our channel state only the
// `commitment_signed` message afterwards will.
let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
- let res = self.internal_update_add_htlc(counterparty_node_id, msg);
+ let res = self.internal_update_add_htlc(&counterparty_node_id, msg);
let persist = match &res {
Err(e) if e.closes_channel() => NotifyOption::DoPersist,
Err(_) => NotifyOption::SkipPersistHandleEvents,
Ok(()) => NotifyOption::SkipPersistNoEvents,
};
- let _ = handle_error!(self, res, *counterparty_node_id);
+ let _ = handle_error!(self, res, counterparty_node_id);
persist
});
}
- fn handle_update_fulfill_htlc(&self, counterparty_node_id: &PublicKey, msg: &msgs::UpdateFulfillHTLC) {
+ fn handle_update_fulfill_htlc(&self, counterparty_node_id: PublicKey, msg: &msgs::UpdateFulfillHTLC) {
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
- let _ = handle_error!(self, self.internal_update_fulfill_htlc(counterparty_node_id, msg), *counterparty_node_id);
+ let _ = handle_error!(self, self.internal_update_fulfill_htlc(&counterparty_node_id, msg), counterparty_node_id);
}
- fn handle_update_fail_htlc(&self, counterparty_node_id: &PublicKey, msg: &msgs::UpdateFailHTLC) {
+ fn handle_update_fail_htlc(&self, counterparty_node_id: PublicKey, msg: &msgs::UpdateFailHTLC) {
// Note that we never need to persist the updated ChannelManager for an inbound
// update_fail_htlc message - the message itself doesn't change our channel state only the
// `commitment_signed` message afterwards will.
let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
- let res = self.internal_update_fail_htlc(counterparty_node_id, msg);
+ let res = self.internal_update_fail_htlc(&counterparty_node_id, msg);
let persist = match &res {
Err(e) if e.closes_channel() => NotifyOption::DoPersist,
Err(_) => NotifyOption::SkipPersistHandleEvents,
Ok(()) => NotifyOption::SkipPersistNoEvents,
};
- let _ = handle_error!(self, res, *counterparty_node_id);
+ let _ = handle_error!(self, res, counterparty_node_id);
persist
});
}
- fn handle_update_fail_malformed_htlc(&self, counterparty_node_id: &PublicKey, msg: &msgs::UpdateFailMalformedHTLC) {
+ fn handle_update_fail_malformed_htlc(&self, counterparty_node_id: PublicKey, msg: &msgs::UpdateFailMalformedHTLC) {
// Note that we never need to persist the updated ChannelManager for an inbound
// update_fail_malformed_htlc message - the message itself doesn't change our channel state
// only the `commitment_signed` message afterwards will.
let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
- let res = self.internal_update_fail_malformed_htlc(counterparty_node_id, msg);
+ let res = self.internal_update_fail_malformed_htlc(&counterparty_node_id, msg);
let persist = match &res {
Err(e) if e.closes_channel() => NotifyOption::DoPersist,
Err(_) => NotifyOption::SkipPersistHandleEvents,
Ok(()) => NotifyOption::SkipPersistNoEvents,
};
- let _ = handle_error!(self, res, *counterparty_node_id);
+ let _ = handle_error!(self, res, counterparty_node_id);
persist
});
}
- fn handle_commitment_signed(&self, counterparty_node_id: &PublicKey, msg: &msgs::CommitmentSigned) {
+ fn handle_commitment_signed(&self, counterparty_node_id: PublicKey, msg: &msgs::CommitmentSigned) {
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
- let _ = handle_error!(self, self.internal_commitment_signed(counterparty_node_id, msg), *counterparty_node_id);
+ let _ = handle_error!(self, self.internal_commitment_signed(&counterparty_node_id, msg), counterparty_node_id);
}
- fn handle_revoke_and_ack(&self, counterparty_node_id: &PublicKey, msg: &msgs::RevokeAndACK) {
+ fn handle_revoke_and_ack(&self, counterparty_node_id: PublicKey, msg: &msgs::RevokeAndACK) {
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
- let _ = handle_error!(self, self.internal_revoke_and_ack(counterparty_node_id, msg), *counterparty_node_id);
+ let _ = handle_error!(self, self.internal_revoke_and_ack(&counterparty_node_id, msg), counterparty_node_id);
}
- fn handle_update_fee(&self, counterparty_node_id: &PublicKey, msg: &msgs::UpdateFee) {
+ fn handle_update_fee(&self, counterparty_node_id: PublicKey, msg: &msgs::UpdateFee) {
// Note that we never need to persist the updated ChannelManager for an inbound
// update_fee message - the message itself doesn't change our channel state only the
// `commitment_signed` message afterwards will.
let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
- let res = self.internal_update_fee(counterparty_node_id, msg);
+ let res = self.internal_update_fee(&counterparty_node_id, msg);
let persist = match &res {
Err(e) if e.closes_channel() => NotifyOption::DoPersist,
Err(_) => NotifyOption::SkipPersistHandleEvents,
Ok(()) => NotifyOption::SkipPersistNoEvents,
};
- let _ = handle_error!(self, res, *counterparty_node_id);
+ let _ = handle_error!(self, res, counterparty_node_id);
persist
});
}
- fn handle_announcement_signatures(&self, counterparty_node_id: &PublicKey, msg: &msgs::AnnouncementSignatures) {
+ fn handle_announcement_signatures(&self, counterparty_node_id: PublicKey, msg: &msgs::AnnouncementSignatures) {
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
- let _ = handle_error!(self, self.internal_announcement_signatures(counterparty_node_id, msg), *counterparty_node_id);
+ let _ = handle_error!(self, self.internal_announcement_signatures(&counterparty_node_id, msg), counterparty_node_id);
}
- fn handle_channel_update(&self, counterparty_node_id: &PublicKey, msg: &msgs::ChannelUpdate) {
+ fn handle_channel_update(&self, counterparty_node_id: PublicKey, msg: &msgs::ChannelUpdate) {
PersistenceNotifierGuard::optionally_notify(self, || {
- if let Ok(persist) = handle_error!(self, self.internal_channel_update(counterparty_node_id, msg), *counterparty_node_id) {
+ if let Ok(persist) = handle_error!(self, self.internal_channel_update(&counterparty_node_id, msg), counterparty_node_id) {
persist
} else {
NotifyOption::DoPersist
});
}
- fn handle_channel_reestablish(&self, counterparty_node_id: &PublicKey, msg: &msgs::ChannelReestablish) {
+ fn handle_channel_reestablish(&self, counterparty_node_id: PublicKey, msg: &msgs::ChannelReestablish) {
let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
- let res = self.internal_channel_reestablish(counterparty_node_id, msg);
+ let res = self.internal_channel_reestablish(&counterparty_node_id, msg);
let persist = match &res {
Err(e) if e.closes_channel() => NotifyOption::DoPersist,
Err(_) => NotifyOption::SkipPersistHandleEvents,
Ok(persist) => *persist,
};
- let _ = handle_error!(self, res, *counterparty_node_id);
+ let _ = handle_error!(self, res, counterparty_node_id);
persist
});
}
- fn peer_disconnected(&self, counterparty_node_id: &PublicKey) {
+ fn peer_disconnected(&self, counterparty_node_id: PublicKey) {
let _persistence_guard = PersistenceNotifierGuard::optionally_notify(
self, || NotifyOption::SkipPersistHandleEvents);
let mut failed_channels = Vec::new();
let mut per_peer_state = self.per_peer_state.write().unwrap();
let remove_peer = {
log_debug!(
- WithContext::from(&self.logger, Some(*counterparty_node_id), None, None),
+ WithContext::from(&self.logger, Some(counterparty_node_id), None, None),
"Marking channels with {} disconnected and generating channel_updates.",
log_pubkey!(counterparty_node_id)
);
- if let Some(peer_state_mutex) = per_peer_state.get(counterparty_node_id) {
+ if let Some(peer_state_mutex) = per_peer_state.get(&counterparty_node_id) {
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
let peer_state = &mut *peer_state_lock;
let pending_msg_events = &mut peer_state.pending_msg_events;
} else { debug_assert!(false, "Unconnected peer disconnected"); true }
};
if remove_peer {
- per_peer_state.remove(counterparty_node_id);
+ per_peer_state.remove(&counterparty_node_id);
}
mem::drop(per_peer_state);
}
}
- fn peer_connected(&self, counterparty_node_id: &PublicKey, init_msg: &msgs::Init, inbound: bool) -> Result<(), ()> {
- let logger = WithContext::from(&self.logger, Some(*counterparty_node_id), None, None);
+ fn peer_connected(&self, counterparty_node_id: PublicKey, init_msg: &msgs::Init, inbound: bool) -> Result<(), ()> {
+ let logger = WithContext::from(&self.logger, Some(counterparty_node_id), None, None);
if !init_msg.features.supports_static_remote_key() {
log_debug!(logger, "Peer {} does not support static remote key, disconnecting", log_pubkey!(counterparty_node_id));
return Err(());
log_debug!(logger, "Generating channel_reestablish events for {}", log_pubkey!(counterparty_node_id));
let per_peer_state = self.per_peer_state.read().unwrap();
- if let Some(peer_state_mutex) = per_peer_state.get(counterparty_node_id) {
+ if let Some(peer_state_mutex) = per_peer_state.get(&counterparty_node_id) {
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
let peer_state = &mut *peer_state_lock;
let pending_msg_events = &mut peer_state.pending_msg_events;
res
}
- fn handle_error(&self, counterparty_node_id: &PublicKey, msg: &msgs::ErrorMessage) {
+ fn handle_error(&self, counterparty_node_id: PublicKey, msg: &msgs::ErrorMessage) {
match &msg.data as &str {
"cannot co-op close channel w/ active htlcs"|
"link failed to shutdown" =>
self,
|| -> NotifyOption {
let per_peer_state = self.per_peer_state.read().unwrap();
- let peer_state_mutex_opt = per_peer_state.get(counterparty_node_id);
+ let peer_state_mutex_opt = per_peer_state.get(&counterparty_node_id);
if peer_state_mutex_opt.is_none() { return NotifyOption::SkipPersistNoEvents; }
let mut peer_state = peer_state_mutex_opt.unwrap().lock().unwrap();
if let Some(ChannelPhase::Funded(chan)) = peer_state.channel_by_id.get(&msg.channel_id) {
if let Some(msg) = chan.get_outbound_shutdown() {
peer_state.pending_msg_events.push(events::MessageSendEvent::SendShutdown {
- node_id: *counterparty_node_id,
+ node_id: counterparty_node_id,
msg,
});
}
peer_state.pending_msg_events.push(events::MessageSendEvent::HandleError {
- node_id: *counterparty_node_id,
+ node_id: counterparty_node_id,
action: msgs::ErrorAction::SendWarningMessage {
msg: msgs::WarningMessage {
channel_id: msg.channel_id,
if msg.channel_id.is_zero() {
let channel_ids: Vec<ChannelId> = {
let per_peer_state = self.per_peer_state.read().unwrap();
- let peer_state_mutex_opt = per_peer_state.get(counterparty_node_id);
+ let peer_state_mutex_opt = per_peer_state.get(&counterparty_node_id);
if peer_state_mutex_opt.is_none() { return; }
let mut peer_state_lock = peer_state_mutex_opt.unwrap().lock().unwrap();
let peer_state = &mut *peer_state_lock;
};
for channel_id in channel_ids {
// Untrusted messages from peer, we throw away the error if id points to a non-existent channel
- let _ = self.force_close_channel_with_peer(&channel_id, counterparty_node_id, Some(&msg.data), true);
+ let _ = self.force_close_channel_with_peer(&channel_id, &counterparty_node_id, Some(&msg.data), true);
}
} else {
{
// First check if we can advance the channel type and try again.
let per_peer_state = self.per_peer_state.read().unwrap();
- let peer_state_mutex_opt = per_peer_state.get(counterparty_node_id);
+ let peer_state_mutex_opt = per_peer_state.get(&counterparty_node_id);
if peer_state_mutex_opt.is_none() { return; }
let mut peer_state_lock = peer_state_mutex_opt.unwrap().lock().unwrap();
let peer_state = &mut *peer_state_lock;
Some(ChannelPhase::UnfundedOutboundV1(ref mut chan)) => {
if let Ok(msg) = chan.maybe_handle_error_without_close(self.chain_hash, &self.fee_estimator) {
peer_state.pending_msg_events.push(events::MessageSendEvent::SendOpenChannel {
- node_id: *counterparty_node_id,
+ node_id: counterparty_node_id,
msg,
});
return;
Some(ChannelPhase::UnfundedOutboundV2(ref mut chan)) => {
if let Ok(msg) = chan.maybe_handle_error_without_close(self.chain_hash, &self.fee_estimator) {
peer_state.pending_msg_events.push(events::MessageSendEvent::SendOpenChannelV2 {
- node_id: *counterparty_node_id,
+ node_id: counterparty_node_id,
msg,
});
return;
}
// Untrusted messages from peer, we throw away the error if id points to a non-existent channel
- let _ = self.force_close_channel_with_peer(&msg.channel_id, counterparty_node_id, Some(&msg.data), true);
+ let _ = self.force_close_channel_with_peer(&msg.channel_id, &counterparty_node_id, Some(&msg.data), true);
}
}
provided_node_features(&self.default_configuration)
}
- fn provided_init_features(&self, _their_init_features: &PublicKey) -> InitFeatures {
+ fn provided_init_features(&self, _their_init_features: PublicKey) -> InitFeatures {
provided_init_features(&self.default_configuration)
}
Some(vec![self.chain_hash])
}
- fn handle_tx_add_input(&self, counterparty_node_id: &PublicKey, msg: &msgs::TxAddInput) {
+ fn handle_tx_add_input(&self, counterparty_node_id: PublicKey, msg: &msgs::TxAddInput) {
let _: Result<(), _> = handle_error!(self, Err(MsgHandleErrInternal::send_err_msg_no_close(
"Dual-funded channels not supported".to_owned(),
- msg.channel_id.clone())), *counterparty_node_id);
+ msg.channel_id.clone())), counterparty_node_id);
}
- fn handle_tx_add_output(&self, counterparty_node_id: &PublicKey, msg: &msgs::TxAddOutput) {
+ fn handle_tx_add_output(&self, counterparty_node_id: PublicKey, msg: &msgs::TxAddOutput) {
let _: Result<(), _> = handle_error!(self, Err(MsgHandleErrInternal::send_err_msg_no_close(
"Dual-funded channels not supported".to_owned(),
- msg.channel_id.clone())), *counterparty_node_id);
+ msg.channel_id.clone())), counterparty_node_id);
}
- fn handle_tx_remove_input(&self, counterparty_node_id: &PublicKey, msg: &msgs::TxRemoveInput) {
+ fn handle_tx_remove_input(&self, counterparty_node_id: PublicKey, msg: &msgs::TxRemoveInput) {
let _: Result<(), _> = handle_error!(self, Err(MsgHandleErrInternal::send_err_msg_no_close(
"Dual-funded channels not supported".to_owned(),
- msg.channel_id.clone())), *counterparty_node_id);
+ msg.channel_id.clone())), counterparty_node_id);
}
- fn handle_tx_remove_output(&self, counterparty_node_id: &PublicKey, msg: &msgs::TxRemoveOutput) {
+ fn handle_tx_remove_output(&self, counterparty_node_id: PublicKey, msg: &msgs::TxRemoveOutput) {
let _: Result<(), _> = handle_error!(self, Err(MsgHandleErrInternal::send_err_msg_no_close(
"Dual-funded channels not supported".to_owned(),
- msg.channel_id.clone())), *counterparty_node_id);
+ msg.channel_id.clone())), counterparty_node_id);
}
- fn handle_tx_complete(&self, counterparty_node_id: &PublicKey, msg: &msgs::TxComplete) {
+ fn handle_tx_complete(&self, counterparty_node_id: PublicKey, msg: &msgs::TxComplete) {
let _: Result<(), _> = handle_error!(self, Err(MsgHandleErrInternal::send_err_msg_no_close(
"Dual-funded channels not supported".to_owned(),
- msg.channel_id.clone())), *counterparty_node_id);
+ msg.channel_id.clone())), counterparty_node_id);
}
- fn handle_tx_signatures(&self, counterparty_node_id: &PublicKey, msg: &msgs::TxSignatures) {
+ fn handle_tx_signatures(&self, counterparty_node_id: PublicKey, msg: &msgs::TxSignatures) {
let _: Result<(), _> = handle_error!(self, Err(MsgHandleErrInternal::send_err_msg_no_close(
"Dual-funded channels not supported".to_owned(),
- msg.channel_id.clone())), *counterparty_node_id);
+ msg.channel_id.clone())), counterparty_node_id);
}
- fn handle_tx_init_rbf(&self, counterparty_node_id: &PublicKey, msg: &msgs::TxInitRbf) {
+ fn handle_tx_init_rbf(&self, counterparty_node_id: PublicKey, msg: &msgs::TxInitRbf) {
let _: Result<(), _> = handle_error!(self, Err(MsgHandleErrInternal::send_err_msg_no_close(
"Dual-funded channels not supported".to_owned(),
- msg.channel_id.clone())), *counterparty_node_id);
+ msg.channel_id.clone())), counterparty_node_id);
}
- fn handle_tx_ack_rbf(&self, counterparty_node_id: &PublicKey, msg: &msgs::TxAckRbf) {
+ fn handle_tx_ack_rbf(&self, counterparty_node_id: PublicKey, msg: &msgs::TxAckRbf) {
let _: Result<(), _> = handle_error!(self, Err(MsgHandleErrInternal::send_err_msg_no_close(
"Dual-funded channels not supported".to_owned(),
- msg.channel_id.clone())), *counterparty_node_id);
+ msg.channel_id.clone())), counterparty_node_id);
}
- fn handle_tx_abort(&self, counterparty_node_id: &PublicKey, msg: &msgs::TxAbort) {
+ fn handle_tx_abort(&self, counterparty_node_id: PublicKey, msg: &msgs::TxAbort) {
let _: Result<(), _> = handle_error!(self, Err(MsgHandleErrInternal::send_err_msg_no_close(
"Dual-funded channels not supported".to_owned(),
- msg.channel_id.clone())), *counterparty_node_id);
+ msg.channel_id.clone())), counterparty_node_id);
}
}
// Node 3, unrelated to the only channel, shouldn't care if it receives a channel_update
// about the channel.
- nodes[2].node.handle_channel_update(&nodes[1].node.get_our_node_id(), &chan.0);
- nodes[2].node.handle_channel_update(&nodes[1].node.get_our_node_id(), &chan.1);
+ nodes[2].node.handle_channel_update(nodes[1].node.get_our_node_id(), &chan.0);
+ nodes[2].node.handle_channel_update(nodes[1].node.get_our_node_id(), &chan.1);
assert!(!nodes[2].node.get_event_or_persistence_needed_future().poll_is_complete());
// The nodes which are a party to the channel should also ignore messages from unrelated
// parties.
- nodes[0].node.handle_channel_update(&nodes[2].node.get_our_node_id(), &chan.0);
- nodes[0].node.handle_channel_update(&nodes[2].node.get_our_node_id(), &chan.1);
- nodes[1].node.handle_channel_update(&nodes[2].node.get_our_node_id(), &chan.0);
- nodes[1].node.handle_channel_update(&nodes[2].node.get_our_node_id(), &chan.1);
+ nodes[0].node.handle_channel_update(nodes[2].node.get_our_node_id(), &chan.0);
+ nodes[0].node.handle_channel_update(nodes[2].node.get_our_node_id(), &chan.1);
+ nodes[1].node.handle_channel_update(nodes[2].node.get_our_node_id(), &chan.0);
+ nodes[1].node.handle_channel_update(nodes[2].node.get_our_node_id(), &chan.1);
assert!(!nodes[0].node.get_event_or_persistence_needed_future().poll_is_complete());
assert!(!nodes[1].node.get_event_or_persistence_needed_future().poll_is_complete());
// First deliver each peers' own message, checking that the node doesn't need to be
// persisted and that its channel info remains the same.
- nodes[0].node.handle_channel_update(&nodes[1].node.get_our_node_id(), &as_update);
- nodes[1].node.handle_channel_update(&nodes[0].node.get_our_node_id(), &bs_update);
+ nodes[0].node.handle_channel_update(nodes[1].node.get_our_node_id(), &as_update);
+ nodes[1].node.handle_channel_update(nodes[0].node.get_our_node_id(), &bs_update);
assert!(!nodes[0].node.get_event_or_persistence_needed_future().poll_is_complete());
assert!(!nodes[1].node.get_event_or_persistence_needed_future().poll_is_complete());
assert_eq!(nodes[0].node.list_channels()[0], node_a_chan_info);
// Finally, deliver the other peers' message, ensuring each node needs to be persisted and
// the channel info has updated.
- nodes[0].node.handle_channel_update(&nodes[1].node.get_our_node_id(), &bs_update);
- nodes[1].node.handle_channel_update(&nodes[0].node.get_our_node_id(), &as_update);
+ nodes[0].node.handle_channel_update(nodes[1].node.get_our_node_id(), &bs_update);
+ nodes[1].node.handle_channel_update(nodes[0].node.get_our_node_id(), &as_update);
assert!(nodes[0].node.get_event_or_persistence_needed_future().poll_is_complete());
assert!(nodes[1].node.get_event_or_persistence_needed_future().poll_is_complete());
assert_ne!(nodes[0].node.list_channels()[0], node_a_chan_info);
assert_eq!(events.len(), 1);
let ev = events.drain(..).next().unwrap();
let payment_event = SendEvent::from_event(ev);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
check_added_monitors!(nodes[1], 0);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[1]);
assert_eq!(updates.update_fail_htlcs.len(), 1);
assert!(updates.update_fail_malformed_htlcs.is_empty());
assert!(updates.update_fee.is_none());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], updates.commitment_signed, true, true);
expect_payment_failed!(nodes[0], our_payment_hash, true);
check_added_monitors!(nodes[1], 2);
let bs_first_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &bs_first_updates.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &bs_first_updates.update_fulfill_htlcs[0]);
expect_payment_sent(&nodes[0], payment_preimage, None, false, false);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_first_updates.commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_first_updates.commitment_signed);
check_added_monitors!(nodes[0], 1);
let (as_first_raa, as_first_cs) = get_revoke_commit_msgs!(nodes[0], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_first_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_first_raa);
check_added_monitors!(nodes[1], 1);
let bs_second_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_first_cs);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_first_cs);
check_added_monitors!(nodes[1], 1);
let bs_first_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &bs_second_updates.update_fulfill_htlcs[0]);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_second_updates.commitment_signed);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &bs_second_updates.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_second_updates.commitment_signed);
check_added_monitors!(nodes[0], 1);
let as_second_raa = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_first_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_first_raa);
let as_second_updates = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
check_added_monitors!(nodes[0], 1);
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_second_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_second_raa);
check_added_monitors!(nodes[1], 1);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_second_updates.commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_second_updates.commitment_signed);
check_added_monitors!(nodes[1], 1);
let bs_third_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_third_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_third_raa);
check_added_monitors!(nodes[0], 1);
// Note that successful MPP payments will generate a single PaymentSent event upon the first
assert_eq!(events.len(), 1);
let ev = events.drain(..).next().unwrap();
let payment_event = SendEvent::from_event(ev);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
check_added_monitors!(nodes[1], 0);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
// We have to forward pending HTLCs twice - once tries to forward the payment forward (and
assert_eq!(updates.update_fail_htlcs.len(), 1);
assert!(updates.update_fail_malformed_htlcs.is_empty());
assert!(updates.update_fee.is_none());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], updates.commitment_signed, true, true);
expect_payment_failed!(nodes[0], payment_hash, true);
assert_eq!(events.len(), 1);
let ev = events.drain(..).next().unwrap();
let payment_event = SendEvent::from_event(ev);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
check_added_monitors!(nodes[1], 0);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[1]);
assert_eq!(updates.update_fail_htlcs.len(), 1);
assert!(updates.update_fail_malformed_htlcs.is_empty());
assert!(updates.update_fee.is_none());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], updates.commitment_signed, true, true);
expect_payment_failed!(nodes[0], payment_hash, true);
assert_eq!(events.len(), 1);
let ev = events.drain(..).next().unwrap();
let payment_event = SendEvent::from_event(ev);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
check_added_monitors!(nodes[1], 0);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[1]);
assert_eq!(updates.update_fail_htlcs.len(), 1);
assert!(updates.update_fail_malformed_htlcs.is_empty());
assert!(updates.update_fee.is_none());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], updates.commitment_signed, true, true);
expect_payment_failed!(nodes[0], payment_hash, true);
assert!(updates.update_fail_htlcs.is_empty());
assert!(updates.update_fail_malformed_htlcs.is_empty());
assert!(updates.update_fee.is_none());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
nodes[1].logger.assert_log_contains("lightning::ln::channelmanager", "Payment preimage didn't match payment hash", 1);
}
assert!(updates.update_fail_htlcs.is_empty());
assert!(updates.update_fail_malformed_htlcs.is_empty());
assert!(updates.update_fee.is_none());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
nodes[1].logger.assert_log_contains("lightning::ln::channelmanager", "We don't support MPP keysend payments", 1);
}
}
// Test that we do not retrieve the pending broadcast messages when we are not connected to any peer
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
- nodes[0].node.peer_disconnected(&nodes[2].node.get_our_node_id());
- nodes[2].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[2].node.get_our_node_id());
+ nodes[2].node.peer_disconnected(nodes[0].node.get_our_node_id());
let node_0_events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(node_0_events.len(), 0);
// Now we reconnect to a peer
- nodes[0].node.peer_connected(&nodes[2].node.get_our_node_id(), &msgs::Init {
+ nodes[0].node.peer_connected(nodes[2].node.get_our_node_id(), &msgs::Init {
features: nodes[2].node.init_features(), networks: None, remote_network_address: None
}, true).unwrap();
- nodes[2].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init {
+ nodes[2].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, false).unwrap();
let chan = create_announced_chan_between_nodes(&nodes, 0, 1);
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
let error_message = "Channel force-closed";
nodes[0].node.force_close_broadcasting_latest_txn(&chan.2, &nodes[1].node.get_our_node_id(), error_message.to_string()).unwrap();
check_closed_broadcast!(nodes[0], true);
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 1_000_000, 500_000_000, 42, None, 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(), &open_channel);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &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(), &accept_channel);
+ nodes[0].node.handle_accept_channel(nodes[1].node.get_our_node_id(), &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 = ChannelId::from_bytes(tx.compute_txid().to_byte_array());
let funding_created_msg = get_event_msg!(nodes[0], MessageSendEvent::SendFundingCreated, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &funding_created_msg);
+ nodes[1].node.handle_funding_created(nodes[0].node.get_our_node_id(), &funding_created_msg);
{
let nodes_0_lock = nodes[0].node.outpoint_to_peer.lock().unwrap();
assert_eq!(nodes_0_lock.len(), 1);
}
check_added_monitors!(nodes[1], 1);
let funding_signed = get_event_msg!(nodes[1], MessageSendEvent::SendFundingSigned, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_funding_signed(&nodes[1].node.get_our_node_id(), &funding_signed);
+ nodes[0].node.handle_funding_signed(nodes[1].node.get_our_node_id(), &funding_signed);
check_added_monitors!(nodes[0], 1);
expect_channel_pending_event(&nodes[0], &nodes[1].node.get_our_node_id());
let (channel_ready, _) = create_chan_between_nodes_with_value_confirm(&nodes[0], &nodes[1], &tx);
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(), &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(), &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(), &nodes_1_shutdown);
+ nodes[0].node.handle_shutdown(nodes[1].node.get_our_node_id(), &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);
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &closing_signed_node_0);
{
// Assert that the channel is kept in the `outpoint_to_peer` map for both nodes until the
// channel can be fully closed by both parties (i.e. no outstanding htlcs exists, the
assert!(nodes_1_lock.contains_key(&funding_output));
}
- nodes[0].node.handle_closing_signed(&nodes[1].node.get_our_node_id(), &get_event_msg!(nodes[1], MessageSendEvent::SendClosingSigned, nodes[0].node.get_our_node_id()));
+ nodes[0].node.handle_closing_signed(nodes[1].node.get_our_node_id(), &get_event_msg!(nodes[1], MessageSendEvent::SendClosingSigned, nodes[0].node.get_our_node_id()));
{
// `nodes[0]` accepts `nodes[1]`'s proposed fee for the closing transaction, and
// therefore has all it needs to fully close the channel (both signatures for the
let (_nodes_0_update, closing_signed_node_0) = get_closing_signed_broadcast!(nodes[0].node, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &closing_signed_node_0.unwrap());
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &closing_signed_node_0.unwrap());
{
// Assert that the channel has now been removed from both parties `outpoint_to_peer` map once
// they both have everything required to fully close the channel.
let mut funding_tx = None;
for idx in 0..super::MAX_UNFUNDED_CHANS_PER_PEER {
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &open_channel_msg);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel_msg);
let accept_channel = get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id());
if idx == 0 {
- nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), &accept_channel);
+ nodes[0].node.handle_accept_channel(nodes[1].node.get_our_node_id(), &accept_channel);
let (temporary_channel_id, tx, _) = create_funding_transaction(&nodes[0], &nodes[1].node.get_our_node_id(), 100_000, 42);
funding_tx = Some(tx.clone());
nodes[0].node.funding_transaction_generated(temporary_channel_id, nodes[1].node.get_our_node_id(), tx).unwrap();
let funding_created_msg = get_event_msg!(nodes[0], MessageSendEvent::SendFundingCreated, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &funding_created_msg);
+ nodes[1].node.handle_funding_created(nodes[0].node.get_our_node_id(), &funding_created_msg);
check_added_monitors!(nodes[1], 1);
expect_channel_pending_event(&nodes[1], &nodes[0].node.get_our_node_id());
let funding_signed = get_event_msg!(nodes[1], MessageSendEvent::SendFundingSigned, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_funding_signed(&nodes[1].node.get_our_node_id(), &funding_signed);
+ nodes[0].node.handle_funding_signed(nodes[1].node.get_our_node_id(), &funding_signed);
check_added_monitors!(nodes[0], 1);
expect_channel_pending_event(&nodes[0], &nodes[1].node.get_our_node_id());
}
// A MAX_UNFUNDED_CHANS_PER_PEER + 1 channel will be summarily rejected
open_channel_msg.common_fields.temporary_channel_id = ChannelId::temporary_from_entropy_source(
&nodes[0].keys_manager);
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &open_channel_msg);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel_msg);
assert_eq!(get_err_msg(&nodes[1], &nodes[0].node.get_our_node_id()).channel_id,
open_channel_msg.common_fields.temporary_channel_id);
let random_pk = PublicKey::from_secret_key(&nodes[0].node.secp_ctx,
&SecretKey::from_slice(&nodes[1].keys_manager.get_secure_random_bytes()).unwrap());
peer_pks.push(random_pk);
- nodes[1].node.peer_connected(&random_pk, &msgs::Init {
+ nodes[1].node.peer_connected(random_pk, &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, true).unwrap();
}
let last_random_pk = PublicKey::from_secret_key(&nodes[0].node.secp_ctx,
&SecretKey::from_slice(&nodes[1].keys_manager.get_secure_random_bytes()).unwrap());
- nodes[1].node.peer_connected(&last_random_pk, &msgs::Init {
+ nodes[1].node.peer_connected(last_random_pk, &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, true).unwrap_err();
// Also importantly, because nodes[0] isn't "protected", we will refuse a reconnection from
// them if we have too many un-channel'd peers.
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
let chan_closed_events = nodes[1].node.get_and_clear_pending_events();
assert_eq!(chan_closed_events.len(), super::MAX_UNFUNDED_CHANS_PER_PEER - 1);
for ev in chan_closed_events {
if let Event::ChannelClosed { .. } = ev { } else { panic!(); }
}
- nodes[1].node.peer_connected(&last_random_pk, &msgs::Init {
+ nodes[1].node.peer_connected(last_random_pk, &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, true).unwrap();
- nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, true).unwrap_err();
// but of course if the connection is outbound its allowed...
- nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, false).unwrap();
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
// Now nodes[0] is disconnected but still has a pending, un-funded channel lying around.
// Even though we accept one more connection from new peers, we won't actually let them
// open channels.
assert!(peer_pks.len() > super::MAX_UNFUNDED_CHANNEL_PEERS - 1);
for i in 0..super::MAX_UNFUNDED_CHANNEL_PEERS - 1 {
- nodes[1].node.handle_open_channel(&peer_pks[i], &open_channel_msg);
+ nodes[1].node.handle_open_channel(peer_pks[i], &open_channel_msg);
get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, peer_pks[i]);
open_channel_msg.common_fields.temporary_channel_id = ChannelId::temporary_from_entropy_source(&nodes[0].keys_manager);
}
- nodes[1].node.handle_open_channel(&last_random_pk, &open_channel_msg);
+ nodes[1].node.handle_open_channel(last_random_pk, &open_channel_msg);
assert_eq!(get_err_msg(&nodes[1], &last_random_pk).channel_id,
open_channel_msg.common_fields.temporary_channel_id);
// If we fund the first channel, nodes[0] has a live on-chain channel with us, it is now
// "protected" and can connect again.
mine_transaction(&nodes[1], funding_tx.as_ref().unwrap());
- nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, true).unwrap();
get_event_msg!(nodes[1], MessageSendEvent::SendChannelReestablish, nodes[0].node.get_our_node_id());
// Further, because the first channel was funded, we can open another channel with
// last_random_pk.
- nodes[1].node.handle_open_channel(&last_random_pk, &open_channel_msg);
+ nodes[1].node.handle_open_channel(last_random_pk, &open_channel_msg);
get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, last_random_pk);
}
let mut open_channel_msg = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
for _ in 0..super::MAX_UNFUNDED_CHANS_PER_PEER {
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &open_channel_msg);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel_msg);
get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id());
open_channel_msg.common_fields.temporary_channel_id = ChannelId::temporary_from_entropy_source(&nodes[0].keys_manager);
}
// Once we have MAX_UNFUNDED_CHANS_PER_PEER unfunded channels, new inbound channels will be
// rejected.
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &open_channel_msg);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel_msg);
assert_eq!(get_err_msg(&nodes[1], &nodes[0].node.get_our_node_id()).channel_id,
open_channel_msg.common_fields.temporary_channel_id);
get_event_msg!(nodes[1], MessageSendEvent::SendOpenChannel, nodes[0].node.get_our_node_id());
// but even with such an outbound channel, additional inbound channels will still fail.
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &open_channel_msg);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel_msg);
assert_eq!(get_err_msg(&nodes[1], &nodes[0].node.get_our_node_id()).channel_id,
open_channel_msg.common_fields.temporary_channel_id);
}
for _ in 0..super::MAX_UNFUNDED_CHANNEL_PEERS - 1 {
let random_pk = PublicKey::from_secret_key(&nodes[0].node.secp_ctx,
&SecretKey::from_slice(&nodes[1].keys_manager.get_secure_random_bytes()).unwrap());
- nodes[1].node.peer_connected(&random_pk, &msgs::Init {
+ nodes[1].node.peer_connected(random_pk, &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, true).unwrap();
- nodes[1].node.handle_open_channel(&random_pk, &open_channel_msg);
+ nodes[1].node.handle_open_channel(random_pk, &open_channel_msg);
let events = nodes[1].node.get_and_clear_pending_events();
match events[0] {
Event::OpenChannelRequest { temporary_channel_id, .. } => {
// If we try to accept a channel from another peer non-0conf it will fail.
let last_random_pk = PublicKey::from_secret_key(&nodes[0].node.secp_ctx,
&SecretKey::from_slice(&nodes[1].keys_manager.get_secure_random_bytes()).unwrap());
- nodes[1].node.peer_connected(&last_random_pk, &msgs::Init {
+ nodes[1].node.peer_connected(last_random_pk, &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, true).unwrap();
- nodes[1].node.handle_open_channel(&last_random_pk, &open_channel_msg);
+ nodes[1].node.handle_open_channel(last_random_pk, &open_channel_msg);
let events = nodes[1].node.get_and_clear_pending_events();
match events[0] {
Event::OpenChannelRequest { temporary_channel_id, .. } => {
open_channel_msg.common_fields.temporary_channel_id);
// ...however if we accept the same channel 0conf it should work just fine.
- nodes[1].node.handle_open_channel(&last_random_pk, &open_channel_msg);
+ nodes[1].node.handle_open_channel(last_random_pk, &open_channel_msg);
let events = nodes[1].node.get_and_clear_pending_events();
match events[0] {
Event::OpenChannelRequest { temporary_channel_id, .. } => {
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100_000, 0, 42, None, 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(), &open_channel_msg);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel_msg);
assert!(nodes[1].node.get_and_clear_pending_events().is_empty());
let msg_events = nodes[1].node.get_and_clear_pending_msg_events();
match &msg_events[0] {
_ => panic!("Unexpected event"),
}
- nodes[2].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &open_channel_msg);
+ nodes[2].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel_msg);
let events = nodes[2].node.get_and_clear_pending_events();
match events[0] {
Event::OpenChannelRequest { temporary_channel_id, .. } =>
let open_channel_msg = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
assert!(open_channel_msg.common_fields.channel_type.as_ref().unwrap().supports_anchors_zero_fee_htlc_tx());
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &open_channel_msg);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel_msg);
let events = nodes[1].node.get_and_clear_pending_events();
match events[0] {
Event::OpenChannelRequest { temporary_channel_id, .. } => {
}
let error_msg = get_err_msg(&nodes[1], &nodes[0].node.get_our_node_id());
- nodes[0].node.handle_error(&nodes[1].node.get_our_node_id(), &error_msg);
+ nodes[0].node.handle_error(nodes[1].node.get_our_node_id(), &error_msg);
let open_channel_msg = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
assert!(!open_channel_msg.common_fields.channel_type.unwrap().supports_anchors_zero_fee_htlc_tx());
// Open a channel, immediately disconnect each other, and broadcast Alice's latest state.
let (_, _, chan_id, funding_tx) = create_announced_chan_between_nodes(&nodes, 0, 1);
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
nodes[0].node.force_close_broadcasting_latest_txn(&chan_id, &nodes[1].node.get_our_node_id(), error_message.to_string()).unwrap();
check_closed_broadcast(&nodes[0], 1, true);
check_added_monitors(&nodes[0], 1);
// Since they're disconnected, Bob won't receive Alice's `Error` message. Reconnect them
// such that Bob sends a `ChannelReestablish` to Alice since the channel is still open from
// their side.
- nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init {
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).unwrap();
- nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, false).unwrap();
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
let channel_reestablish = get_event_msg!(
nodes[1], MessageSendEvent::SendChannelReestablish, nodes[0].node.get_our_node_id()
);
- nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &channel_reestablish);
+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &channel_reestablish);
// Alice should respond with an error since the channel isn't known, but a bogus
// `ChannelReestablish` should be sent first, such that we actually trigger Bob to force
assert_eq!(*node_id, nodes[1].node.get_our_node_id());
assert_eq!(msg.next_local_commitment_number, 0);
assert_eq!(msg.next_remote_commitment_number, 0);
- nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &msg);
+ nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), &msg);
} else { panic!() };
check_closed_broadcast(&nodes[1], 1, true);
check_added_monitors(&nodes[1], 1);
}, genesis_block.header.time);
let node_b_holder = ANodeHolder { node: &node_b };
- node_a.peer_connected(&node_b.get_our_node_id(), &Init {
+ node_a.peer_connected(node_b.get_our_node_id(), &Init {
features: node_b.init_features(), networks: None, remote_network_address: None
}, true).unwrap();
- node_b.peer_connected(&node_a.get_our_node_id(), &Init {
+ node_b.peer_connected(node_a.get_our_node_id(), &Init {
features: node_a.init_features(), networks: None, remote_network_address: None
}, false).unwrap();
node_a.create_channel(node_b.get_our_node_id(), 8_000_000, 100_000_000, 42, None, None).unwrap();
- node_b.handle_open_channel(&node_a.get_our_node_id(), &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(), &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(), &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(), &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) {
node_a.funding_transaction_generated(temporary_channel_id, node_b.get_our_node_id(), tx.clone()).unwrap();
} else { panic!(); }
- node_b.handle_funding_created(&node_a.get_our_node_id(), &get_event_msg!(node_a_holder, MessageSendEvent::SendFundingCreated, node_b.get_our_node_id()));
+ node_b.handle_funding_created(node_a.get_our_node_id(), &get_event_msg!(node_a_holder, MessageSendEvent::SendFundingCreated, node_b.get_our_node_id()));
let events_b = node_b.get_and_clear_pending_events();
assert_eq!(events_b.len(), 1);
match events_b[0] {
_ => panic!("Unexpected event"),
}
- node_a.handle_funding_signed(&node_b.get_our_node_id(), &get_event_msg!(node_b_holder, MessageSendEvent::SendFundingSigned, node_a.get_our_node_id()));
+ node_a.handle_funding_signed(node_b.get_our_node_id(), &get_event_msg!(node_b_holder, MessageSendEvent::SendFundingSigned, node_a.get_our_node_id()));
let events_a = node_a.get_and_clear_pending_events();
assert_eq!(events_a.len(), 1);
match events_a[0] {
Listen::block_connected(&node_a, &block, 1);
Listen::block_connected(&node_b, &block, 1);
- node_a.handle_channel_ready(&node_b.get_our_node_id(), &get_event_msg!(node_b_holder, MessageSendEvent::SendChannelReady, node_a.get_our_node_id()));
+ node_a.handle_channel_ready(node_b.get_our_node_id(), &get_event_msg!(node_b_holder, MessageSendEvent::SendChannelReady, node_a.get_our_node_id()));
let msg_events = node_a.get_and_clear_pending_msg_events();
assert_eq!(msg_events.len(), 2);
match msg_events[0] {
MessageSendEvent::SendChannelReady { ref msg, .. } => {
- node_b.handle_channel_ready(&node_a.get_our_node_id(), msg);
+ node_b.handle_channel_ready(node_a.get_our_node_id(), msg);
get_event_msg!(node_b_holder, MessageSendEvent::SendChannelUpdate, node_a.get_our_node_id());
},
_ => panic!(),
RouteParameters::from_payment_params_and_value(payment_params, 10_000),
Retry::Attempts(0)).unwrap();
let payment_event = SendEvent::from_event($node_a.get_and_clear_pending_msg_events().pop().unwrap());
- $node_b.handle_update_add_htlc(&$node_a.get_our_node_id(), &payment_event.msgs[0]);
- $node_b.handle_commitment_signed(&$node_a.get_our_node_id(), &payment_event.commitment_msg);
+ $node_b.handle_update_add_htlc($node_a.get_our_node_id(), &payment_event.msgs[0]);
+ $node_b.handle_commitment_signed($node_a.get_our_node_id(), &payment_event.commitment_msg);
let (raa, cs) = get_revoke_commit_msgs(&ANodeHolder { node: &$node_b }, &$node_a.get_our_node_id());
- $node_a.handle_revoke_and_ack(&$node_b.get_our_node_id(), &raa);
- $node_a.handle_commitment_signed(&$node_b.get_our_node_id(), &cs);
- $node_b.handle_revoke_and_ack(&$node_a.get_our_node_id(), &get_event_msg!(ANodeHolder { node: &$node_a }, MessageSendEvent::SendRevokeAndACK, $node_b.get_our_node_id()));
+ $node_a.handle_revoke_and_ack($node_b.get_our_node_id(), &raa);
+ $node_a.handle_commitment_signed($node_b.get_our_node_id(), &cs);
+ $node_b.handle_revoke_and_ack($node_a.get_our_node_id(), &get_event_msg!(ANodeHolder { node: &$node_a }, MessageSendEvent::SendRevokeAndACK, $node_b.get_our_node_id()));
expect_pending_htlcs_forwardable!(ANodeHolder { node: &$node_b });
expect_payment_claimable!(ANodeHolder { node: &$node_b }, payment_hash, payment_secret, 10_000);
match $node_b.get_and_clear_pending_msg_events().pop().unwrap() {
MessageSendEvent::UpdateHTLCs { node_id, updates } => {
assert_eq!(node_id, $node_a.get_our_node_id());
- $node_a.handle_update_fulfill_htlc(&$node_b.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
- $node_a.handle_commitment_signed(&$node_b.get_our_node_id(), &updates.commitment_signed);
+ $node_a.handle_update_fulfill_htlc($node_b.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
+ $node_a.handle_commitment_signed($node_b.get_our_node_id(), &updates.commitment_signed);
},
_ => panic!("Failed to generate claim event"),
}
let (raa, cs) = get_revoke_commit_msgs(&ANodeHolder { node: &$node_a }, &$node_b.get_our_node_id());
- $node_b.handle_revoke_and_ack(&$node_a.get_our_node_id(), &raa);
- $node_b.handle_commitment_signed(&$node_a.get_our_node_id(), &cs);
- $node_a.handle_revoke_and_ack(&$node_b.get_our_node_id(), &get_event_msg!(ANodeHolder { node: &$node_b }, MessageSendEvent::SendRevokeAndACK, $node_a.get_our_node_id()));
+ $node_b.handle_revoke_and_ack($node_a.get_our_node_id(), &raa);
+ $node_b.handle_commitment_signed($node_a.get_our_node_id(), &cs);
+ $node_a.handle_revoke_and_ack($node_b.get_our_node_id(), &get_event_msg!(ANodeHolder { node: &$node_b }, MessageSendEvent::SendRevokeAndACK, $node_a.get_our_node_id()));
expect_payment_sent!(ANodeHolder { node: &$node_a }, payment_preimage);
}
}
impl<'a, 'b, 'c> Node<'a, 'b, 'c> {
- pub fn init_features(&self, peer_node_id: &PublicKey) -> InitFeatures {
+ pub fn init_features(&self, peer_node_id: PublicKey) -> InitFeatures {
self.override_init_features.borrow().clone()
.unwrap_or_else(|| self.node.init_features() | self.onion_messenger.provided_init_features(peer_node_id))
}
let funding_created_msg = get_event_msg!(node_a, MessageSendEvent::SendFundingCreated, node_b.node.get_our_node_id());
assert_eq!(funding_created_msg.temporary_channel_id, expected_temporary_channel_id);
- node_b.node.handle_funding_created(&node_a.node.get_our_node_id(), &funding_created_msg);
+ node_b.node.handle_funding_created(node_a.node.get_our_node_id(), &funding_created_msg);
{
let mut added_monitors = node_b.chain_monitor.added_monitors.lock().unwrap();
assert_eq!(added_monitors.len(), 1);
}
expect_channel_pending_event(&node_b, &node_a.node.get_our_node_id());
- node_a.node.handle_funding_signed(&node_b.node.get_our_node_id(), &get_event_msg!(node_b, MessageSendEvent::SendFundingSigned, node_a.node.get_our_node_id()));
+ node_a.node.handle_funding_signed(node_b.node.get_our_node_id(), &get_event_msg!(node_b, MessageSendEvent::SendFundingSigned, node_a.node.get_our_node_id()));
{
let mut added_monitors = node_a.chain_monitor.added_monitors.lock().unwrap();
assert_eq!(added_monitors.len(), 1);
initiator.node.create_channel(receiver.node.get_our_node_id(), 100_000, 10_001, 42, None, 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(), &open_channel);
+ receiver.node.handle_open_channel(initiator.node.get_our_node_id(), &open_channel);
let events = receiver.node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
match events[0] {
let accept_channel = get_event_msg!(receiver, MessageSendEvent::SendAcceptChannel, initiator.node.get_our_node_id());
assert_eq!(accept_channel.common_fields.minimum_depth, 0);
- initiator.node.handle_accept_channel(&receiver.node.get_our_node_id(), &accept_channel);
+ initiator.node.handle_accept_channel(receiver.node.get_our_node_id(), &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();
let funding_created = get_event_msg!(initiator, MessageSendEvent::SendFundingCreated, receiver.node.get_our_node_id());
- receiver.node.handle_funding_created(&initiator.node.get_our_node_id(), &funding_created);
+ receiver.node.handle_funding_created(initiator.node.get_our_node_id(), &funding_created);
check_added_monitors!(receiver, 1);
let bs_signed_locked = receiver.node.get_and_clear_pending_msg_events();
assert_eq!(bs_signed_locked.len(), 2);
match &bs_signed_locked[0] {
MessageSendEvent::SendFundingSigned { node_id, msg } => {
assert_eq!(*node_id, initiator.node.get_our_node_id());
- initiator.node.handle_funding_signed(&receiver.node.get_our_node_id(), &msg);
+ initiator.node.handle_funding_signed(receiver.node.get_our_node_id(), &msg);
expect_channel_pending_event(&initiator, &receiver.node.get_our_node_id());
expect_channel_pending_event(&receiver, &initiator.node.get_our_node_id());
check_added_monitors!(initiator, 1);
match &bs_signed_locked[1] {
MessageSendEvent::SendChannelReady { node_id, msg } => {
assert_eq!(*node_id, initiator.node.get_our_node_id());
- initiator.node.handle_channel_ready(&receiver.node.get_our_node_id(), &msg);
+ initiator.node.handle_channel_ready(receiver.node.get_our_node_id(), &msg);
expect_channel_ready_event(&initiator, &receiver.node.get_our_node_id());
}
_ => panic!("Unexpected event"),
}
- receiver.node.handle_channel_ready(&initiator.node.get_our_node_id(), &as_channel_ready);
+ receiver.node.handle_channel_ready(initiator.node.get_our_node_id(), &as_channel_ready);
expect_channel_ready_event(&receiver, &initiator.node.get_our_node_id());
let as_channel_update = get_event_msg!(initiator, MessageSendEvent::SendChannelUpdate, receiver.node.get_our_node_id());
let bs_channel_update = get_event_msg!(receiver, MessageSendEvent::SendChannelUpdate, initiator.node.get_our_node_id());
- initiator.node.handle_channel_update(&receiver.node.get_our_node_id(), &bs_channel_update);
- receiver.node.handle_channel_update(&initiator.node.get_our_node_id(), &as_channel_update);
+ initiator.node.handle_channel_update(receiver.node.get_our_node_id(), &bs_channel_update);
+ receiver.node.handle_channel_update(initiator.node.get_our_node_id(), &as_channel_update);
assert_eq!(initiator.node.list_usable_channels().len(), initiator_channels + 1);
assert_eq!(receiver.node.list_usable_channels().len(), receiver_channels + 1);
let open_channel_msg = get_event_msg!(node_a, MessageSendEvent::SendOpenChannel, node_b.node.get_our_node_id());
assert_eq!(open_channel_msg.common_fields.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);
- node_b.node.handle_open_channel(&node_a.node.get_our_node_id(), &open_channel_msg);
+ node_b.node.handle_open_channel(node_a.node.get_our_node_id(), &open_channel_msg);
if node_b.node.get_current_default_configuration().manually_accept_inbound_channels {
let events = node_b.node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
}
let accept_channel_msg = get_event_msg!(node_b, MessageSendEvent::SendAcceptChannel, node_a.node.get_our_node_id());
assert_eq!(accept_channel_msg.common_fields.temporary_channel_id, create_chan_id);
- node_a.node.handle_accept_channel(&node_b.node.get_our_node_id(), &accept_channel_msg);
+ node_a.node.handle_accept_channel(node_b.node.get_our_node_id(), &accept_channel_msg);
assert_ne!(node_b.node.list_channels().iter().find(|channel| channel.channel_id == create_chan_id).unwrap().user_channel_id, 0);
create_chan_id
pub fn create_chan_between_nodes_with_value_confirm_first<'a, 'b, 'c, 'd>(node_recv: &'a Node<'b, 'c, 'c>, node_conf: &'a Node<'b, 'c, 'd>, tx: &Transaction, conf_height: u32) {
confirm_transaction_at(node_conf, tx, conf_height);
connect_blocks(node_conf, CHAN_CONFIRM_DEPTH - 1);
- node_recv.node.handle_channel_ready(&node_conf.node.get_our_node_id(), &get_event_msg!(node_conf, MessageSendEvent::SendChannelReady, node_recv.node.get_our_node_id()));
+ node_recv.node.handle_channel_ready(node_conf.node.get_our_node_id(), &get_event_msg!(node_conf, MessageSendEvent::SendChannelReady, node_recv.node.get_our_node_id()));
}
pub fn create_chan_between_nodes_with_value_confirm_second<'a, 'b, 'c>(node_recv: &Node<'a, 'b, 'c>, node_conf: &Node<'a, 'b, 'c>) -> ((msgs::ChannelReady, msgs::AnnouncementSignatures), ChannelId) {
}
pub fn create_chan_between_nodes_with_value_b<'a, 'b, 'c>(node_a: &Node<'a, 'b, 'c>, node_b: &Node<'a, 'b, 'c>, as_funding_msgs: &(msgs::ChannelReady, msgs::AnnouncementSignatures)) -> (msgs::ChannelAnnouncement, msgs::ChannelUpdate, msgs::ChannelUpdate) {
- node_b.node.handle_channel_ready(&node_a.node.get_our_node_id(), &as_funding_msgs.0);
+ node_b.node.handle_channel_ready(node_a.node.get_our_node_id(), &as_funding_msgs.0);
let bs_announcement_sigs = get_event_msg!(node_b, MessageSendEvent::SendAnnouncementSignatures, node_a.node.get_our_node_id());
- node_b.node.handle_announcement_signatures(&node_a.node.get_our_node_id(), &as_funding_msgs.1);
+ node_b.node.handle_announcement_signatures(node_a.node.get_our_node_id(), &as_funding_msgs.1);
let events_7 = node_b.node.get_and_clear_pending_msg_events();
assert_eq!(events_7.len(), 1);
_ => panic!("Unexpected event"),
};
- node_a.node.handle_announcement_signatures(&node_b.node.get_our_node_id(), &bs_announcement_sigs);
+ node_a.node.handle_announcement_signatures(node_b.node.get_our_node_id(), &bs_announcement_sigs);
let events_8 = node_a.node.get_and_clear_pending_msg_events();
assert_eq!(events_8.len(), 1);
let as_update = match events_8[0] {
no_announce_cfg.channel_handshake_config.announce_for_forwarding = false;
nodes[a].node.create_channel(nodes[b].node.get_our_node_id(), channel_value, push_msat, 42, None, Some(no_announce_cfg)).unwrap();
let open_channel = get_event_msg!(nodes[a], MessageSendEvent::SendOpenChannel, nodes[b].node.get_our_node_id());
- nodes[b].node.handle_open_channel(&nodes[a].node.get_our_node_id(), &open_channel);
+ nodes[b].node.handle_open_channel(nodes[a].node.get_our_node_id(), &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(), &accept_channel);
+ nodes[a].node.handle_accept_channel(nodes[b].node.get_our_node_id(), &accept_channel);
let (temporary_channel_id, tx, _) = create_funding_transaction(&nodes[a], &nodes[b].node.get_our_node_id(), channel_value, 42);
nodes[a].node.funding_transaction_generated(temporary_channel_id, nodes[b].node.get_our_node_id(), tx.clone()).unwrap();
- nodes[b].node.handle_funding_created(&nodes[a].node.get_our_node_id(), &get_event_msg!(nodes[a], MessageSendEvent::SendFundingCreated, nodes[b].node.get_our_node_id()));
+ nodes[b].node.handle_funding_created(nodes[a].node.get_our_node_id(), &get_event_msg!(nodes[a], MessageSendEvent::SendFundingCreated, nodes[b].node.get_our_node_id()));
check_added_monitors!(nodes[b], 1);
let cs_funding_signed = get_event_msg!(nodes[b], MessageSendEvent::SendFundingSigned, nodes[a].node.get_our_node_id());
expect_channel_pending_event(&nodes[b], &nodes[a].node.get_our_node_id());
- nodes[a].node.handle_funding_signed(&nodes[b].node.get_our_node_id(), &cs_funding_signed);
+ nodes[a].node.handle_funding_signed(nodes[b].node.get_our_node_id(), &cs_funding_signed);
expect_channel_pending_event(&nodes[a], &nodes[b].node.get_our_node_id());
check_added_monitors!(nodes[a], 1);
confirm_transaction_at(&nodes[b], &tx, conf_height);
connect_blocks(&nodes[b], CHAN_CONFIRM_DEPTH - 1);
let as_channel_ready = get_event_msg!(nodes[a], MessageSendEvent::SendChannelReady, nodes[b].node.get_our_node_id());
- nodes[a].node.handle_channel_ready(&nodes[b].node.get_our_node_id(), &get_event_msg!(nodes[b], MessageSendEvent::SendChannelReady, nodes[a].node.get_our_node_id()));
+ nodes[a].node.handle_channel_ready(nodes[b].node.get_our_node_id(), &get_event_msg!(nodes[b], MessageSendEvent::SendChannelReady, nodes[a].node.get_our_node_id()));
expect_channel_ready_event(&nodes[a], &nodes[b].node.get_our_node_id());
let as_update = get_event_msg!(nodes[a], MessageSendEvent::SendChannelUpdate, nodes[b].node.get_our_node_id());
- nodes[b].node.handle_channel_ready(&nodes[a].node.get_our_node_id(), &as_channel_ready);
+ nodes[b].node.handle_channel_ready(nodes[a].node.get_our_node_id(), &as_channel_ready);
expect_channel_ready_event(&nodes[b], &nodes[a].node.get_our_node_id());
let bs_update = get_event_msg!(nodes[b], MessageSendEvent::SendChannelUpdate, nodes[a].node.get_our_node_id());
- nodes[a].node.handle_channel_update(&nodes[b].node.get_our_node_id(), &bs_update);
- nodes[b].node.handle_channel_update(&nodes[a].node.get_our_node_id(), &as_update);
+ nodes[a].node.handle_channel_update(nodes[b].node.get_our_node_id(), &bs_update);
+ nodes[b].node.handle_channel_update(nodes[a].node.get_our_node_id(), &as_update);
let mut found_a = false;
for chan in nodes[a].node.list_usable_channels() {
let node_id_a = nodes[a].node.get_our_node_id();
let node_id_b = nodes[b].node.get_our_node_id();
assert!(node.gossip_sync.handle_channel_announcement(None, ann).unwrap());
- node.gossip_sync.handle_channel_update(Some(&node_id_a), upd_1).unwrap();
- node.gossip_sync.handle_channel_update(Some(&node_id_b), upd_2).unwrap();
+ node.gossip_sync.handle_channel_update(Some(node_id_a), upd_1).unwrap();
+ node.gossip_sync.handle_channel_update(Some(node_id_b), upd_2).unwrap();
// Note that channel_updates are also delivered to ChannelManagers to ensure we have
// forwarding info for local channels even if its not accepted in the network graph.
- node.node.handle_channel_update(&node_id_a, &upd_1);
- node.node.handle_channel_update(&node_id_b, &upd_2);
+ node.node.handle_channel_update(node_id_a, &upd_1);
+ node.node.handle_channel_update(node_id_b, &upd_2);
}
}
/// check whether an error message event has occurred.
pub fn check_closed_broadcast(node: &Node, num_channels: usize, with_error_msg: bool) -> Vec<msgs::ErrorMessage> {
let mut dummy_connected = false;
- if !is_any_peer_connected(node) {
+ if !is_any_peer_connected(&node) {
connect_dummy_node(&node);
dummy_connected = true;
}
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(), &get_event_msg!(struct_a, MessageSendEvent::SendShutdown, node_b.get_our_node_id()));
+ node_b.handle_shutdown(node_a.get_our_node_id(), &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);
})
};
- node_a.handle_shutdown(&node_b.get_our_node_id(), &shutdown_b);
+ node_a.handle_shutdown(node_b.get_our_node_id(), &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());
+ node_a.handle_closing_signed(node_b.get_our_node_id(), &closing_signed_b.unwrap());
- node_b.handle_closing_signed(&node_a.get_our_node_id(), &get_event_msg!(struct_a, MessageSendEvent::SendClosingSigned, node_b.get_our_node_id()));
+ node_b.handle_closing_signed(node_a.get_our_node_id(), &get_event_msg!(struct_a, MessageSendEvent::SendClosingSigned, node_b.get_our_node_id()));
assert_eq!(broadcaster_b.txn_broadcasted.lock().unwrap().len(), 1);
tx_b = broadcaster_b.txn_broadcasted.lock().unwrap().remove(0);
let (bs_update, closing_signed_b) = get_closing_signed_broadcast!(node_b, node_a.get_our_node_id());
- node_a.handle_closing_signed(&node_b.get_our_node_id(), &closing_signed_b.unwrap());
+ node_a.handle_closing_signed(node_b.get_our_node_id(), &closing_signed_b.unwrap());
let (as_update, none_a) = get_closing_signed_broadcast!(node_a, node_b.get_our_node_id());
assert!(none_a.is_none());
assert_eq!(broadcaster_a.txn_broadcasted.lock().unwrap().len(), 1);
} else {
let closing_signed_a = get_event_msg!(struct_a, MessageSendEvent::SendClosingSigned, node_b.get_our_node_id());
- node_b.handle_closing_signed(&node_a.get_our_node_id(), &closing_signed_a);
- node_a.handle_closing_signed(&node_b.get_our_node_id(), &get_event_msg!(struct_b, MessageSendEvent::SendClosingSigned, node_a.get_our_node_id()));
+ node_b.handle_closing_signed(node_a.get_our_node_id(), &closing_signed_a);
+ node_a.handle_closing_signed(node_b.get_our_node_id(), &get_event_msg!(struct_b, MessageSendEvent::SendClosingSigned, node_a.get_our_node_id()));
assert_eq!(broadcaster_a.txn_broadcasted.lock().unwrap().len(), 1);
tx_a = broadcaster_a.txn_broadcasted.lock().unwrap().remove(0);
let (as_update, closing_signed_a) = get_closing_signed_broadcast!(node_a, node_b.get_our_node_id());
- node_b.handle_closing_signed(&node_a.get_our_node_id(), &closing_signed_a.unwrap());
+ node_b.handle_closing_signed(node_a.get_our_node_id(), &closing_signed_a.unwrap());
let (bs_update, none_b) = get_closing_signed_broadcast!(node_b, node_a.get_our_node_id());
assert!(none_b.is_none());
assert_eq!(broadcaster_b.txn_broadcasted.lock().unwrap().len(), 1);
{
$crate::ln::functional_test_utils::check_added_monitors(&$node_a, 0);
assert!($node_a.node.get_and_clear_pending_msg_events().is_empty());
- $node_a.node.handle_commitment_signed(&$node_b.node.get_our_node_id(), &$commitment_signed);
+ $node_a.node.handle_commitment_signed($node_b.node.get_our_node_id(), &$commitment_signed);
check_added_monitors(&$node_a, 1);
let (extra_msg_option, bs_revoke_and_ack) = $crate::ln::functional_test_utils::do_main_commitment_signed_dance(&$node_a, &$node_b, $fail_backwards);
assert!(extra_msg_option.is_none());
/// Returns any additional message `node_b` generated in addition to the `revoke_and_ack` response.
pub fn commitment_signed_dance_through_cp_raa(node_a: &Node<'_, '_, '_>, node_b: &Node<'_, '_, '_>, fail_backwards: bool, includes_claim: bool) -> Option<MessageSendEvent> {
let (extra_msg_option, bs_revoke_and_ack) = do_main_commitment_signed_dance(node_a, node_b, fail_backwards);
- node_a.node.handle_revoke_and_ack(&node_b.node.get_our_node_id(), &bs_revoke_and_ack);
+ node_a.node.handle_revoke_and_ack(node_b.node.get_our_node_id(), &bs_revoke_and_ack);
check_added_monitors(node_a, if includes_claim { 0 } else { 1 });
extra_msg_option
}
let (as_revoke_and_ack, as_commitment_signed) = get_revoke_commit_msgs!(node_a, node_b.node.get_our_node_id());
check_added_monitors!(node_b, 0);
assert!(node_b.node.get_and_clear_pending_msg_events().is_empty());
- node_b.node.handle_revoke_and_ack(&node_a.node.get_our_node_id(), &as_revoke_and_ack);
+ node_b.node.handle_revoke_and_ack(node_a.node.get_our_node_id(), &as_revoke_and_ack);
assert!(node_b.node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(node_b, 1);
- node_b.node.handle_commitment_signed(&node_a.node.get_our_node_id(), &as_commitment_signed);
+ node_b.node.handle_commitment_signed(node_a.node.get_our_node_id(), &as_commitment_signed);
let (bs_revoke_and_ack, extra_msg_option) = {
let mut events = node_b.node.get_and_clear_pending_msg_events();
assert!(events.len() <= 2);
pub fn do_commitment_signed_dance(node_a: &Node<'_, '_, '_>, node_b: &Node<'_, '_, '_>, commitment_signed: &msgs::CommitmentSigned, fail_backwards: bool, skip_last_step: bool) {
check_added_monitors!(node_a, 0);
assert!(node_a.node.get_and_clear_pending_msg_events().is_empty());
- node_a.node.handle_commitment_signed(&node_b.node.get_our_node_id(), commitment_signed);
+ node_a.node.handle_commitment_signed(node_b.node.get_our_node_id(), commitment_signed);
check_added_monitors!(node_a, 1);
// If this commitment signed dance was due to a claim, don't check for an RAA monitor update.
// iterate from the receiving node to the origin node and handle update fail htlc.
for (&node, &prev_node) in expected_path.iter().rev().zip(expected_path.iter().rev().skip(1)) {
let updates = get_htlc_update_msgs!(node, prev_node.node.get_our_node_id());
- prev_node.node.handle_update_fail_htlc(&node.node.get_our_node_id(), &updates.update_fail_htlcs[0]);
+ prev_node.node.handle_update_fail_htlc(node.node.get_our_node_id(), &updates.update_fail_htlcs[0]);
check_added_monitors!(prev_node, 0);
let is_first_hop = origin_node_id == prev_node.node.get_our_node_id();
let is_last_hop = idx == expected_path.len() - 1;
assert_eq!(node.node.get_our_node_id(), payment_event.node_id);
- node.node.handle_update_add_htlc(&prev_node.node.get_our_node_id(), &payment_event.msgs[0]);
+ node.node.handle_update_add_htlc(prev_node.node.get_our_node_id(), &payment_event.msgs[0]);
check_added_monitors!(node, 0);
if is_last_hop && is_probe {
macro_rules! last_update_fulfill_dance {
($node: expr, $prev_node: expr) => {
{
- $node.node.handle_update_fulfill_htlc(&$prev_node.node.get_our_node_id(), &next_msgs.as_ref().unwrap().0);
+ $node.node.handle_update_fulfill_htlc($prev_node.node.get_our_node_id(), &next_msgs.as_ref().unwrap().0);
check_added_monitors!($node, 0);
assert!($node.node.get_and_clear_pending_msg_events().is_empty());
commitment_signed_dance!($node, $prev_node, next_msgs.as_ref().unwrap().1, false);
macro_rules! mid_update_fulfill_dance {
($idx: expr, $node: expr, $prev_node: expr, $next_node: expr, $new_msgs: expr) => {
{
- $node.node.handle_update_fulfill_htlc(&$prev_node.node.get_our_node_id(), &next_msgs.as_ref().unwrap().0);
+ $node.node.handle_update_fulfill_htlc($prev_node.node.get_our_node_id(), &next_msgs.as_ref().unwrap().0);
let mut fee = {
let (base_fee, prop_fee) = {
let per_peer_state = $node.node.per_peer_state.read().unwrap();
assert_eq!(expected_next_node, node.node.get_our_node_id());
let update_next_node = !skip_last || idx != expected_route.len() - 1;
if next_msgs.is_some() {
- node.node.handle_update_fail_htlc(&prev_node.node.get_our_node_id(), &next_msgs.as_ref().unwrap().0);
+ node.node.handle_update_fail_htlc(prev_node.node.get_our_node_id(), &next_msgs.as_ref().unwrap().0);
commitment_signed_dance!(node, prev_node, next_msgs.as_ref().unwrap().1, update_next_node);
if !update_next_node {
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(node, vec![HTLCDestination::NextHopChannel { node_id: Some(prev_node.node.get_our_node_id()), channel_id: next_msgs.as_ref().unwrap().0.channel_id }]);
if !skip_last {
let prev_node = expected_route.first().unwrap();
- origin_node.node.handle_update_fail_htlc(&prev_node.node.get_our_node_id(), &next_msgs.as_ref().unwrap().0);
+ origin_node.node.handle_update_fail_htlc(prev_node.node.get_our_node_id(), &next_msgs.as_ref().unwrap().0);
check_added_monitors!(origin_node, 0);
assert!(origin_node.node.get_and_clear_pending_msg_events().is_empty());
commitment_signed_dance!(origin_node, prev_node, next_msgs.as_ref().unwrap().1, false);
let node_id_b = node_b.node.get_our_node_id();
let init_a = msgs::Init {
- features: node_a.init_features(&node_id_b),
+ features: node_a.init_features(node_id_b),
networks: None,
remote_network_address: None,
};
let init_b = msgs::Init {
- features: node_b.init_features(&node_id_a),
+ features: node_b.init_features(node_id_a),
networks: None,
remote_network_address: None,
};
- node_a.node.peer_connected(&node_id_b, &init_b, true).unwrap();
- node_b.node.peer_connected(&node_id_a, &init_a, false).unwrap();
- node_a.onion_messenger.peer_connected(&node_id_b, &init_b, true).unwrap();
- node_b.onion_messenger.peer_connected(&node_id_a, &init_a, false).unwrap();
+ node_a.node.peer_connected(node_id_b, &init_b, true).unwrap();
+ node_b.node.peer_connected(node_id_a, &init_a, false).unwrap();
+ node_a.onion_messenger.peer_connected(node_id_b, &init_b, true).unwrap();
+ node_b.onion_messenger.peer_connected(node_id_a, &init_a, false).unwrap();
}
pub fn connect_dummy_node<'a, 'b: 'a, 'c: 'b>(node: &Node<'a, 'b, 'c>) {
remote_network_address: None
};
- node.node.peer_connected(&node_id_dummy, &init_dummy, true).unwrap();
- node.onion_messenger.peer_connected(&node_id_dummy, &init_dummy, true).unwrap();
+ node.node.peer_connected(node_id_dummy, &init_dummy, true).unwrap();
+ node.onion_messenger.peer_connected(node_id_dummy, &init_dummy, true).unwrap();
}
pub fn disconnect_dummy_node<'a, 'b: 'a, 'c: 'b>(node: &Node<'a, 'b, 'c>) {
let node_id_dummy = PublicKey::from_slice(&[2; 33]).unwrap();
- node.node.peer_disconnected(&node_id_dummy);
- node.onion_messenger.peer_disconnected(&node_id_dummy);
+ node.node.peer_disconnected(node_id_dummy);
+ node.onion_messenger.peer_disconnected(node_id_dummy);
}
// Note that the following only works for CLTV values up to 128
assert_eq!(node_id, nodes[b].node.get_our_node_id());
assert_eq!(msg.data, expected_error);
if needs_err_handle {
- nodes[b].node.handle_error(&nodes[a].node.get_our_node_id(), msg);
+ nodes[b].node.handle_error(nodes[a].node.get_our_node_id(), msg);
}
},
MessageSendEvent::HandleError { node_id, action: msgs::ErrorAction::DisconnectPeer { ref msg } } => {
assert_eq!(node_id, nodes[b].node.get_our_node_id());
assert_eq!(msg.as_ref().unwrap().data, expected_error);
if needs_err_handle {
- nodes[b].node.handle_error(&nodes[a].node.get_our_node_id(), msg.as_ref().unwrap());
+ nodes[b].node.handle_error(nodes[a].node.get_our_node_id(), msg.as_ref().unwrap());
}
},
_ => panic!("Unexpected event"),
}
let node_id_a = nodes[a].node.get_our_node_id();
for node in nodes {
- node.gossip_sync.handle_channel_update(Some(&node_id_a), &as_update).unwrap();
- node.gossip_sync.handle_channel_update(Some(&node_id_a), &bs_update).unwrap();
+ node.gossip_sync.handle_channel_update(Some(node_id_a), &as_update).unwrap();
+ node.gossip_sync.handle_channel_update(Some(node_id_a), &bs_update).unwrap();
}
}
let mut resp_1 = Vec::new();
for msg in reestablish_1 {
- node_b.node.handle_channel_reestablish(&node_a.node.get_our_node_id(), &msg);
+ node_b.node.handle_channel_reestablish(node_a.node.get_our_node_id(), &msg);
resp_1.push(handle_chan_reestablish_msgs!(node_b, node_a));
}
if pending_cell_htlc_claims.0 != 0 || pending_cell_htlc_fails.0 != 0 {
let mut resp_2 = Vec::new();
for msg in reestablish_2 {
- node_a.node.handle_channel_reestablish(&node_b.node.get_our_node_id(), &msg);
+ node_a.node.handle_channel_reestablish(node_b.node.get_our_node_id(), &msg);
resp_2.push(handle_chan_reestablish_msgs!(node_a, node_b));
}
if pending_cell_htlc_claims.1 != 0 || pending_cell_htlc_fails.1 != 0 {
for chan_msgs in resp_1.drain(..) {
if send_channel_ready.0 {
- node_a.node.handle_channel_ready(&node_b.node.get_our_node_id(), &chan_msgs.0.unwrap());
+ node_a.node.handle_channel_ready(node_b.node.get_our_node_id(), &chan_msgs.0.unwrap());
let announcement_event = node_a.node.get_and_clear_pending_msg_events();
if !announcement_event.is_empty() {
assert_eq!(announcement_event.len(), 1);
}
if pending_raa.0 {
assert!(chan_msgs.3 == RAACommitmentOrder::RevokeAndACKFirst);
- node_a.node.handle_revoke_and_ack(&node_b.node.get_our_node_id(), &chan_msgs.1.unwrap());
+ node_a.node.handle_revoke_and_ack(node_b.node.get_our_node_id(), &chan_msgs.1.unwrap());
assert!(node_a.node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(node_a, 1);
} else {
assert_eq!(commitment_update.update_fail_htlcs.len(), pending_htlc_fails.0 + pending_cell_htlc_fails.0);
assert!(commitment_update.update_fail_malformed_htlcs.is_empty());
for update_add in commitment_update.update_add_htlcs {
- node_a.node.handle_update_add_htlc(&node_b.node.get_our_node_id(), &update_add);
+ node_a.node.handle_update_add_htlc(node_b.node.get_our_node_id(), &update_add);
}
for update_fulfill in commitment_update.update_fulfill_htlcs {
- node_a.node.handle_update_fulfill_htlc(&node_b.node.get_our_node_id(), &update_fulfill);
+ node_a.node.handle_update_fulfill_htlc(node_b.node.get_our_node_id(), &update_fulfill);
}
for update_fail in commitment_update.update_fail_htlcs {
- node_a.node.handle_update_fail_htlc(&node_b.node.get_our_node_id(), &update_fail);
+ node_a.node.handle_update_fail_htlc(node_b.node.get_our_node_id(), &update_fail);
}
if !pending_responding_commitment_signed.0 {
commitment_signed_dance!(node_a, node_b, commitment_update.commitment_signed, false);
} else {
- node_a.node.handle_commitment_signed(&node_b.node.get_our_node_id(), &commitment_update.commitment_signed);
+ node_a.node.handle_commitment_signed(node_b.node.get_our_node_id(), &commitment_update.commitment_signed);
check_added_monitors!(node_a, 1);
let as_revoke_and_ack = get_event_msg!(node_a, MessageSendEvent::SendRevokeAndACK, node_b.node.get_our_node_id());
// No commitment_signed so get_event_msg's assert(len == 1) passes
- node_b.node.handle_revoke_and_ack(&node_a.node.get_our_node_id(), &as_revoke_and_ack);
+ node_b.node.handle_revoke_and_ack(node_a.node.get_our_node_id(), &as_revoke_and_ack);
assert!(node_b.node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(node_b, if pending_responding_commitment_signed_dup_monitor.0 { 0 } else { 1 });
}
for chan_msgs in resp_2.drain(..) {
if send_channel_ready.1 {
- node_b.node.handle_channel_ready(&node_a.node.get_our_node_id(), &chan_msgs.0.unwrap());
+ node_b.node.handle_channel_ready(node_a.node.get_our_node_id(), &chan_msgs.0.unwrap());
let announcement_event = node_b.node.get_and_clear_pending_msg_events();
if !announcement_event.is_empty() {
assert_eq!(announcement_event.len(), 1);
}
if pending_raa.1 {
assert!(chan_msgs.3 == RAACommitmentOrder::RevokeAndACKFirst);
- node_b.node.handle_revoke_and_ack(&node_a.node.get_our_node_id(), &chan_msgs.1.unwrap());
+ node_b.node.handle_revoke_and_ack(node_a.node.get_our_node_id(), &chan_msgs.1.unwrap());
assert!(node_b.node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(node_b, 1);
} else {
assert_eq!(commitment_update.update_fail_htlcs.len(), pending_htlc_fails.1 + pending_cell_htlc_fails.1);
assert!(commitment_update.update_fail_malformed_htlcs.is_empty());
for update_add in commitment_update.update_add_htlcs {
- node_b.node.handle_update_add_htlc(&node_a.node.get_our_node_id(), &update_add);
+ node_b.node.handle_update_add_htlc(node_a.node.get_our_node_id(), &update_add);
}
for update_fulfill in commitment_update.update_fulfill_htlcs {
- node_b.node.handle_update_fulfill_htlc(&node_a.node.get_our_node_id(), &update_fulfill);
+ node_b.node.handle_update_fulfill_htlc(node_a.node.get_our_node_id(), &update_fulfill);
}
for update_fail in commitment_update.update_fail_htlcs {
- node_b.node.handle_update_fail_htlc(&node_a.node.get_our_node_id(), &update_fail);
+ node_b.node.handle_update_fail_htlc(node_a.node.get_our_node_id(), &update_fail);
}
if !pending_responding_commitment_signed.1 {
commitment_signed_dance!(node_b, node_a, commitment_update.commitment_signed, false);
} else {
- node_b.node.handle_commitment_signed(&node_a.node.get_our_node_id(), &commitment_update.commitment_signed);
+ node_b.node.handle_commitment_signed(node_a.node.get_our_node_id(), &commitment_update.commitment_signed);
check_added_monitors!(node_b, 1);
let bs_revoke_and_ack = get_event_msg!(node_b, MessageSendEvent::SendRevokeAndACK, node_a.node.get_our_node_id());
// No commitment_signed so get_event_msg's assert(len == 1) passes
- node_a.node.handle_revoke_and_ack(&node_b.node.get_our_node_id(), &bs_revoke_and_ack);
+ node_a.node.handle_revoke_and_ack(node_b.node.get_our_node_id(), &bs_revoke_and_ack);
assert!(node_a.node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(node_a, if pending_responding_commitment_signed_dup_monitor.1 { 0 } else { 1 });
}
*override_config,
).unwrap();
let open_channel_msg = get_event_msg!(funding_node, MessageSendEvent::SendOpenChannel, other_node.node.get_our_node_id());
- other_node.node.handle_open_channel(&funding_node.node.get_our_node_id(), &open_channel_msg);
+ other_node.node.handle_open_channel(funding_node.node.get_our_node_id(), &open_channel_msg);
let accept_channel_msg = get_event_msg!(other_node, MessageSendEvent::SendAcceptChannel, funding_node.node.get_our_node_id());
- funding_node.node.handle_accept_channel(&other_node.node.get_our_node_id(), &accept_channel_msg);
+ funding_node.node.handle_accept_channel(other_node.node.get_our_node_id(), &accept_channel_msg);
// Create the corresponding funding output.
let events = funding_node.node.get_and_clear_pending_events();
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 1_000_000, 0, 42, None, None).unwrap();
let open_chan = 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(), &open_chan);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_chan);
let accept_chan = 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(), &accept_chan);
+ nodes[0].node.handle_accept_channel(nodes[1].node.get_our_node_id(), &accept_chan);
let (temp_chan_id, tx, funding_output) =
create_funding_transaction(&nodes[0], &nodes[1].node.get_our_node_id(), 1_000_000, 42);
let new_chan_id = ChannelId::v1_from_funding_outpoint(funding_output);
nodes[0].node.funding_transaction_generated(temp_chan_id, nodes[1].node.get_our_node_id(), tx).unwrap();
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
check_closed_events(&nodes[0], &[ExpectedCloseEvent::from_id_reason(new_chan_id, true, ClosureReason::DisconnectedPeer)]);
// After ddf75afd16 we'd panic on reconnection if we exchanged funding info, so test that
// explicitly here.
- nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init {
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).unwrap();
assert_eq!(nodes[0].node.get_and_clear_pending_msg_events(), Vec::new());
// Test helper that asserts we get the correct error string given a mutator
// that supposedly makes the channel open message insane
let insane_open_helper = |expected_error_str: &str, message_mutator: fn(msgs::OpenChannel) -> msgs::OpenChannel| {
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &message_mutator(open_channel_message.clone()));
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &message_mutator(open_channel_message.clone()));
let msg_events = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(msg_events.len(), 1);
let expected_regex = regex::Regex::new(expected_error_str).unwrap();
open_channel_message.channel_reserve_satoshis = 0;
open_channel_message.common_fields.max_htlc_value_in_flight_msat = 100_000_000;
}
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &open_channel_message);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel_message);
// Extract the channel accept message from node1 to node0
let mut accept_channel_message = get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id());
accept_channel_message.channel_reserve_satoshis = 0;
accept_channel_message.common_fields.max_htlc_value_in_flight_msat = 100_000_000;
}
- nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), &accept_channel_message);
+ nodes[0].node.handle_accept_channel(nodes[1].node.get_our_node_id(), &accept_channel_message);
{
let sender_node = if send_from_initiator { &nodes[1] } else { &nodes[0] };
let counterparty_node = if send_from_initiator { &nodes[0] } else { &nodes[1] };
_ => panic!("Unexpected event"),
};
- nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), update_msg.unwrap());
+ nodes[1].node.handle_update_fee(nodes[0].node.get_our_node_id(), update_msg.unwrap());
// ...but before it's delivered, nodes[1] starts to send a payment back to nodes[0]...
let (route, our_payment_hash, _, our_payment_secret) = get_route_and_payment_hash!(nodes[1], nodes[0], 40000);
assert_eq!(payment_event.msgs.len(), 1);
// ...now when the messages get delivered everyone should be happy
- nodes[0].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &payment_event.msgs[0]);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &payment_event.commitment_msg); // (2)
+ nodes[0].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &payment_event.commitment_msg); // (2)
let as_revoke_and_ack = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
// nodes[0] is awaiting nodes[1] revoke_and_ack so get_event_msg's assert(len == 1) passes
check_added_monitors!(nodes[0], 1);
// deliver(1), generate (3):
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), commitment_signed);
let bs_revoke_and_ack = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
// nodes[1] is awaiting nodes[0] revoke_and_ack so get_event_msg's assert(len == 1) passes
check_added_monitors!(nodes[1], 1);
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_revoke_and_ack); // deliver (2)
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_revoke_and_ack); // deliver (2)
let bs_update = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
assert!(bs_update.update_add_htlcs.is_empty()); // (4)
assert!(bs_update.update_fulfill_htlcs.is_empty()); // (4)
assert!(bs_update.update_fee.is_none()); // (4)
check_added_monitors!(nodes[1], 1);
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_revoke_and_ack); // deliver (3)
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_revoke_and_ack); // deliver (3)
let as_update = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
assert!(as_update.update_add_htlcs.is_empty()); // (5)
assert!(as_update.update_fulfill_htlcs.is_empty()); // (5)
assert!(as_update.update_fee.is_none()); // (5)
check_added_monitors!(nodes[0], 1);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_update.commitment_signed); // deliver (4)
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_update.commitment_signed); // deliver (4)
let as_second_revoke = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
// only (6) so get_event_msg's assert(len == 1) passes
check_added_monitors!(nodes[0], 1);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_update.commitment_signed); // deliver (5)
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_update.commitment_signed); // deliver (5)
let bs_second_revoke = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
check_added_monitors!(nodes[1], 1);
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_second_revoke);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_second_revoke);
check_added_monitors!(nodes[0], 1);
let events_2 = nodes[0].node.get_and_clear_pending_events();
_ => panic!("Unexpected event"),
}
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_second_revoke); // deliver (6)
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_second_revoke); // deliver (6)
check_added_monitors!(nodes[1], 1);
}
_ => panic!("Unexpected event"),
};
- nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), update_msg.unwrap());
+ nodes[1].node.handle_update_fee(nodes[0].node.get_our_node_id(), update_msg.unwrap());
// ...but before it's delivered, nodes[1] starts to send a payment back to nodes[0]...
let (route, our_payment_hash, _, our_payment_secret) = get_route_and_payment_hash!(nodes[1], nodes[0], 40000);
assert_eq!(payment_event.msgs.len(), 1);
// ...now when the messages get delivered everyone should be happy
- nodes[0].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &payment_event.msgs[0]);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &payment_event.commitment_msg); // (2)
+ nodes[0].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &payment_event.commitment_msg); // (2)
let as_revoke_msg = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
// nodes[0] is awaiting nodes[1] revoke_and_ack so get_event_msg's assert(len == 1) passes
check_added_monitors!(nodes[0], 1);
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_revoke_msg); // deliver (2)
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_revoke_msg); // deliver (2)
check_added_monitors!(nodes[1], 1);
// We can't continue, sadly, because our (1) now has a bogus signature
};
// Deliver first update_fee/commitment_signed pair, generating (1) and (2):
- nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), update_msg_1);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), commitment_signed_1);
+ nodes[1].node.handle_update_fee(nodes[0].node.get_our_node_id(), update_msg_1);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), commitment_signed_1);
let (bs_revoke_msg, bs_commitment_signed) = get_revoke_commit_msgs!(nodes[1], nodes[0].node.get_our_node_id());
check_added_monitors!(nodes[1], 1);
feerate_per_kw: (initial_feerate + 30) as u32,
};
- nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), &update_msg_2);
+ nodes[1].node.handle_update_fee(nodes[0].node.get_our_node_id(), &update_msg_2);
update_msg_2.feerate_per_kw = (initial_feerate + 40) as u32;
// Deliver (3)
- nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), &update_msg_2);
+ nodes[1].node.handle_update_fee(nodes[0].node.get_our_node_id(), &update_msg_2);
// Deliver (1), generating (3) and (4)
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_revoke_msg);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_revoke_msg);
let as_second_update = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
check_added_monitors!(nodes[0], 1);
assert!(as_second_update.update_add_htlcs.is_empty());
assert_eq!(as_second_update.update_fee.as_ref().unwrap().feerate_per_kw, update_msg_2.feerate_per_kw);
// Deliver (2) commitment_signed
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_commitment_signed);
let as_revoke_msg = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
check_added_monitors!(nodes[0], 1);
// No commitment_signed so get_event_msg's assert(len == 1) passes
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_revoke_msg);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_revoke_msg);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[1], 1);
// Delever (4)
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_second_update.commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_second_update.commitment_signed);
let (bs_second_revoke, bs_second_commitment) = get_revoke_commit_msgs!(nodes[1], nodes[0].node.get_our_node_id());
check_added_monitors!(nodes[1], 1);
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_second_revoke);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_second_revoke);
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[0], 1);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_second_commitment);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_second_commitment);
let as_second_revoke = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
// No commitment_signed so get_event_msg's assert(len == 1) passes
check_added_monitors!(nodes[0], 1);
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_second_revoke);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_second_revoke);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[1], 1);
}
let open_channel = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
if steps & 0x0f == 1 { return; }
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &open_channel);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel);
let accept_channel = get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id());
if steps & 0x0f == 2 { return; }
- nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), &accept_channel);
+ nodes[0].node.handle_accept_channel(nodes[1].node.get_our_node_id(), &accept_channel);
let (temporary_channel_id, tx, funding_output) = create_funding_transaction(&nodes[0], &nodes[1].node.get_our_node_id(), 100000, 42);
let funding_created = get_event_msg!(nodes[0], MessageSendEvent::SendFundingCreated, nodes[1].node.get_our_node_id());
if steps & 0x0f == 4 { return; }
- nodes[1].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &funding_created);
+ nodes[1].node.handle_funding_created(nodes[0].node.get_our_node_id(), &funding_created);
{
let mut added_monitors = nodes[1].chain_monitor.added_monitors.lock().unwrap();
assert_eq!(added_monitors.len(), 1);
let funding_signed = get_event_msg!(nodes[1], MessageSendEvent::SendFundingSigned, nodes[0].node.get_our_node_id());
if steps & 0x0f == 5 { return; }
- nodes[0].node.handle_funding_signed(&nodes[1].node.get_our_node_id(), &funding_signed);
+ nodes[0].node.handle_funding_signed(nodes[1].node.get_our_node_id(), &funding_signed);
{
let mut added_monitors = nodes[0].chain_monitor.added_monitors.lock().unwrap();
assert_eq!(added_monitors.len(), 1);
},
_ => panic!("Unexpected event"),
};
- nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), update_msg.unwrap());
+ nodes[1].node.handle_update_fee(nodes[0].node.get_our_node_id(), update_msg.unwrap());
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), commitment_signed);
let (revoke_msg, commitment_signed) = get_revoke_commit_msgs!(nodes[1], nodes[0].node.get_our_node_id());
check_added_monitors!(nodes[1], 1);
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &revoke_msg);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &revoke_msg);
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[0], 1);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &commitment_signed);
let revoke_msg = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
// No commitment_signed so get_event_msg's assert(len == 1) passes
check_added_monitors!(nodes[0], 1);
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &revoke_msg);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &revoke_msg);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[1], 1);
}
check_added_monitors!(nodes[0], 1);
let update_msg = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), &update_msg.update_fee.unwrap());
+ nodes[1].node.handle_update_fee(nodes[0].node.get_our_node_id(), &update_msg.update_fee.unwrap());
commitment_signed_dance!(nodes[1], nodes[0], update_msg.commitment_signed, false);
feerate_per_kw: non_buffer_feerate + 4,
};
- nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), &update_fee);
+ nodes[1].node.handle_update_fee(nodes[0].node.get_our_node_id(), &update_fee);
//While producing the commitment_signed response after handling a received update_fee request the
//check to see if the funder, who sent the update_fee request, can afford the new fee (funder_balance >= fee+channel_reserve)
//Should produce and error.
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &commit_signed_msg);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &commit_signed_msg);
nodes[1].logger.assert_log_contains("lightning::ln::channelmanager", "Funding remote cannot afford proposed new fee", 3);
check_added_monitors!(nodes[1], 1);
check_closed_broadcast!(nodes[1], true);
},
_ => panic!("Unexpected event"),
};
- nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), update_msg.unwrap());
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), commitment_signed);
+ nodes[1].node.handle_update_fee(nodes[0].node.get_our_node_id(), update_msg.unwrap());
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), commitment_signed);
let (revoke_msg, commitment_signed) = get_revoke_commit_msgs!(nodes[1], nodes[0].node.get_our_node_id());
check_added_monitors!(nodes[1], 1);
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
// node[1] has nothing to do
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &revoke_msg);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &revoke_msg);
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[0], 1);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &commitment_signed);
let revoke_msg = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
// No commitment_signed so get_event_msg's assert(len == 1) passes
check_added_monitors!(nodes[0], 1);
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &revoke_msg);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &revoke_msg);
check_added_monitors!(nodes[1], 1);
// AwaitingRemoteRevoke ends here
assert_eq!(commitment_update.update_fail_malformed_htlcs.len(), 0);
assert_eq!(commitment_update.update_fee.is_none(), true);
- nodes[0].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &commitment_update.update_add_htlcs[0]);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &commitment_update.commitment_signed);
+ nodes[0].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &commitment_update.update_add_htlcs[0]);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &commitment_update.commitment_signed);
check_added_monitors!(nodes[0], 1);
let (revoke, commitment_signed) = get_revoke_commit_msgs!(nodes[0], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &revoke);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &revoke);
check_added_monitors!(nodes[1], 1);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &commitment_signed);
check_added_monitors!(nodes[1], 1);
let revoke = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
// No commitment_signed so get_event_msg's assert(len == 1) passes
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &revoke);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &revoke);
check_added_monitors!(nodes[0], 1);
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
},
_ => panic!("Unexpected event"),
};
- nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), update_msg.unwrap());
+ nodes[1].node.handle_update_fee(nodes[0].node.get_our_node_id(), update_msg.unwrap());
// Generate (2) and (3):
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), commitment_signed);
let (revoke_msg, commitment_signed_0) = get_revoke_commit_msgs!(nodes[1], nodes[0].node.get_our_node_id());
check_added_monitors!(nodes[1], 1);
// Deliver (2):
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &revoke_msg);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &revoke_msg);
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[0], 1);
_ => panic!("Unexpected event"),
};
- nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), update_msg.unwrap());
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), commitment_signed);
+ nodes[1].node.handle_update_fee(nodes[0].node.get_our_node_id(), update_msg.unwrap());
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), commitment_signed);
check_added_monitors!(nodes[1], 1);
// ... creating (5)
let revoke_msg = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
// No commitment_signed so get_event_msg's assert(len == 1) passes
// Handle (3), creating (6):
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &commitment_signed_0);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &commitment_signed_0);
check_added_monitors!(nodes[0], 1);
let revoke_msg_0 = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
// No commitment_signed so get_event_msg's assert(len == 1) passes
// Deliver (5):
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &revoke_msg);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &revoke_msg);
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[0], 1);
// Deliver (6), creating (7):
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &revoke_msg_0);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &revoke_msg_0);
let commitment_update = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
assert!(commitment_update.update_add_htlcs.is_empty());
assert!(commitment_update.update_fulfill_htlcs.is_empty());
check_added_monitors!(nodes[1], 1);
// Deliver (7)
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &commitment_update.commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &commitment_update.commitment_signed);
check_added_monitors!(nodes[0], 1);
let revoke_msg = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
// No commitment_signed so get_event_msg's assert(len == 1) passes
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &revoke_msg);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &revoke_msg);
check_added_monitors!(nodes[1], 1);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
let payment_event = SendEvent::from_event(events.pop().unwrap());
assert_eq!(payment_event.node_id, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
// We have to forward pending HTLCs twice - once tries to forward the payment forward (and
// fails), the second will process the resulting failure and fail the HTLC backward.
check_added_monitors!(nodes[1], 1);
let bs_fail_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &bs_fail_updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &bs_fail_updates.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], bs_fail_updates.commitment_signed, false, true);
expect_payment_failed_with_update!(nodes[0], payment_hash_2, false, chan_2.0.contents.short_channel_id, false);
// Now forward all the pending HTLCs and claim them back
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &initial_payment_event.msgs[0]);
- nodes[2].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &initial_payment_event.commitment_msg);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &initial_payment_event.msgs[0]);
+ nodes[2].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &initial_payment_event.commitment_msg);
check_added_monitors!(nodes[2], 1);
let (bs_revoke_and_ack, bs_commitment_signed) = get_revoke_commit_msgs!(nodes[2], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[2].node.get_our_node_id(), &bs_revoke_and_ack);
+ nodes[1].node.handle_revoke_and_ack(nodes[2].node.get_our_node_id(), &bs_revoke_and_ack);
check_added_monitors!(nodes[1], 1);
let as_updates = get_htlc_update_msgs!(nodes[1], nodes[2].node.get_our_node_id());
- nodes[1].node.handle_commitment_signed(&nodes[2].node.get_our_node_id(), &bs_commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[2].node.get_our_node_id(), &bs_commitment_signed);
check_added_monitors!(nodes[1], 1);
let as_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[2].node.get_our_node_id());
for ref update in as_updates.update_add_htlcs.iter() {
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), update);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), update);
}
- nodes[2].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &as_updates.commitment_signed);
+ nodes[2].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &as_updates.commitment_signed);
check_added_monitors!(nodes[2], 1);
- nodes[2].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &as_raa);
+ nodes[2].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &as_raa);
check_added_monitors!(nodes[2], 1);
let (bs_revoke_and_ack, bs_commitment_signed) = get_revoke_commit_msgs!(nodes[2], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[2].node.get_our_node_id(), &bs_revoke_and_ack);
+ nodes[1].node.handle_revoke_and_ack(nodes[2].node.get_our_node_id(), &bs_revoke_and_ack);
check_added_monitors!(nodes[1], 1);
- nodes[1].node.handle_commitment_signed(&nodes[2].node.get_our_node_id(), &bs_commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[2].node.get_our_node_id(), &bs_commitment_signed);
check_added_monitors!(nodes[1], 1);
let as_final_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[2].node.get_our_node_id());
- nodes[2].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &as_final_raa);
+ nodes[2].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &as_final_raa);
check_added_monitors!(nodes[2], 1);
expect_pending_htlcs_forwardable!(nodes[2]);
blinding_point: None,
};
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &msg);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &msg);
// Now manually create the commitment_signed message corresponding to the update_add
// nodes[0] just sent. In the code for construction of this message, "local" refers
};
// Send the commitment_signed message to the nodes[1].
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &commit_signed_msg);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &commit_signed_msg);
let _ = nodes[1].node.get_and_clear_pending_msg_events();
// Send the RAA to nodes[1].
#[cfg(taproot)]
next_local_nonce: None,
};
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &raa_msg);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &raa_msg);
let events = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
blinding_point: None,
};
- nodes[0].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &msg);
+ nodes[0].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &msg);
// Check that the payment failed and the channel is closed in response to the malicious UpdateAdd.
nodes[0].logger.assert_log_contains("lightning::ln::channelmanager", "Cannot accept HTLC that would put our balance under counterparty-announced channel reserve value", 3);
assert_eq!(nodes[0].node.list_channels().len(), 0);
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100_000, push_amt, 42, None, None).unwrap();
let mut open_channel_msg = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
open_channel_msg.push_msat += 1;
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &open_channel_msg);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel_msg);
let msg_events = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(msg_events.len(), 1);
assert_eq!(events.len(), 1);
SendEvent::from_event(events.remove(0))
};
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event_1.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event_1.msgs[0]);
// Attempt to trigger a channel reserve violation --> payment failure.
let commit_tx_fee_2_htlcs = commit_tx_fee_msat(feerate, 2, &channel_type_features);
blinding_point: None,
};
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &msg);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &msg);
// Check that the payment failed and the channel is closed in response to the malicious UpdateAdd.
nodes[1].logger.assert_log_contains("lightning::ln::channelmanager", "Remote HTLC add would put them under remote reserve value", 3);
assert_eq!(nodes[1].node.list_channels().len(), 1);
assert_eq!(events.len(), 1);
SendEvent::from_event(events.remove(0))
};
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event_1.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event_1.msgs[0]);
// channel reserve test with htlc pending output > 0
let recv_value_2 = stat01.value_to_self_msat - amt_msat_1 - stat01.channel_reserve_msat - total_fee_msat - commit_tx_fee_2_htlcs;
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
// flush the pending htlc
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &payment_event_1.commitment_msg);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &payment_event_1.commitment_msg);
let (as_revoke_and_ack, as_commitment_signed) = get_revoke_commit_msgs!(nodes[1], nodes[0].node.get_our_node_id());
check_added_monitors!(nodes[1], 1);
// the pending htlc should be promoted to committed
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &as_revoke_and_ack);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &as_revoke_and_ack);
check_added_monitors!(nodes[0], 1);
let commitment_update_2 = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &as_commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &as_commitment_signed);
let bs_revoke_and_ack = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
// No commitment_signed so get_event_msg's assert(len == 1) passes
check_added_monitors!(nodes[0], 1);
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &bs_revoke_and_ack);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &bs_revoke_and_ack);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[1], 1);
expect_pending_htlcs_forwardable!(nodes[1]);
let ref payment_event_11 = expect_forward!(nodes[1]);
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &payment_event_11.msgs[0]);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &payment_event_11.msgs[0]);
commitment_signed_dance!(nodes[2], nodes[1], payment_event_11.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[2]);
// flush the htlcs in the holding cell
assert_eq!(commitment_update_2.update_add_htlcs.len(), 2);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &commitment_update_2.update_add_htlcs[0]);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &commitment_update_2.update_add_htlcs[1]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &commitment_update_2.update_add_htlcs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &commitment_update_2.update_add_htlcs[1]);
commitment_signed_dance!(nodes[1], nodes[0], &commitment_update_2.commitment_signed, false);
expect_pending_htlcs_forwardable!(nodes[1]);
let ref payment_event_3 = expect_forward!(nodes[1]);
assert_eq!(payment_event_3.msgs.len(), 2);
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &payment_event_3.msgs[0]);
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &payment_event_3.msgs[1]);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &payment_event_3.msgs[0]);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &payment_event_3.msgs[1]);
commitment_signed_dance!(nodes[2], nodes[1], &payment_event_3.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[2]);
check_added_monitors!(nodes[1], 1);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &bs_removes.update_fulfill_htlcs[0]);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_removes.commitment_signed);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &bs_removes.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_removes.commitment_signed);
check_added_monitors!(nodes[0], 1);
let as_raa = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
expect_payment_sent(&nodes[0], payment_preimage_1, None, false, false);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &send_1.msgs[0]);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &send_1.commitment_msg);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &send_1.msgs[0]);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &send_1.commitment_msg);
check_added_monitors!(nodes[1], 1);
// B is already AwaitingRAA, so cant generate a CS here
let bs_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_raa);
check_added_monitors!(nodes[1], 1);
let bs_cs = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_raa);
check_added_monitors!(nodes[0], 1);
let as_cs = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_cs.commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_cs.commitment_signed);
check_added_monitors!(nodes[1], 1);
let bs_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
// However, the RAA A generates here *does* fully resolve the HTLC from B's point of view (as A
// can no longer broadcast a commitment transaction with it and B has the preimage so can go
// on-chain as necessary).
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &bs_cs.update_fulfill_htlcs[0]);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_cs.commitment_signed);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &bs_cs.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_cs.commitment_signed);
check_added_monitors!(nodes[0], 1);
let as_raa = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
expect_payment_sent(&nodes[0], payment_preimage_2, None, false, false);
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_raa);
check_added_monitors!(nodes[1], 1);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
// Note that as this RAA was generated before the delivery of the update_fulfill it shouldn't
// resolve the second HTLC from A's point of view.
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_raa);
check_added_monitors!(nodes[0], 1);
expect_payment_path_successful!(nodes[0]);
let as_cs = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
SendEvent::from_event(events.remove(0))
};
- nodes[0].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &send_2.msgs[0]);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &send_2.commitment_msg);
+ nodes[0].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &send_2.msgs[0]);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &send_2.commitment_msg);
check_added_monitors!(nodes[0], 1);
let as_raa = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
// Now just resolve all the outstanding messages/HTLCs for completeness...
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_cs.commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_cs.commitment_signed);
check_added_monitors!(nodes[1], 1);
let bs_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_raa);
check_added_monitors!(nodes[1], 1);
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_raa);
check_added_monitors!(nodes[0], 1);
expect_payment_path_successful!(nodes[0]);
let as_cs = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_cs.commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_cs.commitment_signed);
check_added_monitors!(nodes[1], 1);
let bs_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_raa);
check_added_monitors!(nodes[0], 1);
expect_pending_htlcs_forwardable!(nodes[0]);
};
let node_id_4 = nodes[4].node.get_our_node_id();
let node_id_3 = nodes[3].node.get_our_node_id();
- nodes[3].gossip_sync.handle_channel_update(Some(&node_id_4), &close_chan_update_2).unwrap();
- nodes[4].gossip_sync.handle_channel_update(Some(&node_id_3), &close_chan_update_1).unwrap();
+ nodes[3].gossip_sync.handle_channel_update(Some(node_id_4), &close_chan_update_2).unwrap();
+ nodes[4].gossip_sync.handle_channel_update(Some(node_id_3), &close_chan_update_1).unwrap();
assert_eq!(nodes[3].node.list_channels().len(), 0);
assert_eq!(nodes[4].node.list_channels().len(), 0);
assert!(update_fail_malformed_htlcs.is_empty());
assert_eq!(nodes[0].node.get_our_node_id(), *node_id);
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], commitment_signed, false, true);
expect_payment_failed_with_update!(nodes[0], payment_hash, false, chan_2.0.contents.short_channel_id, true);
},
assert!(updates.update_fail_malformed_htlcs.is_empty());
assert_eq!(updates.update_fail_htlcs.len(), 1);
assert!(updates.update_fee.is_none());
- nodes[1].node.handle_update_fail_htlc(&nodes[2].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
+ nodes[1].node.handle_update_fail_htlc(nodes[2].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
let bs_raa = commitment_signed_dance!(nodes[1], nodes[2], updates.commitment_signed, false, true, false, true);
// Drop the last RAA from 3 -> 2
assert!(updates.update_fail_malformed_htlcs.is_empty());
assert_eq!(updates.update_fail_htlcs.len(), 1);
assert!(updates.update_fee.is_none());
- nodes[1].node.handle_update_fail_htlc(&nodes[2].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
- nodes[1].node.handle_commitment_signed(&nodes[2].node.get_our_node_id(), &updates.commitment_signed);
+ nodes[1].node.handle_update_fail_htlc(nodes[2].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
+ nodes[1].node.handle_commitment_signed(nodes[2].node.get_our_node_id(), &updates.commitment_signed);
check_added_monitors!(nodes[1], 1);
// Note that nodes[1] is in AwaitingRAA, so won't send a CS
let as_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[2].node.get_our_node_id());
- nodes[2].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &as_raa);
+ nodes[2].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &as_raa);
check_added_monitors!(nodes[2], 1);
nodes[2].node.fail_htlc_backwards(&third_payment_hash);
assert!(updates.update_fail_malformed_htlcs.is_empty());
assert_eq!(updates.update_fail_htlcs.len(), 1);
assert!(updates.update_fee.is_none());
- nodes[1].node.handle_update_fail_htlc(&nodes[2].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
+ nodes[1].node.handle_update_fail_htlc(nodes[2].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
// At this point first_payment_hash has dropped out of the latest two commitment
// transactions that nodes[1] is tracking...
- nodes[1].node.handle_commitment_signed(&nodes[2].node.get_our_node_id(), &updates.commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[2].node.get_our_node_id(), &updates.commitment_signed);
check_added_monitors!(nodes[1], 1);
// Note that nodes[1] is (still) in AwaitingRAA, so won't send a CS
let as_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[2].node.get_our_node_id());
- nodes[2].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &as_raa);
+ nodes[2].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &as_raa);
check_added_monitors!(nodes[2], 1);
// Add a fourth HTLC, this one will get sequestered away in nodes[1]'s holding cell waiting
check_added_monitors!(nodes[1], 0);
if deliver_bs_raa {
- nodes[1].node.handle_revoke_and_ack(&nodes[2].node.get_our_node_id(), &bs_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[2].node.get_our_node_id(), &bs_raa);
// One monitor for the new revocation preimage, no second on as we won't generate a new
// commitment transaction for nodes[0] until process_pending_htlc_forwards().
check_added_monitors!(nodes[1], 1);
assert!(update_fail_malformed_htlcs.is_empty());
assert_eq!(nodes[0].node.get_our_node_id(), *node_id);
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &update_fail_htlcs[0]);
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &update_fail_htlcs[1]);
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &update_fail_htlcs[2]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &update_fail_htlcs[1]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &update_fail_htlcs[2]);
commitment_signed_dance!(nodes[0], nodes[1], commitment_signed, false, true);
skimmed_fee_msat: None,
blinding_point: None,
};
- nodes[0].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &update_add_htlc);
+ nodes[0].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &update_add_htlc);
}
let events = nodes[0].node.get_and_clear_pending_events();
assert_eq!(events.len(), 3);
SendEvent::from_event(events.remove(0))
};
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[1]);
assert_eq!(payment_event.msgs.len(), 1);
check_added_monitors!(nodes[1], 1);
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &payment_event.msgs[0]);
- nodes[2].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &payment_event.commitment_msg);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[2].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &payment_event.commitment_msg);
check_added_monitors!(nodes[2], 1);
let (_, _) = get_revoke_commit_msgs!(nodes[2], nodes[1].node.get_our_node_id());
expect_payment_claimed!(nodes[1], payment_hash, 1_000_000);
check_added_monitors!(nodes[1], 1);
let claim_msgs = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &claim_msgs.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &claim_msgs.update_fulfill_htlcs[0]);
expect_payment_sent(&nodes[0], payment_preimage, None, false, false);
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
let mut reconnect_args = ReconnectArgs::new(&nodes[0], &nodes[1]);
reconnect_args.pending_htlc_claims.0 = 1;
// broadcasted, even though it's created by `nodes[0]`.
let expected_temporary_channel_id = nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 1_000_000, 500_000_000, 42, None, 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(), &open_channel);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &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(), &accept_channel);
+ nodes[0].node.handle_accept_channel(nodes[1].node.get_our_node_id(), &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);
assert_eq!(temporary_channel_id, expected_temporary_channel_id);
}
// The peers disconnect before the funding is broadcasted.
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
// The time for peers to reconnect expires.
for _ in 0..UNFUNDED_CHANNEL_AGE_LIMIT_TICKS {
create_announced_chan_between_nodes(&nodes, 0, 1);
create_announced_chan_between_nodes(&nodes, 1, 2);
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
let mut reconnect_args = ReconnectArgs::new(&nodes[0], &nodes[1]);
reconnect_args.send_channel_ready = (true, true);
reconnect_nodes(reconnect_args);
fail_payment(&nodes[0], &vec!(&nodes[1], &nodes[2]), payment_hash_2);
claim_payment(&nodes[0], &vec!(&nodes[1], &nodes[2]), payment_preimage_1);
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[1]));
let (payment_preimage_3, payment_hash_3, ..) = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 1000000);
let payment_hash_5 = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 1000000).1;
let payment_hash_6 = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 1000000).1;
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
claim_payment_along_route(
ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1], &nodes[2]]], payment_preimage_3)
if messages_delivered < 2 {
// Drop the payment_event messages, and let them get re-generated in reconnect_nodes!
} else {
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
if messages_delivered >= 3 {
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &payment_event.commitment_msg);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &payment_event.commitment_msg);
check_added_monitors!(nodes[1], 1);
let (bs_revoke_and_ack, bs_commitment_signed) = get_revoke_commit_msgs!(nodes[1], nodes[0].node.get_our_node_id());
if messages_delivered >= 4 {
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_revoke_and_ack);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_revoke_and_ack);
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[0], 1);
if messages_delivered >= 5 {
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_commitment_signed);
let as_revoke_and_ack = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
// No commitment_signed so get_event_msg's assert(len == 1) passes
check_added_monitors!(nodes[0], 1);
if messages_delivered >= 6 {
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_revoke_and_ack);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_revoke_and_ack);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[1], 1);
}
}
}
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
if messages_delivered < 3 {
if simulate_broken_lnd {
// lnd has a long-standing bug where they send a channel_ready prior to a
// in `reconnect_nodes` but we currently don't fail based on that.
//
// See-also <https://github.com/lightningnetwork/lnd/issues/4006>
- nodes[1].node.handle_channel_ready(&nodes[0].node.get_our_node_id(), &as_channel_ready.as_ref().unwrap().0);
+ nodes[1].node.handle_channel_ready(nodes[0].node.get_our_node_id(), &as_channel_ready.as_ref().unwrap().0);
}
// Even if the channel_ready messages get exchanged, as long as nothing further was
// received on either side, both sides will need to resend them.
};
}
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[1]));
nodes[1].node.process_pending_htlc_forwards();
};
if messages_delivered >= 1 {
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &update_fulfill_htlc);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &update_fulfill_htlc);
let events_4 = nodes[0].node.get_and_clear_pending_events();
assert_eq!(events_4.len(), 1);
}
if messages_delivered >= 2 {
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &commitment_signed);
check_added_monitors!(nodes[0], 1);
let (as_revoke_and_ack, as_commitment_signed) = get_revoke_commit_msgs!(nodes[0], nodes[1].node.get_our_node_id());
if messages_delivered >= 3 {
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_revoke_and_ack);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_revoke_and_ack);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[1], 1);
if messages_delivered >= 4 {
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_commitment_signed);
let bs_revoke_and_ack = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
// No commitment_signed so get_event_msg's assert(len == 1) passes
check_added_monitors!(nodes[1], 1);
if messages_delivered >= 5 {
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_revoke_and_ack);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_revoke_and_ack);
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[0], 1);
}
}
}
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
if messages_delivered < 2 {
let mut reconnect_args = ReconnectArgs::new(&nodes[0], &nodes[1]);
reconnect_args.pending_htlc_claims.0 = 1;
expect_payment_path_successful!(nodes[0]);
}
if messages_delivered <= 5 {
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
}
reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[1]));
// Ensure nodes[0] generates a channel_ready after the transactions_confirmed
let as_channel_ready = get_event_msg!(nodes[0], MessageSendEvent::SendChannelReady, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_channel_ready(&nodes[0].node.get_our_node_id(), &as_channel_ready);
+ nodes[1].node.handle_channel_ready(nodes[0].node.get_our_node_id(), &as_channel_ready);
}
#[test]
// Ensure nodes[0] generates a channel_ready after the transactions_confirmed
let as_channel_ready = get_event_msg!(nodes[0], MessageSendEvent::SendChannelReady, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_channel_ready(&nodes[0].node.get_our_node_id(), &as_channel_ready);
+ nodes[1].node.handle_channel_ready(nodes[0].node.get_our_node_id(), &as_channel_ready);
}
#[test]
// Ensure nodes[0] generates a channel_ready after the transactions_confirmed
let as_channel_ready = get_event_msg!(nodes[0], MessageSendEvent::SendChannelReady, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_channel_ready(&nodes[0].node.get_our_node_id(), &as_channel_ready);
+ nodes[1].node.handle_channel_ready(nodes[0].node.get_our_node_id(), &as_channel_ready);
}
#[test]
assert!(update_fail_malformed_htlcs.is_empty());
assert!(update_fee.is_none());
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &update_fulfill_htlcs[0]);
let events_3 = nodes[0].node.get_and_clear_pending_events();
assert_eq!(events_3.len(), 1);
match events_3[0] {
_ => panic!("Unexpected event"),
}
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), commitment_signed);
let _ = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
// No commitment_signed so get_event_msg's assert(len == 1) passes
check_added_monitors!(nodes[0], 1);
_ => panic!("Unexpected event"),
}
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
- nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init {
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).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 {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, false).unwrap();
let reestablish_2 = get_chan_reestablish_msgs!(nodes[1], nodes[0]);
assert_eq!(reestablish_2.len(), 1);
- nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &reestablish_2[0]);
+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &reestablish_2[0]);
let as_resp = handle_chan_reestablish_msgs!(nodes[0], nodes[1]);
- nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &reestablish_1[0]);
+ nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), &reestablish_1[0]);
let bs_resp = handle_chan_reestablish_msgs!(nodes[1], nodes[0]);
assert!(as_resp.0.is_none());
assert!(as_resp.2.as_ref().unwrap().update_fail_htlcs.is_empty());
assert!(as_resp.2.as_ref().unwrap().update_fail_malformed_htlcs.is_empty());
assert!(as_resp.2.as_ref().unwrap().update_fee.is_none());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &as_resp.2.as_ref().unwrap().update_add_htlcs[0]);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_resp.2.as_ref().unwrap().commitment_signed);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &as_resp.2.as_ref().unwrap().update_add_htlcs[0]);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_resp.2.as_ref().unwrap().commitment_signed);
let bs_revoke_and_ack = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
// No commitment_signed so get_event_msg's assert(len == 1) passes
check_added_monitors!(nodes[1], 1);
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), as_resp.1.as_ref().unwrap());
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), as_resp.1.as_ref().unwrap());
let bs_second_commitment_signed = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
assert!(bs_second_commitment_signed.update_add_htlcs.is_empty());
assert!(bs_second_commitment_signed.update_fulfill_htlcs.is_empty());
assert!(bs_second_commitment_signed.update_fee.is_none());
check_added_monitors!(nodes[1], 1);
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_revoke_and_ack);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_revoke_and_ack);
let as_commitment_signed = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
assert!(as_commitment_signed.update_add_htlcs.is_empty());
assert!(as_commitment_signed.update_fulfill_htlcs.is_empty());
assert!(as_commitment_signed.update_fee.is_none());
check_added_monitors!(nodes[0], 1);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_second_commitment_signed.commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_second_commitment_signed.commitment_signed);
let as_revoke_and_ack = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
// No commitment_signed so get_event_msg's assert(len == 1) passes
check_added_monitors!(nodes[0], 1);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_commitment_signed.commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_commitment_signed.commitment_signed);
let bs_second_revoke_and_ack = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
// No commitment_signed so get_event_msg's assert(len == 1) passes
check_added_monitors!(nodes[1], 1);
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_revoke_and_ack);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_revoke_and_ack);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[1], 1);
_ => panic!("Unexpected event"),
}
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_second_revoke_and_ack);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_second_revoke_and_ack);
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[0], 1);
assert!(htlc_timeout_updates.update_fail_malformed_htlcs.is_empty());
assert!(htlc_timeout_updates.update_fee.is_none());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &htlc_timeout_updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &htlc_timeout_updates.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], htlc_timeout_updates.commitment_signed, false);
// 100_000 msat as u64, followed by the height at which we failed back above
let mut expected_failure_data = (100_000 as u64).to_be_bytes().to_vec();
if forwarded_htlc {
check_added_monitors!(nodes[0], 1);
let payment_event = SendEvent::from_event(nodes[0].node.get_and_clear_pending_msg_events().remove(0));
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[1]);
}
assert_eq!(fail_commit.len(), 1);
match fail_commit[0] {
MessageSendEvent::UpdateHTLCs { updates: msgs::CommitmentUpdate { ref update_fail_htlcs, ref commitment_signed, .. }, .. } => {
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], commitment_signed, true, true);
},
_ => unreachable!(),
assert!(htlc_updates.update_fail_malformed_htlcs.is_empty());
check_added_monitors!(nodes[1], 1);
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &htlc_updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &htlc_updates.update_fail_htlcs[0]);
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
{
commitment_signed_dance!(nodes[0], nodes[1], &htlc_updates.commitment_signed, false, true);
assert!(updates.update_fail_malformed_htlcs.is_empty());
check_added_monitors!(nodes[1], 1);
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], &updates.commitment_signed, false);
expect_payment_sent(&nodes[0], our_payment_preimage, None, true, true);
}
check_added_monitors!(nodes[4], 1);
let four_removes = get_htlc_update_msgs!(nodes[4], nodes[3].node.get_our_node_id());
- nodes[3].node.handle_update_fail_htlc(&nodes[4].node.get_our_node_id(), &four_removes.update_fail_htlcs[0]);
- nodes[3].node.handle_update_fail_htlc(&nodes[4].node.get_our_node_id(), &four_removes.update_fail_htlcs[1]);
- nodes[3].node.handle_update_fail_htlc(&nodes[4].node.get_our_node_id(), &four_removes.update_fail_htlcs[2]);
- nodes[3].node.handle_update_fail_htlc(&nodes[4].node.get_our_node_id(), &four_removes.update_fail_htlcs[3]);
+ nodes[3].node.handle_update_fail_htlc(nodes[4].node.get_our_node_id(), &four_removes.update_fail_htlcs[0]);
+ nodes[3].node.handle_update_fail_htlc(nodes[4].node.get_our_node_id(), &four_removes.update_fail_htlcs[1]);
+ nodes[3].node.handle_update_fail_htlc(nodes[4].node.get_our_node_id(), &four_removes.update_fail_htlcs[2]);
+ nodes[3].node.handle_update_fail_htlc(nodes[4].node.get_our_node_id(), &four_removes.update_fail_htlcs[3]);
commitment_signed_dance!(nodes[3], nodes[4], four_removes.commitment_signed, false);
// Fail 3rd below-dust and 7th above-dust HTLCs
check_added_monitors!(nodes[5], 1);
let two_removes = get_htlc_update_msgs!(nodes[5], nodes[3].node.get_our_node_id());
- nodes[3].node.handle_update_fail_htlc(&nodes[5].node.get_our_node_id(), &two_removes.update_fail_htlcs[0]);
- nodes[3].node.handle_update_fail_htlc(&nodes[5].node.get_our_node_id(), &two_removes.update_fail_htlcs[1]);
+ nodes[3].node.handle_update_fail_htlc(nodes[5].node.get_our_node_id(), &two_removes.update_fail_htlcs[0]);
+ nodes[3].node.handle_update_fail_htlc(nodes[5].node.get_our_node_id(), &two_removes.update_fail_htlcs[1]);
commitment_signed_dance!(nodes[3], nodes[5], two_removes.commitment_signed, false);
let ds_prev_commitment_tx = get_local_commitment_txn!(nodes[3], chan_2_3.2);
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[3], failed_destinations_3);
check_added_monitors!(nodes[3], 1);
let six_removes = get_htlc_update_msgs!(nodes[3], nodes[2].node.get_our_node_id());
- nodes[2].node.handle_update_fail_htlc(&nodes[3].node.get_our_node_id(), &six_removes.update_fail_htlcs[0]);
- nodes[2].node.handle_update_fail_htlc(&nodes[3].node.get_our_node_id(), &six_removes.update_fail_htlcs[1]);
- nodes[2].node.handle_update_fail_htlc(&nodes[3].node.get_our_node_id(), &six_removes.update_fail_htlcs[2]);
- nodes[2].node.handle_update_fail_htlc(&nodes[3].node.get_our_node_id(), &six_removes.update_fail_htlcs[3]);
- nodes[2].node.handle_update_fail_htlc(&nodes[3].node.get_our_node_id(), &six_removes.update_fail_htlcs[4]);
- nodes[2].node.handle_update_fail_htlc(&nodes[3].node.get_our_node_id(), &six_removes.update_fail_htlcs[5]);
+ nodes[2].node.handle_update_fail_htlc(nodes[3].node.get_our_node_id(), &six_removes.update_fail_htlcs[0]);
+ nodes[2].node.handle_update_fail_htlc(nodes[3].node.get_our_node_id(), &six_removes.update_fail_htlcs[1]);
+ nodes[2].node.handle_update_fail_htlc(nodes[3].node.get_our_node_id(), &six_removes.update_fail_htlcs[2]);
+ nodes[2].node.handle_update_fail_htlc(nodes[3].node.get_our_node_id(), &six_removes.update_fail_htlcs[3]);
+ nodes[2].node.handle_update_fail_htlc(nodes[3].node.get_our_node_id(), &six_removes.update_fail_htlcs[4]);
+ nodes[2].node.handle_update_fail_htlc(nodes[3].node.get_our_node_id(), &six_removes.update_fail_htlcs[5]);
if deliver_last_raa {
commitment_signed_dance!(nodes[2], nodes[3], six_removes.commitment_signed, false);
} else {
assert_eq!(updates.update_fail_htlcs.len(), if announce_latest { 4 } else { 3 });
&nodes[1]
};
- target.node.handle_update_fail_htlc(&nodes[2].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
- target.node.handle_update_fail_htlc(&nodes[2].node.get_our_node_id(), &updates.update_fail_htlcs[1]);
- target.node.handle_update_fail_htlc(&nodes[2].node.get_our_node_id(), &updates.update_fail_htlcs[2]);
+ target.node.handle_update_fail_htlc(nodes[2].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
+ target.node.handle_update_fail_htlc(nodes[2].node.get_our_node_id(), &updates.update_fail_htlcs[1]);
+ target.node.handle_update_fail_htlc(nodes[2].node.get_our_node_id(), &updates.update_fail_htlcs[2]);
if announce_latest {
- target.node.handle_update_fail_htlc(&nodes[2].node.get_our_node_id(), &updates.update_fail_htlcs[3]);
+ target.node.handle_update_fail_htlc(nodes[2].node.get_our_node_id(), &updates.update_fail_htlcs[3]);
if *node_id == nodes[0].node.get_our_node_id() {
- target.node.handle_update_fail_htlc(&nodes[2].node.get_our_node_id(), &updates.update_fail_htlcs[4]);
+ target.node.handle_update_fail_htlc(nodes[2].node.get_our_node_id(), &updates.update_fail_htlcs[4]);
}
}
commitment_signed_dance!(target, nodes[2], updates.commitment_signed, false, true);
expect_payment_claimed!(nodes[1], payment_hash, if use_dust { 50000 } else { 3_000_000 });
let bs_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &bs_updates.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &bs_updates.update_fulfill_htlcs[0]);
expect_payment_sent(&nodes[0], payment_preimage, None, false, false);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_updates.commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_updates.commitment_signed);
check_added_monitors!(nodes[0], 1);
let as_updates = get_revoke_commit_msgs!(nodes[0], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_updates.0);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_updates.0);
check_added_monitors!(nodes[1], 1);
let starting_block = nodes[1].best_block_info();
check_added_monitors!(nodes[1], 1);
let bs_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &bs_updates.update_fail_htlcs[0]);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_updates.commitment_signed);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &bs_updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_updates.commitment_signed);
check_added_monitors!(nodes[0], 1);
let as_updates = get_revoke_commit_msgs!(nodes[0], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_updates.0);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_updates.0);
check_added_monitors!(nodes[1], 1);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_updates.1);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_updates.1);
check_added_monitors!(nodes[1], 1);
let bs_revoke_and_ack = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
if check_revoke_no_close {
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_revoke_and_ack);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_revoke_and_ack);
check_added_monitors!(nodes[0], 1);
}
let push_msat=10001;
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), channel_value_satoshis, push_msat, 42, None, None).unwrap();
let node0_to_1_send_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(), &node0_to_1_send_open_channel);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &node0_to_1_send_open_channel);
get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id());
// Create a second channel with the same random values. This used to panic due to a colliding
node0_to_1_send_open_channel.common_fields.dust_limit_satoshis = 547;
node0_to_1_send_open_channel.channel_reserve_satoshis = 100001;
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &node0_to_1_send_open_channel);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &node0_to_1_send_open_channel);
let events = nodes[1].node.get_and_clear_pending_msg_events();
let err_msg = match events[0] {
MessageSendEvent::HandleError { action: ErrorAction::SendErrorMessage { ref msg }, node_id: _ } => {
_ => panic!("Unexpected event"),
};
- nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), update_msg.unwrap());
+ nodes[1].node.handle_update_fee(nodes[0].node.get_our_node_id(), update_msg.unwrap());
let mut chan_stat = get_channel_value_stat!(nodes[0], nodes[1], chan.2);
let channel_reserve = chan_stat.channel_reserve_msat;
assert_eq!(chan_stat.holding_cell_outbound_amount_msat, max_can_send);
// Flush the pending fee update.
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), commitment_signed);
let (as_revoke_and_ack, _) = get_revoke_commit_msgs!(nodes[1], nodes[0].node.get_our_node_id());
check_added_monitors!(nodes[1], 1);
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &as_revoke_and_ack);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &as_revoke_and_ack);
check_added_monitors!(nodes[0], 1);
// Upon receipt of the RAA, there will be an attempt to resend the holding cell
_ => panic!("Unexpected event"),
};
- nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), update_msg.unwrap());
+ nodes[1].node.handle_update_fee(nodes[0].node.get_our_node_id(), update_msg.unwrap());
let mut chan_stat = get_channel_value_stat!(nodes[0], nodes[1], chan.2);
let channel_reserve = chan_stat.channel_reserve_msat;
assert_eq!(chan_stat.holding_cell_outbound_amount_msat, amt_1 + amt_2);
// Flush the pending fee update.
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), commitment_signed);
let (revoke_and_ack, commitment_signed) = get_revoke_commit_msgs!(nodes[1], nodes[0].node.get_our_node_id());
check_added_monitors!(nodes[1], 1);
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &revoke_and_ack);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &commitment_signed);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &revoke_and_ack);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &commitment_signed);
check_added_monitors!(nodes[0], 2);
// Upon receipt of the RAA, there will be an attempt to resend the holding cell HTLCs,
MessageSendEvent::SendRevokeAndACK { msg, .. } => msg,
_ => panic!("Unexpected event"),
};
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &raa);
check_added_monitors!(nodes[1], 1);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
let events = nodes[1].node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
expect_payment_claimed!(nodes[1], payment_hash_1, amt_1);
let update_msgs = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &update_msgs.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &update_msgs.update_fulfill_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], update_msgs.commitment_signed, false, true);
expect_payment_sent!(nodes[0], payment_preimage_1);
}
_ => panic!("Unexpected event"),
};
- nodes[2].node.handle_update_fee(&nodes[1].node.get_our_node_id(), update_msg.unwrap());
+ nodes[2].node.handle_update_fee(nodes[1].node.get_our_node_id(), update_msg.unwrap());
let mut chan_stat = get_channel_value_stat!(nodes[0], nodes[1], chan_0_1.2);
let channel_reserve = chan_stat.channel_reserve_msat;
SendEvent::from_event(events.remove(0))
};
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
check_added_monitors!(nodes[1], 0);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[1]);
assert_eq!(chan_stat.holding_cell_outbound_amount_msat, max_can_send);
// Flush the pending fee update.
- nodes[2].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), commitment_signed);
+ nodes[2].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), commitment_signed);
let (raa, commitment_signed) = get_revoke_commit_msgs!(nodes[2], nodes[1].node.get_our_node_id());
check_added_monitors!(nodes[2], 1);
- nodes[1].node.handle_revoke_and_ack(&nodes[2].node.get_our_node_id(), &raa);
- nodes[1].node.handle_commitment_signed(&nodes[2].node.get_our_node_id(), &commitment_signed);
+ nodes[1].node.handle_revoke_and_ack(nodes[2].node.get_our_node_id(), &raa);
+ nodes[1].node.handle_commitment_signed(nodes[2].node.get_our_node_id(), &commitment_signed);
check_added_monitors!(nodes[1], 2);
// A final RAA message is generated to finalize the fee update.
_ => panic!("Unexpected event"),
};
- nodes[2].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &raa_msg);
+ nodes[2].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &raa_msg);
check_added_monitors!(nodes[2], 1);
assert!(nodes[2].node.get_and_clear_pending_msg_events().is_empty());
};
// Pass the failure messages back to nodes[0].
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &fail_msg);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &commitment_signed);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &fail_msg);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &commitment_signed);
// Complete the HTLC failure+removal process.
let (raa, commitment_signed) = get_revoke_commit_msgs!(nodes[0], nodes[1].node.get_our_node_id());
check_added_monitors!(nodes[0], 1);
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &raa);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &commitment_signed);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &raa);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &commitment_signed);
check_added_monitors!(nodes[1], 2);
let final_raa_event = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(final_raa_event.len(), 1);
&MessageSendEvent::SendRevokeAndACK { ref msg, .. } => msg.clone(),
_ => panic!("Unexpected event"),
};
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &raa);
expect_payment_failed_with_update!(nodes[0], our_payment_hash, false, chan_1_2.0.contents.short_channel_id, false);
check_added_monitors!(nodes[0], 1);
}
let mut updates = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
updates.update_add_htlcs[0].amount_msat = 0;
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
nodes[1].logger.assert_log_contains("lightning::ln::channelmanager", "Remote side tried to send a 0-msat HTLC", 3);
check_closed_broadcast!(nodes[1], true).unwrap();
check_added_monitors!(nodes[1], 1);
}
SendEvent::from_event(events.remove(0))
};
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
check_added_monitors!(nodes[1], 0);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
check_added_monitors!(nodes[0], 1);
let mut updates = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
updates.update_add_htlcs[0].amount_msat = htlc_minimum_msat-1;
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
assert!(nodes[1].node.list_channels().is_empty());
let err_msg = check_closed_broadcast!(nodes[1], true).unwrap();
assert!(regex::Regex::new(r"Remote side tried to send less than our minimum HTLC value\. Lower limit: \(\d+\)\. Actual: \(\d+\)").unwrap().is_match(err_msg.data.as_str()));
// at this time channel-initiatee receivers are not required to enforce that senders
// respect the fee_spike_reserve.
updates.update_add_htlcs[0].amount_msat = max_can_send + commit_tx_fee_outbound + 1;
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
assert!(nodes[1].node.list_channels().is_empty());
let err_msg = check_closed_broadcast!(nodes[1], true).unwrap();
for i in 0..50 {
msg.htlc_id = i as u64;
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &msg);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &msg);
}
msg.htlc_id = (50) as u64;
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &msg);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &msg);
assert!(nodes[1].node.list_channels().is_empty());
let err_msg = check_closed_broadcast!(nodes[1], true).unwrap();
check_added_monitors!(nodes[0], 1);
let mut updates = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
updates.update_add_htlcs[0].amount_msat = get_channel_value_stat!(nodes[1], nodes[0], chan.2).counterparty_max_htlc_value_in_flight_msat + 1;
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
assert!(nodes[1].node.list_channels().is_empty());
let err_msg = check_closed_broadcast!(nodes[1], true).unwrap();
check_added_monitors!(nodes[0], 1);
let mut updates = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
updates.update_add_htlcs[0].cltv_expiry = 500000000;
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
assert!(nodes[1].node.list_channels().is_empty());
let err_msg = check_closed_broadcast!(nodes[1], true).unwrap();
RecipientOnionFields::secret_only(our_payment_secret), PaymentId(our_payment_hash.0)).unwrap();
check_added_monitors!(nodes[0], 1);
let updates = get_htlc_update_msgs!(nodes[0], 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_update_add_htlc(nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
//Disconnect and Reconnect
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
- nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init {
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).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 {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, false).unwrap();
let reestablish_2 = get_chan_reestablish_msgs!(nodes[1], nodes[0]);
assert_eq!(reestablish_2.len(), 1);
- nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &reestablish_2[0]);
+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &reestablish_2[0]);
handle_chan_reestablish_msgs!(nodes[0], nodes[1]);
- nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &reestablish_1[0]);
+ nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), &reestablish_1[0]);
handle_chan_reestablish_msgs!(nodes[1], nodes[0]);
//Resend HTLC
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
assert_eq!(updates.commitment_signed.htlc_signatures.len(), 1);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &updates.commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &updates.commitment_signed);
check_added_monitors!(nodes[1], 1);
let _bs_responses = get_revoke_commit_msgs!(nodes[1], nodes[0].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_update_add_htlc(nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
assert!(nodes[1].node.list_channels().is_empty());
let err_msg = check_closed_broadcast!(nodes[1], true).unwrap();
check_added_monitors!(nodes[0], 1);
let updates = get_htlc_update_msgs!(nodes[0], 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_update_add_htlc(nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
let update_msg = msgs::UpdateFulfillHTLC{
channel_id: chan.2,
payment_preimage: our_payment_preimage,
};
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &update_msg);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &update_msg);
assert!(nodes[0].node.list_channels().is_empty());
let err_msg = check_closed_broadcast!(nodes[0], true).unwrap();
RecipientOnionFields::secret_only(our_payment_secret), PaymentId(our_payment_hash.0)).unwrap();
check_added_monitors!(nodes[0], 1);
let updates = get_htlc_update_msgs!(nodes[0], 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_update_add_htlc(nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
let update_msg = msgs::UpdateFailHTLC{
channel_id: chan.2,
reason: msgs::OnionErrorPacket { data: Vec::new()},
};
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &update_msg);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &update_msg);
assert!(nodes[0].node.list_channels().is_empty());
let err_msg = check_closed_broadcast!(nodes[0], true).unwrap();
RecipientOnionFields::secret_only(our_payment_secret), PaymentId(our_payment_hash.0)).unwrap();
check_added_monitors!(nodes[0], 1);
let updates = get_htlc_update_msgs!(nodes[0], 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_update_add_htlc(nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
let update_msg = msgs::UpdateFailMalformedHTLC{
channel_id: chan.2,
htlc_id: 0,
failure_code: 0x8000,
};
- nodes[0].node.handle_update_fail_malformed_htlc(&nodes[1].node.get_our_node_id(), &update_msg);
+ nodes[0].node.handle_update_fail_malformed_htlc(nodes[1].node.get_our_node_id(), &update_msg);
assert!(nodes[0].node.list_channels().is_empty());
let err_msg = check_closed_broadcast!(nodes[0], true).unwrap();
update_fulfill_msg.htlc_id = 1;
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &update_fulfill_msg);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &update_fulfill_msg);
assert!(nodes[0].node.list_channels().is_empty());
let err_msg = check_closed_broadcast!(nodes[0], true).unwrap();
update_fulfill_msg.payment_preimage = PaymentPreimage([1; 32]);
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &update_fulfill_msg);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &update_fulfill_msg);
assert!(nodes[0].node.list_channels().is_empty());
let err_msg = check_closed_broadcast!(nodes[0], true).unwrap();
let mut updates = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
updates.update_add_htlcs[0].onion_routing_packet.version = 1; //Produce a malformed HTLC message
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
check_added_monitors!(nodes[1], 0);
commitment_signed_dance!(nodes[1], nodes[0], updates.commitment_signed, false, true);
}
};
update_msg.failure_code &= !0x8000;
- nodes[0].node.handle_update_fail_malformed_htlc(&nodes[1].node.get_our_node_id(), &update_msg);
+ nodes[0].node.handle_update_fail_malformed_htlc(nodes[1].node.get_our_node_id(), &update_msg);
assert!(nodes[0].node.list_channels().is_empty());
let err_msg = check_closed_broadcast!(nodes[0], true).unwrap();
assert_eq!(events.len(), 1);
SendEvent::from_event(events.remove(0))
};
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
check_added_monitors!(nodes[1], 0);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[1]);
//Second Hop
payment_event.msgs[0].onion_routing_packet.version = 1; //Produce a malformed HTLC message
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &payment_event.msgs[0]);
check_added_monitors!(nodes[2], 0);
commitment_signed_dance!(nodes[2], nodes[1], payment_event.commitment_msg, false, true);
}
};
- nodes[1].node.handle_update_fail_malformed_htlc(&nodes[2].node.get_our_node_id(), &update_msg.0);
+ nodes[1].node.handle_update_fail_malformed_htlc(nodes[2].node.get_our_node_id(), &update_msg.0);
check_added_monitors!(nodes[1], 0);
commitment_signed_dance!(nodes[1], nodes[2], update_msg.1, false, true);
SendEvent::from_node(&nodes[0])
};
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[1]);
check_added_monitors!(nodes[1], 1);
// Second Hop
payment_event.msgs[0].onion_routing_packet.version = 1; // Trigger an invalid_onion_version error
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &payment_event.msgs[0]);
check_added_monitors!(nodes[2], 0);
commitment_signed_dance!(nodes[2], nodes[1], payment_event.commitment_msg, false, true);
// Set the NODE bit (BADONION and PERM already set in invalid_onion_version error)
update_msg.failure_code |= 0x2000;
- nodes[1].node.handle_update_fail_malformed_htlc(&nodes[2].node.get_our_node_id(), &update_msg);
+ nodes[1].node.handle_update_fail_malformed_htlc(nodes[2].node.get_our_node_id(), &update_msg);
commitment_signed_dance!(nodes[1], nodes[2], updates.commitment_signed, false, true);
},
_ => panic!("Unexpected event"),
match events_4[0] {
MessageSendEvent::UpdateHTLCs { ref updates, .. } => {
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], updates.commitment_signed, false, true);
},
_ => panic!("Unexpected event"),
check_added_monitors!(nodes[1], 1);
let remove = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &remove.update_fail_htlcs[0]);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &remove.commitment_signed);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &remove.update_fail_htlcs[0]);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &remove.commitment_signed);
check_added_monitors!(nodes[0], 1);
// Cache one local commitment tx as lastest
// We test msg.to_self_delay <= config.their_to_self_delay is enforced in Chanel::accept_channel()
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 1000000, 1000000, 42, None, None).unwrap();
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &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(), &get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id()));
let mut accept_channel = get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id());
accept_channel.common_fields.to_self_delay = 200;
- nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), &accept_channel);
+ nodes[0].node.handle_accept_channel(nodes[1].node.get_our_node_id(), &accept_channel);
let reason_msg;
if let MessageSendEvent::HandleError { ref action, .. } = nodes[0].node.get_and_clear_pending_msg_events()[0] {
match action {
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
let mut payment_event = SendEvent::from_event(events.pop().unwrap());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
// Note that we first have to wait a random delay before processing the receipt of the HTLC,
};
check_added_monitors!(nodes[1], 1);
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &update_fail_htlc);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &update_fail_htlc);
commitment_signed_dance!(nodes[0], nodes[1], commitment_signed, false, true);
// 10_000 msat as u64, followed by a height of CHAN_CONFIRM_DEPTH as u32
create_announced_chan_between_nodes(&nodes, 0, 1);
// Disconnect peers
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
for _ in 0..DISABLE_GOSSIP_TICKS + 1 {
nodes[0].node.timer_tick_occurred();
}
}
// Reconnect peers
- nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init {
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).unwrap();
let reestablish_1 = get_chan_reestablish_msgs!(nodes[0], nodes[1]);
assert_eq!(reestablish_1.len(), 3);
- nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, false).unwrap();
let reestablish_2 = get_chan_reestablish_msgs!(nodes[1], nodes[0]);
assert_eq!(reestablish_2.len(), 3);
// Reestablish chan_1
- nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &reestablish_2[0]);
+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &reestablish_2[0]);
handle_chan_reestablish_msgs!(nodes[0], nodes[1]);
- nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &reestablish_1[0]);
+ nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), &reestablish_1[0]);
handle_chan_reestablish_msgs!(nodes[1], nodes[0]);
// Reestablish chan_2
- nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &reestablish_2[1]);
+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &reestablish_2[1]);
handle_chan_reestablish_msgs!(nodes[0], nodes[1]);
- nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &reestablish_1[1]);
+ nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), &reestablish_1[1]);
handle_chan_reestablish_msgs!(nodes[1], nodes[0]);
// Reestablish chan_3
- nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &reestablish_2[2]);
+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &reestablish_2[2]);
handle_chan_reestablish_msgs!(nodes[0], nodes[1]);
- nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &reestablish_1[2]);
+ nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), &reestablish_1[2]);
handle_chan_reestablish_msgs!(nodes[1], nodes[0]);
for _ in 0..ENABLE_GOSSIP_TICKS {
&SecretKey::from_slice(&keys.as_ref().release_commitment_secret(INITIAL_COMMITMENT_NUMBER - 2).unwrap()).unwrap());
}
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(),
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(),
&msgs::RevokeAndACK {
channel_id,
per_commitment_secret,
let res = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
assert_eq!(res.common_fields.htlc_minimum_msat, 1);
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &res);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &res);
let res = get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id());
assert_eq!(res.common_fields.htlc_minimum_msat, 1);
}
let temp_channel_id = nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 42, None, Some(manually_accept_conf)).unwrap();
let res = 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(), &res);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &res);
// Assert that `nodes[1]` has no `MessageSendEvent::SendAcceptChannel` in `msg_events` before
// accepting the inbound channel request.
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 42, None, Some(manually_accept_conf)).unwrap();
let res = 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(), &res);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &res);
// Assert that `nodes[1]` has no `MessageSendEvent::SendAcceptChannel` in `msg_events` before
// rejecting the inbound channel request.
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 42, None, Some(manually_accept_conf)).unwrap();
let res = 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(), &res);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &res);
// Assert that `nodes[1]` has no `MessageSendEvent::SendAcceptChannel` in `msg_events` before
// accepting the inbound channel request.
payment_event.msgs[0].onion_routing_packet = new_onion_packet;
}
- node.node.handle_update_add_htlc(&prev_node.node.get_our_node_id(), &payment_event.msgs[0]);
+ node.node.handle_update_add_htlc(prev_node.node.get_our_node_id(), &payment_event.msgs[0]);
check_added_monitors!(node, 0);
commitment_signed_dance!(node, prev_node, payment_event.commitment_msg, false);
expect_pending_htlcs_forwardable!(node);
check_added_monitors!(nodes[0], 1);
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
let mut payment_event = SendEvent::from_event(events.pop().unwrap());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
}
// Note that after leaving the above scope we have no knowledge of any arguments or return
check_added_monitors!(nodes[0], 1);
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
let payment_event = SendEvent::from_event(events.pop().unwrap());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
// We have to forward pending HTLCs once to process the receipt of the HTLC and then
let mut events = nodes[1].node.get_and_clear_pending_msg_events();
match events.pop().unwrap() {
MessageSendEvent::UpdateHTLCs { node_id: _, updates: msgs::CommitmentUpdate { update_fail_htlcs, commitment_signed, .. } } => {
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], commitment_signed, false);
},
_ => panic!("Unexpected event"),
let updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
assert_eq!(updates.update_fulfill_htlcs.len(), 1);
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
{
let mut node_0_per_peer_lock;
let mut node_0_peer_state_lock;
let updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
assert_eq!(updates.update_add_htlcs.len(), 1);
- nodes[0].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &updates.update_add_htlcs[0]);
+ nodes[0].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &updates.update_add_htlcs[0]);
{
let mut node_0_per_peer_lock;
let mut node_0_peer_state_lock;
// Create an initial channel
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 42, None, None).unwrap();
let mut open_chan_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(), &open_chan_msg);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_chan_msg);
let accept_chan_msg = 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(), &accept_chan_msg);
+ nodes[0].node.handle_accept_channel(nodes[1].node.get_our_node_id(), &accept_chan_msg);
// Move the first channel through the funding flow...
let (temporary_channel_id, tx, _) = create_funding_transaction(&nodes[0], &nodes[1].node.get_our_node_id(), 100000, 42);
let funding_created_msg = get_event_msg!(nodes[0], MessageSendEvent::SendFundingCreated, nodes[1].node.get_our_node_id());
let channel_id = ChannelId::v1_from_funding_outpoint(crate::chain::transaction::OutPoint { txid: funding_created_msg.funding_txid, index: funding_created_msg.funding_output_index });
- nodes[0].node.handle_error(&nodes[1].node.get_our_node_id(), &msgs::ErrorMessage { channel_id, data: "Hi".to_owned() });
+ nodes[0].node.handle_error(nodes[1].node.get_our_node_id(), &msgs::ErrorMessage { channel_id, data: "Hi".to_owned() });
assert!(nodes[0].chain_monitor.added_monitors.lock().unwrap().is_empty());
check_closed_event!(nodes[0], 2, ClosureReason::CounterpartyForceClosed { peer_msg: UntrustedString("Hi".to_string()) }, true,
[nodes[1].node.get_our_node_id()], 100000);
assert!(carol_updates.update_fee.is_none());
assert_eq!(carol_updates.update_fulfill_htlcs.len(), 1);
- nodes[1].node.handle_update_fulfill_htlc(&nodes[2].node.get_our_node_id(), &carol_updates.update_fulfill_htlcs[0]);
+ nodes[1].node.handle_update_fulfill_htlc(nodes[2].node.get_our_node_id(), &carol_updates.update_fulfill_htlcs[0]);
let went_onchain = go_onchain_before_fulfill || force_closing_node == 1;
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], if went_onchain { None } else { Some(1000) }, went_onchain, false);
// If Alice broadcasted but Bob doesn't know yet, here he prepares to tell her about the preimage.
_ => panic!("Unexpected event"),
};
}
- nodes[1].node.handle_commitment_signed(&nodes[2].node.get_our_node_id(), &carol_updates.commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[2].node.get_our_node_id(), &carol_updates.commitment_signed);
// One monitor update for the preimage to update the Bob<->Alice channel, one monitor update
// Carol<->Bob's updated commitment transaction info.
check_added_monitors!(nodes[1], 2);
_ => panic!("Unexpected event"),
};
- nodes[2].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bob_revocation);
+ nodes[2].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bob_revocation);
check_added_monitors!(nodes[2], 1);
- nodes[2].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bob_updates.commitment_signed);
+ nodes[2].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bob_updates.commitment_signed);
check_added_monitors!(nodes[2], 1);
let events = nodes[2].node.get_and_clear_pending_msg_events();
},
_ => panic!("Unexpected event"),
};
- nodes[1].node.handle_revoke_and_ack(&nodes[2].node.get_our_node_id(), &carol_revocation);
+ nodes[1].node.handle_revoke_and_ack(nodes[2].node.get_our_node_id(), &carol_revocation);
check_added_monitors!(nodes[1], 1);
// If this test requires the force-closed channel to not be on-chain until after the fulfill,
// Assert that `nodes[0]` can accept both `OpenChannel` requests, even though they use the same
// `temporary_channel_id` as they are from different peers.
- nodes[0].node.handle_open_channel(&nodes[1].node.get_our_node_id(), &open_chan_msg_chan_1_0);
+ nodes[0].node.handle_open_channel(nodes[1].node.get_our_node_id(), &open_chan_msg_chan_1_0);
{
let events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
}
}
- nodes[0].node.handle_open_channel(&nodes[2].node.get_our_node_id(), &open_chan_msg_chan_2_0);
+ nodes[0].node.handle_open_channel(nodes[2].node.get_our_node_id(), &open_chan_msg_chan_2_0);
{
let events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
nodes[2].node.funding_transaction_generated_unchecked(temp_chan_id_ca, nodes[0].node.get_our_node_id(), tx.clone(), funding_output.index).unwrap();
let funding_created_msg = get_event_msg!(nodes[2], MessageSendEvent::SendFundingCreated, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_funding_created(&nodes[2].node.get_our_node_id(), &funding_created_msg);
+ nodes[0].node.handle_funding_created(nodes[2].node.get_our_node_id(), &funding_created_msg);
get_event_msg!(nodes[0], MessageSendEvent::SendFundingSigned, nodes[2].node.get_our_node_id());
expect_channel_pending_event(&nodes[0], &nodes[2].node.get_our_node_id());
check_added_monitors!(nodes[0], 1);
// SendFundingCreated. However, when the peer responds with a funding_signed it will send the
// appropriate error message.
let as_funding_created = get_event_msg!(nodes[0], MessageSendEvent::SendFundingCreated, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &as_funding_created);
+ nodes[1].node.handle_funding_created(nodes[0].node.get_our_node_id(), &as_funding_created);
check_added_monitors!(nodes[1], 1);
expect_channel_pending_event(&nodes[1], &nodes[0].node.get_our_node_id());
let reason = ClosureReason::ProcessingError { err: format!("An existing channel using outpoint {} is open with peer {}", funding_output, nodes[2].node.get_our_node_id()), };
check_closed_events(&nodes[0], &[ExpectedCloseEvent::from_id_reason(ChannelId::v1_from_funding_outpoint(funding_output), true, reason)]);
let funding_signed = get_event_msg!(nodes[1], MessageSendEvent::SendFundingSigned, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_funding_signed(&nodes[1].node.get_our_node_id(), &funding_signed);
+ nodes[0].node.handle_funding_signed(nodes[1].node.get_our_node_id(), &funding_signed);
get_err_msg(&nodes[0], &nodes[1].node.get_our_node_id());
}
nodes[0].node.funding_transaction_generated(temp_chan_id, nodes[1].node.get_our_node_id(), tx.clone()).unwrap();
let mut funding_created_msg = get_event_msg!(nodes[0], MessageSendEvent::SendFundingCreated, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &funding_created_msg);
+ nodes[1].node.handle_funding_created(nodes[0].node.get_our_node_id(), &funding_created_msg);
let funding_signed_msg = get_event_msg!(nodes[1], MessageSendEvent::SendFundingSigned, nodes[0].node.get_our_node_id());
check_added_monitors!(nodes[1], 1);
expect_channel_pending_event(&nodes[1], &nodes[0].node.get_our_node_id());
- nodes[0].node.handle_funding_signed(&nodes[1].node.get_our_node_id(), &funding_signed_msg);
+ nodes[0].node.handle_funding_signed(nodes[1].node.get_our_node_id(), &funding_signed_msg);
// At this point, the channel should be closed, after having generated one monitor write (the
// watch_channel call which failed), but zero monitor updates.
check_added_monitors!(nodes[0], 1);
let mut open_chan_msg = get_event_msg!(nodes[2], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
let node_c_temp_chan_id = open_chan_msg.common_fields.temporary_channel_id;
open_chan_msg.common_fields.temporary_channel_id = real_channel_id;
- nodes[1].node.handle_open_channel(&nodes[2].node.get_our_node_id(), &open_chan_msg);
+ nodes[1].node.handle_open_channel(nodes[2].node.get_our_node_id(), &open_chan_msg);
let mut accept_chan_msg = get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[2].node.get_our_node_id());
accept_chan_msg.common_fields.temporary_channel_id = node_c_temp_chan_id;
- nodes[2].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), &accept_chan_msg);
+ nodes[2].node.handle_accept_channel(nodes[1].node.get_our_node_id(), &accept_chan_msg);
// Now that we have a second channel with the same funding txo, send a bogus funding message
// and let nodes[1] remove the inbound channel.
funding_created_msg.temporary_channel_id = real_channel_id;
// Make the signature invalid by changing the funding output
funding_created_msg.funding_output_index += 10;
- nodes[1].node.handle_funding_created(&nodes[2].node.get_our_node_id(), &funding_created_msg);
+ nodes[1].node.handle_funding_created(nodes[2].node.get_our_node_id(), &funding_created_msg);
get_err_msg(&nodes[1], &nodes[2].node.get_our_node_id());
let err = "Invalid funding_created signature from peer".to_owned();
let reason = ClosureReason::ProcessingError { err };
// Create an initial channel
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 42, None, None).unwrap();
let mut open_chan_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(), &open_chan_msg);
- nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), &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(), &open_chan_msg);
+ nodes[0].node.handle_accept_channel(nodes[1].node.get_our_node_id(), &get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id()));
// Try to create a second channel with the same temporary_channel_id as the first and check
// that it is rejected.
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &open_chan_msg);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_chan_msg);
{
let events = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
check_added_monitors!(nodes[0], 0);
let mut funding_created_msg = get_event_msg!(nodes[0], MessageSendEvent::SendFundingCreated, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &funding_created_msg);
+ nodes[1].node.handle_funding_created(nodes[0].node.get_our_node_id(), &funding_created_msg);
{
let mut added_monitors = nodes[1].chain_monitor.added_monitors.lock().unwrap();
assert_eq!(added_monitors.len(), 1);
// Technically this is allowed by the spec, but we don't support it and there's little reason
// to. Still, it shouldn't cause any other issues.
open_chan_msg.common_fields.temporary_channel_id = channel_id;
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &open_chan_msg);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_chan_msg);
{
let events = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
// Now try to create a second channel which has a duplicate funding output.
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 42, None, None).unwrap();
let open_chan_2_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(), &open_chan_2_msg);
- nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), &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(), &open_chan_2_msg);
+ nodes[0].node.handle_accept_channel(nodes[1].node.get_our_node_id(), &get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id()));
create_funding_transaction(&nodes[0], &nodes[1].node.get_our_node_id(), 100000, 42); // Get and check the FundingGenerationReady event
let funding_created = {
}.unwrap()
};
check_added_monitors!(nodes[0], 0);
- nodes[1].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &funding_created);
+ nodes[1].node.handle_funding_created(nodes[0].node.get_our_node_id(), &funding_created);
// At this point we'll look up if the channel_id is present and immediately fail the channel
// without trying to persist the `ChannelMonitor`.
check_added_monitors!(nodes[1], 0);
// finally, finish creating the original channel and send a payment over it to make sure
// everything is functional.
- nodes[0].node.handle_funding_signed(&nodes[1].node.get_our_node_id(), &funding_signed_msg);
+ nodes[0].node.handle_funding_signed(nodes[1].node.get_our_node_id(), &funding_signed_msg);
{
let mut added_monitors = nodes[0].chain_monitor.added_monitors.lock().unwrap();
assert_eq!(added_monitors.len(), 1);
assert_eq!(nodes[2].node.list_usable_channels().len(), 1);
// Closing a channel from a different peer has no effect
- nodes[0].node.handle_error(&nodes[1].node.get_our_node_id(), &msgs::ErrorMessage { channel_id: chan_3.2, data: "ERR".to_owned() });
+ nodes[0].node.handle_error(nodes[1].node.get_our_node_id(), &msgs::ErrorMessage { channel_id: chan_3.2, data: "ERR".to_owned() });
assert_eq!(nodes[0].node.list_usable_channels().len(), 3);
// Closing one channel doesn't impact others
- nodes[0].node.handle_error(&nodes[1].node.get_our_node_id(), &msgs::ErrorMessage { channel_id: chan_2.2, data: "ERR".to_owned() });
+ nodes[0].node.handle_error(nodes[1].node.get_our_node_id(), &msgs::ErrorMessage { channel_id: chan_2.2, data: "ERR".to_owned() });
check_added_monitors!(nodes[0], 1);
check_closed_broadcast!(nodes[0], false);
check_closed_event!(nodes[0], 1, ClosureReason::CounterpartyForceClosed { peer_msg: UntrustedString("ERR".to_string()) },
// A null channel ID should close all channels
let _chan_4 = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 10001);
- nodes[0].node.handle_error(&nodes[1].node.get_our_node_id(), &msgs::ErrorMessage { channel_id: ChannelId::new_zero(), data: "ERR".to_owned() });
+ nodes[0].node.handle_error(nodes[1].node.get_our_node_id(), &msgs::ErrorMessage { channel_id: ChannelId::new_zero(), data: "ERR".to_owned() });
check_added_monitors!(nodes[0], 2);
check_closed_event!(nodes[0], 2, ClosureReason::CounterpartyForceClosed { peer_msg: UntrustedString("ERR".to_string()) },
[nodes[1].node.get_our_node_id(); 2], 100000);
assert_eq!(nodes[0].node.list_usable_channels().len(), 1);
assert!(nodes[0].node.list_usable_channels()[0].channel_id == chan_3.2);
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
assert_eq!(nodes[0].node.list_usable_channels().len(), 1);
assert!(nodes[0].node.list_usable_channels()[0].channel_id == chan_3.2);
}
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100_000, 10_000, 42, None, None).unwrap();
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &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(), &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(), &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(), &get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id()));
let (temporary_channel_id, mut tx, _) = create_funding_transaction(&nodes[0], &nodes[1].node.get_our_node_id(), 100_000, 42);
}
nodes[0].node.funding_transaction_generated_unchecked(temporary_channel_id, nodes[1].node.get_our_node_id(), tx.clone(), 0).unwrap();
- nodes[1].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendFundingCreated, nodes[1].node.get_our_node_id()));
+ nodes[1].node.handle_funding_created(nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendFundingCreated, nodes[1].node.get_our_node_id()));
check_added_monitors!(nodes[1], 1);
expect_channel_pending_event(&nodes[1], &nodes[0].node.get_our_node_id());
- nodes[0].node.handle_funding_signed(&nodes[1].node.get_our_node_id(), &get_event_msg!(nodes[1], MessageSendEvent::SendFundingSigned, nodes[0].node.get_our_node_id()));
+ nodes[0].node.handle_funding_signed(nodes[1].node.get_our_node_id(), &get_event_msg!(nodes[1], MessageSendEvent::SendFundingSigned, nodes[0].node.get_our_node_id()));
check_added_monitors!(nodes[0], 1);
expect_channel_pending_event(&nodes[0], &nodes[1].node.get_our_node_id());
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 42, None, 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(), &open_channel);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &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(), &accept_channel);
+ nodes[0].node.handle_accept_channel(nodes[1].node.get_our_node_id(), &accept_channel);
// Create the coinbase funding transaction.
let (temporary_channel_id, tx, _) = create_coinbase_funding_transaction(&nodes[0], &nodes[1].node.get_our_node_id(), 100000, 42);
check_added_monitors!(nodes[0], 0);
let funding_created = get_event_msg!(nodes[0], MessageSendEvent::SendFundingCreated, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &funding_created);
+ nodes[1].node.handle_funding_created(nodes[0].node.get_our_node_id(), &funding_created);
check_added_monitors!(nodes[1], 1);
expect_channel_pending_event(&nodes[1], &nodes[0].node.get_our_node_id());
let funding_signed = get_event_msg!(nodes[1], MessageSendEvent::SendFundingSigned, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_funding_signed(&nodes[1].node.get_our_node_id(), &funding_signed);
+ nodes[0].node.handle_funding_signed(nodes[1].node.get_our_node_id(), &funding_signed);
check_added_monitors!(nodes[0], 1);
expect_channel_pending_event(&nodes[0], &nodes[1].node.get_our_node_id());
// Now connect one more block which results in 100 confirmations of the coinbase transaction.
connect_blocks(&nodes[0], 1);
// There should now be a `channel_ready` which can be handled.
- let _ = &nodes[1].node.handle_channel_ready(&nodes[0].node.get_our_node_id(), &get_event_msg!(&nodes[0], MessageSendEvent::SendChannelReady, nodes[1].node.get_our_node_id()));
+ let _ = &nodes[1].node.handle_channel_ready(nodes[0].node.get_our_node_id(), &get_event_msg!(&nodes[0], MessageSendEvent::SendChannelReady, nodes[1].node.get_our_node_id()));
confirm_transaction_at(&nodes[1], &tx, 1);
connect_blocks(&nodes[1], COINBASE_MATURITY - 2);
create_announced_chan_between_nodes(&nodes, 0, 1);
let (chan_announce, _, channel_id, _) = create_announced_chan_between_nodes(&nodes, 1, 2);
let (_, payment_hash, ..) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 1_000_000);
- nodes[1].node.peer_disconnected(&nodes[2].node.get_our_node_id());
- nodes[2].node.peer_disconnected(&nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[2].node.get_our_node_id());
+ nodes[2].node.peer_disconnected(nodes[1].node.get_our_node_id());
let error_message = "Channel force-closed";
nodes[1].node.force_close_broadcasting_latest_txn(&channel_id, &nodes[2].node.get_our_node_id(), error_message.to_string()).unwrap();
check_closed_broadcast!(nodes[1], true);
assert_eq!(updates.update_fail_htlcs.len(), 1);
assert!(updates.update_fail_malformed_htlcs.is_empty());
assert!(updates.update_fee.is_none());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], updates.commitment_signed, true, true);
expect_payment_failed_with_update!(nodes[0], payment_hash, false, chan_announce.contents.short_channel_id, true);
}
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
let mut payment_event = SendEvent::from_event(events.pop().unwrap());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
}
expect_pending_htlcs_forwardable!(nodes[1]);
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
let mut payment_event = SendEvent::from_event(events.pop().unwrap());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
// At this point, nodes[1] would notice it has too much value for the payment. It will
// assume the second is a privacy attack (no longer particularly relevant
let fail_updates_1 = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
assert_eq!(fail_updates_1.update_fail_htlcs.len(), 2);
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &fail_updates_1.update_fail_htlcs[0]);
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &fail_updates_1.update_fail_htlcs[1]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &fail_updates_1.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &fail_updates_1.update_fail_htlcs[1]);
commitment_signed_dance!(nodes[0], nodes[1], fail_updates_1.commitment_signed, false);
let failure_events = nodes[0].node.get_and_clear_pending_events();
check_added_monitors!(nodes[1], 1);
let fail_updates_1 = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &fail_updates_1.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &fail_updates_1.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], fail_updates_1.commitment_signed, false);
expect_payment_failed_conditions(&nodes[0], our_payment_hash, true, PaymentFailedConditions::new());
assert_eq!(events.len(), 1);
let payment_event = SendEvent::from_event(events.pop().unwrap());
- nodes[2].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[2].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[2], nodes[0], payment_event.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[2]);
assert_eq!(events.len(), 1);
let payment_event = SendEvent::from_event(events.pop().unwrap());
- nodes[3].node.handle_update_add_htlc(&nodes[2].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[3].node.handle_update_add_htlc(nodes[2].node.get_our_node_id(), &payment_event.msgs[0]);
check_added_monitors!(nodes[3], 0);
commitment_signed_dance!(nodes[3], nodes[2], payment_event.commitment_msg, true, true);
check_added_monitors!(nodes[3], 1);
let fail_updates_1 = get_htlc_update_msgs!(nodes[3], nodes[2].node.get_our_node_id());
- nodes[2].node.handle_update_fail_htlc(&nodes[3].node.get_our_node_id(), &fail_updates_1.update_fail_htlcs[0]);
+ nodes[2].node.handle_update_fail_htlc(nodes[3].node.get_our_node_id(), &fail_updates_1.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[2], nodes[3], fail_updates_1.commitment_signed, false);
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[2], vec![HTLCDestination::NextHopChannel { node_id: Some(nodes[3].node.get_our_node_id()), channel_id: chan_2_3.2 }]);
check_added_monitors!(nodes[2], 1);
let fail_updates_2 = get_htlc_update_msgs!(nodes[2], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fail_htlc(&nodes[2].node.get_our_node_id(), &fail_updates_2.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[2].node.get_our_node_id(), &fail_updates_2.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[2], fail_updates_2.commitment_signed, false);
expect_payment_failed_conditions(&nodes[0], our_payment_hash, true, PaymentFailedConditions::new().mpp_parts_remain());
if on_holder_tx {
open_channel.common_fields.dust_limit_satoshis = 546;
}
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &open_channel);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel);
let mut 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(), &accept_channel);
+ nodes[0].node.handle_accept_channel(nodes[1].node.get_our_node_id(), &accept_channel);
let channel_type_features = ChannelTypeFeatures::only_static_remote_key();
}
nodes[0].node.funding_transaction_generated(temporary_channel_id, nodes[1].node.get_our_node_id(), tx.clone()).unwrap();
- nodes[1].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendFundingCreated, nodes[1].node.get_our_node_id()));
+ nodes[1].node.handle_funding_created(nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendFundingCreated, nodes[1].node.get_our_node_id()));
check_added_monitors!(nodes[1], 1);
expect_channel_pending_event(&nodes[1], &nodes[0].node.get_our_node_id());
- nodes[0].node.handle_funding_signed(&nodes[1].node.get_our_node_id(), &get_event_msg!(nodes[1], MessageSendEvent::SendFundingSigned, nodes[0].node.get_our_node_id()));
+ nodes[0].node.handle_funding_signed(nodes[1].node.get_our_node_id(), &get_event_msg!(nodes[1], MessageSendEvent::SendFundingSigned, nodes[0].node.get_our_node_id()));
check_added_monitors!(nodes[0], 1);
expect_channel_pending_event(&nodes[0], &nodes[1].node.get_our_node_id());
let mut events = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
let payment_event = SendEvent::from_event(events.remove(0));
- nodes[0].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[0].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &payment_event.msgs[0]);
// With default dust exposure: 5000 sats
if on_holder_tx {
// Outbound dust balance: 6399 sats
check_added_monitors(&nodes[2], 1);
let send = SendEvent::from_node(&nodes[2]);
- nodes[0].node.handle_update_add_htlc(&nodes[2].node.get_our_node_id(), &send.msgs[0]);
+ nodes[0].node.handle_update_add_htlc(nodes[2].node.get_our_node_id(), &send.msgs[0]);
commitment_signed_dance!(nodes[0], nodes[2], send.commitment_msg, false, true);
expect_pending_htlcs_forwardable!(nodes[0]);
);
let fail = get_htlc_update_msgs(&nodes[0], &nodes[2].node.get_our_node_id());
- nodes[2].node.handle_update_fail_htlc(&nodes[0].node.get_our_node_id(), &fail.update_fail_htlcs[0]);
+ nodes[2].node.handle_update_fail_htlc(nodes[0].node.get_our_node_id(), &fail.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[2], nodes[0], fail.commitment_signed, false);
expect_payment_failed_conditions(&nodes[2], payment_hash, false, PaymentFailedConditions::new());
}
let temp_channel_id = nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100_000, 0, 42, None, None).unwrap();
let open_channel_message = 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(), &open_channel_message);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel_message);
let accept_channel_message = 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(), &accept_channel_message);
+ nodes[0].node.handle_accept_channel(nodes[1].node.get_our_node_id(), &accept_channel_message);
let best_height = nodes[0].node.best_block.read().unwrap().height;
let temp_channel_id = nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100_000, 0, 42, None, None).unwrap();
let open_channel_message = 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(), &open_channel_message);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel_message);
let accept_channel_message = 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(), &accept_channel_message);
+ nodes[0].node.handle_accept_channel(nodes[1].node.get_our_node_id(), &accept_channel_message);
let best_height = nodes[0].node.best_block.read().unwrap().height;
assert_eq!(events.len(), 1);
match events[0] {
MessageSendEvent::UpdateHTLCs { updates: msgs::CommitmentUpdate { ref update_fee, ref commitment_signed, .. }, .. } => {
- nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), update_fee.as_ref().unwrap());
+ nodes[1].node.handle_update_fee(nodes[0].node.get_our_node_id(), update_fee.as_ref().unwrap());
commitment_signed_dance!(nodes[1], nodes[0], commitment_signed, false);
},
_ => panic!("Unexpected event"),
assert_eq!(events.len(), 1);
match events[0] {
MessageSendEvent::UpdateHTLCs { updates: msgs::CommitmentUpdate { ref update_fee, ref commitment_signed, .. }, .. } => {
- nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), update_fee.as_ref().unwrap());
+ nodes[1].node.handle_update_fee(nodes[0].node.get_our_node_id(), update_fee.as_ref().unwrap());
commitment_signed_dance!(nodes[1], nodes[0], commitment_signed, false);
},
_ => panic!("Unexpected event"),
assert_eq!(events.len(), 1);
match events[0] {
MessageSendEvent::UpdateHTLCs { updates: msgs::CommitmentUpdate { ref update_fee, .. }, .. } => {
- nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), update_fee.as_ref().unwrap());
+ nodes[1].node.handle_update_fee(nodes[0].node.get_our_node_id(), update_fee.as_ref().unwrap());
check_closed_event!(nodes[1], 1, ClosureReason::PeerFeerateTooLow {
peer_feerate_sat_per_kw: 1000, required_feerate_sat_per_kw: 5000,
}, [nodes[0].node.get_our_node_id()], 100000);
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
let mut payment_event = SendEvent::from_event(events.pop().unwrap());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[1]);
check_added_monitors!(nodes[1], 1);
let fail_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &fail_updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &fail_updates.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], fail_updates.commitment_signed, false, true);
expect_payment_failed!(nodes[0], payment_hash, true);
nodes[0].node.timer_tick_occurred();
check_added_monitors!(&nodes[0], 1);
let alice_fee_update = get_htlc_update_msgs(&nodes[0], &nodes[1].node.get_our_node_id());
- nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), alice_fee_update.update_fee.as_ref().unwrap());
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &alice_fee_update.commitment_signed);
+ nodes[1].node.handle_update_fee(nodes[0].node.get_our_node_id(), alice_fee_update.update_fee.as_ref().unwrap());
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &alice_fee_update.commitment_signed);
check_added_monitors!(&nodes[1], 1);
// This will prompt Bob (nodes[1]) to respond with his `CommitmentSigned` and `RevokeAndACK`.
let (bob_revoke_and_ack, bob_commitment_signed) = get_revoke_commit_msgs!(&nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bob_revoke_and_ack);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bob_revoke_and_ack);
check_added_monitors!(&nodes[0], 1);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bob_commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bob_commitment_signed);
check_added_monitors(&nodes[0], 1);
// Alice then needs to send her final `RevokeAndACK` to complete the commitment dance. We
//
// Note that since the commitment dance didn't complete above, Alice is expected to resend her
// final `RevokeAndACK` to Bob to complete it.
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
let bob_init = msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
};
- nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &bob_init, true).unwrap();
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &bob_init, true).unwrap();
let alice_init = msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
};
- nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &alice_init, true).unwrap();
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &alice_init, true).unwrap();
// Upon reconnection, Alice sends her `ChannelReestablish` to Bob. Alice, however, hasn't
// received Bob's yet, so she should disconnect him after reaching
let alice_channel_reestablish = get_event_msg!(
nodes[0], MessageSendEvent::SendChannelReestablish, nodes[1].node.get_our_node_id()
);
- nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &alice_channel_reestablish);
+ nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), &alice_channel_reestablish);
check_disconnect(&nodes[0]);
// Bob now sends his `ChannelReestablish` to Alice to resume the channel and consider it "live".
None
}
).unwrap();
- nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &bob_channel_reestablish);
+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &bob_channel_reestablish);
// Sanity check that Alice won't disconnect Bob since she's no longer waiting for any messages.
for _ in 0..DISCONNECT_PEER_AWAITING_RESPONSE_TICKS {
check_disconnect(&nodes[1]);
// Finally, have Bob process the last message.
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &alice_revoke_and_ack);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &alice_revoke_and_ack);
check_added_monitors(&nodes[1], 1);
// At this point, neither node should attempt to disconnect each other, since they aren't
let temp_channel_id = nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100_000, 0, 42, None, None).unwrap();
let open_channel_message = 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(), &open_channel_message);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel_message);
let accept_channel_message = 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(), &accept_channel_message);
+ nodes[0].node.handle_accept_channel(nodes[1].node.get_our_node_id(), &accept_channel_message);
let events = nodes[0].node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
let temp_channel_id = nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100_000, 0, 42, None, None).unwrap();
let open_channel_message = 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(), &open_channel_message);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel_message);
let accept_channel_message = 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(), &accept_channel_message);
+ nodes[0].node.handle_accept_channel(nodes[1].node.get_our_node_id(), &accept_channel_message);
let events = nodes[0].node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
let open_channel_msg = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
assert_eq!(open_channel_msg.common_fields.temporary_channel_id, create_chan_id);
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
// Make sure that we have not removed the OutboundV1Channel from node[0] immediately.
assert_eq!(nodes[0].node.list_channels().len(), 1);
let open_channel_msg = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
assert_eq!(open_channel_msg.common_fields.temporary_channel_id, create_chan_id);
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
// Make sure that we have not removed the OutboundV1Channel from node[0] immediately.
assert_eq!(nodes[0].node.list_channels().len(), 1);
assert_eq!(nodes[1].node.list_channels().len(), 0);
// The peers now reconnect
- nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init {
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).unwrap();
- nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, false).unwrap();
for dest in &[1, 2] {
let htlc_fulfill_updates = get_htlc_update_msgs!(nodes[*dest], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fulfill_htlc(&nodes[*dest].node.get_our_node_id(), &htlc_fulfill_updates.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[*dest].node.get_our_node_id(), &htlc_fulfill_updates.update_fulfill_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[*dest], htlc_fulfill_updates.commitment_signed, false);
check_added_monitors(&nodes[0], 0);
}
check_added_monitors(&nodes[1], 1);
let send_event = SendEvent::from_node(&nodes[1]);
- nodes[0].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &send_event.msgs[0]);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &send_event.commitment_msg);
+ nodes[0].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &send_event.msgs[0]);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &send_event.commitment_msg);
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
if do_reload {
let chan_1_monitor_serialized = get_monitor!(nodes[0], chan_id_2).encode();
reload_node!(nodes[0], test_default_channel_config(), &nodes_0_serialized, &[&chan_0_monitor_serialized, &chan_1_monitor_serialized], persister, chain_monitor, nodes_0_deserialized);
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
- nodes[2].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
+ nodes[2].node.peer_disconnected(nodes[0].node.get_our_node_id());
reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[1]));
reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[2]));
]);
// Go through the funding_created and funding_signed flow with node 1.
- nodes[1].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &funding_created_msgs[0]);
+ nodes[1].node.handle_funding_created(nodes[0].node.get_our_node_id(), &funding_created_msgs[0]);
check_added_monitors(&nodes[1], 1);
expect_channel_pending_event(&nodes[1], &nodes[0].node.get_our_node_id());
let funding_signed_msg = get_event_msg!(nodes[1], MessageSendEvent::SendFundingSigned, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_funding_signed(&nodes[1].node.get_our_node_id(), &funding_signed_msg);
+ nodes[0].node.handle_funding_signed(nodes[1].node.get_our_node_id(), &funding_signed_msg);
check_added_monitors(&nodes[0], 1);
// The transaction should not have been broadcast before all channels are ready.
assert_eq!(nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().len(), 0);
// Go through the funding_created and funding_signed flow with node 2.
- nodes[2].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &funding_created_msgs[1]);
+ nodes[2].node.handle_funding_created(nodes[0].node.get_our_node_id(), &funding_created_msgs[1]);
check_added_monitors(&nodes[2], 1);
expect_channel_pending_event(&nodes[2], &nodes[0].node.get_our_node_id());
let funding_signed_msg = get_event_msg!(nodes[2], MessageSendEvent::SendFundingSigned, nodes[0].node.get_our_node_id());
chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
- nodes[0].node.handle_funding_signed(&nodes[2].node.get_our_node_id(), &funding_signed_msg);
+ nodes[0].node.handle_funding_signed(nodes[2].node.get_our_node_id(), &funding_signed_msg);
check_added_monitors(&nodes[0], 1);
// The transaction should not have been broadcast before persisting all monitors has been
]);
// Go through the funding_created and funding_signed flow with node 1.
- nodes[1].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &funding_created_msgs[0]);
+ nodes[1].node.handle_funding_created(nodes[0].node.get_our_node_id(), &funding_created_msgs[0]);
check_added_monitors(&nodes[1], 1);
expect_channel_pending_event(&nodes[1], &nodes[0].node.get_our_node_id());
let funding_signed_msg = get_event_msg!(nodes[1], MessageSendEvent::SendFundingSigned, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_funding_signed(&nodes[1].node.get_our_node_id(), &funding_signed_msg);
+ nodes[0].node.handle_funding_signed(nodes[1].node.get_our_node_id(), &funding_signed_msg);
check_added_monitors(&nodes[0], 1);
// The transaction should not have been broadcast before all channels are ready.
]);
// Go through the funding_created and funding_signed flow with node 1.
- nodes[1].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &funding_created_msgs[0]);
+ nodes[1].node.handle_funding_created(nodes[0].node.get_our_node_id(), &funding_created_msgs[0]);
check_added_monitors(&nodes[1], 1);
expect_channel_pending_event(&nodes[1], &nodes[0].node.get_our_node_id());
let funding_signed_msg = get_event_msg!(nodes[1], MessageSendEvent::SendFundingSigned, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_funding_signed(&nodes[1].node.get_our_node_id(), &funding_signed_msg);
+ nodes[0].node.handle_funding_signed(nodes[1].node.get_our_node_id(), &funding_signed_msg);
check_added_monitors(&nodes[0], 1);
// Go through the funding_created and funding_signed flow with node 2.
- nodes[2].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &funding_created_msgs[1]);
+ nodes[2].node.handle_funding_created(nodes[0].node.get_our_node_id(), &funding_created_msgs[1]);
check_added_monitors(&nodes[2], 1);
expect_channel_pending_event(&nodes[2], &nodes[0].node.get_our_node_id());
let funding_signed_msg = get_event_msg!(nodes[2], MessageSendEvent::SendFundingSigned, nodes[0].node.get_our_node_id());
chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
- nodes[0].node.handle_funding_signed(&nodes[2].node.get_our_node_id(), &funding_signed_msg);
+ nodes[0].node.handle_funding_signed(nodes[2].node.get_our_node_id(), &funding_signed_msg);
check_added_monitors(&nodes[0], 1);
// The transaction should not have been broadcast before all channels are ready.
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100_000, 0, 42, None, 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(), &open_channel_msg);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel_msg);
let events = nodes[1].node.get_and_clear_pending_events();
match events[0] {
Event::OpenChannelRequest { temporary_channel_id, .. } => {
assert!(nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100_000, 0, 42, None, None).is_ok());
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(), &open_channel);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &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(), &accept_channel);
+ nodes[0].node.handle_accept_channel(nodes[1].node.get_our_node_id(), &accept_channel);
let (temporary_channel_id, _tx, funding_outpoint) = create_funding_transaction(&nodes[0], &nodes[1].node.get_our_node_id(), 100_000, 42);
nodes[0].node.unsafe_manual_funding_transaction_generated(temporary_channel_id, nodes[1].node.get_our_node_id(), funding_outpoint).unwrap();
check_added_monitors!(nodes[0], 0);
let funding_created = get_event_msg!(nodes[0], MessageSendEvent::SendFundingCreated, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &funding_created);
+ nodes[1].node.handle_funding_created(nodes[0].node.get_our_node_id(), &funding_created);
check_added_monitors!(nodes[1], 1);
expect_channel_pending_event(&nodes[1], &nodes[0].node.get_our_node_id());
let funding_signed = get_event_msg!(nodes[1], MessageSendEvent::SendFundingSigned, nodes[0].node.get_our_node_id());
let err = msgs::ErrorMessage { channel_id: funding_signed.channel_id, data: "".to_string() };
- nodes[0].node.handle_error(&nodes[1].node.get_our_node_id(), &err);
+ nodes[0].node.handle_error(nodes[1].node.get_our_node_id(), &err);
let close_events = nodes[0].node.get_and_clear_pending_events();
assert_eq!(close_events.len(), 2);
assert!(nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100_000, 0, 42, None, None).is_ok());
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(), &open_channel);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &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(), &accept_channel);
+ nodes[0].node.handle_accept_channel(nodes[1].node.get_our_node_id(), &accept_channel);
let (temporary_channel_id, tx, funding_outpoint) = create_funding_transaction(&nodes[0], &nodes[1].node.get_our_node_id(), 100_000, 42);
nodes[0].node.unsafe_manual_funding_transaction_generated(temporary_channel_id, nodes[1].node.get_our_node_id(), funding_outpoint).unwrap();
check_added_monitors!(nodes[0], 0);
let funding_created = get_event_msg!(nodes[0], MessageSendEvent::SendFundingCreated, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &funding_created);
+ nodes[1].node.handle_funding_created(nodes[0].node.get_our_node_id(), &funding_created);
check_added_monitors!(nodes[1], 1);
expect_channel_pending_event(&nodes[1], &nodes[0].node.get_our_node_id());
let funding_signed = get_event_msg!(nodes[1], MessageSendEvent::SendFundingSigned, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_funding_signed(&nodes[1].node.get_our_node_id(), &funding_signed);
+ nodes[0].node.handle_funding_signed(nodes[1].node.get_our_node_id(), &funding_signed);
check_added_monitors!(nodes[0], 1);
let events = &nodes[0].node.get_and_clear_pending_events();
assert_eq!(events.len(), 2);
mine_transaction(&nodes[1], &tx);
let as_channel_ready = get_event_msg!(nodes[1], MessageSendEvent::SendChannelReady, nodes[0].node.get_our_node_id());
- nodes[1].node.handle_channel_ready(&nodes[0].node.get_our_node_id(), &as_channel_ready);
+ nodes[1].node.handle_channel_ready(nodes[0].node.get_our_node_id(), &as_channel_ready);
let as_channel_ready = get_event_msg!(nodes[0], MessageSendEvent::SendChannelReady, nodes[1].node.get_our_node_id());
- nodes[0].node.handle_channel_ready(&nodes[1].node.get_our_node_id(), &as_channel_ready);
+ nodes[0].node.handle_channel_ready(nodes[1].node.get_our_node_id(), &as_channel_ready);
expect_channel_ready_event(&nodes[0], &nodes[1].node.get_our_node_id());
expect_channel_ready_event(&nodes[1], &nodes[0].node.get_our_node_id());
assert_eq!(events.len(), 1);
SendEvent::from_event(events.remove(0))
};
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &payment_event.commitment_msg);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &payment_event.commitment_msg);
check_added_monitors(&nodes[1], 1);
let events = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 2);
// yet announced.
let pub_channel_scid = mine_transaction(&nodes[0], &conf_tx);
let node_a_pub_channel_ready = get_event_msg!(nodes[0], MessageSendEvent::SendChannelReady, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_channel_ready(&nodes[0].node.get_our_node_id(), &node_a_pub_channel_ready);
+ nodes[1].node.handle_channel_ready(nodes[0].node.get_our_node_id(), &node_a_pub_channel_ready);
assert_eq!(mine_transaction(&nodes[1], &conf_tx), pub_channel_scid);
let events = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 2);
if let MessageSendEvent::SendChannelReady { msg, .. } = &events[0] {
- nodes[0].node.handle_channel_ready(&nodes[1].node.get_our_node_id(), msg);
+ nodes[0].node.handle_channel_ready(nodes[1].node.get_our_node_id(), msg);
} else { panic!(); }
if let MessageSendEvent::SendChannelUpdate { msg, .. } = &events[1] {
- nodes[0].node.handle_channel_update(&nodes[1].node.get_our_node_id(), msg);
+ nodes[0].node.handle_channel_update(nodes[1].node.get_our_node_id(), msg);
} else { panic!(); }
- nodes[1].node.handle_channel_update(&nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendChannelUpdate, nodes[1].node.get_our_node_id()));
+ nodes[1].node.handle_channel_update(nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendChannelUpdate, nodes[1].node.get_our_node_id()));
expect_channel_ready_event(&nodes[0], &nodes[1].node.get_our_node_id());
expect_channel_ready_event(&nodes[1], &nodes[0].node.get_our_node_id());
// With only one sufficient-value peer connected we should only get its hint
scid_aliases.remove(&chan_b.0.short_channel_id_alias.unwrap());
- nodes[0].node.peer_disconnected(&nodes[2].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[2].node.get_our_node_id());
match_invoice_routes(Some(1_000_000_000), &nodes[0], scid_aliases.clone());
// If we don't have any sufficient-value peers connected we should get all hints with
// sufficient value, even though there is a connected insufficient-value peer.
scid_aliases.insert(chan_b.0.short_channel_id_alias.unwrap());
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
match_invoice_routes(Some(1_000_000_000), &nodes[0], scid_aliases);
}
private_chan_cfg.channel_handshake_config.announce_for_forwarding = false;
let temporary_channel_id = nodes[2].node.create_channel(nodes[0].node.get_our_node_id(), 1_000_000, 500_000_000, 42, None, 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(), &open_channel);
+ nodes[0].node.handle_open_channel(nodes[2].node.get_our_node_id(), &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(), &accept_channel);
+ nodes[2].node.handle_accept_channel(nodes[0].node.get_our_node_id(), &accept_channel);
let tx = sign_funding_transaction(&nodes[2], &nodes[0], 1_000_000, temporary_channel_id);
confirm_transaction_at(&nodes[0], &tx, conf_height);
connect_blocks(&nodes[0], CHAN_CONFIRM_DEPTH - 1);
let as_channel_ready = get_event_msg!(nodes[2], MessageSendEvent::SendChannelReady, nodes[0].node.get_our_node_id());
- nodes[2].node.handle_channel_ready(&nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendChannelReady, nodes[2].node.get_our_node_id()));
+ nodes[2].node.handle_channel_ready(nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendChannelReady, nodes[2].node.get_our_node_id()));
get_event_msg!(nodes[2], MessageSendEvent::SendChannelUpdate, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_channel_ready(&nodes[2].node.get_our_node_id(), &as_channel_ready);
+ nodes[0].node.handle_channel_ready(nodes[2].node.get_our_node_id(), &as_channel_ready);
get_event_msg!(nodes[0], MessageSendEvent::SendChannelUpdate, nodes[2].node.get_our_node_id());
expect_channel_ready_event(&nodes[0], &nodes[2].node.get_our_node_id());
expect_channel_ready_event(&nodes[2], &nodes[0].node.get_our_node_id());
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);
- 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);
+ 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);
// Ensure that the invoice doesn't include any route hints for any of `nodes[0]` channels,
// even though all channels between `nodes[1]` and `nodes[0]` are private, as there is a
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);
- 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);
+ 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);
- 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);
+ 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);
// As all of `nodes[0]` channels are public, no channels should be included in the hints
match_invoice_routes(Some(5000), &nodes[0], HashSet::new());
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);
- 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);
+ 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);
- 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);
+ 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 payment_amt = 10_000;
let route_hints = vec![
};
(SendEvent::from_event(events.remove(0)), fwd_idx)
};
- nodes[fwd_idx].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[fwd_idx].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[fwd_idx], nodes[0], &payment_event.commitment_msg, false, true);
// Note that we have to "forward pending HTLCs" twice before we see the PaymentClaimable as
private_chan_cfg.channel_handshake_config.announce_for_forwarding = false;
let temporary_channel_id = nodes[1].node.create_channel(nodes[3].node.get_our_node_id(), 1_000_000, 500_000_000, 42, None, 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(), &open_channel);
+ nodes[3].node.handle_open_channel(nodes[1].node.get_our_node_id(), &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(), &accept_channel);
+ nodes[1].node.handle_accept_channel(nodes[3].node.get_our_node_id(), &accept_channel);
let tx = sign_funding_transaction(&nodes[1], &nodes[3], 1_000_000, temporary_channel_id);
confirm_transaction_at(&nodes[3], &tx, conf_height);
connect_blocks(&nodes[3], CHAN_CONFIRM_DEPTH - 1);
let as_channel_ready = get_event_msg!(nodes[1], MessageSendEvent::SendChannelReady, nodes[3].node.get_our_node_id());
- nodes[1].node.handle_channel_ready(&nodes[3].node.get_our_node_id(), &get_event_msg!(nodes[3], MessageSendEvent::SendChannelReady, nodes[1].node.get_our_node_id()));
+ nodes[1].node.handle_channel_ready(nodes[3].node.get_our_node_id(), &get_event_msg!(nodes[3], MessageSendEvent::SendChannelReady, nodes[1].node.get_our_node_id()));
get_event_msg!(nodes[1], MessageSendEvent::SendChannelUpdate, nodes[3].node.get_our_node_id());
- nodes[3].node.handle_channel_ready(&nodes[1].node.get_our_node_id(), &as_channel_ready);
+ nodes[3].node.handle_channel_ready(nodes[1].node.get_our_node_id(), &as_channel_ready);
get_event_msg!(nodes[3], MessageSendEvent::SendChannelUpdate, nodes[1].node.get_our_node_id());
expect_channel_ready_event(&nodes[1], &nodes[3].node.get_our_node_id());
expect_channel_ready_event(&nodes[3], &nodes[1].node.get_our_node_id());
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);
- 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);
+ 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);
// Hints should include `chan_0_1` from as `nodes[1]` only have private channels, but not
// `chan_0_2` as `nodes[2]` only has public channels.
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);
- 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);
+ 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);
let chan_0_3 = create_unannounced_chan_between_nodes_with_value(&nodes, 0, 3, 100000, 10001);
let payment_id = PaymentId([1; 32]);
nodes[0].node.pay_for_offer(&offer, None, Some(5000), None, payment_id, Retry::Attempts(0), None).unwrap();
let invreq_om = nodes[0].onion_messenger.next_onion_message_for_peer(nodes[1].node.get_our_node_id()).unwrap();
- nodes[1].onion_messenger.handle_onion_message(&nodes[0].node.get_our_node_id(), &invreq_om);
+ nodes[1].onion_messenger.handle_onion_message(nodes[0].node.get_our_node_id(), &invreq_om);
let invoice_om = nodes[1].onion_messenger.next_onion_message_for_peer(nodes[0].node.get_our_node_id()).unwrap();
- nodes[0].onion_messenger.handle_onion_message(&nodes[1].node.get_our_node_id(), &invoice_om);
+ nodes[0].onion_messenger.handle_onion_message(nodes[1].node.get_our_node_id(), &invoice_om);
// TODO: assert on the invoice error once we support replying to invoice OMs with failure info
nodes[0].logger.assert_log_contains("lightning::ln::channelmanager", "Failed paying invoice: OnionPacketSizeExceeded", 1);
let bs_txn = get_local_commitment_txn!(nodes[1], chan_id_2);
let updates = get_htlc_update_msgs!(nodes[0], 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_update_add_htlc(nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
commitment_signed_dance!(nodes[1], nodes[0], updates.commitment_signed, false);
expect_pending_htlcs_forwardable!(nodes[1]);
check_added_monitors!(nodes[1], 1);
let fail_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &fail_updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &fail_updates.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], fail_updates.commitment_signed, true, true);
expect_payment_failed_with_update!(nodes[0], payment_hash, false, update_a.contents.short_channel_id, true);
}
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(), &node_0_shutdown);
+ nodes[1].node.handle_shutdown(nodes[0].node.get_our_node_id(), &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(), &node_1_shutdown);
+ nodes[0].node.handle_shutdown(nodes[1].node.get_our_node_id(), &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);
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &node_0_closing_signed);
let node_1_closing_signed = get_event_msg!(nodes[1], MessageSendEvent::SendClosingSigned, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_closing_signed(&nodes[1].node.get_our_node_id(), &node_1_closing_signed);
+ nodes[0].node.handle_closing_signed(nodes[1].node.get_our_node_id(), &node_1_closing_signed);
let (_, node_0_2nd_closing_signed) = get_closing_signed_broadcast!(nodes[0].node, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed.unwrap());
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed.unwrap());
let (_, _) = get_closing_signed_broadcast!(nodes[1].node, nodes[0].node.get_our_node_id());
let shutdown_tx = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0);
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(), &node_0_shutdown);
+ nodes[1].node.handle_shutdown(nodes[0].node.get_our_node_id(), &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(), &node_1_shutdown);
+ nodes[0].node.handle_shutdown(nodes[1].node.get_our_node_id(), &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);
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &node_0_closing_signed);
let node_1_closing_signed = get_event_msg!(nodes[1], MessageSendEvent::SendClosingSigned, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_closing_signed(&nodes[1].node.get_our_node_id(), &node_1_closing_signed);
+ nodes[0].node.handle_closing_signed(nodes[1].node.get_our_node_id(), &node_1_closing_signed);
let (_, node_0_2nd_closing_signed) = get_closing_signed_broadcast!(nodes[0].node, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed.unwrap());
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed.unwrap());
let (_, node_1_none) = get_closing_signed_broadcast!(nodes[1].node, nodes[0].node.get_our_node_id());
assert!(node_1_none.is_none());
if prev_commitment_tx {
// To build a previous commitment transaction, deliver one round of commitment messages.
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &b_htlc_msgs.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &b_htlc_msgs.update_fulfill_htlcs[0]);
expect_payment_sent(&nodes[0], payment_preimage, None, false, false);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &b_htlc_msgs.commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &b_htlc_msgs.commitment_signed);
check_added_monitors!(nodes[0], 1);
let (as_raa, as_cs) = get_revoke_commit_msgs!(nodes[0], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_raa);
let _htlc_updates = get_htlc_update_msgs!(&nodes[1], nodes[0].node.get_our_node_id());
check_added_monitors!(nodes[1], 1);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_cs);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_cs);
let _bs_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
check_added_monitors!(nodes[1], 1);
}
check_added_monitors!(nodes[0], 1);
let updates = get_htlc_update_msgs!(nodes[0], 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_update_add_htlc(nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
commitment_signed_dance!(nodes[1], nodes[0], updates.commitment_signed, false);
expect_pending_htlcs_forwardable!(nodes[1]);
check_added_monitors!(nodes[0], 1);
let updates = get_htlc_update_msgs!(nodes[0], 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_update_add_htlc(nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
commitment_signed_dance!(nodes[1], nodes[0], updates.commitment_signed, false);
expect_pending_htlcs_forwardable!(nodes[1]);
check_added_monitors!(nodes[0], 1);
let fee_update = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), &fee_update.update_fee.unwrap());
+ nodes[1].node.handle_update_fee(nodes[0].node.get_our_node_id(), &fee_update.update_fee.unwrap());
commitment_signed_dance!(nodes[1], nodes[0], fee_update.commitment_signed, false);
nodes[0].node.claim_funds(claimed_payment_preimage);
pub trait ChannelMessageHandler : MessageSendEventsProvider {
// Channel init:
/// Handle an incoming `open_channel` message from the given peer.
- fn handle_open_channel(&self, their_node_id: &PublicKey, msg: &OpenChannel);
+ fn handle_open_channel(&self, their_node_id: PublicKey, msg: &OpenChannel);
/// Handle an incoming `open_channel2` message from the given peer.
- fn handle_open_channel_v2(&self, their_node_id: &PublicKey, msg: &OpenChannelV2);
+ fn handle_open_channel_v2(&self, their_node_id: PublicKey, msg: &OpenChannelV2);
/// Handle an incoming `accept_channel` message from the given peer.
- fn handle_accept_channel(&self, their_node_id: &PublicKey, msg: &AcceptChannel);
+ fn handle_accept_channel(&self, their_node_id: PublicKey, msg: &AcceptChannel);
/// Handle an incoming `accept_channel2` message from the given peer.
- fn handle_accept_channel_v2(&self, their_node_id: &PublicKey, msg: &AcceptChannelV2);
+ fn handle_accept_channel_v2(&self, their_node_id: PublicKey, msg: &AcceptChannelV2);
/// Handle an incoming `funding_created` message from the given peer.
- fn handle_funding_created(&self, their_node_id: &PublicKey, msg: &FundingCreated);
+ fn handle_funding_created(&self, their_node_id: PublicKey, msg: &FundingCreated);
/// Handle an incoming `funding_signed` message from the given peer.
- fn handle_funding_signed(&self, their_node_id: &PublicKey, msg: &FundingSigned);
+ fn handle_funding_signed(&self, their_node_id: PublicKey, msg: &FundingSigned);
/// Handle an incoming `channel_ready` message from the given peer.
- fn handle_channel_ready(&self, their_node_id: &PublicKey, msg: &ChannelReady);
+ fn handle_channel_ready(&self, their_node_id: PublicKey, msg: &ChannelReady);
// Channel close:
/// Handle an incoming `shutdown` message from the given peer.
- fn handle_shutdown(&self, their_node_id: &PublicKey, msg: &Shutdown);
+ fn handle_shutdown(&self, their_node_id: PublicKey, msg: &Shutdown);
/// Handle an incoming `closing_signed` message from the given peer.
- fn handle_closing_signed(&self, their_node_id: &PublicKey, msg: &ClosingSigned);
+ fn handle_closing_signed(&self, their_node_id: PublicKey, msg: &ClosingSigned);
// Quiescence
/// Handle an incoming `stfu` message from the given peer.
- fn handle_stfu(&self, their_node_id: &PublicKey, msg: &Stfu);
+ fn handle_stfu(&self, their_node_id: PublicKey, msg: &Stfu);
// Splicing
/// Handle an incoming `splice_init` message from the given peer.
#[cfg(splicing)]
- fn handle_splice_init(&self, their_node_id: &PublicKey, msg: &SpliceInit);
+ fn handle_splice_init(&self, their_node_id: PublicKey, msg: &SpliceInit);
/// Handle an incoming `splice_ack` message from the given peer.
#[cfg(splicing)]
- fn handle_splice_ack(&self, their_node_id: &PublicKey, msg: &SpliceAck);
+ fn handle_splice_ack(&self, their_node_id: PublicKey, msg: &SpliceAck);
/// Handle an incoming `splice_locked` message from the given peer.
#[cfg(splicing)]
- fn handle_splice_locked(&self, their_node_id: &PublicKey, msg: &SpliceLocked);
+ fn handle_splice_locked(&self, their_node_id: PublicKey, msg: &SpliceLocked);
// Interactive channel construction
/// Handle an incoming `tx_add_input message` from the given peer.
- fn handle_tx_add_input(&self, their_node_id: &PublicKey, msg: &TxAddInput);
+ fn handle_tx_add_input(&self, their_node_id: PublicKey, msg: &TxAddInput);
/// Handle an incoming `tx_add_output` message from the given peer.
- fn handle_tx_add_output(&self, their_node_id: &PublicKey, msg: &TxAddOutput);
+ fn handle_tx_add_output(&self, their_node_id: PublicKey, msg: &TxAddOutput);
/// Handle an incoming `tx_remove_input` message from the given peer.
- fn handle_tx_remove_input(&self, their_node_id: &PublicKey, msg: &TxRemoveInput);
+ fn handle_tx_remove_input(&self, their_node_id: PublicKey, msg: &TxRemoveInput);
/// Handle an incoming `tx_remove_output` message from the given peer.
- fn handle_tx_remove_output(&self, their_node_id: &PublicKey, msg: &TxRemoveOutput);
+ fn handle_tx_remove_output(&self, their_node_id: PublicKey, msg: &TxRemoveOutput);
/// Handle an incoming `tx_complete message` from the given peer.
- fn handle_tx_complete(&self, their_node_id: &PublicKey, msg: &TxComplete);
+ fn handle_tx_complete(&self, their_node_id: PublicKey, msg: &TxComplete);
/// Handle an incoming `tx_signatures` message from the given peer.
- fn handle_tx_signatures(&self, their_node_id: &PublicKey, msg: &TxSignatures);
+ fn handle_tx_signatures(&self, their_node_id: PublicKey, msg: &TxSignatures);
/// Handle an incoming `tx_init_rbf` message from the given peer.
- fn handle_tx_init_rbf(&self, their_node_id: &PublicKey, msg: &TxInitRbf);
+ fn handle_tx_init_rbf(&self, their_node_id: PublicKey, msg: &TxInitRbf);
/// Handle an incoming `tx_ack_rbf` message from the given peer.
- fn handle_tx_ack_rbf(&self, their_node_id: &PublicKey, msg: &TxAckRbf);
+ fn handle_tx_ack_rbf(&self, their_node_id: PublicKey, msg: &TxAckRbf);
/// Handle an incoming `tx_abort message` from the given peer.
- fn handle_tx_abort(&self, their_node_id: &PublicKey, msg: &TxAbort);
+ fn handle_tx_abort(&self, their_node_id: PublicKey, msg: &TxAbort);
// HTLC handling:
/// Handle an incoming `update_add_htlc` message from the given peer.
- fn handle_update_add_htlc(&self, their_node_id: &PublicKey, msg: &UpdateAddHTLC);
+ fn handle_update_add_htlc(&self, their_node_id: PublicKey, msg: &UpdateAddHTLC);
/// Handle an incoming `update_fulfill_htlc` message from the given peer.
- fn handle_update_fulfill_htlc(&self, their_node_id: &PublicKey, msg: &UpdateFulfillHTLC);
+ fn handle_update_fulfill_htlc(&self, their_node_id: PublicKey, msg: &UpdateFulfillHTLC);
/// Handle an incoming `update_fail_htlc` message from the given peer.
- fn handle_update_fail_htlc(&self, their_node_id: &PublicKey, msg: &UpdateFailHTLC);
+ fn handle_update_fail_htlc(&self, their_node_id: PublicKey, msg: &UpdateFailHTLC);
/// Handle an incoming `update_fail_malformed_htlc` message from the given peer.
- fn handle_update_fail_malformed_htlc(&self, their_node_id: &PublicKey, msg: &UpdateFailMalformedHTLC);
+ fn handle_update_fail_malformed_htlc(&self, their_node_id: PublicKey, msg: &UpdateFailMalformedHTLC);
/// Handle an incoming `commitment_signed` message from the given peer.
- fn handle_commitment_signed(&self, their_node_id: &PublicKey, msg: &CommitmentSigned);
+ fn handle_commitment_signed(&self, their_node_id: PublicKey, msg: &CommitmentSigned);
/// Handle an incoming `revoke_and_ack` message from the given peer.
- fn handle_revoke_and_ack(&self, their_node_id: &PublicKey, msg: &RevokeAndACK);
+ fn handle_revoke_and_ack(&self, their_node_id: PublicKey, msg: &RevokeAndACK);
/// Handle an incoming `update_fee` message from the given peer.
- fn handle_update_fee(&self, their_node_id: &PublicKey, msg: &UpdateFee);
+ fn handle_update_fee(&self, their_node_id: PublicKey, msg: &UpdateFee);
// Channel-to-announce:
/// Handle an incoming `announcement_signatures` message from the given peer.
- fn handle_announcement_signatures(&self, their_node_id: &PublicKey, msg: &AnnouncementSignatures);
+ fn handle_announcement_signatures(&self, their_node_id: PublicKey, msg: &AnnouncementSignatures);
// Connection loss/reestablish:
/// Indicates a connection to the peer failed/an existing connection was lost.
- fn peer_disconnected(&self, their_node_id: &PublicKey);
+ fn peer_disconnected(&self, their_node_id: PublicKey);
/// Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
///
/// May return an `Err(())` if the features the peer supports are not sufficient to communicate
/// with us. Implementors should be somewhat conservative about doing so, however, as other
/// message handlers may still wish to communicate with this peer.
- fn peer_connected(&self, their_node_id: &PublicKey, msg: &Init, inbound: bool) -> Result<(), ()>;
+ fn peer_connected(&self, their_node_id: PublicKey, msg: &Init, inbound: bool) -> Result<(), ()>;
/// Handle an incoming `channel_reestablish` message from the given peer.
- fn handle_channel_reestablish(&self, their_node_id: &PublicKey, msg: &ChannelReestablish);
+ fn handle_channel_reestablish(&self, their_node_id: PublicKey, msg: &ChannelReestablish);
/// Handle an incoming `channel_update` message from the given peer.
- fn handle_channel_update(&self, their_node_id: &PublicKey, msg: &ChannelUpdate);
+ fn handle_channel_update(&self, their_node_id: PublicKey, msg: &ChannelUpdate);
// Error:
/// Handle an incoming `error` message from the given peer.
- fn handle_error(&self, their_node_id: &PublicKey, msg: &ErrorMessage);
+ fn handle_error(&self, their_node_id: PublicKey, msg: &ErrorMessage);
// Handler information:
/// Gets the node feature flags which this handler itself supports. All available handlers are
/// which are sent in our [`Init`] message.
///
/// Note that this method is called before [`Self::peer_connected`].
- fn provided_init_features(&self, their_node_id: &PublicKey) -> InitFeatures;
+ fn provided_init_features(&self, their_node_id: PublicKey) -> InitFeatures;
/// Gets the chain hashes for this `ChannelMessageHandler` indicating which chains it supports.
///
/// `false` or returning an `Err` otherwise.
///
/// If `their_node_id` is `None`, the message was generated by our own local node.
- fn handle_node_announcement(&self, their_node_id: Option<&PublicKey>, msg: &NodeAnnouncement) -> Result<bool, LightningError>;
+ fn handle_node_announcement(&self, their_node_id: Option<PublicKey>, msg: &NodeAnnouncement) -> Result<bool, LightningError>;
/// Handle a `channel_announcement` message, returning `true` if it should be forwarded on, `false`
/// or returning an `Err` otherwise.
///
/// If `their_node_id` is `None`, the message was generated by our own local node.
- fn handle_channel_announcement(&self, their_node_id: Option<&PublicKey>, msg: &ChannelAnnouncement) -> Result<bool, LightningError>;
+ fn handle_channel_announcement(&self, their_node_id: Option<PublicKey>, msg: &ChannelAnnouncement) -> Result<bool, LightningError>;
/// Handle an incoming `channel_update` message, returning true if it should be forwarded on,
/// `false` or returning an `Err` otherwise.
///
/// If `their_node_id` is `None`, the message was generated by our own local node.
- fn handle_channel_update(&self, their_node_id: Option<&PublicKey>, msg: &ChannelUpdate) -> Result<bool, LightningError>;
+ fn handle_channel_update(&self, their_node_id: Option<PublicKey>, msg: &ChannelUpdate) -> Result<bool, LightningError>;
/// Gets channel announcements and updates required to dump our routing table to a remote node,
/// starting at the `short_channel_id` indicated by `starting_point` and including announcements
/// for a single channel.
/// May return an `Err(())` if the features the peer supports are not sufficient to communicate
/// with us. Implementors should be somewhat conservative about doing so, however, as other
/// message handlers may still wish to communicate with this peer.
- fn peer_connected(&self, their_node_id: &PublicKey, init: &Init, inbound: bool) -> Result<(), ()>;
+ fn peer_connected(&self, their_node_id: PublicKey, init: &Init, inbound: bool) -> Result<(), ()>;
/// Handles the reply of a query we initiated to learn about channels
/// for a given range of blocks. We can expect to receive one or more
/// replies to a single query.
- fn handle_reply_channel_range(&self, their_node_id: &PublicKey, msg: ReplyChannelRange) -> Result<(), LightningError>;
+ fn handle_reply_channel_range(&self, their_node_id: PublicKey, msg: ReplyChannelRange) -> Result<(), LightningError>;
/// Handles the reply of a query we initiated asking for routing gossip
/// messages for a list of channels. We should receive this message when
/// a node has completed its best effort to send us the pertaining routing
/// gossip messages.
- fn handle_reply_short_channel_ids_end(&self, their_node_id: &PublicKey, msg: ReplyShortChannelIdsEnd) -> Result<(), LightningError>;
+ fn handle_reply_short_channel_ids_end(&self, their_node_id: PublicKey, msg: ReplyShortChannelIdsEnd) -> Result<(), LightningError>;
/// Handles when a peer asks us to send a list of `short_channel_id`s
/// for the requested range of blocks.
- fn handle_query_channel_range(&self, their_node_id: &PublicKey, msg: QueryChannelRange) -> Result<(), LightningError>;
+ fn handle_query_channel_range(&self, their_node_id: PublicKey, msg: QueryChannelRange) -> Result<(), LightningError>;
/// Handles when a peer asks us to send routing gossip messages for a
/// list of `short_channel_id`s.
- fn handle_query_short_channel_ids(&self, their_node_id: &PublicKey, msg: QueryShortChannelIds) -> Result<(), LightningError>;
+ fn handle_query_short_channel_ids(&self, their_node_id: PublicKey, msg: QueryShortChannelIds) -> Result<(), LightningError>;
// Handler queueing status:
/// Indicates that there are a large number of [`ChannelAnnouncement`] (or other) messages
/// which are sent in our [`Init`] message.
///
/// Note that this method is called before [`Self::peer_connected`].
- fn provided_init_features(&self, their_node_id: &PublicKey) -> InitFeatures;
+ fn provided_init_features(&self, their_node_id: PublicKey) -> InitFeatures;
}
/// A handler for received [`OnionMessage`]s and for providing generated ones to send.
pub trait OnionMessageHandler {
/// Handle an incoming `onion_message` message from the given peer.
- fn handle_onion_message(&self, peer_node_id: &PublicKey, msg: &OnionMessage);
+ fn handle_onion_message(&self, peer_node_id: PublicKey, msg: &OnionMessage);
/// Returns the next pending onion message for the peer with the given node id.
fn next_onion_message_for_peer(&self, peer_node_id: PublicKey) -> Option<OnionMessage>;
/// May return an `Err(())` if the features the peer supports are not sufficient to communicate
/// with us. Implementors should be somewhat conservative about doing so, however, as other
/// message handlers may still wish to communicate with this peer.
- fn peer_connected(&self, their_node_id: &PublicKey, init: &Init, inbound: bool) -> Result<(), ()>;
+ fn peer_connected(&self, their_node_id: PublicKey, init: &Init, inbound: bool) -> Result<(), ()>;
/// Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to
/// drop and refuse to forward onion messages to this peer.
- fn peer_disconnected(&self, their_node_id: &PublicKey);
+ fn peer_disconnected(&self, their_node_id: PublicKey);
/// Performs actions that should happen roughly every ten seconds after startup. Allows handlers
/// to drop any buffered onion messages intended for prospective peers.
/// which are sent in our [`Init`] message.
///
/// Note that this method is called before [`Self::peer_connected`].
- fn provided_init_features(&self, their_node_id: &PublicKey) -> InitFeatures;
+ fn provided_init_features(&self, their_node_id: PublicKey) -> InitFeatures;
}
#[derive(Clone)]
let node_id_b = node_b.node.get_our_node_id();
let init_a = Init {
- features: node_a.init_features(&node_id_b),
+ features: node_a.init_features(node_id_b),
networks: None,
remote_network_address: None,
};
let init_b = Init {
- features: node_b.init_features(&node_id_a),
+ features: node_b.init_features(node_id_a),
networks: None,
remote_network_address: None,
};
- node_a.node.peer_connected(&node_id_b, &init_b, true).unwrap();
- node_b.node.peer_connected(&node_id_a, &init_a, false).unwrap();
- node_a.onion_messenger.peer_connected(&node_id_b, &init_b, true).unwrap();
- node_b.onion_messenger.peer_connected(&node_id_a, &init_a, false).unwrap();
+ node_a.node.peer_connected(node_id_b, &init_b, true).unwrap();
+ node_b.node.peer_connected(node_id_a, &init_a, false).unwrap();
+ node_a.onion_messenger.peer_connected(node_id_b, &init_b, true).unwrap();
+ node_b.onion_messenger.peer_connected(node_id_a, &init_a, false).unwrap();
}
fn disconnect_peers<'a, 'b, 'c>(node_a: &Node<'a, 'b, 'c>, peers: &[&Node<'a, 'b, 'c>]) {
for node_b in peers {
- node_a.node.peer_disconnected(&node_b.node.get_our_node_id());
- node_b.node.peer_disconnected(&node_a.node.get_our_node_id());
- node_a.onion_messenger.peer_disconnected(&node_b.node.get_our_node_id());
- node_b.onion_messenger.peer_disconnected(&node_a.node.get_our_node_id());
+ node_a.node.peer_disconnected(node_b.node.get_our_node_id());
+ node_b.node.peer_disconnected(node_a.node.get_our_node_id());
+ node_a.onion_messenger.peer_disconnected(node_b.node.get_our_node_id());
+ node_b.onion_messenger.peer_disconnected(node_a.node.get_our_node_id());
}
}
let node_pubkey = node.node.get_our_node_id();
node.gossip_sync.handle_node_announcement(None, &msg).unwrap();
for peer in peers {
- peer.gossip_sync.handle_node_announcement(Some(&node_pubkey), &msg).unwrap();
+ peer.gossip_sync.handle_node_announcement(Some(node_pubkey), &msg).unwrap();
}
}
connect_peers(david, bob);
let onion_message = david.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
- bob.onion_messenger.handle_onion_message(&david_id, &onion_message);
+ bob.onion_messenger.handle_onion_message(david_id, &onion_message);
connect_peers(alice, charlie);
let onion_message = bob.onion_messenger.next_onion_message_for_peer(alice_id).unwrap();
- alice.onion_messenger.handle_onion_message(&bob_id, &onion_message);
+ alice.onion_messenger.handle_onion_message(bob_id, &onion_message);
let (invoice_request, reply_path) = extract_invoice_request(alice, &onion_message);
let payment_context = PaymentContext::Bolt12Offer(Bolt12OfferContext {
assert_eq!(reply_path.introduction_node(), &IntroductionNode::NodeId(charlie_id));
let onion_message = alice.onion_messenger.next_onion_message_for_peer(charlie_id).unwrap();
- charlie.onion_messenger.handle_onion_message(&alice_id, &onion_message);
+ charlie.onion_messenger.handle_onion_message(alice_id, &onion_message);
let onion_message = charlie.onion_messenger.next_onion_message_for_peer(david_id).unwrap();
- david.onion_messenger.handle_onion_message(&charlie_id, &onion_message);
+ david.onion_messenger.handle_onion_message(charlie_id, &onion_message);
let (invoice, _) = extract_invoice(david, &onion_message);
assert_eq!(invoice.amount_msats(), 10_000_000);
connect_peers(alice, charlie);
let onion_message = alice.onion_messenger.next_onion_message_for_peer(charlie_id).unwrap();
- charlie.onion_messenger.handle_onion_message(&alice_id, &onion_message);
+ charlie.onion_messenger.handle_onion_message(alice_id, &onion_message);
let onion_message = charlie.onion_messenger.next_onion_message_for_peer(david_id).unwrap();
- david.onion_messenger.handle_onion_message(&charlie_id, &onion_message);
+ david.onion_messenger.handle_onion_message(charlie_id, &onion_message);
let (invoice, _) = extract_invoice(david, &onion_message);
assert_eq!(invoice, expected_invoice);
expect_recent_payment!(bob, RecentPaymentDetails::AwaitingInvoice, payment_id);
let onion_message = bob.onion_messenger.next_onion_message_for_peer(alice_id).unwrap();
- alice.onion_messenger.handle_onion_message(&bob_id, &onion_message);
+ alice.onion_messenger.handle_onion_message(bob_id, &onion_message);
let (invoice_request, reply_path) = extract_invoice_request(alice, &onion_message);
let payment_context = PaymentContext::Bolt12Offer(Bolt12OfferContext {
assert_eq!(reply_path.introduction_node(), &IntroductionNode::NodeId(bob_id));
let onion_message = alice.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
- bob.onion_messenger.handle_onion_message(&alice_id, &onion_message);
+ bob.onion_messenger.handle_onion_message(alice_id, &onion_message);
let (invoice, _) = extract_invoice(bob, &onion_message);
assert_eq!(invoice.amount_msats(), 10_000_000);
let expected_invoice = alice.node.request_refund_payment(&refund).unwrap();
let onion_message = alice.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
- bob.onion_messenger.handle_onion_message(&alice_id, &onion_message);
+ bob.onion_messenger.handle_onion_message(alice_id, &onion_message);
let (invoice, _) = extract_invoice(bob, &onion_message);
assert_eq!(invoice, expected_invoice);
expect_recent_payment!(bob, RecentPaymentDetails::AwaitingInvoice, payment_id);
let onion_message = bob.onion_messenger.next_onion_message_for_peer(alice_id).unwrap();
- alice.onion_messenger.handle_onion_message(&bob_id, &onion_message);
+ alice.onion_messenger.handle_onion_message(bob_id, &onion_message);
let (invoice_request, _) = extract_invoice_request(alice, &onion_message);
let payment_context = PaymentContext::Bolt12Offer(Bolt12OfferContext {
});
let onion_message = alice.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
- bob.onion_messenger.handle_onion_message(&alice_id, &onion_message);
+ bob.onion_messenger.handle_onion_message(alice_id, &onion_message);
let (invoice, _) = extract_invoice(bob, &onion_message);
route_bolt12_payment(bob, &[alice], &invoice);
let expected_invoice = alice.node.request_refund_payment(&refund).unwrap();
let onion_message = alice.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
- bob.onion_messenger.handle_onion_message(&alice_id, &onion_message);
+ bob.onion_messenger.handle_onion_message(alice_id, &onion_message);
let (invoice, _) = extract_invoice(bob, &onion_message);
assert_eq!(invoice, expected_invoice);
// Send, extract and verify the first Invoice Request message
let onion_message = david.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
- bob.onion_messenger.handle_onion_message(&david_id, &onion_message);
+ bob.onion_messenger.handle_onion_message(david_id, &onion_message);
connect_peers(alice, charlie);
let onion_message = bob.onion_messenger.next_onion_message_for_peer(alice_id).unwrap();
- alice.onion_messenger.handle_onion_message(&bob_id, &onion_message);
+ alice.onion_messenger.handle_onion_message(bob_id, &onion_message);
let (_, reply_path) = extract_invoice_request(alice, &onion_message);
assert_eq!(reply_path.introduction_node(), &IntroductionNode::NodeId(charlie_id));
// Send, extract and verify the second Invoice Request message
let onion_message = david.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
- bob.onion_messenger.handle_onion_message(&david_id, &onion_message);
+ bob.onion_messenger.handle_onion_message(david_id, &onion_message);
let onion_message = bob.onion_messenger.next_onion_message_for_peer(alice_id).unwrap();
- alice.onion_messenger.handle_onion_message(&bob_id, &onion_message);
+ alice.onion_messenger.handle_onion_message(bob_id, &onion_message);
let (_, reply_path) = extract_invoice_request(alice, &onion_message);
assert_eq!(reply_path.introduction_node(), &IntroductionNode::NodeId(nodes[6].node.get_our_node_id()));
connect_peers(david, bob);
let onion_message = david.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
- bob.onion_messenger.handle_onion_message(&david_id, &onion_message);
+ bob.onion_messenger.handle_onion_message(david_id, &onion_message);
connect_peers(alice, charlie);
// Send, extract and verify the second Invoice Request message
let onion_message = david.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
- bob.onion_messenger.handle_onion_message(&david_id, &onion_message);
+ bob.onion_messenger.handle_onion_message(david_id, &onion_message);
let onion_message = bob.onion_messenger.next_onion_message_for_peer(alice_id).unwrap();
expect_recent_payment!(bob, RecentPaymentDetails::AwaitingInvoice, payment_id);
let onion_message = bob.onion_messenger.next_onion_message_for_peer(alice_id).unwrap();
- alice.onion_messenger.handle_onion_message(&bob_id, &onion_message);
+ alice.onion_messenger.handle_onion_message(bob_id, &onion_message);
let (invoice_request, _) = extract_invoice_request(alice, &onion_message);
let payment_context = PaymentContext::Bolt12Offer(Bolt12OfferContext {
});
let onion_message = alice.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
- bob.onion_messenger.handle_onion_message(&alice_id, &onion_message);
+ bob.onion_messenger.handle_onion_message(alice_id, &onion_message);
let (invoice, context) = match get_event!(bob, Event::InvoiceReceived) {
Event::InvoiceReceived { payment_id: actual_payment_id, invoice, context, .. } => {
expect_recent_payment!(bob, RecentPaymentDetails::AwaitingInvoice, payment_id);
let onion_message = bob.onion_messenger.next_onion_message_for_peer(alice_id).unwrap();
- alice.onion_messenger.handle_onion_message(&bob_id, &onion_message);
+ alice.onion_messenger.handle_onion_message(bob_id, &onion_message);
let (invoice_request, reply_path) = extract_invoice_request(alice, &onion_message);
let payment_context = PaymentContext::Bolt12Offer(Bolt12OfferContext {
assert_eq!(reply_path.introduction_node(), &IntroductionNode::NodeId(alice_id));
let onion_message = alice.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
- bob.onion_messenger.handle_onion_message(&alice_id, &onion_message);
+ bob.onion_messenger.handle_onion_message(alice_id, &onion_message);
let (invoice, _) = extract_invoice(bob, &onion_message);
assert_ne!(invoice.signing_pubkey(), alice_id);
}
let onion_message = david.onion_messenger.next_onion_message_for_peer(alice_id).unwrap();
- alice.onion_messenger.handle_onion_message(&david_id, &onion_message);
+ alice.onion_messenger.handle_onion_message(david_id, &onion_message);
let (invoice_request, reply_path) = extract_invoice_request(alice, &onion_message);
assert_eq!(invoice_request.amount_msats(), None);
connect_peers(david, bob);
let onion_message = david.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
- bob.onion_messenger.handle_onion_message(&david_id, &onion_message);
+ bob.onion_messenger.handle_onion_message(david_id, &onion_message);
let onion_message = bob.onion_messenger.next_onion_message_for_peer(alice_id).unwrap();
- alice.onion_messenger.handle_onion_message(&bob_id, &onion_message);
+ alice.onion_messenger.handle_onion_message(bob_id, &onion_message);
let (invoice_request, reply_path) = extract_invoice_request(alice, &onion_message);
assert_eq!(invoice_request.amount_msats(), None);
connect_peers(david, bob);
let onion_message = david.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
- bob.onion_messenger.handle_onion_message(&david_id, &onion_message);
+ bob.onion_messenger.handle_onion_message(david_id, &onion_message);
connect_peers(alice, charlie);
let onion_message = bob.onion_messenger.next_onion_message_for_peer(alice_id).unwrap();
- alice.onion_messenger.handle_onion_message(&bob_id, &onion_message);
+ alice.onion_messenger.handle_onion_message(bob_id, &onion_message);
let (invoice_request, reply_path) = extract_invoice_request(alice, &onion_message);
assert_eq!(invoice_request.amount_msats(), None);
assert_eq!(reply_path.introduction_node(), &IntroductionNode::NodeId(charlie_id));
let onion_message = alice.onion_messenger.next_onion_message_for_peer(charlie_id).unwrap();
- charlie.onion_messenger.handle_onion_message(&alice_id, &onion_message);
+ charlie.onion_messenger.handle_onion_message(alice_id, &onion_message);
let onion_message = charlie.onion_messenger.next_onion_message_for_peer(david_id).unwrap();
- david.onion_messenger.handle_onion_message(&charlie_id, &onion_message);
+ david.onion_messenger.handle_onion_message(charlie_id, &onion_message);
expect_recent_payment!(david, RecentPaymentDetails::AwaitingInvoice, payment_id);
}
}
let onion_message = alice.onion_messenger.next_onion_message_for_peer(david_id).unwrap();
- david.onion_messenger.handle_onion_message(&alice_id, &onion_message);
+ david.onion_messenger.handle_onion_message(alice_id, &onion_message);
let (invoice, _) = extract_invoice(david, &onion_message);
assert_eq!(invoice, expected_invoice);
connect_peers(alice, charlie);
let onion_message = alice.onion_messenger.next_onion_message_for_peer(charlie_id).unwrap();
- charlie.onion_messenger.handle_onion_message(&alice_id, &onion_message);
+ charlie.onion_messenger.handle_onion_message(alice_id, &onion_message);
let onion_message = charlie.onion_messenger.next_onion_message_for_peer(david_id).unwrap();
- david.onion_messenger.handle_onion_message(&charlie_id, &onion_message);
+ david.onion_messenger.handle_onion_message(charlie_id, &onion_message);
let (invoice, _) = extract_invoice(david, &onion_message);
assert_eq!(invoice, expected_invoice);
connect_peers(david, bob);
let onion_message = david.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
- bob.onion_messenger.handle_onion_message(&david_id, &onion_message);
+ bob.onion_messenger.handle_onion_message(david_id, &onion_message);
connect_peers(alice, charlie);
let onion_message = bob.onion_messenger.next_onion_message_for_peer(alice_id).unwrap();
- alice.onion_messenger.handle_onion_message(&bob_id, &onion_message);
+ alice.onion_messenger.handle_onion_message(bob_id, &onion_message);
let onion_message = alice.onion_messenger.next_onion_message_for_peer(charlie_id).unwrap();
- charlie.onion_messenger.handle_onion_message(&alice_id, &onion_message);
+ charlie.onion_messenger.handle_onion_message(alice_id, &onion_message);
let onion_message = charlie.onion_messenger.next_onion_message_for_peer(david_id).unwrap();
- david.onion_messenger.handle_onion_message(&charlie_id, &onion_message);
+ david.onion_messenger.handle_onion_message(charlie_id, &onion_message);
let invoice_error = extract_invoice_error(david, &onion_message);
assert_eq!(invoice_error, InvoiceError::from(Bolt12SemanticError::MissingPaths));
connect_peers(alice, charlie);
let onion_message = alice.onion_messenger.next_onion_message_for_peer(charlie_id).unwrap();
- charlie.onion_messenger.handle_onion_message(&alice_id, &onion_message);
+ charlie.onion_messenger.handle_onion_message(alice_id, &onion_message);
let onion_message = charlie.onion_messenger.next_onion_message_for_peer(david_id).unwrap();
- david.onion_messenger.handle_onion_message(&charlie_id, &onion_message);
+ david.onion_messenger.handle_onion_message(charlie_id, &onion_message);
// David initiates paying the first invoice
let payment_context = PaymentContext::Bolt12Refund(Bolt12RefundContext {});
connect_peers(david, bob);
let onion_message = alice.onion_messenger.next_onion_message_for_peer(charlie_id).unwrap();
- charlie.onion_messenger.handle_onion_message(&alice_id, &onion_message);
+ charlie.onion_messenger.handle_onion_message(alice_id, &onion_message);
let onion_message = charlie.onion_messenger.next_onion_message_for_peer(david_id).unwrap();
- david.onion_messenger.handle_onion_message(&charlie_id, &onion_message);
+ david.onion_messenger.handle_onion_message(charlie_id, &onion_message);
let (invoice2, _) = extract_invoice(david, &onion_message);
assert_eq!(invoice1.payer_metadata(), invoice2.payer_metadata());
connect_peers(david, bob);
let onion_message = david.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
- bob.onion_messenger.handle_onion_message(&david_id, &onion_message);
+ bob.onion_messenger.handle_onion_message(david_id, &onion_message);
connect_peers(alice, charlie);
let onion_message = bob.onion_messenger.next_onion_message_for_peer(alice_id).unwrap();
- alice.onion_messenger.handle_onion_message(&bob_id, &onion_message);
+ alice.onion_messenger.handle_onion_message(bob_id, &onion_message);
let (invoice_request, reply_path) = extract_invoice_request(alice, &onion_message);
let nonce = extract_offer_nonce(alice, &onion_message);
let onion_message = alice.onion_messenger.next_onion_message_for_peer(charlie_id).unwrap();
- charlie.onion_messenger.handle_onion_message(&alice_id, &onion_message);
+ charlie.onion_messenger.handle_onion_message(alice_id, &onion_message);
// Drop the invoice in favor for one with unknown required features.
let onion_message = charlie.onion_messenger.next_onion_message_for_peer(david_id).unwrap();
alice.node.pending_offers_messages.lock().unwrap().push((message, instructions));
let onion_message = alice.onion_messenger.next_onion_message_for_peer(charlie_id).unwrap();
- charlie.onion_messenger.handle_onion_message(&alice_id, &onion_message);
+ charlie.onion_messenger.handle_onion_message(alice_id, &onion_message);
let onion_message = charlie.onion_messenger.next_onion_message_for_peer(david_id).unwrap();
- david.onion_messenger.handle_onion_message(&charlie_id, &onion_message);
+ david.onion_messenger.handle_onion_message(charlie_id, &onion_message);
// Confirm that david drops this failed payment from his pending outbound payments.
match get_event!(david, Event::PaymentFailed) {
callback_node();
}
// 0 => 1 update_add & CS
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &update_add_0);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add_0);
commitment_signed_dance!(nodes[1], nodes[0], &update_0.commitment_signed, false, true);
let update_1_0 = match test_case {
}
// 1 => 2
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &update_add_1);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &update_add_1);
commitment_signed_dance!(nodes[2], nodes[1], update_1.commitment_signed, false, true);
if test_case == 2 || test_case == 200 {
}
// 2 => 1
- nodes[1].node.handle_update_fail_htlc(&nodes[2].node.get_our_node_id(), &fail_msg);
+ nodes[1].node.handle_update_fail_htlc(nodes[2].node.get_our_node_id(), &fail_msg);
commitment_signed_dance!(nodes[1], nodes[2], update_2_1.commitment_signed, true);
// backward fail on 1
if test_case == 100 {
callback_fail(&mut fail_msg);
}
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &fail_msg);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &fail_msg);
} else {
- nodes[0].node.handle_update_fail_malformed_htlc(&nodes[1].node.get_our_node_id(), &update_1_0.update_fail_malformed_htlcs[0]);
+ nodes[0].node.handle_update_fail_malformed_htlc(nodes[1].node.get_our_node_id(), &update_1_0.update_fail_malformed_htlcs[0]);
};
commitment_signed_dance!(nodes[0], nodes[1], update_1_0.commitment_signed, false, true);
let short_channel_id = channels[1].0.contents.short_channel_id;
run_onion_failure_test("channel_disabled", 0, &nodes, &route, &payment_hash, &payment_secret, |_| {}, || {
// disconnect event to the channel between nodes[1] ~ nodes[2]
- nodes[1].node.peer_disconnected(&nodes[2].node.get_our_node_id());
- nodes[2].node.peer_disconnected(&nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[2].node.get_our_node_id());
+ nodes[2].node.peer_disconnected(nodes[1].node.get_our_node_id());
}, true, Some(UPDATE|7),
Some(NetworkUpdate::ChannelFailure { short_channel_id, is_permanent: false }),
Some(short_channel_id));
check_added_monitors!(nodes[0], 1);
let update_0 = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
let mut update_add_0 = update_0.update_add_htlcs[0].clone();
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &update_add_0);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add_0);
commitment_signed_dance!(nodes[1], nodes[0], &update_0.commitment_signed, false, true);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(&nodes[1], 1);
let update_1 = get_htlc_update_msgs!(nodes[1], nodes[2].node.get_our_node_id());
let mut update_add_1 = update_1.update_add_htlcs[0].clone();
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &update_add_1);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &update_add_1);
commitment_signed_dance!(nodes[2], nodes[1], update_1.commitment_signed, false, true);
expect_pending_htlcs_forwardable!(nodes[2]);
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
let mut payment_event = SendEvent::from_event(events.pop().unwrap());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[1]);
_ => panic!("Unexpected event"),
};
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &update_fail_htlc);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &update_fail_htlc);
commitment_signed_dance!(nodes[0], nodes[1], commitment_signed, false, true);
let failure_data = match failure_code {
let update_0 = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
let mut update_add = update_0.update_add_htlcs[0].clone();
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &update_add);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add);
commitment_signed_dance!(nodes[1], nodes[0], &update_0.commitment_signed, false, true);
// Modify the payload so the phantom hop's HMAC is bogus.
check_added_monitors!(&nodes[1], 1);
assert!(update_1.update_fail_htlcs.len() == 1);
let fail_msg = update_1.update_fail_htlcs[0].clone();
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &fail_msg);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &fail_msg);
commitment_signed_dance!(nodes[0], nodes[1], update_1.commitment_signed, false);
// Ensure the payment fails with the expected error.
let update_0 = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
let mut update_add = update_0.update_add_htlcs[0].clone();
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &update_add);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add);
commitment_signed_dance!(nodes[1], nodes[0], &update_0.commitment_signed, false, true);
// Modify the onion packet to have an invalid payment amount.
check_added_monitors!(&nodes[1], 1);
assert!(update_1.update_fail_htlcs.len() == 1);
let fail_msg = update_1.update_fail_htlcs[0].clone();
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &fail_msg);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &fail_msg);
commitment_signed_dance!(nodes[0], nodes[1], update_1.commitment_signed, false);
// Ensure the payment fails with the expected error.
let update_0 = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
let mut update_add = update_0.update_add_htlcs[0].clone();
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &update_add);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add);
commitment_signed_dance!(nodes[1], nodes[0], &update_0.commitment_signed, false, true);
// Modify the payload so the phantom hop's HMAC is bogus.
check_added_monitors!(&nodes[1], 1);
assert!(update_1.update_fail_htlcs.len() == 1);
let fail_msg = update_1.update_fail_htlcs[0].clone();
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &fail_msg);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &fail_msg);
commitment_signed_dance!(nodes[0], nodes[1], update_1.commitment_signed, false);
// Ensure the payment fails with the expected error.
let update_0 = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
let mut update_add = update_0.update_add_htlcs[0].clone();
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &update_add);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add);
commitment_signed_dance!(nodes[1], nodes[0], &update_0.commitment_signed, false, true);
expect_pending_htlcs_forwardable_ignore!(nodes[1]);
check_added_monitors!(&nodes[1], 1);
assert!(update_1.update_fail_htlcs.len() == 1);
let fail_msg = update_1.update_fail_htlcs[0].clone();
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &fail_msg);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &fail_msg);
commitment_signed_dance!(nodes[0], nodes[1], update_1.commitment_signed, false);
// Ensure the payment fails with the expected error.
// Modify the route to have a too-low cltv.
update_add.cltv_expiry -= 10;
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &update_add);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add);
commitment_signed_dance!(nodes[1], nodes[0], &update_0.commitment_signed, false, true);
let update_1 = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
assert!(update_1.update_fail_htlcs.len() == 1);
let fail_msg = update_1.update_fail_htlcs[0].clone();
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &fail_msg);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &fail_msg);
commitment_signed_dance!(nodes[0], nodes[1], update_1.commitment_signed, false);
// Ensure the payment fails with the expected error.
let mut update_add = update_0.update_add_htlcs[0].clone();
connect_blocks(&nodes[1], CLTV_FAR_FAR_AWAY);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &update_add);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add);
commitment_signed_dance!(nodes[1], nodes[0], &update_0.commitment_signed, false, true);
let update_1 = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
assert!(update_1.update_fail_htlcs.len() == 1);
let fail_msg = update_1.update_fail_htlcs[0].clone();
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &fail_msg);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &fail_msg);
commitment_signed_dance!(nodes[0], nodes[1], update_1.commitment_signed, false);
// Ensure the payment fails with the expected error.
let update_0 = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
let mut update_add = update_0.update_add_htlcs[0].clone();
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &update_add);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add);
commitment_signed_dance!(nodes[1], nodes[0], &update_0.commitment_signed, false, true);
expect_pending_htlcs_forwardable_ignore!(nodes[1]);
check_added_monitors!(&nodes[1], 1);
assert!(update_1.update_fail_htlcs.len() == 1);
let fail_msg = update_1.update_fail_htlcs[0].clone();
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &fail_msg);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &fail_msg);
commitment_signed_dance!(nodes[0], nodes[1], update_1.commitment_signed, false);
// Ensure the payment fails with the expected error.
let update_0 = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
let mut update_add = update_0.update_add_htlcs[0].clone();
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &update_add);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add);
commitment_signed_dance!(nodes[1], nodes[0], &update_0.commitment_signed, false, true);
let update_1 = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
assert!(update_1.update_fail_htlcs.len() == 1);
let fail_msg = update_1.update_fail_htlcs[0].clone();
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &fail_msg);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &fail_msg);
commitment_signed_dance!(nodes[0], nodes[1], update_1.commitment_signed, false);
// Ensure the payment fails with the expected error.
let update_0 = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
let mut update_add = update_0.update_add_htlcs[0].clone();
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &update_add);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add);
commitment_signed_dance!(nodes[1], nodes[0], &update_0.commitment_signed, false, true);
expect_pending_htlcs_forwardable_ignore!(nodes[1]);
check_added_monitors!(&nodes[1], 1);
assert!(update_1.update_fail_htlcs.len() == 1);
let fail_msg = update_1.update_fail_htlcs[0].clone();
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &fail_msg);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &fail_msg);
commitment_signed_dance!(nodes[0], nodes[1], update_1.commitment_signed, false);
// Ensure the payment fails with the expected error.
// Add the HTLC along the first hop.
let fail_path_msgs_1 = remove_first_msg_event_to_node(&nodes[2].node.get_our_node_id(), &mut events);
let send_event = SendEvent::from_event(fail_path_msgs_1);
- nodes[2].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
+ nodes[2].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
commitment_signed_dance!(nodes[2], nodes[0], &send_event.commitment_msg, false);
// Attempt to forward the payment and complete the 2nd path's failure.
assert!(htlc_updates.update_fulfill_htlcs.is_empty());
assert!(htlc_updates.update_fail_malformed_htlcs.is_empty());
check_added_monitors!(nodes[2], 1);
- nodes[0].node.handle_update_fail_htlc(&nodes[2].node.get_our_node_id(), &htlc_updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[2].node.get_our_node_id(), &htlc_updates.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[2], htlc_updates.commitment_signed, false);
let mut events = nodes[0].node.get_and_clear_pending_events();
match events[1] {
// Add the HTLC along the first hop.
let fail_path_msgs_1 = remove_first_msg_event_to_node(&nodes[2].node.get_our_node_id(), &mut events);
let send_event = SendEvent::from_event(fail_path_msgs_1);
- nodes[2].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
+ nodes[2].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
commitment_signed_dance!(nodes[2], nodes[0], &send_event.commitment_msg, false);
// Attempt to forward the payment and complete the 2nd path's failure.
assert!(htlc_updates.update_fulfill_htlcs.is_empty());
assert!(htlc_updates.update_fail_malformed_htlcs.is_empty());
check_added_monitors!(nodes[2], 1);
- nodes[0].node.handle_update_fail_htlc(&nodes[2].node.get_our_node_id(),
+ nodes[0].node.handle_update_fail_htlc(nodes[2].node.get_our_node_id(),
&htlc_updates.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[2], htlc_updates.commitment_signed, false);
let mut events = nodes[0].node.get_and_clear_pending_events();
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[3], vec![HTLCDestination::FailedPayment { payment_hash }]);
let htlc_fail_updates_3_1 = get_htlc_update_msgs!(nodes[3], nodes[1].node.get_our_node_id());
assert_eq!(htlc_fail_updates_3_1.update_fail_htlcs.len(), 1);
- nodes[1].node.handle_update_fail_htlc(&nodes[3].node.get_our_node_id(), &htlc_fail_updates_3_1.update_fail_htlcs[0]);
+ nodes[1].node.handle_update_fail_htlc(nodes[3].node.get_our_node_id(), &htlc_fail_updates_3_1.update_fail_htlcs[0]);
check_added_monitors!(nodes[3], 1);
commitment_signed_dance!(nodes[1], nodes[3], htlc_fail_updates_3_1.commitment_signed, false);
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], vec![HTLCDestination::NextHopChannel { node_id: Some(nodes[3].node.get_our_node_id()), channel_id: chan_3_id }]);
let htlc_fail_updates_1_0 = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
assert_eq!(htlc_fail_updates_1_0.update_fail_htlcs.len(), 1);
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &htlc_fail_updates_1_0.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &htlc_fail_updates_1_0.update_fail_htlcs[0]);
check_added_monitors!(nodes[1], 1);
commitment_signed_dance!(nodes[0], nodes[1], htlc_fail_updates_1_0.commitment_signed, false);
}
check_added_monitors!(nodes[0], 1);
let send_event = SendEvent::from_node(&nodes[0]);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
do_commitment_signed_dance(&nodes[1], &nodes[0], &send_event.commitment_msg, false, false);
expect_pending_htlcs_forwardable!(nodes[1]);
// Previously, a refactor caused us to stop including the payment preimage in the onion which
let update_0 = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
let update_add_0 = update_0.update_add_htlcs[0].clone();
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &update_add_0);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add_0);
commitment_signed_dance!(nodes[1], nodes[0], &update_0.commitment_signed, false, true);
expect_pending_htlcs_forwardable!(nodes[1]);
check_added_monitors!(&nodes[1], 1);
let update_1 = get_htlc_update_msgs!(nodes[1], nodes[3].node.get_our_node_id());
let update_add_1 = update_1.update_add_htlcs[0].clone();
- nodes[3].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &update_add_1);
+ nodes[3].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &update_add_1);
commitment_signed_dance!(nodes[3], nodes[1], update_1.commitment_signed, false, true);
assert!(nodes[3].node.get_and_clear_pending_msg_events().is_empty());
let update_2 = get_htlc_update_msgs!(nodes[0], nodes[2].node.get_our_node_id());
let update_add_2 = update_2.update_add_htlcs[0].clone();
- nodes[2].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &update_add_2);
+ nodes[2].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add_2);
commitment_signed_dance!(nodes[2], nodes[0], &update_2.commitment_signed, false, true);
expect_pending_htlcs_forwardable!(nodes[2]);
check_added_monitors!(&nodes[2], 1);
let update_3 = get_htlc_update_msgs!(nodes[2], nodes[3].node.get_our_node_id());
let update_add_3 = update_3.update_add_htlcs[0].clone();
- nodes[3].node.handle_update_add_htlc(&nodes[2].node.get_our_node_id(), &update_add_3);
+ nodes[3].node.handle_update_add_htlc(nodes[2].node.get_our_node_id(), &update_add_3);
commitment_signed_dance!(nodes[3], nodes[2], update_3.commitment_signed, false, true);
assert!(nodes[3].node.get_and_clear_pending_msg_events().is_empty());
// Fail back along nodes[2]
let update_fail_0 = get_htlc_update_msgs!(&nodes[3], &nodes[2].node.get_our_node_id());
- nodes[2].node.handle_update_fail_htlc(&nodes[3].node.get_our_node_id(), &update_fail_0.update_fail_htlcs[0]);
+ nodes[2].node.handle_update_fail_htlc(nodes[3].node.get_our_node_id(), &update_fail_0.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[2], nodes[3], update_fail_0.commitment_signed, false);
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[2], vec![HTLCDestination::NextHopChannel { node_id: Some(nodes[3].node.get_our_node_id()), channel_id: chan_4_channel_id }]);
check_added_monitors!(nodes[2], 1);
let update_fail_1 = get_htlc_update_msgs!(nodes[2], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fail_htlc(&nodes[2].node.get_our_node_id(), &update_fail_1.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[2].node.get_our_node_id(), &update_fail_1.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[2], update_fail_1.commitment_signed, false);
expect_payment_failed_conditions(&nodes[0], payment_hash, true, PaymentFailedConditions::new());
let (route, payment_hash, _, payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[1], 100_000);
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
unwrap_send_err!(nodes[0].node.send_payment_with_route(route, payment_hash,
RecipientOnionFields::secret_only(payment_secret), PaymentId(payment_hash.0)
// We relay the payment to nodes[1] while its disconnected from nodes[2], causing the payment
// to be returned immediately to nodes[0], without having nodes[2] fail the inbound payment
// which would prevent retry.
- nodes[1].node.peer_disconnected(&nodes[2].node.get_our_node_id());
- nodes[2].node.peer_disconnected(&nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[2].node.get_our_node_id());
+ nodes[2].node.peer_disconnected(nodes[1].node.get_our_node_id());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false, true);
// nodes[1] now immediately fails the HTLC as the next-hop channel is disconnected
let _ = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
}
check_added_monitors!(nodes[0], 1);
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
- nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init {
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).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 {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, false).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);
+ 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();
assert_eq!(as_err.len(), 2);
match as_err[1] {
MessageSendEvent::HandleError { node_id, action: msgs::ErrorAction::SendErrorMessage { ref msg } } => {
assert_eq!(node_id, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_error(&nodes[0].node.get_our_node_id(), msg);
+ nodes[1].node.handle_error(nodes[0].node.get_our_node_id(), msg);
check_closed_event!(nodes[1], 1, ClosureReason::CounterpartyForceClosed { peer_msg: UntrustedString(format!("Got a message for a channel from the wrong node! No such channel for the passed counterparty_node_id {}",
&nodes[1].node.get_our_node_id())) }, [nodes[0].node.get_our_node_id()], 100000);
check_added_monitors!(nodes[1], 1);
expect_payment_claimed!(nodes[2], payment_hash_1, 1_000_000);
let htlc_fulfill_updates = get_htlc_update_msgs!(nodes[2], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_update_fulfill_htlc(&nodes[2].node.get_our_node_id(), &htlc_fulfill_updates.update_fulfill_htlcs[0]);
+ nodes[1].node.handle_update_fulfill_htlc(nodes[2].node.get_our_node_id(), &htlc_fulfill_updates.update_fulfill_htlcs[0]);
check_added_monitors!(nodes[1], 1);
commitment_signed_dance!(nodes[1], nodes[2], htlc_fulfill_updates.commitment_signed, false);
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], None, true, false);
let chan_0_monitor_serialized = get_monitor!(nodes[0], chan_id).encode();
reload_node!(nodes[0], test_default_channel_config(), nodes_0_serialized, &[&chan_0_monitor_serialized], first_persister, first_new_chain_monitor, first_nodes_0_deserialized);
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
// On reload, the ChannelManager should realize it is stale compared to the ChannelMonitor and
// force-close the channel.
assert_eq!(nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0).len(), 1);
check_added_monitors!(nodes[0], 1);
- nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init {
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).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 {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, false).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);
+ 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();
assert_eq!(as_err.len(), 2);
let bs_commitment_tx;
match as_err[1] {
MessageSendEvent::HandleError { node_id, action: msgs::ErrorAction::SendErrorMessage { ref msg } } => {
assert_eq!(node_id, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_error(&nodes[0].node.get_our_node_id(), msg);
+ nodes[1].node.handle_error(nodes[0].node.get_our_node_id(), msg);
check_closed_event!(nodes[1], 1, ClosureReason::CounterpartyForceClosed { peer_msg: UntrustedString(format!("Got a message for a channel from the wrong node! No such channel for the passed counterparty_node_id {}", &nodes[1].node.get_our_node_id())) }
, [nodes[0].node.get_our_node_id()], 100000);
check_added_monitors!(nodes[1], 1);
check_added_monitors!(nodes[2], 1);
let htlc_fulfill_updates = get_htlc_update_msgs!(nodes[2], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_update_fail_htlc(&nodes[2].node.get_our_node_id(), &htlc_fulfill_updates.update_fail_htlcs[0]);
+ nodes[1].node.handle_update_fail_htlc(nodes[2].node.get_our_node_id(), &htlc_fulfill_updates.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[1], nodes[2], htlc_fulfill_updates.commitment_signed, false);
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1],
[HTLCDestination::NextHopChannel { node_id: Some(nodes[2].node.get_our_node_id()), channel_id: chan_id_2 }]);
assert!(!nodes[0].node.get_and_clear_pending_msg_events().is_empty());
reload_node!(nodes[0], test_default_channel_config(), nodes_0_serialized, &[&chan_0_monitor_serialized, &chan_1_monitor_serialized], second_persister, second_new_chain_monitor, second_nodes_0_deserialized);
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
nodes[0].node.test_process_background_events();
check_added_monitors(&nodes[0], 1);
// Check that after reload we can send the payment again (though we shouldn't, since it was
// claimed previously).
reload_node!(nodes[0], test_default_channel_config(), nodes_0_serialized, &[&chan_0_monitor_serialized, &chan_1_monitor_serialized], third_persister, third_new_chain_monitor, third_nodes_0_deserialized);
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
nodes[0].node.test_process_background_events();
check_added_monitors(&nodes[0], 1);
check_added_monitors!(nodes[0], 1);
check_closed_event!(nodes[0], 1, ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(true) }, [nodes[1].node.get_our_node_id()], 100000);
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
// Connect blocks until the CLTV timeout is up so that we get an HTLC-Timeout transaction
connect_blocks(&nodes[0], TEST_FINAL_CLTV + LATENCY_GRACE_PERIOD_BLOCKS + 1);
expect_payment_claimed!(nodes[1], payment_hash, 100_000);
let htlc_fulfill_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &htlc_fulfill_updates.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &htlc_fulfill_updates.update_fulfill_htlcs[0]);
expect_payment_sent(&nodes[0], payment_preimage, None, false, false);
// Now reload nodes[1]...
reload_node!(nodes[1], &chan_manager_serialized, &[&chan_0_monitor_serialized], persister, new_chain_monitor, nodes_1_deserialized);
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[1]));
nodes[1].node.fail_htlc_backwards(&payment_hash);
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], vec![HTLCDestination::FailedPayment { payment_hash }]);
check_added_monitors!(nodes[1], 1);
let htlc_fail_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &htlc_fail_updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &htlc_fail_updates.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], htlc_fail_updates.commitment_signed, false);
// nodes[0] shouldn't generate any events here, while it just got a payment failure completion
// it had already considered the payment fulfilled, and now they just got free money.
check_added_monitors!(nodes[0], 1);
let updates = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
let probe_event = SendEvent::from_commitment_update(nodes[1].node.get_our_node_id(), updates);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &probe_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &probe_event.msgs[0]);
check_added_monitors!(nodes[1], 0);
commitment_signed_dance!(nodes[1], nodes[0], probe_event.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[1]);
let updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
// Skip the PendingHTLCsForwardable event
let _events = nodes[1].node.get_and_clear_pending_events();
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
check_added_monitors!(nodes[0], 0);
commitment_signed_dance!(nodes[0], nodes[1], updates.commitment_signed, false);
check_added_monitors!(nodes[0], 1);
let updates = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
let probe_event = SendEvent::from_commitment_update(nodes[1].node.get_our_node_id(), updates);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &probe_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &probe_event.msgs[0]);
check_added_monitors!(nodes[1], 0);
commitment_signed_dance!(nodes[1], nodes[0], probe_event.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[1]);
assert_eq!(events.len(), 1);
SendEvent::from_event(events.remove(0))
};
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], &payment_event.commitment_msg, false, true);
// Check that we generate the PaymentIntercepted event when an intercept forward is detected.
check_added_monitors!(&nodes[1], 1);
assert!(update_fail.update_fail_htlcs.len() == 1);
let fail_msg = update_fail.update_fail_htlcs[0].clone();
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &fail_msg);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &fail_msg);
commitment_signed_dance!(nodes[0], nodes[1], update_fail.commitment_signed, false);
// Ensure the payment fails with the expected error.
assert_eq!(events.len(), 1);
SendEvent::from_event(events.remove(0))
};
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[2], nodes[1], &payment_event.commitment_msg, false, true);
expect_pending_htlcs_forwardable!(nodes[2]);
assert!(htlc_timeout_updates.update_fail_malformed_htlcs.is_empty());
assert!(htlc_timeout_updates.update_fee.is_none());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &htlc_timeout_updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &htlc_timeout_updates.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], htlc_timeout_updates.commitment_signed, false);
expect_payment_failed!(nodes[0], payment_hash, false, 0x2000 | 2, []);
// Forward the intercepted payments.
for (idx, ev) in events.into_iter().enumerate() {
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &ev.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &ev.msgs[0]);
do_commitment_signed_dance(&nodes[1], &nodes[0], &ev.commitment_msg, false, true);
let events = nodes[1].node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
SendEvent::from_event(events.remove(0))
};
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &payment_event.msgs[0]);
do_commitment_signed_dance(&nodes[2], &nodes[1], &payment_event.commitment_msg, false, true);
if idx == num_mpp_parts - 1 {
expect_pending_htlcs_forwardable!(nodes[2]);
check_added_monitors!(nodes[0], 1);
let update_0 = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
let mut update_add = update_0.update_add_htlcs[0].clone();
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &update_add);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add);
commitment_signed_dance!(nodes[1], nodes[0], &update_0.commitment_signed, false, true);
expect_pending_htlcs_forwardable_ignore!(nodes[1]);
nodes[1].node.process_pending_htlc_forwards();
check_added_monitors!(&nodes[1], 1);
assert!(update_1.update_fail_htlcs.len() == 1);
let fail_msg = update_1.update_fail_htlcs[0].clone();
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &fail_msg);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &fail_msg);
commitment_signed_dance!(nodes[0], nodes[1], update_1.commitment_signed, false);
// Ensure the attempt fails and a new PendingHTLCsForwardable event is generated for the retry
assert_eq!(msg_events.len(), 1);
let mut payment_event = SendEvent::from_event(msg_events.remove(0));
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &payment_event.commitment_msg);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &payment_event.commitment_msg);
check_added_monitors!(nodes[1], 1);
let (bs_first_raa, bs_first_cs) = get_revoke_commit_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_first_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_first_raa);
check_added_monitors!(nodes[0], 1);
let as_second_htlc_updates = SendEvent::from_node(&nodes[0]);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_first_cs);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_first_cs);
check_added_monitors!(nodes[0], 1);
let as_first_raa = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_first_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_first_raa);
check_added_monitors!(nodes[1], 1);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &as_second_htlc_updates.msgs[0]);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &as_second_htlc_updates.msgs[1]);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_second_htlc_updates.commitment_msg);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &as_second_htlc_updates.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &as_second_htlc_updates.msgs[1]);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_second_htlc_updates.commitment_msg);
check_added_monitors!(nodes[1], 1);
let (bs_second_raa, bs_second_cs) = get_revoke_commit_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_second_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_second_raa);
check_added_monitors!(nodes[0], 1);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_second_cs);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_second_cs);
check_added_monitors!(nodes[0], 1);
let as_second_raa = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_second_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_second_raa);
check_added_monitors!(nodes[1], 1);
expect_pending_htlcs_forwardable_ignore!(nodes[1]);
let bs_claim_update = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
assert_eq!(bs_claim_update.update_fulfill_htlcs.len(), 1);
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &bs_claim_update.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &bs_claim_update.update_fulfill_htlcs[0]);
expect_payment_sent(&nodes[0], payment_preimage, None, false, false);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_claim_update.commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_claim_update.commitment_signed);
check_added_monitors!(nodes[0], 1);
let (as_third_raa, as_third_cs) = get_revoke_commit_msgs!(nodes[0], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_third_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_third_raa);
check_added_monitors!(nodes[1], 4);
let bs_second_claim_update = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_third_cs);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_third_cs);
check_added_monitors!(nodes[1], 1);
let bs_third_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_third_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_third_raa);
check_added_monitors!(nodes[0], 1);
expect_payment_path_successful!(nodes[0]);
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &bs_second_claim_update.update_fulfill_htlcs[0]);
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &bs_second_claim_update.update_fulfill_htlcs[1]);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_second_claim_update.commitment_signed);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &bs_second_claim_update.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &bs_second_claim_update.update_fulfill_htlcs[1]);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_second_claim_update.commitment_signed);
check_added_monitors!(nodes[0], 1);
let (as_fourth_raa, as_fourth_cs) = get_revoke_commit_msgs!(nodes[0], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_fourth_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_fourth_raa);
check_added_monitors!(nodes[1], 1);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_fourth_cs);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_fourth_cs);
check_added_monitors!(nodes[1], 1);
let bs_second_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_second_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_second_raa);
check_added_monitors!(nodes[0], 1);
let events = nodes[0].node.get_and_clear_pending_events();
assert_eq!(events.len(), 2);
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
let mut payment_event = SendEvent::from_event(events.pop().unwrap());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
check_added_monitors!(nodes[1], 0);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[1]);
check_added_monitors!(nodes[0], 1);
assert_eq!(htlc_updates.msgs.len(), 1);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &htlc_updates.msgs[0]);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &htlc_updates.commitment_msg);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &htlc_updates.msgs[0]);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &htlc_updates.commitment_msg);
check_added_monitors!(nodes[1], 1);
let (bs_first_raa, bs_first_cs) = get_revoke_commit_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_first_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_first_raa);
check_added_monitors!(nodes[0], 1);
let second_htlc_updates = SendEvent::from_node(&nodes[0]);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_first_cs);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_first_cs);
check_added_monitors!(nodes[0], 1);
let as_first_raa = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &second_htlc_updates.msgs[0]);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &second_htlc_updates.commitment_msg);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &second_htlc_updates.msgs[0]);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &second_htlc_updates.commitment_msg);
check_added_monitors!(nodes[1], 1);
let bs_second_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_first_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_first_raa);
check_added_monitors!(nodes[1], 1);
let bs_fail_update = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_second_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_second_raa);
check_added_monitors!(nodes[0], 1);
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &bs_fail_update.update_fail_htlcs[0]);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_fail_update.commitment_signed);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &bs_fail_update.update_fail_htlcs[0]);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_fail_update.commitment_signed);
check_added_monitors!(nodes[0], 1);
let (as_second_raa, as_third_cs) = get_revoke_commit_msgs!(nodes[0], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_second_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_second_raa);
check_added_monitors!(nodes[1], 1);
let bs_second_fail_update = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_third_cs);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_third_cs);
check_added_monitors!(nodes[1], 1);
let bs_third_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &bs_second_fail_update.update_fail_htlcs[0]);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_second_fail_update.commitment_signed);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &bs_second_fail_update.update_fail_htlcs[0]);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_second_fail_update.commitment_signed);
check_added_monitors!(nodes[0], 1);
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_third_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_third_raa);
check_added_monitors!(nodes[0], 1);
let (as_third_raa, as_fourth_cs) = get_revoke_commit_msgs!(nodes[0], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_third_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_third_raa);
check_added_monitors!(nodes[1], 1);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_fourth_cs);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_fourth_cs);
check_added_monitors!(nodes[1], 1);
let bs_fourth_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_fourth_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_fourth_raa);
check_added_monitors!(nodes[0], 1);
// At this point A has sent two HTLCs which both failed due to lack of fee. It now has two
let retry_htlc_updates = SendEvent::from_node(&nodes[0]);
check_added_monitors!(nodes[0], 1);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &retry_htlc_updates.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &retry_htlc_updates.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], &retry_htlc_updates.commitment_msg, false, true);
let bs_fail_update = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &bs_fail_update.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &bs_fail_update.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], &bs_fail_update.commitment_signed, false, true);
let mut events = nodes[0].node.get_and_clear_pending_events();
check_added_monitors!(nodes[0], 1);
assert_eq!(htlc_updates.msgs.len(), 1);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &htlc_updates.msgs[0]);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &htlc_updates.commitment_msg);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &htlc_updates.msgs[0]);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &htlc_updates.commitment_msg);
check_added_monitors!(nodes[1], 1);
let (bs_first_raa, bs_first_cs) = get_revoke_commit_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_first_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_first_raa);
check_added_monitors!(nodes[0], 1);
let second_htlc_updates = SendEvent::from_node(&nodes[0]);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_first_cs);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_first_cs);
check_added_monitors!(nodes[0], 1);
let as_first_raa = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &second_htlc_updates.msgs[0]);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &second_htlc_updates.commitment_msg);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &second_htlc_updates.msgs[0]);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &second_htlc_updates.commitment_msg);
check_added_monitors!(nodes[1], 1);
let bs_second_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_first_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_first_raa);
check_added_monitors!(nodes[1], 1);
let bs_fail_update = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_second_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_second_raa);
check_added_monitors!(nodes[0], 1);
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &bs_fail_update.update_fail_htlcs[0]);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_fail_update.commitment_signed);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &bs_fail_update.update_fail_htlcs[0]);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_fail_update.commitment_signed);
check_added_monitors!(nodes[0], 1);
let (as_second_raa, as_third_cs) = get_revoke_commit_msgs!(nodes[0], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_second_raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &as_second_raa);
check_added_monitors!(nodes[1], 1);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_third_cs);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_third_cs);
check_added_monitors!(nodes[1], 1);
let bs_third_raa = get_event_msg!(nodes[1], MessageSendEvent::SendRevokeAndACK, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_third_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_third_raa);
check_added_monitors!(nodes[0], 1);
let mut events = nodes[0].node.get_and_clear_pending_events();
let retry_htlc_updates = SendEvent::from_node(&nodes[0]);
check_added_monitors!(nodes[0], 1);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &retry_htlc_updates.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &retry_htlc_updates.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], &retry_htlc_updates.commitment_msg, false, true);
expect_pending_htlcs_forwardable!(nodes[1]);
check_added_monitors!(nodes[1], 1);
let bs_forward_update = get_htlc_update_msgs!(nodes[1], nodes[2].node.get_our_node_id());
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &bs_forward_update.update_add_htlcs[0]);
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &bs_forward_update.update_add_htlcs[1]);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &bs_forward_update.update_add_htlcs[0]);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &bs_forward_update.update_add_htlcs[1]);
commitment_signed_dance!(nodes[2], nodes[1], &bs_forward_update.commitment_signed, false);
expect_pending_htlcs_forwardable!(nodes[2]);
let send_event = SendEvent::from_event(send_msg_events.pop().unwrap());
assert_eq!(send_event.msgs.len(), 1);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], send_event.commitment_msg, false, true);
// Note that we only push one route into `expect_find_route` at a time, because that's all
nodes[0].router.expect_find_route(new_route_params, Ok(route.clone()));
let bs_fail_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &bs_fail_updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &bs_fail_updates.update_fail_htlcs[0]);
// The "normal" commitment_signed_dance delivers the final RAA and then calls
// `check_added_monitors` to ensure only the one RAA-generated monitor update was created.
// This races with our other threads which may generate an add-HTLCs commitment update via
// `process_pending_htlc_forwards`. Instead, we defer the monitor update check until after
// *we've* called `process_pending_htlc_forwards` when its guaranteed to have two updates.
let last_raa = commitment_signed_dance!(nodes[0], nodes[1], bs_fail_updates.commitment_signed, false, true, false, true);
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &last_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &last_raa);
let cur_time = Instant::now();
if cur_time > end_time {
if at_midpoint {
let updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &updates.commitment_signed);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &updates.commitment_signed);
check_added_monitors!(nodes[0], 1);
} else {
let htlc_fulfill_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &htlc_fulfill_updates.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &htlc_fulfill_updates.update_fulfill_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], htlc_fulfill_updates.commitment_signed, false);
// Ignore the PaymentSent event which is now pending on nodes[0] - if we were to handle it we'd
// be expected to ignore the eventual conflicting PaymentFailed, but by not looking at it we
check_added_monitors(&nodes[1], 1);
assert_eq!(bs_claims.len(), 1);
if let MessageSendEvent::UpdateHTLCs { updates, .. } = &bs_claims[0] {
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], updates.commitment_signed, false, true);
} else { panic!(); }
let ds_claim_msgs = nodes[3].node.get_and_clear_pending_msg_events();
assert_eq!(ds_claim_msgs.len(), 1);
let cs_claim_msgs = if let MessageSendEvent::UpdateHTLCs { updates, .. } = &ds_claim_msgs[0] {
- nodes[2].node.handle_update_fulfill_htlc(&nodes[3].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
+ nodes[2].node.handle_update_fulfill_htlc(nodes[3].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
let cs_claim_msgs = nodes[2].node.get_and_clear_pending_msg_events();
check_added_monitors(&nodes[2], 1);
commitment_signed_dance!(nodes[2], nodes[3], updates.commitment_signed, false, true);
assert_eq!(cs_claim_msgs.len(), 1);
if let MessageSendEvent::UpdateHTLCs { updates, .. } = &cs_claim_msgs[0] {
- nodes[0].node.handle_update_fulfill_htlc(&nodes[2].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[2].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[2], updates.commitment_signed, false, true);
} else { panic!(); }
let ev = remove_first_msg_event_to_node(&nodes[1].node.get_our_node_id(), &mut events);
let mut payment_event = SendEvent::from_event(ev);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
check_added_monitors!(&nodes[1], 0);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[1]);
let htlc_updates = get_htlc_update_msgs(&nodes[0], &nodes[1].node.get_our_node_id());
let msgs::CommitmentUpdate { update_add_htlcs, commitment_signed, .. } = htlc_updates;
assert_eq!(update_add_htlcs.len(), 1);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &update_add_htlcs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add_htlcs[0]);
commitment_signed_dance!(nodes[1], nodes[0], commitment_signed, false);
// Attempt to forward the payment and complete the path's failure.
let htlc_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
let msgs::CommitmentUpdate { update_fail_htlcs, commitment_signed, .. } = htlc_updates;
assert_eq!(update_fail_htlcs.len(), 1);
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], commitment_signed, false);
let mut events = nodes[0].node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
let payment_event = SendEvent::from_event(events.pop().unwrap());
- nodes[2].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[2].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[2], nodes[0], payment_event.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[2]);
assert_eq!(events.len(), 1);
let payment_event = SendEvent::from_event(events.pop().unwrap());
- nodes[3].node.handle_update_add_htlc(&nodes[2].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[3].node.handle_update_add_htlc(nodes[2].node.get_our_node_id(), &payment_event.msgs[0]);
check_added_monitors!(nodes[3], 0);
commitment_signed_dance!(nodes[3], nodes[2], payment_event.commitment_msg, true, true);
}
check_added_monitors!(nodes[3], 1);
let fail_updates_1 = get_htlc_update_msgs!(nodes[3], nodes[2].node.get_our_node_id());
- nodes[2].node.handle_update_fail_htlc(&nodes[3].node.get_our_node_id(), &fail_updates_1.update_fail_htlcs[0]);
+ nodes[2].node.handle_update_fail_htlc(nodes[3].node.get_our_node_id(), &fail_updates_1.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[2], nodes[3], fail_updates_1.commitment_signed, false);
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[2], vec![
check_added_monitors!(nodes[2], 1);
let fail_updates_2 = get_htlc_update_msgs!(nodes[2], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fail_htlc(&nodes[2].node.get_our_node_id(), &fail_updates_2.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[2].node.get_our_node_id(), &fail_updates_2.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[2], fail_updates_2.commitment_signed, false);
expect_payment_failed_conditions(&nodes[0], our_payment_hash, true,
} else {
(&second_send, &first_send)
};
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &b_recv_ev.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &b_recv_ev.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], b_recv_ev.commitment_msg, false, true);
expect_pending_htlcs_forwardable!(nodes[1]);
check_added_monitors(&nodes[1], 1);
let b_forward_ev = SendEvent::from_node(&nodes[1]);
- nodes[3].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &b_forward_ev.msgs[0]);
+ nodes[3].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &b_forward_ev.msgs[0]);
commitment_signed_dance!(nodes[3], nodes[1], b_forward_ev.commitment_msg, false, true);
expect_pending_htlcs_forwardable!(nodes[3]);
// Before delivering the second MPP HTLC to nodes[2], disconnect nodes[2] and nodes[3], which
// will result in nodes[2] failing the HTLC back.
- nodes[2].node.peer_disconnected(&nodes[3].node.get_our_node_id());
- nodes[3].node.peer_disconnected(&nodes[2].node.get_our_node_id());
+ nodes[2].node.peer_disconnected(nodes[3].node.get_our_node_id());
+ nodes[3].node.peer_disconnected(nodes[2].node.get_our_node_id());
- nodes[2].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &c_recv_ev.msgs[0]);
+ nodes[2].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &c_recv_ev.msgs[0]);
commitment_signed_dance!(nodes[2], nodes[0], c_recv_ev.commitment_msg, false, true);
let cs_fail = get_htlc_update_msgs(&nodes[2], &nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fail_htlc(&nodes[2].node.get_our_node_id(), &cs_fail.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[2].node.get_our_node_id(), &cs_fail.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[2], cs_fail.commitment_signed, false, true);
let payment_fail_retryable_evs = nodes[0].node.get_and_clear_pending_events();
let mon_cd = get_monitor!(nodes[3], chan_id_cd).encode();
reload_node!(nodes[3], config, &nodes[3].node.encode(), &[&mon_bd, &mon_cd],
persister, new_chain_monitor, nodes_0_deserialized);
- nodes[1].node.peer_disconnected(&nodes[3].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[3].node.get_our_node_id());
reconnect_nodes(ReconnectArgs::new(&nodes[1], &nodes[3]));
}
let mut reconnect_args = ReconnectArgs::new(&nodes[2], &nodes[3]);
nodes[0].node.process_pending_htlc_forwards();
check_added_monitors(&nodes[0], 1);
let as_resend = SendEvent::from_node(&nodes[0]);
- nodes[2].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &as_resend.msgs[0]);
+ nodes[2].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &as_resend.msgs[0]);
commitment_signed_dance!(nodes[2], nodes[0], as_resend.commitment_msg, false, true);
expect_pending_htlcs_forwardable!(nodes[2]);
check_added_monitors(&nodes[2], 1);
let cs_forward = SendEvent::from_node(&nodes[2]);
let cd_channel_used = cs_forward.msgs[0].channel_id;
- nodes[3].node.handle_update_add_htlc(&nodes[2].node.get_our_node_id(), &cs_forward.msgs[0]);
+ nodes[3].node.handle_update_add_htlc(nodes[2].node.get_our_node_id(), &cs_forward.msgs[0]);
commitment_signed_dance!(nodes[3], nodes[2], cs_forward.commitment_msg, false, true);
// Finally, check that nodes[3] does the correct thing - either accepting the payment or, if
check_added_monitors(&nodes[3], 1);
let ds_fail = get_htlc_update_msgs(&nodes[3], &nodes[2].node.get_our_node_id());
- nodes[2].node.handle_update_fail_htlc(&nodes[3].node.get_our_node_id(), &ds_fail.update_fail_htlcs[0]);
+ nodes[2].node.handle_update_fail_htlc(nodes[3].node.get_our_node_id(), &ds_fail.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[2], nodes[3], ds_fail.commitment_signed, false, true);
expect_pending_htlcs_forwardable_conditions(nodes[2].node.get_and_clear_pending_events(),
&[HTLCDestination::NextHopChannel { node_id: Some(nodes[3].node.get_our_node_id()), channel_id: cd_channel_used }]);
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
let mut update_add_htlc = if let MessageSendEvent::UpdateHTLCs { updates, .. } = events.pop().unwrap() {
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
check_added_monitors(&nodes[1], 0);
commitment_signed_dance!(nodes[1], nodes[0], &updates.commitment_signed, false);
updates.update_add_htlcs[0].clone()
let mut events = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
if let MessageSendEvent::UpdateHTLCs { updates, .. } = events.pop().unwrap() {
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
check_added_monitors(&nodes[0], 0);
commitment_signed_dance!(nodes[0], nodes[1], &updates.commitment_signed, false);
} else {
// Assume that the forwarding node did forward it, and make sure the recipient rejects it as an
// invalid update and closes the channel.
update_add_htlc.channel_id = chan_id_2;
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &update_add_htlc);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &update_add_htlc);
check_closed_event(&nodes[2], 1, ClosureReason::ProcessingError {
err: "Remote HTLC add would put them under remote reserve value".to_owned()
}, false, &[nodes[1].node.get_our_node_id()], 1_000_000);
let mut msg_events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(msg_events.len(), 1);
let mut send_event = SendEvent::from_event(msg_events.remove(0));
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], &send_event.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[1]);
} else {
channel_id_2
});
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &send_event.msgs[0]);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &send_event.msgs[0]);
commitment_signed_dance!(nodes[2], nodes[1], &send_event.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[2]);
let mut msg_events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(msg_events.len(), 1);
let mut send_event = SendEvent::from_event(msg_events.remove(0));
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], &send_event.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[1]);
&[HTLCDestination::NextHopChannel { node_id: Some(nodes[2].node.get_our_node_id()), channel_id: routed_channel_id }]);
let updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], updates.commitment_signed, false);
let events = nodes[0].node.get_and_clear_pending_events();
expect_payment_failed_conditions_event(events, payment_hash, false, PaymentFailedConditions::new().blamed_scid(routed_scid));
/// Handles the given message sent from `sender_node_id`, possibly producing messages for
/// [`CustomMessageHandler::get_and_clear_pending_msg`] to return and thus for [`PeerManager`]
/// to send.
- fn handle_custom_message(&self, msg: Self::CustomMessage, sender_node_id: &PublicKey) -> Result<(), LightningError>;
+ fn handle_custom_message(&self, msg: Self::CustomMessage, sender_node_id: PublicKey) -> Result<(), LightningError>;
/// Returns the list of pending messages that were generated by the handler, clearing the list
/// in the process. Each message is paired with the node id of the intended recipient. If no
fn get_and_clear_pending_msg(&self) -> Vec<(PublicKey, Self::CustomMessage)>;
/// Indicates a peer disconnected.
- fn peer_disconnected(&self, their_node_id: &PublicKey);
+ fn peer_disconnected(&self, their_node_id: PublicKey);
/// Handle a peer connecting.
///
/// May return an `Err(())` if the features the peer supports are not sufficient to communicate
/// with us. Implementors should be somewhat conservative about doing so, however, as other
/// message handlers may still wish to communicate with this peer.
- fn peer_connected(&self, their_node_id: &PublicKey, msg: &Init, inbound: bool) -> Result<(), ()>;
+ fn peer_connected(&self, their_node_id: PublicKey, msg: &Init, inbound: bool) -> Result<(), ()>;
/// Gets the node feature flags which this handler itself supports. All available handlers are
/// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
/// which are sent in our [`Init`] message.
///
/// [`Init`]: crate::ln::msgs::Init
- fn provided_init_features(&self, their_node_id: &PublicKey) -> InitFeatures;
+ fn provided_init_features(&self, their_node_id: PublicKey) -> InitFeatures;
}
/// A dummy struct which implements `RoutingMessageHandler` without storing any routing information
fn get_and_clear_pending_msg_events(&self) -> Vec<MessageSendEvent> { Vec::new() }
}
impl RoutingMessageHandler for IgnoringMessageHandler {
- fn handle_node_announcement(&self, _their_node_id: Option<&PublicKey>, _msg: &msgs::NodeAnnouncement) -> Result<bool, LightningError> { Ok(false) }
- fn handle_channel_announcement(&self, _their_node_id: Option<&PublicKey>, _msg: &msgs::ChannelAnnouncement) -> Result<bool, LightningError> { Ok(false) }
- fn handle_channel_update(&self, _their_node_id: Option<&PublicKey>, _msg: &msgs::ChannelUpdate) -> Result<bool, LightningError> { Ok(false) }
+ fn handle_node_announcement(&self, _their_node_id: Option<PublicKey>, _msg: &msgs::NodeAnnouncement) -> Result<bool, LightningError> { Ok(false) }
+ fn handle_channel_announcement(&self, _their_node_id: Option<PublicKey>, _msg: &msgs::ChannelAnnouncement) -> Result<bool, LightningError> { Ok(false) }
+ fn handle_channel_update(&self, _their_node_id: Option<PublicKey>, _msg: &msgs::ChannelUpdate) -> Result<bool, LightningError> { Ok(false) }
fn get_next_channel_announcement(&self, _starting_point: u64) ->
Option<(msgs::ChannelAnnouncement, Option<msgs::ChannelUpdate>, Option<msgs::ChannelUpdate>)> { None }
fn get_next_node_announcement(&self, _starting_point: Option<&NodeId>) -> Option<msgs::NodeAnnouncement> { None }
- fn peer_connected(&self, _their_node_id: &PublicKey, _init: &msgs::Init, _inbound: bool) -> Result<(), ()> { Ok(()) }
- fn handle_reply_channel_range(&self, _their_node_id: &PublicKey, _msg: msgs::ReplyChannelRange) -> Result<(), LightningError> { Ok(()) }
- fn handle_reply_short_channel_ids_end(&self, _their_node_id: &PublicKey, _msg: msgs::ReplyShortChannelIdsEnd) -> Result<(), LightningError> { Ok(()) }
- fn handle_query_channel_range(&self, _their_node_id: &PublicKey, _msg: msgs::QueryChannelRange) -> Result<(), LightningError> { Ok(()) }
- fn handle_query_short_channel_ids(&self, _their_node_id: &PublicKey, _msg: msgs::QueryShortChannelIds) -> Result<(), LightningError> { Ok(()) }
+ fn peer_connected(&self, _their_node_id: PublicKey, _init: &msgs::Init, _inbound: bool) -> Result<(), ()> { Ok(()) }
+ fn handle_reply_channel_range(&self, _their_node_id: PublicKey, _msg: msgs::ReplyChannelRange) -> Result<(), LightningError> { Ok(()) }
+ fn handle_reply_short_channel_ids_end(&self, _their_node_id: PublicKey, _msg: msgs::ReplyShortChannelIdsEnd) -> Result<(), LightningError> { Ok(()) }
+ fn handle_query_channel_range(&self, _their_node_id: PublicKey, _msg: msgs::QueryChannelRange) -> Result<(), LightningError> { Ok(()) }
+ fn handle_query_short_channel_ids(&self, _their_node_id: PublicKey, _msg: msgs::QueryShortChannelIds) -> Result<(), LightningError> { Ok(()) }
fn provided_node_features(&self) -> NodeFeatures { NodeFeatures::empty() }
- fn provided_init_features(&self, _their_node_id: &PublicKey) -> InitFeatures {
+ fn provided_init_features(&self, _their_node_id: PublicKey) -> InitFeatures {
InitFeatures::empty()
}
fn processing_queue_high(&self) -> bool { false }
}
impl OnionMessageHandler for IgnoringMessageHandler {
- fn handle_onion_message(&self, _their_node_id: &PublicKey, _msg: &msgs::OnionMessage) {}
+ fn handle_onion_message(&self, _their_node_id: PublicKey, _msg: &msgs::OnionMessage) {}
fn next_onion_message_for_peer(&self, _peer_node_id: PublicKey) -> Option<msgs::OnionMessage> { None }
- fn peer_connected(&self, _their_node_id: &PublicKey, _init: &msgs::Init, _inbound: bool) -> Result<(), ()> { Ok(()) }
- fn peer_disconnected(&self, _their_node_id: &PublicKey) {}
+ fn peer_connected(&self, _their_node_id: PublicKey, _init: &msgs::Init, _inbound: bool) -> Result<(), ()> { Ok(()) }
+ fn peer_disconnected(&self, _their_node_id: PublicKey) {}
fn timer_tick_occurred(&self) {}
fn provided_node_features(&self) -> NodeFeatures { NodeFeatures::empty() }
- fn provided_init_features(&self, _their_node_id: &PublicKey) -> InitFeatures {
+ fn provided_init_features(&self, _their_node_id: PublicKey) -> InitFeatures {
InitFeatures::empty()
}
}
}
impl CustomMessageHandler for IgnoringMessageHandler {
- fn handle_custom_message(&self, _msg: Infallible, _sender_node_id: &PublicKey) -> Result<(), LightningError> {
+ fn handle_custom_message(&self, _msg: Infallible, _sender_node_id: PublicKey) -> Result<(), LightningError> {
// Since we always return `None` in the read the handle method should never be called.
unreachable!();
}
fn get_and_clear_pending_msg(&self) -> Vec<(PublicKey, Self::CustomMessage)> { Vec::new() }
- fn peer_disconnected(&self, _their_node_id: &PublicKey) {}
+ fn peer_disconnected(&self, _their_node_id: PublicKey) {}
- fn peer_connected(&self, _their_node_id: &PublicKey, _msg: &Init, _inbound: bool) -> Result<(), ()> { Ok(()) }
+ fn peer_connected(&self, _their_node_id: PublicKey, _msg: &Init, _inbound: bool) -> Result<(), ()> { Ok(()) }
fn provided_node_features(&self) -> NodeFeatures { NodeFeatures::empty() }
- fn provided_init_features(&self, _their_node_id: &PublicKey) -> InitFeatures {
+ fn provided_init_features(&self, _their_node_id: PublicKey) -> InitFeatures {
InitFeatures::empty()
}
}
pub fn new() -> Self {
Self { message_queue: Mutex::new(Vec::new()) }
}
- fn push_error(&self, node_id: &PublicKey, channel_id: ChannelId) {
+ fn push_error(&self, node_id: PublicKey, channel_id: ChannelId) {
self.message_queue.lock().unwrap().push(MessageSendEvent::HandleError {
action: msgs::ErrorAction::SendErrorMessage {
msg: msgs::ErrorMessage { channel_id, data: "We do not support channel messages, sorry.".to_owned() },
},
- node_id: node_id.clone(),
+ node_id,
});
}
}
impl ChannelMessageHandler for ErroringMessageHandler {
// Any messages which are related to a specific channel generate an error message to let the
// peer know we don't care about channels.
- fn handle_open_channel(&self, their_node_id: &PublicKey, msg: &msgs::OpenChannel) {
+ fn handle_open_channel(&self, their_node_id: PublicKey, msg: &msgs::OpenChannel) {
ErroringMessageHandler::push_error(self, their_node_id, msg.common_fields.temporary_channel_id);
}
- fn handle_accept_channel(&self, their_node_id: &PublicKey, msg: &msgs::AcceptChannel) {
+ fn handle_accept_channel(&self, their_node_id: PublicKey, msg: &msgs::AcceptChannel) {
ErroringMessageHandler::push_error(self, their_node_id, msg.common_fields.temporary_channel_id);
}
- fn handle_funding_created(&self, their_node_id: &PublicKey, msg: &msgs::FundingCreated) {
+ fn handle_funding_created(&self, their_node_id: PublicKey, msg: &msgs::FundingCreated) {
ErroringMessageHandler::push_error(self, their_node_id, msg.temporary_channel_id);
}
- fn handle_funding_signed(&self, their_node_id: &PublicKey, msg: &msgs::FundingSigned) {
+ fn handle_funding_signed(&self, their_node_id: PublicKey, msg: &msgs::FundingSigned) {
ErroringMessageHandler::push_error(self, their_node_id, msg.channel_id);
}
- fn handle_channel_ready(&self, their_node_id: &PublicKey, msg: &msgs::ChannelReady) {
+ fn handle_channel_ready(&self, their_node_id: PublicKey, msg: &msgs::ChannelReady) {
ErroringMessageHandler::push_error(self, their_node_id, msg.channel_id);
}
- fn handle_shutdown(&self, their_node_id: &PublicKey, msg: &msgs::Shutdown) {
+ fn handle_shutdown(&self, their_node_id: PublicKey, msg: &msgs::Shutdown) {
ErroringMessageHandler::push_error(self, their_node_id, msg.channel_id);
}
- fn handle_closing_signed(&self, their_node_id: &PublicKey, msg: &msgs::ClosingSigned) {
+ fn handle_closing_signed(&self, their_node_id: PublicKey, msg: &msgs::ClosingSigned) {
ErroringMessageHandler::push_error(self, their_node_id, msg.channel_id);
}
- fn handle_stfu(&self, their_node_id: &PublicKey, msg: &msgs::Stfu) {
+ fn handle_stfu(&self, their_node_id: PublicKey, msg: &msgs::Stfu) {
ErroringMessageHandler::push_error(&self, their_node_id, msg.channel_id);
}
#[cfg(splicing)]
- fn handle_splice_init(&self, their_node_id: &PublicKey, msg: &msgs::SpliceInit) {
+ fn handle_splice_init(&self, their_node_id: PublicKey, msg: &msgs::SpliceInit) {
ErroringMessageHandler::push_error(&self, their_node_id, msg.channel_id);
}
#[cfg(splicing)]
- fn handle_splice_ack(&self, their_node_id: &PublicKey, msg: &msgs::SpliceAck) {
+ fn handle_splice_ack(&self, their_node_id: PublicKey, msg: &msgs::SpliceAck) {
ErroringMessageHandler::push_error(&self, their_node_id, msg.channel_id);
}
#[cfg(splicing)]
- fn handle_splice_locked(&self, their_node_id: &PublicKey, msg: &msgs::SpliceLocked) {
+ fn handle_splice_locked(&self, their_node_id: PublicKey, msg: &msgs::SpliceLocked) {
ErroringMessageHandler::push_error(&self, their_node_id, msg.channel_id);
}
- fn handle_update_add_htlc(&self, their_node_id: &PublicKey, msg: &msgs::UpdateAddHTLC) {
+ fn handle_update_add_htlc(&self, their_node_id: PublicKey, msg: &msgs::UpdateAddHTLC) {
ErroringMessageHandler::push_error(self, their_node_id, msg.channel_id);
}
- fn handle_update_fulfill_htlc(&self, their_node_id: &PublicKey, msg: &msgs::UpdateFulfillHTLC) {
+ fn handle_update_fulfill_htlc(&self, their_node_id: PublicKey, msg: &msgs::UpdateFulfillHTLC) {
ErroringMessageHandler::push_error(self, their_node_id, msg.channel_id);
}
- fn handle_update_fail_htlc(&self, their_node_id: &PublicKey, msg: &msgs::UpdateFailHTLC) {
+ fn handle_update_fail_htlc(&self, their_node_id: PublicKey, msg: &msgs::UpdateFailHTLC) {
ErroringMessageHandler::push_error(self, their_node_id, msg.channel_id);
}
- fn handle_update_fail_malformed_htlc(&self, their_node_id: &PublicKey, msg: &msgs::UpdateFailMalformedHTLC) {
+ fn handle_update_fail_malformed_htlc(&self, their_node_id: PublicKey, msg: &msgs::UpdateFailMalformedHTLC) {
ErroringMessageHandler::push_error(self, their_node_id, msg.channel_id);
}
- fn handle_commitment_signed(&self, their_node_id: &PublicKey, msg: &msgs::CommitmentSigned) {
+ fn handle_commitment_signed(&self, their_node_id: PublicKey, msg: &msgs::CommitmentSigned) {
ErroringMessageHandler::push_error(self, their_node_id, msg.channel_id);
}
- fn handle_revoke_and_ack(&self, their_node_id: &PublicKey, msg: &msgs::RevokeAndACK) {
+ fn handle_revoke_and_ack(&self, their_node_id: PublicKey, msg: &msgs::RevokeAndACK) {
ErroringMessageHandler::push_error(self, their_node_id, msg.channel_id);
}
- fn handle_update_fee(&self, their_node_id: &PublicKey, msg: &msgs::UpdateFee) {
+ fn handle_update_fee(&self, their_node_id: PublicKey, msg: &msgs::UpdateFee) {
ErroringMessageHandler::push_error(self, their_node_id, msg.channel_id);
}
- fn handle_announcement_signatures(&self, their_node_id: &PublicKey, msg: &msgs::AnnouncementSignatures) {
+ fn handle_announcement_signatures(&self, their_node_id: PublicKey, msg: &msgs::AnnouncementSignatures) {
ErroringMessageHandler::push_error(self, their_node_id, msg.channel_id);
}
- fn handle_channel_reestablish(&self, their_node_id: &PublicKey, msg: &msgs::ChannelReestablish) {
+ fn handle_channel_reestablish(&self, their_node_id: PublicKey, msg: &msgs::ChannelReestablish) {
ErroringMessageHandler::push_error(self, their_node_id, msg.channel_id);
}
// msgs::ChannelUpdate does not contain the channel_id field, so we just drop them.
- fn handle_channel_update(&self, _their_node_id: &PublicKey, _msg: &msgs::ChannelUpdate) {}
- fn peer_disconnected(&self, _their_node_id: &PublicKey) {}
- fn peer_connected(&self, _their_node_id: &PublicKey, _init: &msgs::Init, _inbound: bool) -> Result<(), ()> { Ok(()) }
- fn handle_error(&self, _their_node_id: &PublicKey, _msg: &msgs::ErrorMessage) {}
+ fn handle_channel_update(&self, _their_node_id: PublicKey, _msg: &msgs::ChannelUpdate) {}
+ fn peer_disconnected(&self, _their_node_id: PublicKey) {}
+ fn peer_connected(&self, _their_node_id: PublicKey, _init: &msgs::Init, _inbound: bool) -> Result<(), ()> { Ok(()) }
+ fn handle_error(&self, _their_node_id: PublicKey, _msg: &msgs::ErrorMessage) {}
fn provided_node_features(&self) -> NodeFeatures { NodeFeatures::empty() }
- fn provided_init_features(&self, _their_node_id: &PublicKey) -> InitFeatures {
+ fn provided_init_features(&self, _their_node_id: PublicKey) -> InitFeatures {
// Set a number of features which various nodes may require to talk to us. It's totally
// reasonable to indicate we "support" all kinds of channel features...we just reject all
// channels.
None
}
- fn handle_open_channel_v2(&self, their_node_id: &PublicKey, msg: &msgs::OpenChannelV2) {
+ fn handle_open_channel_v2(&self, their_node_id: PublicKey, msg: &msgs::OpenChannelV2) {
ErroringMessageHandler::push_error(self, their_node_id, msg.common_fields.temporary_channel_id);
}
- fn handle_accept_channel_v2(&self, their_node_id: &PublicKey, msg: &msgs::AcceptChannelV2) {
+ fn handle_accept_channel_v2(&self, their_node_id: PublicKey, msg: &msgs::AcceptChannelV2) {
ErroringMessageHandler::push_error(self, their_node_id, msg.common_fields.temporary_channel_id);
}
- fn handle_tx_add_input(&self, their_node_id: &PublicKey, msg: &msgs::TxAddInput) {
+ fn handle_tx_add_input(&self, their_node_id: PublicKey, msg: &msgs::TxAddInput) {
ErroringMessageHandler::push_error(self, their_node_id, msg.channel_id);
}
- fn handle_tx_add_output(&self, their_node_id: &PublicKey, msg: &msgs::TxAddOutput) {
+ fn handle_tx_add_output(&self, their_node_id: PublicKey, msg: &msgs::TxAddOutput) {
ErroringMessageHandler::push_error(self, their_node_id, msg.channel_id);
}
- fn handle_tx_remove_input(&self, their_node_id: &PublicKey, msg: &msgs::TxRemoveInput) {
+ fn handle_tx_remove_input(&self, their_node_id: PublicKey, msg: &msgs::TxRemoveInput) {
ErroringMessageHandler::push_error(self, their_node_id, msg.channel_id);
}
- fn handle_tx_remove_output(&self, their_node_id: &PublicKey, msg: &msgs::TxRemoveOutput) {
+ fn handle_tx_remove_output(&self, their_node_id: PublicKey, msg: &msgs::TxRemoveOutput) {
ErroringMessageHandler::push_error(self, their_node_id, msg.channel_id);
}
- fn handle_tx_complete(&self, their_node_id: &PublicKey, msg: &msgs::TxComplete) {
+ fn handle_tx_complete(&self, their_node_id: PublicKey, msg: &msgs::TxComplete) {
ErroringMessageHandler::push_error(self, their_node_id, msg.channel_id);
}
- fn handle_tx_signatures(&self, their_node_id: &PublicKey, msg: &msgs::TxSignatures) {
+ fn handle_tx_signatures(&self, their_node_id: PublicKey, msg: &msgs::TxSignatures) {
ErroringMessageHandler::push_error(self, their_node_id, msg.channel_id);
}
- fn handle_tx_init_rbf(&self, their_node_id: &PublicKey, msg: &msgs::TxInitRbf) {
+ fn handle_tx_init_rbf(&self, their_node_id: PublicKey, msg: &msgs::TxInitRbf) {
ErroringMessageHandler::push_error(self, their_node_id, msg.channel_id);
}
- fn handle_tx_ack_rbf(&self, their_node_id: &PublicKey, msg: &msgs::TxAckRbf) {
+ fn handle_tx_ack_rbf(&self, their_node_id: PublicKey, msg: &msgs::TxAckRbf) {
ErroringMessageHandler::push_error(self, their_node_id, msg.channel_id);
}
- fn handle_tx_abort(&self, their_node_id: &PublicKey, msg: &msgs::TxAbort) {
+ fn handle_tx_abort(&self, their_node_id: PublicKey, msg: &msgs::TxAbort) {
ErroringMessageHandler::push_error(self, their_node_id, msg.channel_id);
}
}
SecretKey::from_slice(&Sha256::from_engine(ephemeral_hash).to_byte_array()).expect("You broke SHA-256!")
}
- fn init_features(&self, their_node_id: &PublicKey) -> InitFeatures {
+ fn init_features(&self, their_node_id: PublicKey) -> InitFeatures {
self.message_handler.chan_handler.provided_init_features(their_node_id)
| self.message_handler.route_handler.provided_init_features(their_node_id)
| self.message_handler.onion_message_handler.provided_init_features(their_node_id)
peer.set_their_node_id(their_node_id);
insert_node_id!();
- let features = self.init_features(&their_node_id);
+ let features = self.init_features(their_node_id);
let networks = self.message_handler.chan_handler.get_chain_hashes();
let resp = msgs::Init { features, networks, remote_network_address: filter_addresses(peer.their_socket_address.clone()) };
self.enqueue_message(peer, &resp);
peer.pending_read_is_header = true;
peer.set_their_node_id(their_node_id);
insert_node_id!();
- let features = self.init_features(&their_node_id);
+ let features = self.init_features(their_node_id);
let networks = self.message_handler.chan_handler.get_chain_hashes();
let resp = msgs::Init { features, networks, remote_network_address: filter_addresses(peer.their_socket_address.clone()) };
self.enqueue_message(peer, &resp);
peer_lock: MutexGuard<Peer>,
message: wire::Message<<<CMH as Deref>::Target as wire::CustomMessageReader>::CustomMessage>
) -> Result<Option<wire::Message<<<CMH as Deref>::Target as wire::CustomMessageReader>::CustomMessage>>, MessageHandlingError> {
- let their_node_id = peer_lock.their_node_id.clone().expect("We know the peer's public key by the time we receive messages").0;
+ let their_node_id = peer_lock.their_node_id.expect("We know the peer's public key by the time we receive messages").0;
let logger = WithContext::from(&self.logger, Some(their_node_id), None, None);
- let message = match self.do_handle_message_holding_peer_lock(peer_lock, message, &their_node_id, &logger)? {
+ let message = match self.do_handle_message_holding_peer_lock(peer_lock, message, their_node_id, &logger)? {
Some(processed_message) => processed_message,
None => return Ok(None),
};
- self.do_handle_message_without_peer_lock(peer_mutex, message, &their_node_id, &logger)
+ self.do_handle_message_without_peer_lock(peer_mutex, message, their_node_id, &logger)
}
// Conducts all message processing that requires us to hold the `peer_lock`.
&self,
mut peer_lock: MutexGuard<Peer>,
message: wire::Message<<<CMH as Deref>::Target as wire::CustomMessageReader>::CustomMessage>,
- their_node_id: &PublicKey,
+ their_node_id: PublicKey,
logger: &WithContext<'a, L>
) -> Result<Option<wire::Message<<<CMH as Deref>::Target as wire::CustomMessageReader>::CustomMessage>>, MessageHandlingError>
{
}
}
- let our_features = self.init_features(&their_node_id);
+ let our_features = self.init_features(their_node_id);
if msg.features.requires_unknown_bits_from(&our_features) {
log_debug!(logger, "Peer {} requires features unknown to us: {:?}",
log_pubkey!(their_node_id), msg.features.required_unknown_bits_from(&our_features));
peer_lock.sync_status = InitSyncTracker::ChannelsSyncing(0);
}
- if let Err(()) = self.message_handler.route_handler.peer_connected(&their_node_id, &msg, peer_lock.inbound_connection) {
+ if let Err(()) = self.message_handler.route_handler.peer_connected(their_node_id, &msg, peer_lock.inbound_connection) {
log_debug!(logger, "Route Handler decided we couldn't communicate with peer {}", log_pubkey!(their_node_id));
return Err(PeerHandleError { }.into());
}
- if let Err(()) = self.message_handler.chan_handler.peer_connected(&their_node_id, &msg, peer_lock.inbound_connection) {
+ if let Err(()) = self.message_handler.chan_handler.peer_connected(their_node_id, &msg, peer_lock.inbound_connection) {
log_debug!(logger, "Channel Handler decided we couldn't communicate with peer {}", log_pubkey!(their_node_id));
return Err(PeerHandleError { }.into());
}
- if let Err(()) = self.message_handler.onion_message_handler.peer_connected(&their_node_id, &msg, peer_lock.inbound_connection) {
+ if let Err(()) = self.message_handler.onion_message_handler.peer_connected(their_node_id, &msg, peer_lock.inbound_connection) {
log_debug!(logger, "Onion Message Handler decided we couldn't communicate with peer {}", log_pubkey!(their_node_id));
return Err(PeerHandleError { }.into());
}
- if let Err(()) = self.message_handler.custom_message_handler.peer_connected(&their_node_id, &msg, peer_lock.inbound_connection) {
+ if let Err(()) = self.message_handler.custom_message_handler.peer_connected(their_node_id, &msg, peer_lock.inbound_connection) {
log_debug!(logger, "Custom Message Handler decided we couldn't communicate with peer {}", log_pubkey!(their_node_id));
return Err(PeerHandleError { }.into());
}
&self,
peer_mutex: &Mutex<Peer>,
message: wire::Message<<<CMH as Deref>::Target as wire::CustomMessageReader>::CustomMessage>,
- their_node_id: &PublicKey,
+ their_node_id: PublicKey,
logger: &WithContext<'a, L>
) -> Result<Option<wire::Message<<<CMH as Deref>::Target as wire::CustomMessageReader>::CustomMessage>>, MessageHandlingError>
{
},
wire::Message::Error(msg) => {
log_debug!(logger, "Got Err message from {}: {}", log_pubkey!(their_node_id), PrintableString(&msg.data));
- self.message_handler.chan_handler.handle_error(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_error(their_node_id, &msg);
if msg.channel_id.is_zero() {
return Err(PeerHandleError { }.into());
}
// Channel messages:
wire::Message::OpenChannel(msg) => {
- self.message_handler.chan_handler.handle_open_channel(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_open_channel(their_node_id, &msg);
},
wire::Message::OpenChannelV2(msg) => {
- self.message_handler.chan_handler.handle_open_channel_v2(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_open_channel_v2(their_node_id, &msg);
},
wire::Message::AcceptChannel(msg) => {
- self.message_handler.chan_handler.handle_accept_channel(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_accept_channel(their_node_id, &msg);
},
wire::Message::AcceptChannelV2(msg) => {
- self.message_handler.chan_handler.handle_accept_channel_v2(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_accept_channel_v2(their_node_id, &msg);
},
wire::Message::FundingCreated(msg) => {
- self.message_handler.chan_handler.handle_funding_created(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_funding_created(their_node_id, &msg);
},
wire::Message::FundingSigned(msg) => {
- self.message_handler.chan_handler.handle_funding_signed(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_funding_signed(their_node_id, &msg);
},
wire::Message::ChannelReady(msg) => {
- self.message_handler.chan_handler.handle_channel_ready(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_channel_ready(their_node_id, &msg);
},
// Quiescence messages:
wire::Message::Stfu(msg) => {
- self.message_handler.chan_handler.handle_stfu(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_stfu(their_node_id, &msg);
}
#[cfg(splicing)]
// Splicing messages:
wire::Message::SpliceInit(msg) => {
- self.message_handler.chan_handler.handle_splice_init(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_splice_init(their_node_id, &msg);
}
#[cfg(splicing)]
wire::Message::SpliceAck(msg) => {
- self.message_handler.chan_handler.handle_splice_ack(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_splice_ack(their_node_id, &msg);
}
#[cfg(splicing)]
wire::Message::SpliceLocked(msg) => {
- self.message_handler.chan_handler.handle_splice_locked(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_splice_locked(their_node_id, &msg);
}
// Interactive transaction construction messages:
wire::Message::TxAddInput(msg) => {
- self.message_handler.chan_handler.handle_tx_add_input(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_tx_add_input(their_node_id, &msg);
},
wire::Message::TxAddOutput(msg) => {
- self.message_handler.chan_handler.handle_tx_add_output(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_tx_add_output(their_node_id, &msg);
},
wire::Message::TxRemoveInput(msg) => {
- self.message_handler.chan_handler.handle_tx_remove_input(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_tx_remove_input(their_node_id, &msg);
},
wire::Message::TxRemoveOutput(msg) => {
- self.message_handler.chan_handler.handle_tx_remove_output(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_tx_remove_output(their_node_id, &msg);
},
wire::Message::TxComplete(msg) => {
- self.message_handler.chan_handler.handle_tx_complete(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_tx_complete(their_node_id, &msg);
},
wire::Message::TxSignatures(msg) => {
- self.message_handler.chan_handler.handle_tx_signatures(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_tx_signatures(their_node_id, &msg);
},
wire::Message::TxInitRbf(msg) => {
- self.message_handler.chan_handler.handle_tx_init_rbf(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_tx_init_rbf(their_node_id, &msg);
},
wire::Message::TxAckRbf(msg) => {
- self.message_handler.chan_handler.handle_tx_ack_rbf(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_tx_ack_rbf(their_node_id, &msg);
},
wire::Message::TxAbort(msg) => {
- self.message_handler.chan_handler.handle_tx_abort(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_tx_abort(their_node_id, &msg);
}
wire::Message::Shutdown(msg) => {
- self.message_handler.chan_handler.handle_shutdown(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_shutdown(their_node_id, &msg);
},
wire::Message::ClosingSigned(msg) => {
- self.message_handler.chan_handler.handle_closing_signed(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_closing_signed(their_node_id, &msg);
},
// Commitment messages:
wire::Message::UpdateAddHTLC(msg) => {
- self.message_handler.chan_handler.handle_update_add_htlc(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_update_add_htlc(their_node_id, &msg);
},
wire::Message::UpdateFulfillHTLC(msg) => {
- self.message_handler.chan_handler.handle_update_fulfill_htlc(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_update_fulfill_htlc(their_node_id, &msg);
},
wire::Message::UpdateFailHTLC(msg) => {
- self.message_handler.chan_handler.handle_update_fail_htlc(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_update_fail_htlc(their_node_id, &msg);
},
wire::Message::UpdateFailMalformedHTLC(msg) => {
- self.message_handler.chan_handler.handle_update_fail_malformed_htlc(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_update_fail_malformed_htlc(their_node_id, &msg);
},
wire::Message::CommitmentSigned(msg) => {
- self.message_handler.chan_handler.handle_commitment_signed(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_commitment_signed(their_node_id, &msg);
},
wire::Message::RevokeAndACK(msg) => {
- self.message_handler.chan_handler.handle_revoke_and_ack(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_revoke_and_ack(their_node_id, &msg);
},
wire::Message::UpdateFee(msg) => {
- self.message_handler.chan_handler.handle_update_fee(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_update_fee(their_node_id, &msg);
},
wire::Message::ChannelReestablish(msg) => {
- self.message_handler.chan_handler.handle_channel_reestablish(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_channel_reestablish(their_node_id, &msg);
},
// Routing messages:
wire::Message::AnnouncementSignatures(msg) => {
- self.message_handler.chan_handler.handle_announcement_signatures(&their_node_id, &msg);
+ self.message_handler.chan_handler.handle_announcement_signatures(their_node_id, &msg);
},
wire::Message::ChannelAnnouncement(msg) => {
if self.message_handler.route_handler.handle_channel_announcement(Some(their_node_id), &msg)
self.update_gossip_backlogged();
},
wire::Message::QueryShortChannelIds(msg) => {
- self.message_handler.route_handler.handle_query_short_channel_ids(&their_node_id, msg)?;
+ self.message_handler.route_handler.handle_query_short_channel_ids(their_node_id, msg)?;
},
wire::Message::ReplyShortChannelIdsEnd(msg) => {
- self.message_handler.route_handler.handle_reply_short_channel_ids_end(&their_node_id, msg)?;
+ self.message_handler.route_handler.handle_reply_short_channel_ids_end(their_node_id, msg)?;
},
wire::Message::QueryChannelRange(msg) => {
- self.message_handler.route_handler.handle_query_channel_range(&their_node_id, msg)?;
+ self.message_handler.route_handler.handle_query_channel_range(their_node_id, msg)?;
},
wire::Message::ReplyChannelRange(msg) => {
- self.message_handler.route_handler.handle_reply_channel_range(&their_node_id, msg)?;
+ self.message_handler.route_handler.handle_reply_channel_range(their_node_id, msg)?;
},
// Onion message:
wire::Message::OnionMessage(msg) => {
- self.message_handler.onion_message_handler.handle_onion_message(&their_node_id, &msg);
+ self.message_handler.onion_message_handler.handle_onion_message(their_node_id, &msg);
},
// Unknown messages:
log_trace!(logger, "Received unknown odd message of type {}, ignoring", type_id);
},
wire::Message::Custom(custom) => {
- self.message_handler.custom_message_handler.handle_custom_message(custom, &their_node_id)?;
+ self.message_handler.custom_message_handler.handle_custom_message(custom, their_node_id)?;
},
};
Ok(should_forward)
debug_assert!(peer.their_node_id.is_some());
if let Some((node_id, _)) = peer.their_node_id {
log_trace!(WithContext::from(&self.logger, Some(node_id), None, None), "Disconnecting peer with id {} due to {}", node_id, reason);
- self.message_handler.chan_handler.peer_disconnected(&node_id);
- self.message_handler.onion_message_handler.peer_disconnected(&node_id);
- self.message_handler.custom_message_handler.peer_disconnected(&node_id);
+ self.message_handler.chan_handler.peer_disconnected(node_id);
+ self.message_handler.onion_message_handler.peer_disconnected(node_id);
+ self.message_handler.custom_message_handler.peer_disconnected(node_id);
}
descriptor.disconnect_socket();
}
let removed = self.node_id_to_descriptor.lock().unwrap().remove(&node_id);
debug_assert!(removed.is_some(), "descriptor maps should be consistent");
if !peer.handshake_complete() { return; }
- self.message_handler.chan_handler.peer_disconnected(&node_id);
- self.message_handler.onion_message_handler.peer_disconnected(&node_id);
- self.message_handler.custom_message_handler.peer_disconnected(&node_id);
+ self.message_handler.chan_handler.peer_disconnected(node_id);
+ self.message_handler.onion_message_handler.peer_disconnected(node_id);
+ self.message_handler.custom_message_handler.peer_disconnected(node_id);
}
}
};
}
impl CustomMessageHandler for TestCustomMessageHandler {
- fn handle_custom_message(&self, _: Infallible, _: &PublicKey) -> Result<(), LightningError> {
+ fn handle_custom_message(&self, _: Infallible, _: PublicKey) -> Result<(), LightningError> {
unreachable!();
}
fn get_and_clear_pending_msg(&self) -> Vec<(PublicKey, Self::CustomMessage)> { Vec::new() }
- fn peer_disconnected(&self, _their_node_id: &PublicKey) {}
+ fn peer_disconnected(&self, _their_node_id: PublicKey) {}
- fn peer_connected(&self, _their_node_id: &PublicKey, _msg: &Init, _inbound: bool) -> Result<(), ()> { Ok(()) }
+ fn peer_connected(&self, _their_node_id: PublicKey, _msg: &Init, _inbound: bool) -> Result<(), ()> { Ok(()) }
fn provided_node_features(&self) -> NodeFeatures { NodeFeatures::empty() }
- fn provided_init_features(&self, _: &PublicKey) -> InitFeatures {
+ fn provided_init_features(&self, _: PublicKey) -> InitFeatures {
self.features.clone()
}
}
};
let addr_a = SocketAddress::TcpIpV4{addr: [127, 0, 0, 1], port: 1000};
let id_b = peer_b.node_signer.get_node_id(Recipient::Node).unwrap();
- let features_a = peer_a.init_features(&id_b);
- let features_b = peer_b.init_features(&id_a);
+ let features_a = peer_a.init_features(id_b);
+ let features_b = peer_b.init_features(id_a);
let mut fd_b = FileDescriptor {
fd: 1, outbound_data: Arc::new(Mutex::new(Vec::new())),
disconnect: Arc::new(AtomicBool::new(false)),
RecipientOnionFields::secret_only(our_payment_secret), PaymentId(our_payment_hash.0)).unwrap();
check_added_monitors!(nodes[0], 1);
let payment_event = SendEvent::from_event(nodes[0].node.get_and_clear_pending_msg_events().remove(0));
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false, true);
let htlc_fail_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
assert!(htlc_fail_updates.update_fail_malformed_htlcs.is_empty());
assert!(htlc_fail_updates.update_fee.is_none());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &htlc_fail_updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &htlc_fail_updates.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], htlc_fail_updates.commitment_signed, true, true);
expect_payment_failed_with_update!(nodes[0], our_payment_hash, false, nodes[2].node.list_channels()[0].short_channel_id.unwrap(), true);
// Now disconnect nodes[1] from its peers and restart with accept_forwards_to_priv_channels set
// to true. Sadly there is currently no way to change it at runtime.
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[2].node.peer_disconnected(&nodes[1].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[2].node.peer_disconnected(nodes[1].node.get_our_node_id());
let nodes_1_serialized = nodes[1].node.encode();
let monitor_a_serialized = get_monitor!(nodes[1], chan_id_1).encode();
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 {
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).unwrap();
- nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, false).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);
- nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &bs_reestablish);
+ nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), &as_reestablish);
+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &bs_reestablish);
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 {
+ nodes[1].node.peer_connected(nodes[2].node.get_our_node_id(), &msgs::Init {
features: nodes[2].node.init_features(), networks: None, remote_network_address: None
}, true).unwrap();
- nodes[2].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init {
+ nodes[2].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, false).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);
- nodes[1].node.handle_channel_reestablish(&nodes[2].node.get_our_node_id(), &cs_reestablish);
+ nodes[2].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &bs_reestablish);
+ nodes[1].node.handle_channel_reestablish(nodes[2].node.get_our_node_id(), &cs_reestablish);
get_event_msg!(nodes[1], MessageSendEvent::SendChannelUpdate, nodes[2].node.get_our_node_id());
get_event_msg!(nodes[2], MessageSendEvent::SendChannelUpdate, nodes[1].node.get_our_node_id());
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()));
+ 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());
mine_transaction(&nodes[0], &tx);
assert_eq!(*node_id, nodes[1].node.get_our_node_id());
} else { panic!("Unexpected event"); }
- nodes[1].node.handle_channel_ready(&nodes[0].node.get_our_node_id(), &as_channel_ready);
+ nodes[1].node.handle_channel_ready(nodes[0].node.get_our_node_id(), &as_channel_ready);
expect_channel_ready_event(&nodes[0], &nodes[1].node.get_our_node_id());
expect_channel_ready_event(&nodes[1], &nodes[0].node.get_our_node_id());
let bs_msg_events = nodes[1].node.get_and_clear_pending_msg_events();
connect_blocks(&nodes[0], 4);
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
connect_blocks(&nodes[0], 1);
- nodes[1].node.handle_announcement_signatures(&nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendAnnouncementSignatures, nodes[1].node.get_our_node_id()));
+ nodes[1].node.handle_announcement_signatures(nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendAnnouncementSignatures, nodes[1].node.get_our_node_id()));
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
connect_blocks(&nodes[1], 5);
(msg.clone(), update_msg.clone().unwrap())
} else { panic!("Unexpected event"); };
- nodes[0].node.handle_announcement_signatures(&nodes[1].node.get_our_node_id(), &bs_announcement_sigs);
+ nodes[0].node.handle_announcement_signatures(nodes[1].node.get_our_node_id(), &bs_announcement_sigs);
let as_announce_events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(as_announce_events.len(), 1);
let (announcement, as_update) = if let MessageSendEvent::BroadcastChannelAnnouncement { ref msg, ref update_msg } = as_announce_events[0] {
for (i, node) in nodes.iter().enumerate() {
let counterparty_node_id = nodes[(i + 1) % 2].node.get_our_node_id();
- assert!(node.gossip_sync.handle_channel_announcement(Some(&counterparty_node_id), &announcement).unwrap());
- node.gossip_sync.handle_channel_update(Some(&counterparty_node_id), &as_update).unwrap();
- node.gossip_sync.handle_channel_update(Some(&counterparty_node_id), &bs_update).unwrap();
+ assert!(node.gossip_sync.handle_channel_announcement(Some(counterparty_node_id), &announcement).unwrap());
+ node.gossip_sync.handle_channel_update(Some(counterparty_node_id), &as_update).unwrap();
+ node.gossip_sync.handle_channel_update(Some(counterparty_node_id), &bs_update).unwrap();
}
}
#[test]
pass_along_route(&nodes[0], &[&[&nodes[1], &nodes[2]]], 100_000, payment_hash, payment_secret);
as_channel_ready.short_channel_id_alias = Some(0xeadbeef);
- nodes[2].node.handle_channel_ready(&nodes[1].node.get_our_node_id(), &as_channel_ready);
+ nodes[2].node.handle_channel_ready(nodes[1].node.get_our_node_id(), &as_channel_ready);
// Note that we always respond to a channel_ready with a channel_update. Not a lot of reason
// to bother updating that code, so just drop the message here.
get_event_msg!(nodes[2], MessageSendEvent::SendChannelUpdate, nodes[1].node.get_our_node_id());
// Now test that if a peer sends us a second channel_ready after the channel is operational we
// will use the new alias.
as_channel_ready.short_channel_id_alias = Some(0xdeadbeef);
- nodes[2].node.handle_channel_ready(&nodes[1].node.get_our_node_id(), &as_channel_ready);
+ nodes[2].node.handle_channel_ready(nodes[1].node.get_our_node_id(), &as_channel_ready);
// Note that we always respond to a channel_ready with a channel_update. Not a lot of reason
// to bother updating that code, so just drop the message here.
get_event_msg!(nodes[2], MessageSendEvent::SendChannelUpdate, nodes[1].node.get_our_node_id());
open_channel.common_fields.channel_type.as_mut().unwrap().set_scid_privacy_required();
assert_eq!(open_channel.common_fields.channel_flags & 1, 1); // The `announce_channel` bit is set.
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &open_channel);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &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");
}
// now simulate nodes[1] responding with an Error message, indicating it doesn't understand
// SCID alias.
- nodes[0].node.handle_error(&nodes[1].node.get_our_node_id(), &msgs::ErrorMessage {
+ nodes[0].node.handle_error(nodes[1].node.get_our_node_id(), &msgs::ErrorMessage {
channel_id: init_open_channel.common_fields.temporary_channel_id,
data: "Yo, no SCID aliases, no privacy here!".to_string()
});
let second_open_channel = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
assert!(!second_open_channel.common_fields.channel_type.as_ref().unwrap().supports_scid_privacy());
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &second_open_channel);
- nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), &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(), &second_open_channel);
+ nodes[0].node.handle_accept_channel(nodes[1].node.get_our_node_id(), &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);
assert!(open_channel.common_fields.channel_type.as_ref().unwrap().requires_scid_privacy());
- nodes[2].node.handle_open_channel(&nodes[1].node.get_our_node_id(), &open_channel);
+ nodes[2].node.handle_open_channel(nodes[1].node.get_our_node_id(), &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(), &accept_channel);
+ nodes[1].node.handle_accept_channel(nodes[2].node.get_our_node_id(), &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();
- nodes[2].node.handle_funding_created(&nodes[1].node.get_our_node_id(), &get_event_msg!(nodes[1], MessageSendEvent::SendFundingCreated, nodes[2].node.get_our_node_id()));
+ nodes[2].node.handle_funding_created(nodes[1].node.get_our_node_id(), &get_event_msg!(nodes[1], MessageSendEvent::SendFundingCreated, nodes[2].node.get_our_node_id()));
check_added_monitors!(nodes[2], 1);
let cs_funding_signed = get_event_msg!(nodes[2], MessageSendEvent::SendFundingSigned, nodes[1].node.get_our_node_id());
expect_channel_pending_event(&nodes[2], &nodes[1].node.get_our_node_id());
- nodes[1].node.handle_funding_signed(&nodes[2].node.get_our_node_id(), &cs_funding_signed);
+ nodes[1].node.handle_funding_signed(nodes[2].node.get_our_node_id(), &cs_funding_signed);
expect_channel_pending_event(&nodes[1], &nodes[2].node.get_our_node_id());
check_added_monitors!(nodes[1], 1);
confirm_transaction_at(&nodes[2], &tx, conf_height);
connect_blocks(&nodes[2], CHAN_CONFIRM_DEPTH - 1);
let bs_channel_ready = get_event_msg!(nodes[1], MessageSendEvent::SendChannelReady, nodes[2].node.get_our_node_id());
- nodes[1].node.handle_channel_ready(&nodes[2].node.get_our_node_id(), &get_event_msg!(nodes[2], MessageSendEvent::SendChannelReady, nodes[1].node.get_our_node_id()));
+ nodes[1].node.handle_channel_ready(nodes[2].node.get_our_node_id(), &get_event_msg!(nodes[2], MessageSendEvent::SendChannelReady, nodes[1].node.get_our_node_id()));
expect_channel_ready_event(&nodes[1], &nodes[2].node.get_our_node_id());
let bs_update = get_event_msg!(nodes[1], MessageSendEvent::SendChannelUpdate, nodes[2].node.get_our_node_id());
- nodes[2].node.handle_channel_ready(&nodes[1].node.get_our_node_id(), &bs_channel_ready);
+ nodes[2].node.handle_channel_ready(nodes[1].node.get_our_node_id(), &bs_channel_ready);
expect_channel_ready_event(&nodes[2], &nodes[1].node.get_our_node_id());
let cs_update = get_event_msg!(nodes[2], MessageSendEvent::SendChannelUpdate, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_channel_update(&nodes[2].node.get_our_node_id(), &cs_update);
- nodes[2].node.handle_channel_update(&nodes[1].node.get_our_node_id(), &bs_update);
+ nodes[1].node.handle_channel_update(nodes[2].node.get_our_node_id(), &cs_update);
+ nodes[2].node.handle_channel_update(nodes[1].node.get_our_node_id(), &bs_update);
// Now we can pay just fine using the SCID alias nodes[2] gave to nodes[1]...
let payment_event = SendEvent::from_node(&nodes[0]);
assert_eq!(nodes[1].node.get_our_node_id(), payment_event.node_id);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, true, true);
nodes[1].logger.assert_log_regex("lightning::ln::channelmanager", regex::Regex::new(r"Refusing to forward over real channel SCID as our counterparty requested").unwrap(), 1);
let mut updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], updates.commitment_signed, false);
expect_payment_failed_conditions(&nodes[0], payment_hash_2, false,
RecipientOnionFields::secret_only(payment_secret), PaymentId(payment_hash.0)).unwrap();
check_added_monitors!(nodes[0], 1);
let as_updates = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &as_updates.update_add_htlcs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &as_updates.update_add_htlcs[0]);
commitment_signed_dance!(nodes[1], nodes[0], &as_updates.commitment_signed, false, true);
expect_pending_htlcs_forwardable!(nodes[1]);
check_added_monitors!(nodes[1], 1);
let bs_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &bs_updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &bs_updates.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], bs_updates.commitment_signed, false, true);
// Build the expected channel update
RecipientOnionFields::secret_only(payment_secret), PaymentId(payment_hash.0)).unwrap();
check_added_monitors!(nodes[0], 1);
let as_updates = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &as_updates.update_add_htlcs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &as_updates.update_add_htlcs[0]);
commitment_signed_dance!(nodes[1], nodes[0], &as_updates.commitment_signed, false, true);
let bs_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &bs_updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &bs_updates.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], bs_updates.commitment_signed, false, true);
let mut err_data = Vec::new();
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 42, None, 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(), &open_channel);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel);
let events = nodes[1].node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
match events[0] {
let mut accept_channel = get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id());
assert_eq!(accept_channel.common_fields.minimum_depth, 0);
- nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), &accept_channel);
+ nodes[0].node.handle_accept_channel(nodes[1].node.get_our_node_id(), &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();
let funding_created = get_event_msg!(nodes[0], MessageSendEvent::SendFundingCreated, nodes[1].node.get_our_node_id());
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
- nodes[1].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &funding_created);
+ nodes[1].node.handle_funding_created(nodes[0].node.get_our_node_id(), &funding_created);
check_added_monitors!(nodes[1], 1);
assert!(nodes[1].node.get_and_clear_pending_events().is_empty());
match &bs_signed_locked[0] {
MessageSendEvent::SendFundingSigned { node_id, msg } => {
assert_eq!(*node_id, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_funding_signed(&nodes[1].node.get_our_node_id(), &msg);
+ nodes[0].node.handle_funding_signed(nodes[1].node.get_our_node_id(), &msg);
check_added_monitors!(nodes[0], 1);
}
_ => panic!("Unexpected event"),
match &bs_signed_locked[1] {
MessageSendEvent::SendChannelReady { node_id, msg } => {
assert_eq!(*node_id, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_channel_ready(&nodes[1].node.get_our_node_id(), &msg);
+ nodes[0].node.handle_channel_ready(nodes[1].node.get_our_node_id(), &msg);
}
_ => panic!("Unexpected event"),
}
match &as_locked_update[0] {
MessageSendEvent::SendChannelReady { node_id, msg } => {
assert_eq!(*node_id, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_channel_ready(&nodes[0].node.get_our_node_id(), &msg);
+ nodes[1].node.handle_channel_ready(nodes[0].node.get_our_node_id(), &msg);
}
_ => panic!("Unexpected event"),
}
chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::Completed);
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::Completed);
- nodes[0].node.handle_channel_update(&nodes[1].node.get_our_node_id(), &bs_channel_update);
- nodes[1].node.handle_channel_update(&nodes[0].node.get_our_node_id(), &as_channel_update);
+ nodes[0].node.handle_channel_update(nodes[1].node.get_our_node_id(), &bs_channel_update);
+ nodes[1].node.handle_channel_update(nodes[0].node.get_our_node_id(), &as_channel_update);
assert_eq!(nodes[0].node.list_usable_channels().len(), 1);
assert_eq!(nodes[1].node.list_usable_channels().len(), 2);
check_added_monitors!(nodes[0], 1);
let as_send = SendEvent::from_node(&nodes[0]);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &as_send.msgs[0]);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_send.commitment_msg);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &as_send.msgs[0]);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &as_send.commitment_msg);
check_added_monitors!(nodes[1], 1);
let (bs_raa, bs_commitment_signed) = get_revoke_commit_msgs!(nodes[1], nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_raa);
check_added_monitors!(nodes[0], 1);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_commitment_signed);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_commitment_signed);
check_added_monitors!(nodes[0], 1);
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id()));
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id()));
check_added_monitors!(nodes[1], 1);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
check_added_monitors!(nodes[1], 1);
let bs_send = SendEvent::from_node(&nodes[1]);
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &bs_send.msgs[0]);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &bs_send.msgs[0]);
commitment_signed_dance!(nodes[2], nodes[1], bs_send.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[2]);
expect_payment_claimable!(nodes[2], payment_hash, payment_secret, 1_000_000);
assert_eq!(confirm_transaction(&nodes[1], &tx), scid);
let bs_announcement_sigs = get_event_msg!(nodes[1], MessageSendEvent::SendAnnouncementSignatures, nodes[0].node.get_our_node_id());
- nodes[1].node.handle_announcement_signatures(&nodes[0].node.get_our_node_id(), &as_announcement_sigs);
- nodes[0].node.handle_announcement_signatures(&nodes[1].node.get_our_node_id(), &bs_announcement_sigs);
+ nodes[1].node.handle_announcement_signatures(nodes[0].node.get_our_node_id(), &as_announcement_sigs);
+ nodes[0].node.handle_announcement_signatures(nodes[1].node.get_our_node_id(), &bs_announcement_sigs);
let bs_announcement = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(bs_announcement.len(), 1);
open_channel_msg.common_fields.channel_type = Some(channel_type_features.clone());
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &open_channel_msg);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel_msg);
let msg_events = nodes[1].node.get_and_clear_pending_msg_events();
match msg_events[0] {
open_channel_msg.common_fields.channel_type = Some(channel_type_features.clone());
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &open_channel_msg);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel_msg);
// Assert that `nodes[1]` has no `MessageSendEvent::SendAcceptChannel` in the `msg_events`.
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
open_channel_msg.common_fields.channel_type = Some(channel_type_features);
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &open_channel_msg);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel_msg);
let events = nodes[1].node.get_and_clear_pending_events();
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100_000, 10_001, 42, None, 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(), &open_channel);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel);
let events = nodes[1].node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
match events[0] {
let mut accept_channel = get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id());
assert_eq!(accept_channel.common_fields.minimum_depth, 0);
- nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), &accept_channel);
+ nodes[0].node.handle_accept_channel(nodes[1].node.get_our_node_id(), &accept_channel);
let events = nodes[0].node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
let as_announcement_sigs = get_event_msg!(nodes[0], MessageSendEvent::SendAnnouncementSignatures, nodes[1].node.get_our_node_id());
// Handling the announcement_signatures prior to the first confirmation would panic before.
- nodes[1].node.handle_announcement_signatures(&nodes[0].node.get_our_node_id(), &as_announcement_sigs);
+ nodes[1].node.handle_announcement_signatures(nodes[0].node.get_our_node_id(), &as_announcement_sigs);
assert_eq!(confirm_transaction(&nodes[1], &tx), scid);
let bs_announcement_sigs = get_event_msg!(nodes[1], MessageSendEvent::SendAnnouncementSignatures, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_announcement_signatures(&nodes[1].node.get_our_node_id(), &bs_announcement_sigs);
+ nodes[0].node.handle_announcement_signatures(nodes[1].node.get_our_node_id(), &bs_announcement_sigs);
let as_announcement = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(as_announcement.len(), 1);
}
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);
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
confirm_transaction(&nodes[0], &tx);
let events_1 = nodes[0].node.get_and_clear_pending_msg_events();
reconnect_args.send_channel_ready.1 = true;
reconnect_nodes(reconnect_args);
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
confirm_transaction(&nodes[1], &tx);
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 {
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).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 {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, false).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.
- nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &bs_reestablish);
+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &bs_reestablish);
let events_3 = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events_3.len(), 1);
let as_channel_ready = match events_3[0] {
// nodes[1] received nodes[0]'s channel_ready on the first reconnect above, so it should send
// announcement_signatures as well as channel_update.
- nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &as_reestablish);
+ nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), &as_reestablish);
let events_4 = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(events_4.len(), 3);
let chan_id;
// Re-deliver nodes[0]'s channel_ready, which nodes[1] can safely ignore. It currently
// generates a duplicative private channel_update
- nodes[1].node.handle_channel_ready(&nodes[0].node.get_our_node_id(), &as_channel_ready);
+ nodes[1].node.handle_channel_ready(nodes[0].node.get_our_node_id(), &as_channel_ready);
let events_5 = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(events_5.len(), 1);
match events_5[0] {
// When we deliver nodes[1]'s channel_ready, however, nodes[0] will generate its
// announcement_signatures.
- nodes[0].node.handle_channel_ready(&nodes[1].node.get_our_node_id(), &bs_channel_ready);
+ nodes[0].node.handle_channel_ready(nodes[1].node.get_our_node_id(), &bs_channel_ready);
let events_6 = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events_6.len(), 1);
let as_announcement_sigs = match events_6[0] {
// When we deliver nodes[1]'s announcement_signatures to nodes[0], nodes[0] should immediately
// broadcast the channel announcement globally, as well as re-send its (now-public)
// channel_update.
- nodes[0].node.handle_announcement_signatures(&nodes[1].node.get_our_node_id(), &bs_announcement_sigs);
+ nodes[0].node.handle_announcement_signatures(nodes[1].node.get_our_node_id(), &bs_announcement_sigs);
let events_7 = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events_7.len(), 1);
let (chan_announcement, as_update) = match events_7[0] {
// Finally, deliver nodes[0]'s announcement_signatures to nodes[1] and make sure it creates the
// same channel_announcement.
- nodes[1].node.handle_announcement_signatures(&nodes[0].node.get_our_node_id(), &as_announcement_sigs);
+ nodes[1].node.handle_announcement_signatures(nodes[0].node.get_our_node_id(), &as_announcement_sigs);
let events_8 = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(events_8.len(), 1);
let bs_update = match events_8[0] {
// Provide the channel announcement and public updates to the network graph
let node_1_pubkey = nodes[1].node.get_our_node_id();
- nodes[0].gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &chan_announcement).unwrap();
- nodes[0].gossip_sync.handle_channel_update(Some(&node_1_pubkey), &bs_update).unwrap();
- nodes[0].gossip_sync.handle_channel_update(Some(&node_1_pubkey), &as_update).unwrap();
+ nodes[0].gossip_sync.handle_channel_announcement(Some(node_1_pubkey), &chan_announcement).unwrap();
+ nodes[0].gossip_sync.handle_channel_update(Some(node_1_pubkey), &bs_update).unwrap();
+ nodes[0].gossip_sync.handle_channel_update(Some(node_1_pubkey), &as_update).unwrap();
let (route, _, _, _) = get_route_and_payment_hash!(nodes[0], nodes[1], 1000000);
let payment_preimage = send_along_route(&nodes[0], route, &[&nodes[1]], 1000000).0;
// Check that after deserialization and reconnection we can still generate an identical
// channel_announcement from the cached signatures.
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
let chan_0_monitor_serialized = get_monitor!(nodes[0], chan_id).encode();
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());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
let chan_0_monitor_serialized =
get_monitor!(nodes[0], ChannelId::v1_from_funding_outpoint(OutPoint { txid: tx.compute_txid(), index: 0 })).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 {
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).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 {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, false).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]);
+ nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), &reestablish_1[0]);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
- nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &reestablish_2[0]);
+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &reestablish_2[0]);
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
let (channel_ready, _) = create_chan_between_nodes_with_value_confirm(&nodes[0], &nodes[1], &tx);
let (announcement, as_update, bs_update) = create_chan_between_nodes_with_value_b(&nodes[0], &nodes[1], &channel_ready);
for (i, node) in nodes.iter().enumerate() {
let counterparty_node_id = nodes[(i + 1) % 2].node.get_our_node_id();
- assert!(node.gossip_sync.handle_channel_announcement(Some(&counterparty_node_id), &announcement).unwrap());
- node.gossip_sync.handle_channel_update(Some(&counterparty_node_id), &as_update).unwrap();
- node.gossip_sync.handle_channel_update(Some(&counterparty_node_id), &bs_update).unwrap();
+ assert!(node.gossip_sync.handle_channel_announcement(Some(counterparty_node_id), &announcement).unwrap());
+ node.gossip_sync.handle_channel_update(Some(counterparty_node_id), &as_update).unwrap();
+ node.gossip_sync.handle_channel_update(Some(counterparty_node_id), &bs_update).unwrap();
}
send_payment(&nodes[0], &[&nodes[1]], 1000000);
let node_a = nodes.remove(0);
let node_b = nodes.remove(0);
node_a.node.create_channel(node_b.node.get_our_node_id(), channel_value, push_msat, 42, None, None).unwrap();
- node_b.node.handle_open_channel(&node_a.node.get_our_node_id(), &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(), &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(), &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(), &get_event_msg!(node_b, MessageSendEvent::SendAcceptChannel, node_a.node.get_our_node_id()));
let (temporary_channel_id, tx, funding_output) = create_funding_transaction(&node_a, &node_b.node.get_our_node_id(), channel_value, 42);
node_a.node.funding_transaction_generated(temporary_channel_id, node_b.node.get_our_node_id(), tx.clone()).unwrap();
check_added_monitors!(node_a, 0);
- node_b.node.handle_funding_created(&node_a.node.get_our_node_id(), &get_event_msg!(node_a, MessageSendEvent::SendFundingCreated, node_b.node.get_our_node_id()));
+ node_b.node.handle_funding_created(node_a.node.get_our_node_id(), &get_event_msg!(node_a, MessageSendEvent::SendFundingCreated, node_b.node.get_our_node_id()));
{
let mut added_monitors = node_b.chain_monitor.added_monitors.lock().unwrap();
assert_eq!(added_monitors.len(), 1);
}
let bs_funding_signed = get_event_msg!(node_b, MessageSendEvent::SendFundingSigned, node_a.node.get_our_node_id());
- node_a.node.handle_funding_signed(&node_b.node.get_our_node_id(), &bs_funding_signed);
+ node_a.node.handle_funding_signed(node_b.node.get_our_node_id(), &bs_funding_signed);
{
let mut added_monitors = node_a.chain_monitor.added_monitors.lock().unwrap();
assert_eq!(added_monitors.len(), 1);
let chan_0_monitor_serialized = get_monitor!(nodes[0], bs_funding_signed.channel_id).encode();
reload_node!(nodes[0], nodes[0].node.encode(), &[&chan_0_monitor_serialized], persister, new_chain_monitor, nodes_0_deserialized);
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
// After deserializing, make sure the funding_transaction is still held by the channel manager
let events_4 = nodes[0].node.get_and_clear_pending_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 {
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).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 {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, false).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]);
+ nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), &reestablish_1[0]);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
- nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &reestablish_2[0]);
+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &reestablish_2[0]);
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
let (channel_ready, _) = create_chan_between_nodes_with_value_confirm(&nodes[0], &nodes[1], &tx);
let (announcement, as_update, bs_update) = create_chan_between_nodes_with_value_b(&nodes[0], &nodes[1], &channel_ready);
for (i, node) in nodes.iter().enumerate() {
let counterparty_node_id = nodes[(i + 1) % 2].node.get_our_node_id();
- assert!(node.gossip_sync.handle_channel_announcement(Some(&counterparty_node_id), &announcement).unwrap());
- node.gossip_sync.handle_channel_update(Some(&counterparty_node_id), &as_update).unwrap();
- node.gossip_sync.handle_channel_update(Some(&counterparty_node_id), &bs_update).unwrap();
+ assert!(node.gossip_sync.handle_channel_announcement(Some(counterparty_node_id), &announcement).unwrap());
+ node.gossip_sync.handle_channel_update(Some(counterparty_node_id), &as_update).unwrap();
+ node.gossip_sync.handle_channel_update(Some(counterparty_node_id), &bs_update).unwrap();
}
send_payment(&nodes[0], &[&nodes[1]], 1000000);
let (our_payment_preimage, ..) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
let (_, our_payment_hash, ..) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
let chan_0_monitor_serialized = get_monitor!(nodes[0], chan_id).encode();
reload_node!(nodes[0], nodes[0].node.encode(), &[&chan_0_monitor_serialized], persister, new_chain_monitor, nodes_0_deserialized);
let nodes_0_serialized = nodes[0].node.encode();
route_payment(&nodes[0], &[&nodes[3]], 1000000);
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
- nodes[2].node.peer_disconnected(&nodes[0].node.get_our_node_id());
- nodes[3].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
+ nodes[2].node.peer_disconnected(nodes[0].node.get_our_node_id());
+ nodes[3].node.peer_disconnected(nodes[0].node.get_our_node_id());
// Now the ChannelMonitor (which is now out-of-sync with ChannelManager for channel w/
// nodes[3])
//... 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 {
+ nodes[3].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, true).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 {
+ nodes[0].node.peer_connected(nodes[3].node.get_our_node_id(), &msgs::Init {
features: nodes[3].node.init_features(), networks: None, remote_network_address: None
}, false).unwrap();
- nodes[0].node.handle_channel_reestablish(&nodes[3].node.get_our_node_id(), &reestablish);
+ 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() {
if let MessageSendEvent::HandleError { ref action, .. } = msg_event {
check_added_monitors(&nodes[0], 1);
let update_add_commit = SendEvent::from_node(&nodes[0]);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &update_add_commit.msgs[0]);
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &update_add_commit.commitment_msg);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add_commit.msgs[0]);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &update_add_commit.commitment_msg);
check_added_monitors(&nodes[1], 1);
let (raa, cs) = get_revoke_commit_msgs(&nodes[1], &nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &raa);
check_added_monitors(&nodes[0], 1);
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
if !not_stale {
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &cs);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &cs);
check_added_monitors(&nodes[0], 1);
// A now revokes their original state, at which point reconnect should panic
let raa = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &raa);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &raa);
check_added_monitors(&nodes[1], 1);
expect_pending_htlcs_forwardable_ignore!(nodes[1]);
}
send_payment(&nodes[0], &[&nodes[1]], 8000000);
}
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
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 {
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).unwrap();
- nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, false).unwrap();
// If A has fallen behind substantially, B should send it a message letting it know
// that.
- nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &reestablish_1[0]);
+ nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), &reestablish_1[0]);
let reestablish_msg;
if substantially_old {
let warn_msg = "Peer attempted to reestablish channel with a very old local commitment transaction: 0 (received) vs 4 (expected)".to_owned();
// Check A panics upon seeing proof it has fallen behind.
let reconnect_res = std::panic::catch_unwind(|| {
- nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &reestablish_msg);
+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &reestablish_msg);
});
if not_stale {
assert!(reconnect_res.is_ok());
// 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 {
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).unwrap();
- nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, false).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]);
+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &retry_reestablish[0]);
let mut err_msgs_0 = Vec::with_capacity(1);
if let MessageSendEvent::HandleError { ref action, .. } = nodes[0].node.get_and_clear_pending_msg_events()[1] {
match action {
panic!("Unexpected event!");
}
assert_eq!(err_msgs_0.len(), 1);
- nodes[1].node.handle_error(&nodes[0].node.get_our_node_id(), &err_msgs_0[0]);
+ nodes[1].node.handle_error(nodes[0].node.get_our_node_id(), &err_msgs_0[0]);
assert!(nodes[1].node.list_usable_channels().is_empty());
check_added_monitors!(nodes[1], 1);
check_closed_event!(nodes[1], 1, ClosureReason::CounterpartyForceClosed { peer_msg: UntrustedString(format!("Got a message for a channel from the wrong node! No such channel for the passed counterparty_node_id {}", &nodes[1].node.get_our_node_id())) }
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
let payment_event = SendEvent::from_event(events.pop().unwrap());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
expect_pending_htlcs_forwardable_ignore!(nodes[1]);
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
let payment_event = SendEvent::from_event(events.pop().unwrap());
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
// There is already a PendingHTLCsForwardable event "pending" so another one will not be
assert!(nodes[1].node.get_and_clear_pending_events().is_empty());
// Now restart nodes[1] and make sure it regenerates a single PendingHTLCsForwardable
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[2].node.peer_disconnected(&nodes[1].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[2].node.peer_disconnected(nodes[1].node.get_our_node_id());
let chan_0_monitor_serialized = get_monitor!(nodes[1], chan_id_1).encode();
let chan_1_monitor_serialized = get_monitor!(nodes[1], chan_id_2).encode();
let mut events = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
let payment_event = SendEvent::from_event(events.pop().unwrap());
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[2], nodes[1], payment_event.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[2]);
expect_payment_claimable!(nodes[2], payment_hash_2, payment_secret_2, 200_000);
assert!(get_monitor!(nodes[3], chan_id_persisted).get_stored_preimages().contains_key(&payment_hash));
assert!(get_monitor!(nodes[3], chan_id_not_persisted).get_stored_preimages().contains_key(&payment_hash));
- nodes[1].node.peer_disconnected(&nodes[3].node.get_our_node_id());
- nodes[2].node.peer_disconnected(&nodes[3].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[3].node.get_our_node_id());
+ nodes[2].node.peer_disconnected(nodes[3].node.get_our_node_id());
// During deserialization, we should have closed one channel and broadcast its latest
// commitment transaction. We should also still have the original PaymentClaimable event we
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 {
+ nodes[3].node.peer_connected(nodes[2].node.get_our_node_id(), &msgs::Init {
features: nodes[2].node.init_features(), networks: None, remote_network_address: None
}, true).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 {
+ nodes[2].node.peer_connected(nodes[3].node.get_our_node_id(), &msgs::Init {
features: nodes[3].node.init_features(), networks: None, remote_network_address: None
}, false).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]);
+ nodes[2].node.handle_channel_reestablish(nodes[3].node.get_our_node_id(), &reestablish_1[0]);
get_event_msg!(nodes[2], MessageSendEvent::SendChannelUpdate, nodes[3].node.get_our_node_id());
assert!(nodes[2].node.get_and_clear_pending_msg_events().is_empty());
- nodes[3].node.handle_channel_reestablish(&nodes[2].node.get_our_node_id(), &reestablish_2[0]);
+ nodes[3].node.handle_channel_reestablish(nodes[2].node.get_our_node_id(), &reestablish_2[0]);
// Once we call `get_and_clear_pending_msg_events` the holding cell is cleared and the HTLC
// claim should fly.
let cs_updates = match ds_msgs[1] {
MessageSendEvent::UpdateHTLCs { ref updates, .. } => {
- nodes[2].node.handle_update_fulfill_htlc(&nodes[3].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
+ nodes[2].node.handle_update_fulfill_htlc(nodes[3].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
check_added_monitors!(nodes[2], 1);
let cs_updates = get_htlc_update_msgs!(nodes[2], nodes[0].node.get_our_node_id());
expect_payment_forwarded!(nodes[2], nodes[0], nodes[3], Some(1000), false, false);
_ => panic!(),
};
- nodes[0].node.handle_update_fulfill_htlc(&nodes[2].node.get_our_node_id(), &cs_updates.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[2].node.get_our_node_id(), &cs_updates.update_fulfill_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[2], cs_updates.commitment_signed, false, true);
expect_payment_sent!(nodes[0], payment_preimage);
}
check_added_monitors!(nodes[0], 1);
let payment_event = SendEvent::from_node(&nodes[0]);
- nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
// Store the `ChannelManager` before handling the `PendingHTLCsForwardable`/`HTLCIntercepted`
expect_pending_htlcs_forwardable!(nodes[1]);
let payment_event = SendEvent::from_node(&nodes[1]);
- nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &payment_event.msgs[0]);
- nodes[2].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &payment_event.commitment_msg);
+ nodes[2].node.handle_update_add_htlc(nodes[1].node.get_our_node_id(), &payment_event.msgs[0]);
+ nodes[2].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &payment_event.commitment_msg);
check_added_monitors!(nodes[2], 1);
if claim_htlc {
assert_eq!(bs_commitment_tx.len(), 1);
check_added_monitors!(nodes[1], 1);
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[1]));
if use_cs_commitment {
match &events[0] {
MessageSendEvent::UpdateHTLCs { updates: msgs::CommitmentUpdate { update_fulfill_htlcs, update_fail_htlcs, commitment_signed, .. }, .. } => {
if claim_htlc {
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &update_fulfill_htlcs[0]);
} else {
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &update_fail_htlcs[0]);
}
commitment_signed_dance!(nodes[0], nodes[1], commitment_signed, false);
},
assert_eq!(events.len(), 1);
match &events[0] {
MessageSendEvent::UpdateHTLCs { updates: msgs::CommitmentUpdate { update_fail_htlcs, commitment_signed, .. }, .. } => {
- nodes[1].node.handle_update_fail_htlc(&nodes[2].node.get_our_node_id(), &update_fail_htlcs[0]);
+ nodes[1].node.handle_update_fail_htlc(nodes[2].node.get_our_node_id(), &update_fail_htlcs[0]);
commitment_signed_dance!(nodes[1], nodes[2], commitment_signed, false);
},
_ => panic!("Unexpected event"),
// Now that the ChannelManager has force-closed the channel which had the HTLC removed, it is
// now forgotten everywhere. The ChannelManager should have, as a side-effect of reload,
// learned that the HTLC is gone from the ChannelMonitor and added it to the to-fail-back set.
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[1]));
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], [HTLCDestination::NextHopChannel { node_id: Some(nodes[2].node.get_our_node_id()), channel_id: chan_id_2 }]);
assert_eq!(events.len(), 1);
match &events[0] {
MessageSendEvent::UpdateHTLCs { updates: msgs::CommitmentUpdate { update_fail_htlcs, commitment_signed, .. }, .. } => {
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], commitment_signed, false);
},
_ => panic!("Unexpected event"),
]);
// Go through the funding_created and funding_signed flow with node 1.
- nodes[1].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &funding_created_msgs[0]);
+ nodes[1].node.handle_funding_created(nodes[0].node.get_our_node_id(), &funding_created_msgs[0]);
check_added_monitors(&nodes[1], 1);
expect_channel_pending_event(&nodes[1], &nodes[0].node.get_our_node_id());
// The monitor is persisted when receiving funding_signed.
let funding_signed_msg = get_event_msg!(nodes[1], MessageSendEvent::SendFundingSigned, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_funding_signed(&nodes[1].node.get_our_node_id(), &funding_signed_msg);
+ nodes[0].node.handle_funding_signed(nodes[1].node.get_our_node_id(), &funding_signed_msg);
check_added_monitors(&nodes[0], 1);
// The transaction should not have been broadcast before all channels are ready.
let htlc_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
if claim {
assert_eq!(htlc_updates.update_fulfill_htlcs.len(), 1);
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &htlc_updates.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &htlc_updates.update_fulfill_htlcs[0]);
} else {
assert_eq!(htlc_updates.update_fail_htlcs.len(), 1);
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &htlc_updates.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &htlc_updates.update_fail_htlcs[0]);
}
commitment_signed_dance!(nodes[0], nodes[1], htlc_updates.commitment_signed, false, true);
if claim {
// If we dropped the channel before reloading the node, nodes[1] was also dropped from
// nodes[0] storage, and hence not connected again on startup. We therefore need to
// reconnect to the node before attempting to create a new channel.
- nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &Init {
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).unwrap();
}
// Handle the fee update on the other side, but don't send the last RAA such that the previous
// commitment is still valid (unrevoked).
- nodes[1].node().handle_update_fee(&nodes[0].node.get_our_node_id(), &update_fee);
+ nodes[1].node().handle_update_fee(nodes[0].node.get_our_node_id(), &update_fee);
let _last_revoke_and_ack = commitment_signed_dance!(nodes[1], nodes[0], commit_sig, false, true, false, true);
let error_message = "Channel force-closed";
check_added_monitors!(nodes[0], 1);
let fee_update = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
- nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), &fee_update.update_fee.unwrap());
+ nodes[1].node.handle_update_fee(nodes[0].node.get_our_node_id(), &fee_update.update_fee.unwrap());
commitment_signed_dance!(nodes[1], nodes[0], fee_update.commitment_signed, false);
reload_node!(
nodes[0].node.close_channel(&ChannelId::v1_from_funding_outpoint(OutPoint { txid: tx.compute_txid(), index: 0 }), &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(), &node_0_shutdown);
+ nodes[1].node.handle_shutdown(nodes[0].node.get_our_node_id(), &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(), &node_1_shutdown);
+ nodes[0].node.handle_shutdown(nodes[1].node.get_our_node_id(), &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);
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &node_0_closing_signed);
let node_1_closing_signed = get_event_msg!(nodes[1], MessageSendEvent::SendClosingSigned, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_closing_signed(&nodes[1].node.get_our_node_id(), &node_1_closing_signed);
+ nodes[0].node.handle_closing_signed(nodes[1].node.get_our_node_id(), &node_1_closing_signed);
let (_, node_0_2nd_closing_signed) = get_closing_signed_broadcast!(nodes[0].node, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed.unwrap());
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed.unwrap());
let (_, node_1_none) = get_closing_signed_broadcast!(nodes[1].node, nodes[0].node.get_our_node_id());
assert!(node_1_none.is_none());
expect_channel_shutdown_state!(nodes[1], chan_1.2, ChannelShutdownState::NotShuttingDown);
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(), &node_0_shutdown);
+ nodes[1].node.handle_shutdown(nodes[0].node.get_our_node_id(), &node_0_shutdown);
// node1 goes into NegotiatingClosingFee since there are no HTLCs in flight, note that it
// doesnt mean that node1 has sent/recved its closing signed message
expect_channel_shutdown_state!(nodes[1], chan_1.2, ChannelShutdownState::NegotiatingClosingFee);
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(), &node_1_shutdown);
+ nodes[0].node.handle_shutdown(nodes[1].node.get_our_node_id(), &node_1_shutdown);
expect_channel_shutdown_state!(nodes[0], chan_1.2, ChannelShutdownState::NegotiatingClosingFee);
expect_channel_shutdown_state!(nodes[1], chan_1.2, ChannelShutdownState::NegotiatingClosingFee);
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);
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &node_0_closing_signed);
let node_1_closing_signed = get_event_msg!(nodes[1], MessageSendEvent::SendClosingSigned, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_closing_signed(&nodes[1].node.get_our_node_id(), &node_1_closing_signed);
+ nodes[0].node.handle_closing_signed(nodes[1].node.get_our_node_id(), &node_1_closing_signed);
let (_, node_0_2nd_closing_signed) = get_closing_signed_broadcast!(nodes[0].node, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed.unwrap());
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed.unwrap());
let (_, node_1_none) = get_closing_signed_broadcast!(nodes[1].node, nodes[0].node.get_our_node_id());
assert!(node_1_none.is_none());
expect_channel_shutdown_state!(nodes[1], chan_1.2, ChannelShutdownState::NotShuttingDown);
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(), &node_0_shutdown);
+ nodes[1].node.handle_shutdown(nodes[0].node.get_our_node_id(), &node_0_shutdown);
expect_channel_shutdown_state!(nodes[0], chan_1.2, ChannelShutdownState::ShutdownInitiated);
expect_channel_shutdown_state!(nodes[1], chan_1.2, ChannelShutdownState::ResolvingHTLCs);
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(), &node_1_shutdown);
+ nodes[0].node.handle_shutdown(nodes[1].node.get_our_node_id(), &node_1_shutdown);
expect_channel_shutdown_state!(nodes[0], chan_1.2, ChannelShutdownState::ResolvingHTLCs);
expect_channel_shutdown_state!(nodes[1], chan_1.2, ChannelShutdownState::ResolvingHTLCs);
assert!(updates.update_fail_malformed_htlcs.is_empty());
assert!(updates.update_fee.is_none());
assert_eq!(updates.update_fulfill_htlcs.len(), 1);
- nodes[1].node.handle_update_fulfill_htlc(&nodes[2].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
+ nodes[1].node.handle_update_fulfill_htlc(nodes[2].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], Some(1000), false, false);
check_added_monitors!(nodes[1], 1);
let updates_2 = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
assert!(updates_2.update_fail_malformed_htlcs.is_empty());
assert!(updates_2.update_fee.is_none());
assert_eq!(updates_2.update_fulfill_htlcs.len(), 1);
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &updates_2.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &updates_2.update_fulfill_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], updates_2.commitment_signed, false, true);
expect_payment_sent!(nodes[0], payment_preimage_0);
// ClosingSignNegotion process
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);
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &node_0_closing_signed);
let node_1_closing_signed = get_event_msg!(nodes[1], MessageSendEvent::SendClosingSigned, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_closing_signed(&nodes[1].node.get_our_node_id(), &node_1_closing_signed);
+ nodes[0].node.handle_closing_signed(nodes[1].node.get_our_node_id(), &node_1_closing_signed);
let (_, node_0_2nd_closing_signed) = get_closing_signed_broadcast!(nodes[0].node, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed.unwrap());
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed.unwrap());
let (_, node_1_none) = get_closing_signed_broadcast!(nodes[1].node, nodes[0].node.get_our_node_id());
assert!(node_1_none.is_none());
check_closed_event!(nodes[0], 1, ClosureReason::LocallyInitiatedCooperativeClosure, [nodes[1].node.get_our_node_id()], 100000);
nodes[0].node.close_channel(&chan.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(), &node_0_shutdown);
+ nodes[1].node.handle_shutdown(nodes[0].node.get_our_node_id(), &node_0_shutdown);
// Generate an lnd-like error message and check that we respond by simply screaming louder to
// see if LND will accept our protocol compliance.
let err_msg = msgs::ErrorMessage { channel_id: chan.2, data: "link failed to shutdown".to_string() };
- nodes[0].node.handle_error(&nodes[1].node.get_our_node_id(), &err_msg);
+ nodes[0].node.handle_error(nodes[1].node.get_our_node_id(), &err_msg);
let node_a_responses = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(node_a_responses[0], MessageSendEvent::SendShutdown {
node_id: nodes[1].node.get_our_node_id(),
claim_payment(&nodes[0], &[&nodes[1]], payment_preimage);
// Assume that LND will eventually respond to our Shutdown if we clear all the remaining HTLCs
- nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &node_1_shutdown);
+ nodes[0].node.handle_shutdown(nodes[1].node.get_our_node_id(), &node_1_shutdown);
// ClosingSignNegotion process
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);
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &node_0_closing_signed);
let node_1_closing_signed = get_event_msg!(nodes[1], MessageSendEvent::SendClosingSigned, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_closing_signed(&nodes[1].node.get_our_node_id(), &node_1_closing_signed);
+ nodes[0].node.handle_closing_signed(nodes[1].node.get_our_node_id(), &node_1_closing_signed);
let (_, node_0_2nd_closing_signed) = get_closing_signed_broadcast!(nodes[0].node, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed.unwrap());
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed.unwrap());
let (_, node_1_none) = get_closing_signed_broadcast!(nodes[1].node, nodes[0].node.get_our_node_id());
assert!(node_1_none.is_none());
check_closed_event!(nodes[0], 1, ClosureReason::LocallyInitiatedCooperativeClosure, [nodes[1].node.get_our_node_id()], 100000);
.push_slice(&[0; 20])
.into_script();
- nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &msgs::Shutdown {
+ nodes[0].node.handle_shutdown(nodes[1].node.get_our_node_id(), &msgs::Shutdown {
channel_id: open_chan.common_fields.temporary_channel_id, scriptpubkey: script,
});
check_closed_event!(nodes[0], 1, ClosureReason::CounterpartyCoopClosedUnfundedChannel, [nodes[1].node.get_our_node_id()], 1_000_000);
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(), &node_0_shutdown);
+ nodes[1].node.handle_shutdown(nodes[0].node.get_our_node_id(), &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(), &node_1_shutdown);
+ nodes[0].node.handle_shutdown(nodes[1].node.get_our_node_id(), &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());
assert!(updates.update_fail_malformed_htlcs.is_empty());
assert!(updates.update_fee.is_none());
assert_eq!(updates.update_fulfill_htlcs.len(), 1);
- nodes[1].node.handle_update_fulfill_htlc(&nodes[2].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
+ nodes[1].node.handle_update_fulfill_htlc(nodes[2].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], Some(1000), false, false);
check_added_monitors!(nodes[1], 1);
let updates_2 = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
assert!(updates_2.update_fail_malformed_htlcs.is_empty());
assert!(updates_2.update_fee.is_none());
assert_eq!(updates_2.update_fulfill_htlcs.len(), 1);
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &updates_2.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &updates_2.update_fulfill_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], updates_2.commitment_signed, false, true);
expect_payment_sent!(nodes[0], payment_preimage_0);
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);
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &node_0_closing_signed);
let node_1_closing_signed = get_event_msg!(nodes[1], MessageSendEvent::SendClosingSigned, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_closing_signed(&nodes[1].node.get_our_node_id(), &node_1_closing_signed);
+ nodes[0].node.handle_closing_signed(nodes[1].node.get_our_node_id(), &node_1_closing_signed);
let (_, node_0_2nd_closing_signed) = get_closing_signed_broadcast!(nodes[0].node, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed.unwrap());
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed.unwrap());
let (_, node_1_none) = get_closing_signed_broadcast!(nodes[1].node, nodes[0].node.get_our_node_id());
assert!(node_1_none.is_none());
check_closed_event!(nodes[0], 1, ClosureReason::LocallyInitiatedCooperativeClosure, [nodes[1].node.get_our_node_id()], 100000);
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(), &node_1_shutdown);
+ nodes[0].node.handle_shutdown(nodes[1].node.get_our_node_id(), &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);
+ 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(), &node_0_shutdown);
+ nodes[1].node.handle_shutdown(nodes[0].node.get_our_node_id(), &node_0_shutdown);
commitment_signed_dance!(nodes[1], nodes[0], (), false, true, false, false);
let updates_2 = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
assert!(updates_2.update_fail_malformed_htlcs.is_empty());
assert!(updates_2.update_fee.is_none());
- nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &updates_2.update_fail_htlcs[0]);
+ nodes[0].node.handle_update_fail_htlc(nodes[1].node.get_our_node_id(), &updates_2.update_fail_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], updates_2.commitment_signed, false, true);
if blinded_recipient {
};
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
- nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_closing_signed);
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &node_0_closing_signed);
let node_1_closing_signed = get_event_msg!(nodes[1], MessageSendEvent::SendClosingSigned, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_closing_signed(&nodes[1].node.get_our_node_id(), &node_1_closing_signed);
+ nodes[0].node.handle_closing_signed(nodes[1].node.get_our_node_id(), &node_1_closing_signed);
let (_, node_0_2nd_closing_signed) = get_closing_signed_broadcast!(nodes[0].node, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed.unwrap());
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed.unwrap());
let (_, node_1_none) = get_closing_signed_broadcast!(nodes[1].node, nodes[0].node.get_our_node_id());
assert!(node_1_none.is_none());
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(), &node_1_shutdown);
+ nodes[0].node.handle_shutdown(nodes[1].node.get_our_node_id(), &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(), &node_0_shutdown);
+ nodes[1].node.handle_shutdown(nodes[0].node.get_our_node_id(), &node_0_shutdown);
}
}
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
- nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init {
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, true).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 {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, false).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);
+ nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), &node_0_reestablish);
let node_1_2nd_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());
assert!(node_1_shutdown == node_1_2nd_shutdown);
- nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &node_1_reestablish);
+ 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(), &node_1_2nd_shutdown);
+ nodes[0].node.handle_shutdown(nodes[1].node.get_our_node_id(), &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.channel_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(), &node_1_2nd_shutdown);
+ nodes[0].node.handle_shutdown(nodes[1].node.get_our_node_id(), &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(), &node_0_2nd_shutdown);
+ nodes[1].node.handle_shutdown(nodes[0].node.get_our_node_id(), &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());
assert!(updates.update_fail_malformed_htlcs.is_empty());
assert!(updates.update_fee.is_none());
assert_eq!(updates.update_fulfill_htlcs.len(), 1);
- nodes[1].node.handle_update_fulfill_htlc(&nodes[2].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
+ nodes[1].node.handle_update_fulfill_htlc(nodes[2].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], Some(1000), false, false);
check_added_monitors!(nodes[1], 1);
let updates_2 = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
assert!(updates_2.update_fail_malformed_htlcs.is_empty());
assert!(updates_2.update_fee.is_none());
assert_eq!(updates_2.update_fulfill_htlcs.len(), 1);
- nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &updates_2.update_fulfill_htlcs[0]);
+ nodes[0].node.handle_update_fulfill_htlc(nodes[1].node.get_our_node_id(), &updates_2.update_fulfill_htlcs[0]);
commitment_signed_dance!(nodes[0], nodes[1], updates_2.commitment_signed, false, true);
expect_payment_sent!(nodes[0], payment_preimage);
let node_0_closing_signed = get_event_msg!(nodes[0], MessageSendEvent::SendClosingSigned, nodes[1].node.get_our_node_id());
if recv_count > 0 {
- nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_closing_signed);
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &node_0_closing_signed);
let node_1_closing_signed = get_event_msg!(nodes[1], MessageSendEvent::SendClosingSigned, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_closing_signed(&nodes[1].node.get_our_node_id(), &node_1_closing_signed);
+ nodes[0].node.handle_closing_signed(nodes[1].node.get_our_node_id(), &node_1_closing_signed);
let (_, node_0_2nd_closing_signed) = get_closing_signed_broadcast!(nodes[0].node, nodes[1].node.get_our_node_id());
assert!(node_0_2nd_closing_signed.is_some());
}
- nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
- nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
+ nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
+ nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
- nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init {
+ nodes[1].node.peer_connected(nodes[0].node.get_our_node_id(), &msgs::Init {
features: nodes[0].node.init_features(), networks: None, remote_network_address: None
}, true).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 {
+ nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {
features: nodes[1].node.init_features(), networks: None, remote_network_address: None
}, false).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();
- nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &node_1_2nd_reestablish);
+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &node_1_2nd_reestablish);
let node_0_msgs = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(node_0_msgs.len(), 2);
let node_0_2nd_closing_signed = match node_0_msgs[1] {
};
assert!(node_0_2nd_shutdown == node_0_3rd_shutdown);
- nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &node_0_2nd_reestablish);
+ nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), &node_0_2nd_reestablish);
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(), &node_0_3rd_shutdown);
+ nodes[1].node.handle_shutdown(nodes[0].node.get_our_node_id(), &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(), &node_1_3rd_shutdown);
+ nodes[0].node.handle_shutdown(nodes[1].node.get_our_node_id(), &node_1_3rd_shutdown);
- nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed);
+ 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());
- nodes[0].node.handle_closing_signed(&nodes[1].node.get_our_node_id(), &node_1_closing_signed);
+ nodes[0].node.handle_closing_signed(nodes[1].node.get_our_node_id(), &node_1_closing_signed);
let (_, node_0_2nd_closing_signed) = get_closing_signed_broadcast!(nodes[0].node, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed.unwrap());
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed.unwrap());
let (_, node_1_none) = get_closing_signed_broadcast!(nodes[1].node, nodes[0].node.get_our_node_id());
assert!(node_1_none.is_none());
check_closed_event!(nodes[1], 1, ClosureReason::LocallyInitiatedCooperativeClosure, [nodes[0].node.get_our_node_id()], 100000);
// transaction.
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
- nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &node_1_2nd_reestablish);
+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), &node_1_2nd_reestablish);
let msg_events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(msg_events.len(), 2);
if let MessageSendEvent::HandleError { ref action, .. } = msg_events[1] {
match action {
&ErrorAction::SendErrorMessage { ref msg } => {
- nodes[1].node.handle_error(&nodes[0].node.get_our_node_id(), &msg);
+ nodes[1].node.handle_error(nodes[0].node.get_our_node_id(), &msg);
assert_eq!(msg.channel_id, chan_1.2);
},
_ => panic!("Unexpected event!"),
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(), &node_0_shutdown);
+ nodes[2].node.handle_shutdown(nodes[0].node.get_our_node_id(), &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(), &node_0_orig_shutdown);
+ nodes[2].node.handle_shutdown(nodes[0].node.get_our_node_id(), &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
nodes[0].node.close_channel(&chan.2, &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(), &node_0_shutdown);
+ nodes[2].node.handle_shutdown(nodes[0].node.get_our_node_id(), &node_0_shutdown);
let events = nodes[2].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
match events[0] {
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1000000, 1000000);
nodes[0].node.close_channel(&chan.2, &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(), &node_1_shutdown);
+ nodes[1].node.handle_shutdown(nodes[0].node.get_our_node_id(), &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);
nodes[1].node.close_channel(&chan.2, &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(), &node_0_shutdown);
+ nodes[0].node.handle_shutdown(nodes[1].node.get_our_node_id(), &node_0_shutdown);
let events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
match events[0] {
nodes[1].node.close_channel(&chan.2, &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(), &node_0_shutdown);
+ nodes[0].node.handle_shutdown(nodes[1].node.get_our_node_id(), &node_0_shutdown);
let events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 2);
match events[0] {
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 42, None, None).unwrap();
let mut open_channel = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
open_channel.common_fields.shutdown_scriptpubkey = Some(anysegwit_shutdown_script.clone());
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &open_channel);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel);
let events = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
// Check script when handling an accept_channel message
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 42, None, 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(), &open_channel);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel);
let mut accept_channel = get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id());
accept_channel.common_fields.shutdown_scriptpubkey = Some(anysegwit_shutdown_script.clone());
- nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), &accept_channel);
+ nodes[0].node.handle_accept_channel(nodes[1].node.get_our_node_id(), &accept_channel);
let events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
open_channel.common_fields.shutdown_scriptpubkey = Some(Builder::new().push_int(0)
.push_slice(&[0, 0])
.into_script());
- nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), &open_channel);
+ nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel);
let events = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
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(), &node_0_shutdown);
+ nodes[0].node.handle_shutdown(nodes[1].node.get_our_node_id(), &node_0_shutdown);
let events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 2);
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(), &node_0_shutdown);
+ nodes[0].node.handle_shutdown(nodes[1].node.get_our_node_id(), &node_0_shutdown);
let events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 2);
// 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_0_shutdown);
+ nodes[0].node.handle_shutdown(nodes[1].node.get_our_node_id(), &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");
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(), &node_0_shutdown);
+ nodes[0].node.handle_shutdown(nodes[1].node.get_our_node_id(), &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");
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(), &node_0_shutdown);
+ nodes[1].node.handle_shutdown(nodes[0].node.get_our_node_id(), &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(), &node_1_shutdown);
+ nodes[0].node.handle_shutdown(nodes[1].node.get_our_node_id(), &node_1_shutdown);
{
// Now we set nodes[1] to require a relatively high feerate for closing. This should result
assert!(node_0_closing_signed.fee_satoshis <= 500);
if timeout_step != TimeoutStep::AfterShutdown {
- nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_closing_signed);
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &node_0_closing_signed);
assert!(check_warn_msg!(nodes[1], nodes[0].node.get_our_node_id(), chan_id)
.starts_with("Unable to come to consensus about closing feerate"));
let mut node_0_peer_state_lock;
get_channel_ref!(nodes[0], nodes[1], node_0_per_peer_lock, node_0_peer_state_lock, chan_id).context_mut().closing_fee_limits.as_mut().unwrap().1 *= 10;
}
- nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_closing_signed);
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &node_0_closing_signed);
let node_1_closing_signed = get_event_msg!(nodes[1], MessageSendEvent::SendClosingSigned, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_closing_signed(&nodes[1].node.get_our_node_id(), &node_1_closing_signed);
+ nodes[0].node.handle_closing_signed(nodes[1].node.get_our_node_id(), &node_1_closing_signed);
let node_0_2nd_closing_signed = get_closing_signed_broadcast!(nodes[0].node, nodes[1].node.get_our_node_id());
if timeout_step == TimeoutStep::NoTimeout {
- nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed.1.unwrap());
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed.1.unwrap());
check_closed_event!(nodes[1], 1, ClosureReason::CounterpartyInitiatedCooperativeClosure, [nodes[0].node.get_our_node_id()], 100000);
}
check_closed_event!(nodes[0], 1, ClosureReason::LocallyInitiatedCooperativeClosure, [nodes[1].node.get_our_node_id()], 100000);
nodes[0].node.close_channel(&chan.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(), &node_0_shutdown);
+ nodes[1].node.handle_shutdown(nodes[0].node.get_our_node_id(), &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(), &node_1_shutdown);
+ nodes[0].node.handle_shutdown(nodes[1].node.get_our_node_id(), &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;
assert!(node_0_closing_signed.fee_satoshis < 500);
}
- nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_closing_signed);
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &node_0_closing_signed);
let (_, mut node_1_closing_signed) = get_closing_signed_broadcast!(nodes[1].node, nodes[0].node.get_our_node_id());
node_1_closing_signed.as_mut().unwrap().fee_range = None;
- nodes[0].node.handle_closing_signed(&nodes[1].node.get_our_node_id(), &node_1_closing_signed.unwrap());
+ nodes[0].node.handle_closing_signed(nodes[1].node.get_our_node_id(), &node_1_closing_signed.unwrap());
let (_, node_0_none) = get_closing_signed_broadcast!(nodes[0].node, nodes[1].node.get_our_node_id());
assert!(node_0_none.is_none());
check_closed_event!(nodes[0], 1, ClosureReason::LocallyInitiatedCooperativeClosure, [nodes[1].node.get_our_node_id()], 100000);
nodes[1].node.close_channel_with_feerate_and_script(&chan_id, &nodes[0].node.get_our_node_id(), Some(253 * 5), None).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(), &node_0_shutdown);
- nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &node_1_shutdown);
+ nodes[1].node.handle_shutdown(nodes[0].node.get_our_node_id(), &node_0_shutdown);
+ nodes[0].node.handle_shutdown(nodes[1].node.get_our_node_id(), &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);
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &node_0_closing_signed);
let (_, node_1_closing_signed_opt) = get_closing_signed_broadcast!(nodes[1].node, nodes[0].node.get_our_node_id());
let node_1_closing_signed = node_1_closing_signed_opt.unwrap();
node_0_closing_signed.fee_satoshis);
assert_eq!(node_0_closing_signed.fee_satoshis, node_1_closing_signed.fee_satoshis);
- nodes[0].node.handle_closing_signed(&nodes[1].node.get_our_node_id(), &node_1_closing_signed);
+ nodes[0].node.handle_closing_signed(nodes[1].node.get_our_node_id(), &node_1_closing_signed);
let (_, node_0_none) = get_closing_signed_broadcast!(nodes[0].node, nodes[1].node.get_our_node_id());
assert!(node_0_none.is_none());
check_closed_event!(nodes[0], 1, ClosureReason::LocallyInitiatedCooperativeClosure, [nodes[1].node.get_our_node_id()], 100000);
nodes[0].node.close_channel(&chan_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[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &node_0_shutdown);
- nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &node_1_shutdown);
+ nodes[0].node.handle_shutdown(nodes[1].node.get_our_node_id(), &node_0_shutdown);
+ nodes[1].node.handle_shutdown(nodes[0].node.get_our_node_id(), &node_1_shutdown);
if use_htlc {
- nodes[1].node.handle_update_fail_htlc(&nodes[0].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
+ nodes[1].node.handle_update_fail_htlc(nodes[0].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
} else {
- nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), &updates.update_fee.unwrap());
+ nodes[1].node.handle_update_fee(nodes[0].node.get_our_node_id(), &updates.update_fee.unwrap());
}
- nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &updates.commitment_signed);
+ nodes[1].node.handle_commitment_signed(nodes[0].node.get_our_node_id(), &updates.commitment_signed);
check_added_monitors(&nodes[1], 1);
let (bs_raa, bs_cs) = get_revoke_commit_msgs(&nodes[1], &nodes[0].node.get_our_node_id());
- nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_raa);
+ nodes[0].node.handle_revoke_and_ack(nodes[1].node.get_our_node_id(), &bs_raa);
check_added_monitors(&nodes[0], 1);
// At this point the Channel on nodes[0] has no record of any HTLCs but the latest
assert_eq!(nodes[0].node.get_and_clear_pending_msg_events(), Vec::new());
chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
- nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &bs_cs);
+ nodes[0].node.handle_commitment_signed(nodes[1].node.get_our_node_id(), &bs_cs);
check_added_monitors(&nodes[0], 1);
assert_eq!(nodes[0].node.get_and_clear_pending_msg_events(), Vec::new());
assert_eq!(as_raa_closing_signed.len(), 2);
if let MessageSendEvent::SendRevokeAndACK { msg, .. } = &as_raa_closing_signed[0] {
- nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &msg);
+ nodes[1].node.handle_revoke_and_ack(nodes[0].node.get_our_node_id(), &msg);
check_added_monitors(&nodes[1], 1);
if use_htlc {
expect_payment_failed!(nodes[1], payment_hash_opt.unwrap(), true);
} else { panic!("Unexpected message {:?}", as_raa_closing_signed[0]); }
if let MessageSendEvent::SendClosingSigned { msg, .. } = &as_raa_closing_signed[1] {
- nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &msg);
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &msg);
} else { panic!("Unexpected message {:?}", as_raa_closing_signed[1]); }
let bs_closing_signed = get_event_msg!(nodes[1], MessageSendEvent::SendClosingSigned, nodes[0].node.get_our_node_id());
- nodes[0].node.handle_closing_signed(&nodes[1].node.get_our_node_id(), &bs_closing_signed);
+ nodes[0].node.handle_closing_signed(nodes[1].node.get_our_node_id(), &bs_closing_signed);
let (_, as_2nd_closing_signed) = get_closing_signed_broadcast!(nodes[0].node, nodes[1].node.get_our_node_id());
- nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &as_2nd_closing_signed.unwrap());
+ nodes[1].node.handle_closing_signed(nodes[0].node.get_our_node_id(), &as_2nd_closing_signed.unwrap());
let (_, node_1_none) = get_closing_signed_broadcast!(nodes[1].node, nodes[0].node.get_our_node_id());
assert!(node_1_none.is_none());
let mut features = InitFeatures::empty();
features.set_onion_messages_optional();
let init_msg = msgs::Init { features, networks: None, remote_network_address: None };
- node_a.messenger.peer_connected(&node_b.node_id, &init_msg.clone(), true).unwrap();
- node_b.messenger.peer_connected(&node_a.node_id, &init_msg.clone(), false).unwrap();
+ node_a.messenger.peer_connected(node_b.node_id, &init_msg.clone(), true).unwrap();
+ node_b.messenger.peer_connected(node_a.node_id, &init_msg.clone(), false).unwrap();
}
fn disconnect_peers(node_a: &MessengerNode, node_b: &MessengerNode) {
- node_a.messenger.peer_disconnected(&node_b.node_id);
- node_b.messenger.peer_disconnected(&node_a.node_id);
+ node_a.messenger.peer_disconnected(node_b.node_id);
+ node_b.messenger.peer_disconnected(node_a.node_id);
}
fn release_events(node: &MessengerNode) -> Vec<Event> {
assert_eq!(msgs.len(), 1);
msgs[0].clone()
};
- node.messenger.handle_onion_message(&prev_node.node_id, &onion_msg);
+ node.messenger.handle_onion_message(prev_node.node_id, &onion_msg);
prev_node = node;
}
}
// which is why the asserted strings differ slightly from the spec.
assert_eq!(sender_to_alice_om.encode(), <Vec<u8>>::from_hex("031195a8046dcbb8e17034bca630065e7a0982e4e36f6f7e5a8d4554e4846fcd9905560002531fe6068134503d2723133227c867ac8fa6c83c537e9a44c3c5bdbdcb1fe33793b828776d70aabbd8cef1a5b52d5a397ae1a20f20435ff6057cd8be339d5aee226660ef73b64afa45dbf2e6e8e26eb96a259b2db5aeecda1ce2e768bbc35d389d7f320ca3d2bd14e2689bef2f5ac0307eaaabc1924eb972c1563d4646ae131accd39da766257ed35ea36e4222527d1db4fa7b2000aab9eafcceed45e28b5560312d4e2299bd8d1e7fe27d10925966c28d497aec400b4630485e82efbabc00550996bdad5d6a9a8c75952f126d14ad2cff91e16198691a7ef2937de83209285f1fb90944b4e46bca7c856a9ce3da10cdf2a7d00dc2bf4f114bc4d3ed67b91cbde558ce9af86dc81fbdc37f8e301b29e23c1466659c62bdbf8cff5d4c20f0fb0851ec72f5e9385dd40fdd2e3ed67ca4517117825665e50a3e26f73c66998daf18e418e8aef9ce2d20da33c3629db2933640e03e7b44c2edf49e9b482db7b475cfd4c617ae1d46d5c24d697846f9f08561eac2b065f9b382501f6eabf07343ed6c602f61eab99cdb52adf63fd44a8db2d3016387ea708fc1c08591e19b4d9984ebe31edbd684c2ea86526dd8c7732b1d8d9117511dc1b643976d356258fce8313b1cb92682f41ab72dedd766f06de375f9edacbcd0ca8c99b865ea2b7952318ea1fd20775a28028b5cf59dece5de14f615b8df254eee63493a5111ea987224bea006d8f1b60d565eef06ac0da194dba2a6d02e79b2f2f34e9ca6e1984a507319d86e9d4fcaeea41b4b9144e0b1826304d4cc1da61cfc5f8b9850697df8adc5e9d6f3acb3219b02764b4909f2b2b22e799fd66c383414a84a7d791b899d4aa663770009eb122f90282c8cb9cda16aba6897edcf9b32951d0080c0f52be3ca011fbec3fb16423deb47744645c3b05fdbd932edf54ba6efd26e65340a8e9b1d1216582e1b30d64524f8ca2d6c5ba63a38f7120a3ed71bed8960bcac2feee2dd41c90be48e3c11ec518eb3d872779e4765a6cc28c6b0fa71ab57ced73ae963cc630edae4258cba2bf25821a6ae049fec2fca28b5dd1bb004d92924b65701b06dcf37f0ccd147a13a03f9bc0f98b7d78fe9058089756931e2cd0e0ed92ec6759d07b248069526c67e9e6ce095118fd3501ba0f858ef030b76c6f6beb11a09317b5ad25343f4b31aef02bc555951bc7791c2c289ecf94d5544dcd6ad3021ed8e8e3db34b2a73e1eedb57b578b068a5401836d6e382110b73690a94328c404af25e85a8d6b808893d1b71af6a31fadd8a8cc6e31ecc0d9ff7e6b91fd03c274a5c1f1ccd25b61150220a3fddb04c91012f5f7a83a5c90deb2470089d6e38cd5914b9c946eca6e9d31bbf8667d36cf87effc3f3ff283c21dd4137bd569fe7cf758feac94053e4baf7338bb592c8b7c291667fadf4a9bf9a2a154a18f612cbc7f851b3f8f2070e0a9d180622ee4f8e81b0ab250d504cef24116a3ff188cc829fcd8610b56343569e8dc997629410d1967ca9dd1d27eec5e01e4375aad16c46faba268524b154850d0d6fe3a76af2c6aa3e97647c51036049ac565370028d6a439a2672b6face56e1b171496c0722cfa22d9da631be359661617c5d5a2d286c5e19db9452c1e21a0107b6400debda2decb0c838f342dd017cdb2dccdf1fe97e3df3f881856b546997a3fed9e279c720145101567dd56be21688fed66bf9759e432a9aa89cbbd225d13cdea4ca05f7a45cfb6a682a3d5b1e18f7e6cf934fae5098108bae9058d05c3387a01d8d02a656d2bfff67e9f46b2d8a6aac28129e52efddf6e552214c3f8a45bc7a912cca9a7fec1d7d06412c6972cb9e3dc518983f56530b8bffe7f92c4b6eb47d4aef59fb513c4653a42de61bc17ad7728e7fc7590ff05a9e991de03f023d0aaf8688ed6170def5091c66576a424ac1cb").unwrap());
let sender_dummy_node_id = PublicKey::from_slice(&[2; 33]).unwrap();
- nodes[0].messenger.handle_onion_message(&sender_dummy_node_id, &sender_to_alice_om);
+ nodes[0].messenger.handle_onion_message(sender_dummy_node_id, &sender_to_alice_om);
let alice_to_bob_om = nodes[0].messenger.next_onion_message_for_peer(nodes[1].node_id).unwrap();
assert_eq!(alice_to_bob_om.encode(), <Vec<u8>>::from_hex("031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f05560002536d53f93796cad550b6c68662dca41f7e8c221c31022c64dd1a627b2df3982b25eac261e88369cfc66e1e3b6d9829cb3dcd707046e68a7796065202a7904811bf2608c5611cf74c9eb5371c7eb1a4428bb39a041493e2a568ddb0b2482a6cc6711bc6116cef144ebf988073cb18d9dd4ce2d3aa9de91a7dc6d7c6f11a852024626e66b41ba1158055505dff9cb15aa51099f315564d9ee3ed6349665dc3e209eedf9b5805ee4f69d315df44c80e63d0e2efbdab60ec96f44a3447c6a6ddb1efb6aa4e072bde1dab974081646bfddf3b02daa2b83847d74dd336465e76e9b8fecc2b0414045eeedfc39939088a76820177dd1103c99939e659beb07197bab9f714b30ba8dc83738e9a6553a57888aaeda156c68933a2f4ff35e3f81135076b944ed9856acbfee9c61299a5d1763eadd14bf5eaf71304c8e165e590d7ecbcd25f1650bf5b6c2ad1823b2dc9145e168974ecf6a2273c94decff76d94bc6708007a17f22262d63033c184d0166c14f41b225a956271947aae6ce65890ed8f0d09c6ffe05ec02ee8b9de69d7077a0c5adeb813aabcc1ba8975b73ab06ddea5f4db3c23a1de831602de2b83f990d4133871a1a81e53f86393e6a7c3a7b73f0c099fa72afe26c3027bb9412338a19303bd6e6591c04fb4cde9b832b5f41ae199301ea8c303b5cef3aca599454273565de40e1148156d1f97c1aa9e58459ab318304075e034f5b7899c12587b86776a18a1da96b7bcdc22864fccc4c41538ebce92a6f054d53bf46770273a70e75fe0155cd6d2f2e937465b0825ce3123b8c206fac4c30478fa0f08a97ade7216dce11626401374993213636e93545a31f500562130f2feb04089661ad8c34d5a4cbd2e4e426f37cb094c786198a220a2646ecadc38c04c29ee67b19d662c209a7b30bfecc7fe8bf7d274de0605ee5df4db490f6d32234f6af639d3fce38a2801bcf8d51e9c090a6c6932355a83848129a378095b34e71cb8f51152dc035a4fe8e802fec8de221a02ba5afd6765ce570bef912f87357936ea0b90cb2990f56035e89539ec66e8dbd6ed50835158614096990e019c3eba3d7dd6a77147641c6145e8b17552cd5cf7cd163dd40b9eaeba8c78e03a2cd8c0b7997d6f56d35f38983a202b4eb8a54e14945c4de1a6dde46167e11708b7a5ff5cb9c0f7fc12fae49a012aa90bb1995c038130b749c48e6f1ffb732e92086def42af10fbc460d94abeb7b2fa744a5e9a491d62a08452be8cf2fdef573deedc1fe97098bce889f98200b26f9bb99da9aceddda6d793d8e0e44a2601ef4590cfbb5c3d0197aac691e3d31c20fd8e38764962ca34dabeb85df28feabaf6255d4d0df3d814455186a84423182caa87f9673df770432ad8fdfe78d4888632d460d36d2719e8fa8e4b4ca10d817c5d6bc44a8b2affab8c2ba53b8bf4994d63286c2fad6be04c28661162fa1a67065ecda8ba8c13aee4a8039f4f0110e0c0da2366f178d8903e19136dad6df9d8693ce71f3a270f9941de2a93d9b67bc516207ac1687bf6e00b29723c42c7d9c90df9d5e599dbeb7b73add0a6a2b7aba82f98ac93cb6e60494040445229f983a81c34f7f686d166dfc98ec23a6318d4a02a311ac28d655ea4e0f9c3014984f31e621ef003e98c373561d9040893feece2e0fa6cd2dd565e6fbb2773a2407cb2c3273c306cf71f427f2e551c4092e067cf9869f31ac7c6c80dd52d4f85be57a891a41e34be0d564e39b4af6f46b85339254a58b205fb7e10e7d0470ee73622493f28c08962118c23a1198467e72c4ae1cd482144b419247a5895975ea90d135e2a46ef7e5794a1551a447ff0a0d299b66a7f565cd86531f5e7af5408d85d877ce95b1df12b88b7d5954903a5296325ba478ba1e1a9d1f30a2d5052b2e2889bbd64f72c72bc71d8817288a2").unwrap());
- nodes[1].messenger.handle_onion_message(&nodes[0].node_id, &alice_to_bob_om);
+ nodes[1].messenger.handle_onion_message(nodes[0].node_id, &alice_to_bob_om);
let bob_to_carol_om = nodes[1].messenger.next_onion_message_for_peer(nodes[2].node_id).unwrap();
assert_eq!(bob_to_carol_om.encode(), <Vec<u8>>::from_hex("02b684babfd400c8dd48b367e9754b8021a3594a34dc94d7101776c7f6a86d0582055600029a77e8523162efa1f4208f4f2050cd5c386ddb6ce6d36235ea569d217ec52209fb85fdf7dbc4786c373eebdba0ddc184cfbe6da624f610e93f62c70f2c56be1090b926359969f040f932c03f53974db5656233bd60af375517d4323002937d784c2c88a564bcefe5c33d3fc21c26d94dfacab85e2e19685fd2ff4c543650958524439b6da68779459aee5ffc9dc543339acec73ff43be4c44ddcbe1c11d50e2411a67056ba9db7939d780f5a86123fdd3abd6f075f7a1d78ab7daf3a82798b7ec1e9f1345bc0d1e935098497067e2ae5a51ece396fcb3bb30871ad73aee51b2418b39f00c8e8e22be4a24f4b624e09cb0414dd46239de31c7be035f71e8da4f5a94d15b44061f46414d3f355069b5c5b874ba56704eb126148a22ec873407fe118972127e63ff80e682e410f297f23841777cec0517e933eaf49d7e34bd203266b42081b3a5193b51ccd34b41342bc67cf73523b741f5c012ba2572e9dda15fbe131a6ac2ff24dc2a7622d58b9f3553092cfae7fae3c8864d95f97aa49ec8edeff5d9f5782471160ee412d82ff6767030fc63eec6a93219a108cd41433834b26676a39846a944998796c79cd1cc460531b8ded659cedfd8aecefd91944f00476f1496daafb4ea6af3feacac1390ea510709783c2aa81a29de27f8959f6284f4684102b17815667cbb0645396ac7d542b878d90c42a1f7f00c4c4eedb2a22a219f38afadb4f1f562b6e000a94e75cc38f535b43a3c0384ccef127fde254a9033a317701c710b2b881065723486e3f4d3eea5e12f374a41565fe43fa137c1a252c2153dde055bb343344c65ad0529010ece29bbd405effbebfe3ba21382b94a60ac1a5ffa03f521792a67b30773cb42e862a8a02a8bbd41b842e115969c87d1ff1f8c7b5726b9f20772dd57fe6e4ea41f959a2a673ffad8e2f2a472c4c8564f3a5a47568dd75294b1c7180c500f7392a7da231b1fe9e525ea2d7251afe9ca52a17fe54a116cb57baca4f55b9b6de915924d644cba9dade4ccc01939d7935749c008bafc6d3ad01cd72341ce5ddf7a5d7d21cf0465ab7a3233433aef21f9acf2bfcdc5a8cc003adc4d82ac9d72b36eb74e05c9aa6ccf439ac92e6b84a3191f0764dd2a2e0b4cc3baa08782b232ad6ecd3ca6029bc08cc094aef3aebddcaddc30070cb6023a689641de86cfc6341c8817215a4650f844cd2ca60f2f10c6e44cfc5f23912684d4457bf4f599879d30b79bf12ef1ab8d34dddc15672b82e56169d4c770f0a2a7a960b1e8790773f5ff7fce92219808f16d061cc85e053971213676d28fb48925e9232b66533dbd938458eb2cc8358159df7a2a2e4cf87500ede2afb8ce963a845b98978edf26a6948d4932a6b95d022004556d25515fe158092ce9a913b4b4a493281393ca731e8d8e5a3449b9d888fc4e73ffcbb9c6d6d66e88e03cf6e81a0496ede6e4e4172b08c000601993af38f80c7f68c9d5fff9e0e215cff088285bf039ca731744efcb7825a272ca724517736b4890f47e306b200aa2543c363e2c9090bcf3cf56b5b86868a62471c7123a41740392fc1d5ab28da18dca66618e9af7b42b62b23aba907779e73ca03ec60e6ab9e0484b9cae6578e0fddb6386cb3468506bf6420298bf4a690947ab582255551d82487f271101c72e19e54872ab47eae144db66bc2f8194a666a5daec08d12822cb83a61946234f2dfdbd6ca7d8763e6818adee7b401fcdb1ac42f9df1ac5cc5ac131f2869013c8d6cd29d4c4e3d05bccd34ca83366d616296acf854fa05149bfd763a25b9938e96826a037fdcb85545439c76df6beed3bdbd01458f9cf984997cc4f0a7ac3cc3f5e1eeb59c09cadcf5a537f16e444149c8f17d4bdaef16c9fbabc5ef06eb0f0bf3a07a1beddfeacdaf1df5582d6dbd6bb808d6ab31bc22e5d7").unwrap());
- nodes[2].messenger.handle_onion_message(&nodes[1].node_id, &bob_to_carol_om);
+ nodes[2].messenger.handle_onion_message(nodes[1].node_id, &bob_to_carol_om);
let carol_to_dave_om = nodes[2].messenger.next_onion_message_for_peer(nodes[3].node_id).unwrap();
assert_eq!(carol_to_dave_om.encode(), <Vec<u8>>::from_hex("025aaca62db7ce6b46386206ef9930daa32e979a35cb185a41cb951aa7d254b03c055600025550b2910294fa73bda99b9de9c851be9cbb481e23194a1743033630efba546b86e7d838d0f6e9cc0ed088dbf6889f0dceca3bfc745bd77d013a31311fa932a8bf1d28387d9ff521eabc651dee8f861fed609a68551145a451f017ec44978addeee97a423c08445531da488fd1ddc998e9cdbfcea59517b53fbf1833f0bbe6188dba6ca773a247220ec934010daca9cc185e1ceb136803469baac799e27a0d82abe53dc48a06a55d1f643885cc7894677dd20a4e4152577d1ba74b870b9279f065f9b340cedb3ca13b7df218e853e10ccd1b59c42a2acf93f489e170ee4373d30ab158b60fc20d3ba73a1f8c750951d69fb5b9321b968ddc8114936412346aff802df65516e1c09c51ef19849ff36c0199fd88c8bec301a30fef0c7cb497901c038611303f64e4174b5daf42832aa5586b84d2c9b95f382f4269a5d1bd4be898618dc78dfd451170f72ca16decac5b03e60702112e439cadd104fb3bbb3d5023c9b80823fdcd0a212a7e1aaa6eeb027adc7f8b3723031d135a09a979a4802788bb7861c6cc85501fb91137768b70aeab309b27b885686604ffc387004ac4f8c44b101c39bc0597ef7fd957f53fc5051f534b10eb3852100962b5e58254e5558689913c26ad6072ea41f5c5db10077cfc91101d4ae393be274c74297da5cc381cd88d54753aaa7df74b2f9da8d88a72bc9218fcd1f19e4ff4aace182312b9509c5175b6988f044c5756d232af02a451a02ca752f3c52747773acff6fd07d2032e6ce562a2c42105d106eba02d0b1904182cdc8c74875b082d4989d3a7e9f0e73de7c75d357f4af976c28c0b206c5e8123fc2391d078592d0d5ff686fd245c0a2de2e535b7cca99c0a37d432a8657393a9e3ca53eec1692159046ba52cb9bc97107349d8673f74cbc97e231f1108005c8d03e24ca813cea2294b39a7a493bcc062708f1f6cf0074e387e7d50e0666ce784ef4d31cb860f6cad767438d9ea5156ff0ae86e029e0247bf94df75ee0cda4f2006061455cb2eaff513d558863ae334cef7a3d45f55e7cc13153c6719e9901c1d4db6c03f643b69ea4860690305651794284d9e61eb848ccdf5a77794d376f0af62e46d4835acce6fd9eef5df73ebb8ea3bb48629766967f446e744ecc57ff3642c4aa1ccee9a2f72d5caa75fa05787d08b79408fce792485fdecdc25df34820fb061275d70b84ece540b0fc47b2453612be34f2b78133a64e812598fbe225fd85415f8ffe5340ce955b5fd9d67dd88c1c531dde298ed25f96df271558c812c26fa386966c76f03a6ebccbca49ac955916929bd42e134f982dde03f924c464be5fd1ba44f8dc4c3cbc8162755fd1d8f7dc044b15b1a796c53df7d8769bb167b2045b49cc71e08908796c92c16a235717cabc4bb9f60f8f66ff4fff1f9836388a99583acebdff4a7fb20f48eedcd1f4bdcc06ec8b48e35307df51d9bc81d38a94992dd135b30079e1f592da6e98dff496cb1a7776460a26b06395b176f585636ebdf7eab692b227a31d6979f5a6141292698e91346b6c806b90c7c6971e481559cae92ee8f4136f2226861f5c39ddd29bbdb118a35dece03f49a96804caea79a3dacfbf09d65f2611b5622de51d98e18151acb3bb84c09caaa0cc80edfa743a4679f37d6167618ce99e73362fa6f213409931762618a61f1738c071bba5afc1db24fe94afb70c40d731908ab9a505f76f57a7d40e708fd3df0efc5b7cbb2a7b75cd23449e09684a2f0e2bfa0d6176c35f96fe94d92fc9fa4103972781f81cb6e8df7dbeb0fc529c600d768bed3f08828b773d284f69e9a203459d88c12d6df7a75be2455fec128f07a497a2b2bf626cc6272d0419ca663e9dc66b8224227eb796f0246dcae9c5b0b6cfdbbd40c3245a610481c92047c968c9fc92c04b89cc41a0c15355a8f").unwrap());
// Dave handles the onion message but he'll log that he errored while decoding the hop data
// because he sees it as an empty onion message (the only contents of the sender's OM is "hello"
// with TLV type 1, which Dave ignores because (1) it's odd and he can't understand it and (2) LDK
// only attempts to parse custom OM TLVs with type > 64).
- nodes[3].messenger.handle_onion_message(&nodes[2].node_id, &carol_to_dave_om);
+ nodes[3].messenger.handle_onion_message(nodes[2].node_id, &carol_to_dave_om);
}
APH::Target: AsyncPaymentsMessageHandler,
CMH::Target: CustomOnionMessageHandler,
{
- fn handle_onion_message(&self, peer_node_id: &PublicKey, msg: &OnionMessage) {
- let logger = WithContext::from(&self.logger, Some(*peer_node_id), None, None);
+ fn handle_onion_message(&self, peer_node_id: PublicKey, msg: &OnionMessage) {
+ let logger = WithContext::from(&self.logger, Some(peer_node_id), None, None);
match self.peel_onion_message(msg) {
Ok(PeeledOnion::Receive(message, context, reply_path)) => {
log_trace!(
}
}
- fn peer_connected(&self, their_node_id: &PublicKey, init: &msgs::Init, _inbound: bool) -> Result<(), ()> {
+ fn peer_connected(&self, their_node_id: PublicKey, init: &msgs::Init, _inbound: bool) -> Result<(), ()> {
if init.features.supports_onion_messages() {
self.message_recipients.lock().unwrap()
- .entry(*their_node_id)
+ .entry(their_node_id)
.or_insert_with(|| OnionMessageRecipient::ConnectedPeer(VecDeque::new()))
.mark_connected();
if self.intercept_messages_for_offline_peers {
let mut pending_peer_connected_events =
self.pending_peer_connected_events.lock().unwrap();
pending_peer_connected_events.push(
- Event::OnionMessagePeerConnected { peer_node_id: *their_node_id }
+ Event::OnionMessagePeerConnected { peer_node_id: their_node_id }
);
self.event_notifier.notify();
}
} else {
- self.message_recipients.lock().unwrap().remove(their_node_id);
+ self.message_recipients.lock().unwrap().remove(&their_node_id);
}
Ok(())
}
- fn peer_disconnected(&self, their_node_id: &PublicKey) {
- match self.message_recipients.lock().unwrap().remove(their_node_id) {
+ fn peer_disconnected(&self, their_node_id: PublicKey) {
+ match self.message_recipients.lock().unwrap().remove(&their_node_id) {
Some(OnionMessageRecipient::ConnectedPeer(..)) => {},
Some(_) => debug_assert!(false),
None => {},
features
}
- fn provided_init_features(&self, _their_node_id: &PublicKey) -> InitFeatures {
+ fn provided_init_features(&self, _their_node_id: PublicKey) -> InitFeatures {
let mut features = InitFeatures::empty();
features.set_onion_messages_optional();
features
impl<G: Deref<Target=NetworkGraph<L>>, U: Deref, L: Deref> RoutingMessageHandler for P2PGossipSync<G, U, L>
where U::Target: UtxoLookup, L::Target: Logger
{
- fn handle_node_announcement(&self, _their_node_id: Option<&PublicKey>, msg: &msgs::NodeAnnouncement) -> Result<bool, LightningError> {
+ fn handle_node_announcement(&self, _their_node_id: Option<PublicKey>, msg: &msgs::NodeAnnouncement) -> Result<bool, LightningError> {
self.network_graph.update_node_from_announcement(msg)?;
Ok(msg.contents.excess_data.len() <= MAX_EXCESS_BYTES_FOR_RELAY &&
msg.contents.excess_address_data.len() <= MAX_EXCESS_BYTES_FOR_RELAY &&
msg.contents.excess_data.len() + msg.contents.excess_address_data.len() <= MAX_EXCESS_BYTES_FOR_RELAY)
}
- fn handle_channel_announcement(&self, _their_node_id: Option<&PublicKey>, msg: &msgs::ChannelAnnouncement) -> Result<bool, LightningError> {
+ fn handle_channel_announcement(&self, _their_node_id: Option<PublicKey>, msg: &msgs::ChannelAnnouncement) -> Result<bool, LightningError> {
self.network_graph.update_channel_from_announcement(msg, &*self.utxo_lookup.read().unwrap())?;
Ok(msg.contents.excess_data.len() <= MAX_EXCESS_BYTES_FOR_RELAY)
}
- fn handle_channel_update(&self, _their_node_id: Option<&PublicKey>, msg: &msgs::ChannelUpdate) -> Result<bool, LightningError> {
+ fn handle_channel_update(&self, _their_node_id: Option<PublicKey>, msg: &msgs::ChannelUpdate) -> Result<bool, LightningError> {
self.network_graph.update_channel(msg)?;
Ok(msg.contents.excess_data.len() <= MAX_EXCESS_BYTES_FOR_RELAY)
}
/// [`query_channel_range`]: msgs::QueryChannelRange
/// [`query_scid`]: msgs::QueryShortChannelIds
/// [`reply_scids_end`]: msgs::ReplyShortChannelIdsEnd
- fn peer_connected(&self, their_node_id: &PublicKey, init_msg: &Init, _inbound: bool) -> Result<(), ()> {
+ fn peer_connected(&self, their_node_id: PublicKey, init_msg: &Init, _inbound: bool) -> Result<(), ()> {
// We will only perform a sync with peers that support gossip_queries.
if !init_msg.features.supports_gossip_queries() {
// Don't disconnect peers for not supporting gossip queries. We may wish to have
Ok(())
}
- fn handle_reply_channel_range(&self, _their_node_id: &PublicKey, _msg: ReplyChannelRange) -> Result<(), LightningError> {
+ fn handle_reply_channel_range(&self, _their_node_id: PublicKey, _msg: ReplyChannelRange) -> Result<(), LightningError> {
// We don't make queries, so should never receive replies. If, in the future, the set
// reconciliation extensions to gossip queries become broadly supported, we should revert
// this code to its state pre-0.0.106.
Ok(())
}
- fn handle_reply_short_channel_ids_end(&self, _their_node_id: &PublicKey, _msg: ReplyShortChannelIdsEnd) -> Result<(), LightningError> {
+ fn handle_reply_short_channel_ids_end(&self, _their_node_id: PublicKey, _msg: ReplyShortChannelIdsEnd) -> Result<(), LightningError> {
// We don't make queries, so should never receive replies. If, in the future, the set
// reconciliation extensions to gossip queries become broadly supported, we should revert
// this code to its state pre-0.0.106.
/// sync of the public routing table with 128k channels will generated 16 messages and allocate ~1MB.
/// Logic can be changed to reduce allocation if/when a full sync of the routing table impacts
/// memory constrained systems.
- fn handle_query_channel_range(&self, their_node_id: &PublicKey, msg: QueryChannelRange) -> Result<(), LightningError> {
+ fn handle_query_channel_range(&self, their_node_id: PublicKey, msg: QueryChannelRange) -> Result<(), LightningError> {
log_debug!(self.logger, "Handling query_channel_range peer={}, first_blocknum={}, number_of_blocks={}", log_pubkey!(their_node_id), msg.first_blocknum, msg.number_of_blocks);
let inclusive_start_scid = scid_from_parts(msg.first_blocknum as u64, 0, 0);
Ok(())
}
- fn handle_query_short_channel_ids(&self, _their_node_id: &PublicKey, _msg: QueryShortChannelIds) -> Result<(), LightningError> {
+ fn handle_query_short_channel_ids(&self, _their_node_id: PublicKey, _msg: QueryShortChannelIds) -> Result<(), LightningError> {
// TODO
Err(LightningError {
err: String::from("Not implemented"),
features
}
- fn provided_init_features(&self, _their_node_id: &PublicKey) -> InitFeatures {
+ fn provided_init_features(&self, _their_node_id: PublicKey) -> InitFeatures {
let mut features = InitFeatures::empty();
features.set_gossip_queries_optional();
features
let zero_hash = Sha256dHash::hash(&[0; 32]);
let valid_announcement = get_signed_node_announcement(|_| {}, node_1_privkey, &secp_ctx);
- match gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &valid_announcement) {
+ match gossip_sync.handle_node_announcement(Some(node_1_pubkey), &valid_announcement) {
Ok(_) => panic!(),
Err(e) => assert_eq!("No existing channels for node_announcement", e.err)
};
{
// Announce a channel to add a corresponding node.
let valid_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
- match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_announcement) {
+ match gossip_sync.handle_channel_announcement(Some(node_1_pubkey), &valid_announcement) {
Ok(res) => assert!(res),
_ => panic!()
};
let fake_msghash = hash_to_message!(zero_hash.as_byte_array());
match gossip_sync.handle_node_announcement(
- Some(&node_1_pubkey),
+ Some(node_1_pubkey),
&NodeAnnouncement {
signature: secp_ctx.sign_ecdsa(&fake_msghash, node_1_privkey),
contents: valid_announcement.contents.clone()
Err(e) => assert_eq!(e.err, "Invalid signature on node_announcement message")
};
- match gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &valid_announcement) {
+ match gossip_sync.handle_node_announcement(Some(node_1_pubkey), &valid_announcement) {
Ok(res) => assert!(res),
Err(_) => panic!()
};
unsigned_announcement.excess_data.resize(MAX_EXCESS_BYTES_FOR_RELAY + 1, 0);
}, node_1_privkey, &secp_ctx);
// Return false because contains excess data.
- match gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &announcement_with_data) {
+ match gossip_sync.handle_node_announcement(Some(node_1_pubkey), &announcement_with_data) {
Ok(res) => assert!(!res),
Err(_) => panic!()
};
let outdated_announcement = get_signed_node_announcement(|unsigned_announcement| {
unsigned_announcement.timestamp += 1000 - 10;
}, node_1_privkey, &secp_ctx);
- match gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &outdated_announcement) {
+ match gossip_sync.handle_node_announcement(Some(node_1_pubkey), &outdated_announcement) {
Ok(_) => panic!(),
Err(e) => assert_eq!(e.err, "Update older than last processed update")
};
// Test if the UTXO lookups were not supported
let network_graph = NetworkGraph::new(Network::Testnet, &logger);
let mut gossip_sync = P2PGossipSync::new(&network_graph, None, &logger);
- match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_announcement) {
+ match gossip_sync.handle_channel_announcement(Some(node_1_pubkey), &valid_announcement) {
Ok(res) => assert!(res),
_ => panic!()
};
// If we receive announcement for the same channel (with UTXO lookups disabled),
// drop new one on the floor, since we can't see any changes.
- match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_announcement) {
+ match gossip_sync.handle_channel_announcement(Some(node_1_pubkey), &valid_announcement) {
Ok(_) => panic!(),
Err(e) => assert_eq!(e.err, "Already have non-chain-validated channel")
};
let valid_announcement = get_signed_channel_announcement(|unsigned_announcement| {
unsigned_announcement.short_channel_id += 1;
}, node_1_privkey, node_2_privkey, &secp_ctx);
- match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_announcement) {
+ match gossip_sync.handle_channel_announcement(Some(node_1_pubkey), &valid_announcement) {
Ok(_) => panic!(),
Err(e) => assert_eq!(e.err, "Channel announced without corresponding UTXO entry")
};
let valid_announcement = get_signed_channel_announcement(|unsigned_announcement| {
unsigned_announcement.short_channel_id += 2;
}, node_1_privkey, node_2_privkey, &secp_ctx);
- match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_announcement) {
+ match gossip_sync.handle_channel_announcement(Some(node_1_pubkey), &valid_announcement) {
Ok(res) => assert!(res),
_ => panic!()
};
// chain, we simply ignore all new (duplicate) announcements.
*chain_source.utxo_ret.lock().unwrap() =
UtxoResult::Sync(Ok(TxOut { value: Amount::ZERO, script_pubkey: good_script }));
- match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_announcement) {
+ match gossip_sync.handle_channel_announcement(Some(node_1_pubkey), &valid_announcement) {
Ok(_) => panic!(),
Err(e) => assert_eq!(e.err, "Already have chain-validated channel")
};
let valid_announcement = get_signed_channel_announcement(|unsigned_announcement| {
unsigned_announcement.short_channel_id += 3;
}, node_1_privkey, node_2_privkey, &secp_ctx);
- match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_announcement) {
+ match gossip_sync.handle_channel_announcement(Some(node_1_pubkey), &valid_announcement) {
Ok(_) => panic!(),
Err(e) => assert_eq!(e.err, "Channel with SCID 3 or one of its nodes was removed from our network graph recently")
}
gossip_sync.network_graph().remove_stale_channels_and_tracking_with_time(tracking_time + REMOVED_ENTRIES_TRACKING_AGE_LIMIT_SECS);
// The above channel announcement should be handled as per normal now.
- match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_announcement) {
+ match gossip_sync.handle_channel_announcement(Some(node_1_pubkey), &valid_announcement) {
Ok(res) => assert!(res),
_ => panic!()
}
let mut invalid_sig_announcement = valid_excess_data_announcement.clone();
invalid_sig_announcement.contents.excess_data = Vec::new();
- match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &invalid_sig_announcement) {
+ match gossip_sync.handle_channel_announcement(Some(node_1_pubkey), &invalid_sig_announcement) {
Ok(_) => panic!(),
Err(e) => assert_eq!(e.err, "Invalid signature on channel_announcement message")
};
// Don't relay valid channels with excess data
- match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_excess_data_announcement) {
+ match gossip_sync.handle_channel_announcement(Some(node_1_pubkey), &valid_excess_data_announcement) {
Ok(res) => assert!(!res),
_ => panic!()
};
let channel_to_itself_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_1_privkey, &secp_ctx);
- match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &channel_to_itself_announcement) {
+ match gossip_sync.handle_channel_announcement(Some(node_1_pubkey), &channel_to_itself_announcement) {
Ok(_) => panic!(),
Err(e) => assert_eq!(e.err, "Channel announcement node had a channel with itself")
};
let incorrect_chain_announcement = get_signed_channel_announcement(|unsigned_announcement| {
unsigned_announcement.chain_hash = ChainHash::using_genesis_block(Network::Bitcoin);
}, node_1_privkey, node_2_privkey, &secp_ctx);
- match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &incorrect_chain_announcement) {
+ match gossip_sync.handle_channel_announcement(Some(node_1_pubkey), &incorrect_chain_announcement) {
Ok(_) => panic!(),
Err(e) => assert_eq!(e.err, "Channel announcement chain hash does not match genesis hash")
};
let valid_channel_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
short_channel_id = valid_channel_announcement.contents.short_channel_id;
- match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_channel_announcement) {
+ match gossip_sync.handle_channel_announcement(Some(node_1_pubkey), &valid_channel_announcement) {
Ok(_) => (),
Err(_) => panic!()
};
let valid_channel_update = get_signed_channel_update(|_| {}, node_1_privkey, &secp_ctx);
network_graph.verify_channel_update(&valid_channel_update).unwrap();
- match gossip_sync.handle_channel_update(Some(&node_1_pubkey), &valid_channel_update) {
+ match gossip_sync.handle_channel_update(Some(node_1_pubkey), &valid_channel_update) {
Ok(res) => assert!(res),
_ => panic!(),
};
unsigned_channel_update.excess_data.resize(MAX_EXCESS_BYTES_FOR_RELAY + 1, 0);
}, node_1_privkey, &secp_ctx);
// Return false because contains excess data
- match gossip_sync.handle_channel_update(Some(&node_1_pubkey), &valid_channel_update) {
+ match gossip_sync.handle_channel_update(Some(node_1_pubkey), &valid_channel_update) {
Ok(res) => assert!(!res),
_ => panic!()
};
unsigned_channel_update.timestamp += 110;
unsigned_channel_update.short_channel_id += 1;
}, node_1_privkey, &secp_ctx);
- match gossip_sync.handle_channel_update(Some(&node_1_pubkey), &valid_channel_update) {
+ match gossip_sync.handle_channel_update(Some(node_1_pubkey), &valid_channel_update) {
Ok(_) => panic!(),
Err(e) => assert_eq!(e.err, "Couldn't find channel for update")
};
unsigned_channel_update.htlc_maximum_msat = MAX_VALUE_MSAT + 1;
unsigned_channel_update.timestamp += 110;
}, node_1_privkey, &secp_ctx);
- match gossip_sync.handle_channel_update(Some(&node_1_pubkey), &valid_channel_update) {
+ match gossip_sync.handle_channel_update(Some(node_1_pubkey), &valid_channel_update) {
Ok(_) => panic!(),
Err(e) => assert_eq!(e.err, "htlc_maximum_msat is larger than maximum possible msats")
};
unsigned_channel_update.htlc_maximum_msat = amount_sats.to_sat() * 1000 + 1;
unsigned_channel_update.timestamp += 110;
}, node_1_privkey, &secp_ctx);
- match gossip_sync.handle_channel_update(Some(&node_1_pubkey), &valid_channel_update) {
+ match gossip_sync.handle_channel_update(Some(node_1_pubkey), &valid_channel_update) {
Ok(_) => panic!(),
Err(e) => assert_eq!(e.err, "htlc_maximum_msat is larger than channel capacity or capacity is bogus")
};
let valid_channel_update = get_signed_channel_update(|unsigned_channel_update| {
unsigned_channel_update.timestamp += 100;
}, node_1_privkey, &secp_ctx);
- match gossip_sync.handle_channel_update(Some(&node_1_pubkey), &valid_channel_update) {
+ match gossip_sync.handle_channel_update(Some(node_1_pubkey), &valid_channel_update) {
Ok(_) => panic!(),
Err(e) => assert_eq!(e.err, "Update had same timestamp as last processed update")
};
let zero_hash = Sha256dHash::hash(&[0; 32]);
let fake_msghash = hash_to_message!(zero_hash.as_byte_array());
invalid_sig_channel_update.signature = secp_ctx.sign_ecdsa(&fake_msghash, node_1_privkey);
- match gossip_sync.handle_channel_update(Some(&node_1_pubkey), &invalid_sig_channel_update) {
+ match gossip_sync.handle_channel_update(Some(node_1_pubkey), &invalid_sig_channel_update) {
Ok(_) => panic!(),
Err(e) => assert_eq!(e.err, "Invalid signature on channel_update message")
};
unsigned_channel_update.chain_hash = ChainHash::using_genesis_block(Network::Bitcoin);
}, node_1_privkey, &secp_ctx);
- match gossip_sync.handle_channel_update(Some(&node_1_pubkey), &incorrect_chain_update) {
+ match gossip_sync.handle_channel_update(Some(node_1_pubkey), &incorrect_chain_update) {
Ok(_) => panic!(),
Err(e) => assert_eq!(e.err, "Channel update chain hash does not match genesis hash")
};
// Submit two channel updates for each channel direction (update.flags bit).
let valid_channel_update = get_signed_channel_update(|_| {}, node_1_privkey, &secp_ctx);
- assert!(gossip_sync.handle_channel_update(Some(&node_1_pubkey), &valid_channel_update).is_ok());
+ assert!(gossip_sync.handle_channel_update(Some(node_1_pubkey), &valid_channel_update).is_ok());
assert!(network_graph.read_only().channels().get(&short_channel_id).unwrap().one_to_two.is_some());
let valid_channel_update_2 = get_signed_channel_update(|update| {update.channel_flags |=1;}, node_2_privkey, &secp_ctx);
- gossip_sync.handle_channel_update(Some(&node_1_pubkey), &valid_channel_update_2).unwrap();
+ gossip_sync.handle_channel_update(Some(node_1_pubkey), &valid_channel_update_2).unwrap();
assert!(network_graph.read_only().channels().get(&short_channel_id).unwrap().two_to_one.is_some());
network_graph.remove_stale_channels_and_tracking_with_time(100 + STALE_CHANNEL_UPDATE_AGE_LIMIT_SECS);
let valid_channel_update = get_signed_channel_update(|unsigned_channel_update| {
unsigned_channel_update.timestamp = (announcement_time + 1 + STALE_CHANNEL_UPDATE_AGE_LIMIT_SECS) as u32;
}, node_1_privkey, &secp_ctx);
- assert!(gossip_sync.handle_channel_update(Some(&node_1_pubkey), &valid_channel_update).is_ok());
+ assert!(gossip_sync.handle_channel_update(Some(node_1_pubkey), &valid_channel_update).is_ok());
assert!(network_graph.read_only().channels().get(&short_channel_id).unwrap().one_to_two.is_some());
network_graph.remove_stale_channels_and_tracking_with_time(announcement_time + 1 + STALE_CHANNEL_UPDATE_AGE_LIMIT_SECS);
// Make sure removed channels are tracked.
// Announce a channel we will update
let valid_channel_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
short_channel_id = valid_channel_announcement.contents.short_channel_id;
- match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_channel_announcement) {
+ match gossip_sync.handle_channel_announcement(Some(node_1_pubkey), &valid_channel_announcement) {
Ok(_) => (),
Err(_) => panic!()
};
let valid_channel_update = get_signed_channel_update(|unsigned_channel_update| {
unsigned_channel_update.timestamp = 101;
}, node_1_privkey, &secp_ctx);
- match gossip_sync.handle_channel_update(Some(&node_1_pubkey), &valid_channel_update) {
+ match gossip_sync.handle_channel_update(Some(node_1_pubkey), &valid_channel_update) {
Ok(_) => (),
Err(_) => panic!()
};
unsigned_channel_update.timestamp = 102;
unsigned_channel_update.excess_data = [1; MAX_EXCESS_BYTES_FOR_RELAY + 1].to_vec();
}, node_1_privkey, &secp_ctx);
- match gossip_sync.handle_channel_update(Some(&node_1_pubkey), &valid_channel_update) {
+ match gossip_sync.handle_channel_update(Some(node_1_pubkey), &valid_channel_update) {
Ok(_) => (),
Err(_) => panic!()
};
{
// Announce a channel to add 2 nodes
let valid_channel_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
- match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_channel_announcement) {
+ match gossip_sync.handle_channel_announcement(Some(node_1_pubkey), &valid_channel_announcement) {
Ok(_) => (),
Err(_) => panic!()
};
{
let valid_announcement = get_signed_node_announcement(|_| {}, node_1_privkey, &secp_ctx);
- match gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &valid_announcement) {
+ match gossip_sync.handle_node_announcement(Some(node_1_pubkey), &valid_announcement) {
Ok(_) => (),
Err(_) => panic!()
};
let valid_announcement = get_signed_node_announcement(|_| {}, node_2_privkey, &secp_ctx);
- match gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &valid_announcement) {
+ match gossip_sync.handle_node_announcement(Some(node_1_pubkey), &valid_announcement) {
Ok(_) => (),
Err(_) => panic!()
};
unsigned_announcement.timestamp += 10;
unsigned_announcement.excess_data = [1; MAX_EXCESS_BYTES_FOR_RELAY + 1].to_vec();
}, node_2_privkey, &secp_ctx);
- match gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &valid_announcement) {
+ match gossip_sync.handle_node_announcement(Some(node_1_pubkey), &valid_announcement) {
Ok(res) => assert!(!res),
Err(_) => panic!()
};
// Announce a channel to add a corresponding node.
let valid_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
- match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_announcement) {
+ match gossip_sync.handle_channel_announcement(Some(node_1_pubkey), &valid_announcement) {
Ok(res) => assert!(res),
_ => panic!()
};
let valid_announcement = get_signed_node_announcement(|_| {}, node_1_privkey, &secp_ctx);
- match gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &valid_announcement) {
+ match gossip_sync.handle_node_announcement(Some(node_1_pubkey), &valid_announcement) {
Ok(_) => (),
Err(_) => panic!()
};
// It should ignore if gossip_queries feature is not enabled
{
let init_msg = Init { features: InitFeatures::empty(), networks: None, remote_network_address: None };
- gossip_sync.peer_connected(&node_id_1, &init_msg, true).unwrap();
+ gossip_sync.peer_connected(node_id_1, &init_msg, true).unwrap();
let events = gossip_sync.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 0);
}
let mut features = InitFeatures::empty();
features.set_gossip_queries_optional();
let init_msg = Init { features, networks: None, remote_network_address: None };
- gossip_sync.peer_connected(&node_id_1, &init_msg, true).unwrap();
+ gossip_sync.peer_connected(node_id_1, &init_msg, true).unwrap();
let events = gossip_sync.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
match &events[0] {
let valid_announcement = get_signed_channel_announcement(|unsigned_announcement| {
unsigned_announcement.short_channel_id = scid;
}, node_1_privkey, node_2_privkey, &secp_ctx);
- match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_announcement) {
+ match gossip_sync.handle_channel_announcement(Some(node_1_pubkey), &valid_announcement) {
Ok(_) => (),
_ => panic!()
};
let mut max_firstblocknum = msg.first_blocknum.saturating_sub(1);
let mut c_lightning_0_9_prev_end_blocknum = max_firstblocknum;
let query_end_blocknum = msg.end_blocknum();
- let result = gossip_sync.handle_query_channel_range(test_node_id, msg);
+ let result = gossip_sync.handle_query_channel_range(*test_node_id, msg);
if expected_ok {
assert!(result.is_ok());
let chain_hash = ChainHash::using_genesis_block(Network::Testnet);
- let result = gossip_sync.handle_query_short_channel_ids(&node_id, QueryShortChannelIds {
+ let result = gossip_sync.handle_query_short_channel_ids(node_id, QueryShortChannelIds {
chain_hash,
short_channel_ids: vec![0x0003e8_000000_0000],
});
let node_1_id = NodeId::from_pubkey(&PublicKey::from_secret_key(&secp_ctx, node_1_privkey));
let announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
- gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &announcement).unwrap();
+ gossip_sync.handle_channel_announcement(Some(node_1_pubkey), &announcement).unwrap();
let tcp_ip_v4 = SocketAddress::TcpIpV4 {
addr: [255, 254, 253, 252],
assert!(!network_graph.read_only().node(&node_1_id).unwrap().is_tor_only());
let announcement = get_signed_node_announcement(|_| {}, node_1_privkey, &secp_ctx);
- gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &announcement).unwrap();
+ gossip_sync.handle_node_announcement(Some(node_1_pubkey), &announcement).unwrap();
assert!(!network_graph.read_only().node(&node_1_id).unwrap().is_tor_only());
let announcement = get_signed_node_announcement(
},
node_1_privkey, &secp_ctx
);
- gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &announcement).unwrap();
+ gossip_sync.handle_node_announcement(Some(node_1_pubkey), &announcement).unwrap();
assert!(!network_graph.read_only().node(&node_1_id).unwrap().is_tor_only());
let announcement = get_signed_node_announcement(
},
node_1_privkey, &secp_ctx
);
- gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &announcement).unwrap();
+ gossip_sync.handle_node_announcement(Some(node_1_pubkey), &announcement).unwrap();
assert!(!network_graph.read_only().node(&node_1_id).unwrap().is_tor_only());
let announcement = get_signed_node_announcement(
},
node_1_privkey, &secp_ctx
);
- gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &announcement).unwrap();
+ gossip_sync.handle_node_announcement(Some(node_1_pubkey), &announcement).unwrap();
assert!(!network_graph.read_only().node(&node_1_id).unwrap().is_tor_only());
let announcement = get_signed_node_announcement(
},
node_1_privkey, &secp_ctx
);
- gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &announcement).unwrap();
+ gossip_sync.handle_node_announcement(Some(node_1_pubkey), &announcement).unwrap();
assert!(network_graph.read_only().node(&node_1_id).unwrap().is_tor_only());
let announcement = get_signed_node_announcement(
},
node_1_privkey, &secp_ctx
);
- gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &announcement).unwrap();
+ gossip_sync.handle_node_announcement(Some(node_1_pubkey), &announcement).unwrap();
assert!(network_graph.read_only().node(&node_1_id).unwrap().is_tor_only());
let announcement = get_signed_node_announcement(
},
node_1_privkey, &secp_ctx
);
- gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &announcement).unwrap();
+ gossip_sync.handle_node_announcement(Some(node_1_pubkey), &announcement).unwrap();
assert!(!network_graph.read_only().node(&node_1_id).unwrap().is_tor_only());
}
}
bitcoin_signature_2: secp_ctx.sign_ecdsa(&msghash, node_2_privkey),
contents: unsigned_announcement.clone(),
};
- match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_announcement) {
+ match gossip_sync.handle_channel_announcement(Some(node_1_pubkey), &valid_announcement) {
Ok(res) => assert!(res),
_ => panic!()
};
contents: unsigned_announcement.clone()
};
- match gossip_sync.handle_node_announcement(Some(&node_pubkey), &valid_announcement) {
+ match gossip_sync.handle_node_announcement(Some(node_pubkey), &valid_announcement) {
Ok(_) => (),
Err(_) => panic!()
};
contents: update.clone()
};
- match gossip_sync.handle_channel_update(Some(&node_pubkey), &valid_channel_update) {
+ match gossip_sync.handle_channel_update(Some(node_pubkey), &valid_channel_update) {
Ok(res) => assert!(res),
Err(_) => panic!()
};
}
impl msgs::ChannelMessageHandler for TestChannelMessageHandler {
- fn handle_open_channel(&self, _their_node_id: &PublicKey, msg: &msgs::OpenChannel) {
+ fn handle_open_channel(&self, _their_node_id: PublicKey, msg: &msgs::OpenChannel) {
self.received_msg(wire::Message::OpenChannel(msg.clone()));
}
- fn handle_accept_channel(&self, _their_node_id: &PublicKey, msg: &msgs::AcceptChannel) {
+ fn handle_accept_channel(&self, _their_node_id: PublicKey, msg: &msgs::AcceptChannel) {
self.received_msg(wire::Message::AcceptChannel(msg.clone()));
}
- fn handle_funding_created(&self, _their_node_id: &PublicKey, msg: &msgs::FundingCreated) {
+ fn handle_funding_created(&self, _their_node_id: PublicKey, msg: &msgs::FundingCreated) {
self.received_msg(wire::Message::FundingCreated(msg.clone()));
}
- fn handle_funding_signed(&self, _their_node_id: &PublicKey, msg: &msgs::FundingSigned) {
+ fn handle_funding_signed(&self, _their_node_id: PublicKey, msg: &msgs::FundingSigned) {
self.received_msg(wire::Message::FundingSigned(msg.clone()));
}
- fn handle_channel_ready(&self, _their_node_id: &PublicKey, msg: &msgs::ChannelReady) {
+ fn handle_channel_ready(&self, _their_node_id: PublicKey, msg: &msgs::ChannelReady) {
self.received_msg(wire::Message::ChannelReady(msg.clone()));
}
- fn handle_shutdown(&self, _their_node_id: &PublicKey, msg: &msgs::Shutdown) {
+ fn handle_shutdown(&self, _their_node_id: PublicKey, msg: &msgs::Shutdown) {
self.received_msg(wire::Message::Shutdown(msg.clone()));
}
- fn handle_closing_signed(&self, _their_node_id: &PublicKey, msg: &msgs::ClosingSigned) {
+ fn handle_closing_signed(&self, _their_node_id: PublicKey, msg: &msgs::ClosingSigned) {
self.received_msg(wire::Message::ClosingSigned(msg.clone()));
}
- fn handle_stfu(&self, _their_node_id: &PublicKey, msg: &msgs::Stfu) {
+ fn handle_stfu(&self, _their_node_id: PublicKey, msg: &msgs::Stfu) {
self.received_msg(wire::Message::Stfu(msg.clone()));
}
#[cfg(splicing)]
- fn handle_splice_init(&self, _their_node_id: &PublicKey, msg: &msgs::SpliceInit) {
+ fn handle_splice_init(&self, _their_node_id: PublicKey, msg: &msgs::SpliceInit) {
self.received_msg(wire::Message::SpliceInit(msg.clone()));
}
#[cfg(splicing)]
- fn handle_splice_ack(&self, _their_node_id: &PublicKey, msg: &msgs::SpliceAck) {
+ fn handle_splice_ack(&self, _their_node_id: PublicKey, msg: &msgs::SpliceAck) {
self.received_msg(wire::Message::SpliceAck(msg.clone()));
}
#[cfg(splicing)]
- fn handle_splice_locked(&self, _their_node_id: &PublicKey, msg: &msgs::SpliceLocked) {
+ fn handle_splice_locked(&self, _their_node_id: PublicKey, msg: &msgs::SpliceLocked) {
self.received_msg(wire::Message::SpliceLocked(msg.clone()));
}
- fn handle_update_add_htlc(&self, _their_node_id: &PublicKey, msg: &msgs::UpdateAddHTLC) {
+ fn handle_update_add_htlc(&self, _their_node_id: PublicKey, msg: &msgs::UpdateAddHTLC) {
self.received_msg(wire::Message::UpdateAddHTLC(msg.clone()));
}
- fn handle_update_fulfill_htlc(&self, _their_node_id: &PublicKey, msg: &msgs::UpdateFulfillHTLC) {
+ fn handle_update_fulfill_htlc(&self, _their_node_id: PublicKey, msg: &msgs::UpdateFulfillHTLC) {
self.received_msg(wire::Message::UpdateFulfillHTLC(msg.clone()));
}
- fn handle_update_fail_htlc(&self, _their_node_id: &PublicKey, msg: &msgs::UpdateFailHTLC) {
+ fn handle_update_fail_htlc(&self, _their_node_id: PublicKey, msg: &msgs::UpdateFailHTLC) {
self.received_msg(wire::Message::UpdateFailHTLC(msg.clone()));
}
- fn handle_update_fail_malformed_htlc(&self, _their_node_id: &PublicKey, msg: &msgs::UpdateFailMalformedHTLC) {
+ fn handle_update_fail_malformed_htlc(&self, _their_node_id: PublicKey, msg: &msgs::UpdateFailMalformedHTLC) {
self.received_msg(wire::Message::UpdateFailMalformedHTLC(msg.clone()));
}
- fn handle_commitment_signed(&self, _their_node_id: &PublicKey, msg: &msgs::CommitmentSigned) {
+ fn handle_commitment_signed(&self, _their_node_id: PublicKey, msg: &msgs::CommitmentSigned) {
self.received_msg(wire::Message::CommitmentSigned(msg.clone()));
}
- fn handle_revoke_and_ack(&self, _their_node_id: &PublicKey, msg: &msgs::RevokeAndACK) {
+ fn handle_revoke_and_ack(&self, _their_node_id: PublicKey, msg: &msgs::RevokeAndACK) {
self.received_msg(wire::Message::RevokeAndACK(msg.clone()));
}
- fn handle_update_fee(&self, _their_node_id: &PublicKey, msg: &msgs::UpdateFee) {
+ fn handle_update_fee(&self, _their_node_id: PublicKey, msg: &msgs::UpdateFee) {
self.received_msg(wire::Message::UpdateFee(msg.clone()));
}
- fn handle_channel_update(&self, _their_node_id: &PublicKey, _msg: &msgs::ChannelUpdate) {
+ fn handle_channel_update(&self, _their_node_id: PublicKey, _msg: &msgs::ChannelUpdate) {
// Don't call `received_msg` here as `TestRoutingMessageHandler` generates these sometimes
}
- fn handle_announcement_signatures(&self, _their_node_id: &PublicKey, msg: &msgs::AnnouncementSignatures) {
+ fn handle_announcement_signatures(&self, _their_node_id: PublicKey, msg: &msgs::AnnouncementSignatures) {
self.received_msg(wire::Message::AnnouncementSignatures(msg.clone()));
}
- fn handle_channel_reestablish(&self, _their_node_id: &PublicKey, msg: &msgs::ChannelReestablish) {
+ fn handle_channel_reestablish(&self, _their_node_id: PublicKey, msg: &msgs::ChannelReestablish) {
self.received_msg(wire::Message::ChannelReestablish(msg.clone()));
}
- fn peer_disconnected(&self, their_node_id: &PublicKey) {
- assert!(self.connected_peers.lock().unwrap().remove(their_node_id));
+ fn peer_disconnected(&self, their_node_id: PublicKey) {
+ assert!(self.connected_peers.lock().unwrap().remove(&their_node_id));
}
- fn peer_connected(&self, their_node_id: &PublicKey, _msg: &msgs::Init, _inbound: bool) -> Result<(), ()> {
+ fn peer_connected(&self, their_node_id: PublicKey, _msg: &msgs::Init, _inbound: bool) -> Result<(), ()> {
assert!(self.connected_peers.lock().unwrap().insert(their_node_id.clone()));
// Don't bother with `received_msg` for Init as its auto-generated and we don't want to
// bother re-generating the expected Init message in all tests.
Ok(())
}
- fn handle_error(&self, _their_node_id: &PublicKey, msg: &msgs::ErrorMessage) {
+ fn handle_error(&self, _their_node_id: PublicKey, msg: &msgs::ErrorMessage) {
self.received_msg(wire::Message::Error(msg.clone()));
}
fn provided_node_features(&self) -> NodeFeatures {
channelmanager::provided_node_features(&UserConfig::default())
}
- fn provided_init_features(&self, _their_init_features: &PublicKey) -> InitFeatures {
+ fn provided_init_features(&self, _their_init_features: PublicKey) -> InitFeatures {
channelmanager::provided_init_features(&UserConfig::default())
}
Some(vec![self.chain_hash])
}
- fn handle_open_channel_v2(&self, _their_node_id: &PublicKey, msg: &msgs::OpenChannelV2) {
+ fn handle_open_channel_v2(&self, _their_node_id: PublicKey, msg: &msgs::OpenChannelV2) {
self.received_msg(wire::Message::OpenChannelV2(msg.clone()));
}
- fn handle_accept_channel_v2(&self, _their_node_id: &PublicKey, msg: &msgs::AcceptChannelV2) {
+ fn handle_accept_channel_v2(&self, _their_node_id: PublicKey, msg: &msgs::AcceptChannelV2) {
self.received_msg(wire::Message::AcceptChannelV2(msg.clone()));
}
- fn handle_tx_add_input(&self, _their_node_id: &PublicKey, msg: &msgs::TxAddInput) {
+ fn handle_tx_add_input(&self, _their_node_id: PublicKey, msg: &msgs::TxAddInput) {
self.received_msg(wire::Message::TxAddInput(msg.clone()));
}
- fn handle_tx_add_output(&self, _their_node_id: &PublicKey, msg: &msgs::TxAddOutput) {
+ fn handle_tx_add_output(&self, _their_node_id: PublicKey, msg: &msgs::TxAddOutput) {
self.received_msg(wire::Message::TxAddOutput(msg.clone()));
}
- fn handle_tx_remove_input(&self, _their_node_id: &PublicKey, msg: &msgs::TxRemoveInput) {
+ fn handle_tx_remove_input(&self, _their_node_id: PublicKey, msg: &msgs::TxRemoveInput) {
self.received_msg(wire::Message::TxRemoveInput(msg.clone()));
}
- fn handle_tx_remove_output(&self, _their_node_id: &PublicKey, msg: &msgs::TxRemoveOutput) {
+ fn handle_tx_remove_output(&self, _their_node_id: PublicKey, msg: &msgs::TxRemoveOutput) {
self.received_msg(wire::Message::TxRemoveOutput(msg.clone()));
}
- fn handle_tx_complete(&self, _their_node_id: &PublicKey, msg: &msgs::TxComplete) {
+ fn handle_tx_complete(&self, _their_node_id: PublicKey, msg: &msgs::TxComplete) {
self.received_msg(wire::Message::TxComplete(msg.clone()));
}
- fn handle_tx_signatures(&self, _their_node_id: &PublicKey, msg: &msgs::TxSignatures) {
+ fn handle_tx_signatures(&self, _their_node_id: PublicKey, msg: &msgs::TxSignatures) {
self.received_msg(wire::Message::TxSignatures(msg.clone()));
}
- fn handle_tx_init_rbf(&self, _their_node_id: &PublicKey, msg: &msgs::TxInitRbf) {
+ fn handle_tx_init_rbf(&self, _their_node_id: PublicKey, msg: &msgs::TxInitRbf) {
self.received_msg(wire::Message::TxInitRbf(msg.clone()));
}
- fn handle_tx_ack_rbf(&self, _their_node_id: &PublicKey, msg: &msgs::TxAckRbf) {
+ fn handle_tx_ack_rbf(&self, _their_node_id: PublicKey, msg: &msgs::TxAckRbf) {
self.received_msg(wire::Message::TxAckRbf(msg.clone()));
}
- fn handle_tx_abort(&self, _their_node_id: &PublicKey, msg: &msgs::TxAbort) {
+ fn handle_tx_abort(&self, _their_node_id: PublicKey, msg: &msgs::TxAbort) {
self.received_msg(wire::Message::TxAbort(msg.clone()));
}
}
}
}
impl msgs::RoutingMessageHandler for TestRoutingMessageHandler {
- fn handle_node_announcement(&self, _their_node_id: Option<&PublicKey>, _msg: &msgs::NodeAnnouncement) -> Result<bool, msgs::LightningError> {
+ fn handle_node_announcement(&self, _their_node_id: Option<PublicKey>, _msg: &msgs::NodeAnnouncement) -> Result<bool, msgs::LightningError> {
Err(msgs::LightningError { err: "".to_owned(), action: msgs::ErrorAction::IgnoreError })
}
- fn handle_channel_announcement(&self, _their_node_id: Option<&PublicKey>, _msg: &msgs::ChannelAnnouncement) -> Result<bool, msgs::LightningError> {
+ fn handle_channel_announcement(&self, _their_node_id: Option<PublicKey>, _msg: &msgs::ChannelAnnouncement) -> Result<bool, msgs::LightningError> {
self.chan_anns_recvd.fetch_add(1, Ordering::AcqRel);
Err(msgs::LightningError { err: "".to_owned(), action: msgs::ErrorAction::IgnoreError })
}
- fn handle_channel_update(&self, _their_node_id: Option<&PublicKey>, _msg: &msgs::ChannelUpdate) -> Result<bool, msgs::LightningError> {
+ fn handle_channel_update(&self, _their_node_id: Option<PublicKey>, _msg: &msgs::ChannelUpdate) -> Result<bool, msgs::LightningError> {
self.chan_upds_recvd.fetch_add(1, Ordering::AcqRel);
Err(msgs::LightningError { err: "".to_owned(), action: msgs::ErrorAction::IgnoreError })
}
None
}
- fn peer_connected(&self, their_node_id: &PublicKey, init_msg: &msgs::Init, _inbound: bool) -> Result<(), ()> {
+ fn peer_connected(&self, their_node_id: PublicKey, init_msg: &msgs::Init, _inbound: bool) -> Result<(), ()> {
if !init_msg.features.supports_gossip_queries() {
return Ok(());
}
Ok(())
}
- fn handle_reply_channel_range(&self, _their_node_id: &PublicKey, _msg: msgs::ReplyChannelRange) -> Result<(), msgs::LightningError> {
+ fn handle_reply_channel_range(&self, _their_node_id: PublicKey, _msg: msgs::ReplyChannelRange) -> Result<(), msgs::LightningError> {
Ok(())
}
- fn handle_reply_short_channel_ids_end(&self, _their_node_id: &PublicKey, _msg: msgs::ReplyShortChannelIdsEnd) -> Result<(), msgs::LightningError> {
+ fn handle_reply_short_channel_ids_end(&self, _their_node_id: PublicKey, _msg: msgs::ReplyShortChannelIdsEnd) -> Result<(), msgs::LightningError> {
Ok(())
}
- fn handle_query_channel_range(&self, _their_node_id: &PublicKey, _msg: msgs::QueryChannelRange) -> Result<(), msgs::LightningError> {
+ fn handle_query_channel_range(&self, _their_node_id: PublicKey, _msg: msgs::QueryChannelRange) -> Result<(), msgs::LightningError> {
Ok(())
}
- fn handle_query_short_channel_ids(&self, _their_node_id: &PublicKey, _msg: msgs::QueryShortChannelIds) -> Result<(), msgs::LightningError> {
+ fn handle_query_short_channel_ids(&self, _their_node_id: PublicKey, _msg: msgs::QueryShortChannelIds) -> Result<(), msgs::LightningError> {
Ok(())
}
features
}
- fn provided_init_features(&self, _their_init_features: &PublicKey) -> InitFeatures {
+ fn provided_init_features(&self, _their_init_features: PublicKey) -> InitFeatures {
let mut features = InitFeatures::empty();
features.set_gossip_queries_optional();
features