Skip to content

Commit

Permalink
Add new wire messaging and events but don't handle them
Browse files Browse the repository at this point in the history
  • Loading branch information
dunxen committed Nov 9, 2022
1 parent 77c92b3 commit fb9706f
Show file tree
Hide file tree
Showing 7 changed files with 436 additions and 1 deletion.
11 changes: 11 additions & 0 deletions lightning-net-tokio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,17 @@ mod tests {
fn handle_update_fee(&self, _their_node_id: &PublicKey, _msg: &UpdateFee) {}
fn handle_announcement_signatures(&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, _their_features: InitFeatures, _msg: &OpenChannelV2) {}
fn handle_accept_channel_v2(&self, _their_node_id: &PublicKey, _their_features: InitFeatures, _msg: &AcceptChannelV2) {}
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, _no_connection_possible: bool) {
if *their_node_id == self.expected_pubkey {
self.disconnected_flag.store(true, Ordering::SeqCst);
Expand Down
77 changes: 77 additions & 0 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6100,11 +6100,23 @@ impl<M: Deref , T: Deref , K: Deref , F: Deref , L: Deref >
let _ = handle_error!(self, self.internal_open_channel(counterparty_node_id, their_features, msg), *counterparty_node_id);
}

fn handle_open_channel_v2(&self, counterparty_node_id: &PublicKey, _their_features: InitFeatures, msg: &msgs::OpenChannelV2) {
let _: Result<(), _> = handle_error!(self, Err(MsgHandleErrInternal::send_err_msg_no_close(
"Dual-funded channels not supported".to_owned(),
msg.temporary_channel_id.clone())), *counterparty_node_id);
}

fn handle_accept_channel(&self, counterparty_node_id: &PublicKey, their_features: InitFeatures, msg: &msgs::AcceptChannel) {
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
let _ = handle_error!(self, self.internal_accept_channel(counterparty_node_id, their_features, msg), *counterparty_node_id);
}

fn handle_accept_channel_v2(&self, counterparty_node_id: &PublicKey, _their_features: InitFeatures, msg: &msgs::AcceptChannelV2) {
let _: Result<(), _> = handle_error!(self, Err(MsgHandleErrInternal::send_err_msg_no_close(
"Dual-funded channels not supported".to_owned(),
msg.temporary_channel_id.clone())), *counterparty_node_id);
}

fn handle_funding_created(&self, counterparty_node_id: &PublicKey, msg: &msgs::FundingCreated) {
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
let _ = handle_error!(self, self.internal_funding_created(counterparty_node_id, msg), *counterparty_node_id);
Expand Down Expand Up @@ -6211,10 +6223,21 @@ impl<M: Deref , T: Deref , K: Deref , F: Deref , L: Deref >
pending_msg_events.retain(|msg| {
match msg {
&events::MessageSendEvent::SendAcceptChannel { ref node_id, .. } => node_id != counterparty_node_id,
&events::MessageSendEvent::SendAcceptChannelV2 { ref node_id, .. } => node_id != counterparty_node_id,
&events::MessageSendEvent::SendOpenChannel { ref node_id, .. } => node_id != counterparty_node_id,
&events::MessageSendEvent::SendOpenChannelV2 { ref node_id, .. } => node_id != counterparty_node_id,
&events::MessageSendEvent::SendFundingCreated { ref node_id, .. } => node_id != counterparty_node_id,
&events::MessageSendEvent::SendFundingSigned { ref node_id, .. } => node_id != counterparty_node_id,
&events::MessageSendEvent::SendChannelReady { ref node_id, .. } => node_id != counterparty_node_id,
&events::MessageSendEvent::SendTxAddInput { ref node_id, .. } => node_id != counterparty_node_id,
&events::MessageSendEvent::SendTxAddOutput { ref node_id, .. } => node_id != counterparty_node_id,
&events::MessageSendEvent::SendTxRemoveInput { ref node_id, .. } => node_id != counterparty_node_id,
&events::MessageSendEvent::SendTxRemoveOutput { ref node_id, .. } => node_id != counterparty_node_id,
&events::MessageSendEvent::SendTxComplete { ref node_id, .. } => node_id != counterparty_node_id,
&events::MessageSendEvent::SendTxSignatures { ref node_id, .. } => node_id != counterparty_node_id,
&events::MessageSendEvent::SendTxInitRbf { ref node_id, .. } => node_id != counterparty_node_id,
&events::MessageSendEvent::SendTxAckRbf { ref node_id, .. } => node_id != counterparty_node_id,
&events::MessageSendEvent::SendTxAbort { ref node_id, .. } => node_id != counterparty_node_id,
&events::MessageSendEvent::SendAnnouncementSignatures { ref node_id, .. } => node_id != counterparty_node_id,
&events::MessageSendEvent::UpdateHTLCs { ref node_id, .. } => node_id != counterparty_node_id,
&events::MessageSendEvent::SendRevokeAndACK { ref node_id, .. } => node_id != counterparty_node_id,
Expand Down Expand Up @@ -6341,6 +6364,60 @@ impl<M: Deref , T: Deref , K: Deref , F: Deref , L: Deref >
fn provided_init_features(&self, _their_init_features: &PublicKey) -> InitFeatures {
provided_init_features()
}

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);
}

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);
}

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);
}

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);
}

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);
}

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);
}

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);
}

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);
}

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);
}
}

/// Fetches the set of [`NodeFeatures`] flags which are provided by or required by
Expand Down
24 changes: 24 additions & 0 deletions lightning/src/ln/msgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1052,8 +1052,12 @@ 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, their_features: InitFeatures, msg: &OpenChannel);
/// Handle an incoming open_channel2 message from the given peer.
fn handle_open_channel_v2(&self, their_node_id: &PublicKey, their_features: InitFeatures, msg: &OpenChannelV2);
/// Handle an incoming accept_channel message from the given peer.
fn handle_accept_channel(&self, their_node_id: &PublicKey, their_features: InitFeatures, msg: &AcceptChannel);
/// Handle an incoming accept_channel2 message from the given peer.
fn handle_accept_channel_v2(&self, their_node_id: &PublicKey, their_features: InitFeatures, msg: &AcceptChannelV2);
/// Handle an incoming funding_created message from the given peer.
fn handle_funding_created(&self, their_node_id: &PublicKey, msg: &FundingCreated);
/// Handle an incoming funding_signed message from the given peer.
Expand All @@ -1067,6 +1071,26 @@ pub trait ChannelMessageHandler : MessageSendEventsProvider {
/// Handle an incoming closing_signed message from the given peer.
fn handle_closing_signed(&self, their_node_id: &PublicKey, msg: &ClosingSigned);

// 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);
/// Handle an incoming tx_add_output message from the given peer.
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);
/// Handle an incoming tx_remove_output message from the given peer.
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);
/// Handle an incoming tx_signatures message from the given peer.
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);
/// Handle an incoming tx_ack_rbf message from the given peer.
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);

// 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);
Expand Down
Loading

0 comments on commit fb9706f

Please sign in to comment.