Skip to content

Commit 756064a

Browse files
committed
Add new wire messaging and events but don't handle them
1 parent 6d7ea08 commit 756064a

File tree

7 files changed

+496
-3
lines changed

7 files changed

+496
-3
lines changed

lightning-net-tokio/src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,17 @@ mod tests {
602602
fn handle_update_fee(&self, _their_node_id: &PublicKey, _msg: &UpdateFee) {}
603603
fn handle_announcement_signatures(&self, _their_node_id: &PublicKey, _msg: &AnnouncementSignatures) {}
604604
fn handle_channel_update(&self, _their_node_id: &PublicKey, _msg: &ChannelUpdate) {}
605+
fn handle_open_channel_v2(&self, _their_node_id: &PublicKey, _their_features: InitFeatures, _msg: &OpenChannelV2) {}
606+
fn handle_accept_channel_v2(&self, _their_node_id: &PublicKey, _their_features: InitFeatures, _msg: &AcceptChannelV2) {}
607+
fn handle_tx_add_input(&self, _their_node_id: &PublicKey, _msg: &TxAddInput) {}
608+
fn handle_tx_add_output(&self, _their_node_id: &PublicKey, _msg: &TxAddOutput) {}
609+
fn handle_tx_remove_input(&self, _their_node_id: &PublicKey, _msg: &TxRemoveInput) {}
610+
fn handle_tx_remove_output(&self, _their_node_id: &PublicKey, _msg: &TxRemoveOutput) {}
611+
fn handle_tx_complete(&self, _their_node_id: &PublicKey, _msg: &TxComplete) {}
612+
fn handle_tx_signatures(&self, _their_node_id: &PublicKey, _msg: &TxSignatures) {}
613+
fn handle_tx_init_rbf(&self, _their_node_id: &PublicKey, _msg: &TxInitRbf) {}
614+
fn handle_tx_ack_rbf(&self, _their_node_id: &PublicKey, _msg: &TxAckRbf) {}
615+
fn handle_tx_abort(&self, _their_node_id: &PublicKey, _msg: &TxAbort) {}
605616
fn peer_disconnected(&self, their_node_id: &PublicKey, _no_connection_possible: bool) {
606617
if *their_node_id == self.expected_pubkey {
607618
self.disconnected_flag.store(true, Ordering::SeqCst);

lightning/src/ln/channelmanager.rs

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4503,6 +4503,13 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
45034503
Ok(())
45044504
}
45054505

4506+
fn internal_open_channel_v2(&self, _counterparty_node_id: &PublicKey, _their_features: InitFeatures,
4507+
msg: &msgs::OpenChannelV2) -> Result<(), MsgHandleErrInternal> {
4508+
// TODO - Actually implement
4509+
Err(MsgHandleErrInternal::send_err_msg_no_close("Dual-funded channels not supported".to_owned(),
4510+
msg.temporary_channel_id.clone()))
4511+
}
4512+
45064513
fn internal_accept_channel(&self, counterparty_node_id: &PublicKey, their_features: InitFeatures, msg: &msgs::AcceptChannel) -> Result<(), MsgHandleErrInternal> {
45074514
let (value, output_script, user_id) = {
45084515
let mut channel_lock = self.channel_state.lock().unwrap();
@@ -4529,6 +4536,13 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
45294536
Ok(())
45304537
}
45314538

4539+
fn internal_accept_channel_v2(&self, _counterparty_node_id: &PublicKey, _their_features: InitFeatures,
4540+
msg: &msgs::AcceptChannelV2) -> Result<(), MsgHandleErrInternal> {
4541+
// TODO - Actually implement
4542+
Err(MsgHandleErrInternal::send_err_msg_no_close("Dual-funded channels not supported".to_owned(),
4543+
msg.temporary_channel_id.clone()))
4544+
}
4545+
45324546
fn internal_funding_created(&self, counterparty_node_id: &PublicKey, msg: &msgs::FundingCreated) -> Result<(), MsgHandleErrInternal> {
45334547
let ((funding_msg, monitor, mut channel_ready), mut chan) = {
45344548
let best_block = *self.best_block.read().unwrap();
@@ -5158,6 +5172,60 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
51585172
Ok(())
51595173
}
51605174

5175+
fn internal_tx_add_input(&self, _counterparty_node_id: &PublicKey, msg: &msgs::TxAddInput) -> Result<(), MsgHandleErrInternal> {
5176+
// TODO - Actually implement
5177+
Err(MsgHandleErrInternal::send_err_msg_no_close("Interactive transaction construction not supported".to_owned(),
5178+
msg.channel_id.clone()))
5179+
}
5180+
5181+
fn internal_tx_add_output(&self, _counterparty_node_id: &PublicKey, msg: &msgs::TxAddOutput) -> Result<(), MsgHandleErrInternal> {
5182+
// TODO - Actually implement
5183+
Err(MsgHandleErrInternal::send_err_msg_no_close("Interactive transaction construction not supported".to_owned(),
5184+
msg.channel_id.clone()))
5185+
}
5186+
5187+
fn internal_tx_remove_input(&self, _counterparty_node_id: &PublicKey, msg: &msgs::TxRemoveInput) -> Result<(), MsgHandleErrInternal> {
5188+
// TODO - Actually implement
5189+
Err(MsgHandleErrInternal::send_err_msg_no_close("Interactive transaction construction not supported".to_owned(),
5190+
msg.channel_id.clone()))
5191+
}
5192+
5193+
fn internal_tx_remove_output(&self, _counterparty_node_id: &PublicKey, msg: &msgs::TxRemoveOutput) -> Result<(), MsgHandleErrInternal> {
5194+
// TODO - Actually implement
5195+
Err(MsgHandleErrInternal::send_err_msg_no_close("Interactive transaction construction not supported".to_owned(),
5196+
msg.channel_id.clone()))
5197+
}
5198+
5199+
fn internal_tx_complete(&self, _counterparty_node_id: &PublicKey, msg: &msgs::TxComplete) -> Result<(), MsgHandleErrInternal> {
5200+
// TODO - Actually implement
5201+
Err(MsgHandleErrInternal::send_err_msg_no_close("Interactive transaction construction not supported".to_owned(),
5202+
msg.channel_id.clone()))
5203+
}
5204+
5205+
fn internal_tx_signatures(&self, _counterparty_node_id: &PublicKey, msg: &msgs::TxSignatures) -> Result<(), MsgHandleErrInternal> {
5206+
// TODO - Actually implement
5207+
Err(MsgHandleErrInternal::send_err_msg_no_close("Interactive transaction construction not supported".to_owned(),
5208+
msg.channel_id.clone()))
5209+
}
5210+
5211+
fn internal_tx_init_rbf(&self, _counterparty_node_id: &PublicKey, msg: &msgs::TxInitRbf) -> Result<(), MsgHandleErrInternal> {
5212+
// TODO - Actually implement
5213+
Err(MsgHandleErrInternal::send_err_msg_no_close("Interactive transaction construction not supported".to_owned(),
5214+
msg.channel_id.clone()))
5215+
}
5216+
5217+
fn internal_tx_ack_rbf(&self, _counterparty_node_id: &PublicKey, msg: &msgs::TxAckRbf) -> Result<(), MsgHandleErrInternal> {
5218+
// TODO - Actually implement
5219+
Err(MsgHandleErrInternal::send_err_msg_no_close("Interactive transaction construction not supported".to_owned(),
5220+
msg.channel_id.clone()))
5221+
}
5222+
5223+
fn internal_tx_abort(&self, _counterparty_node_id: &PublicKey, msg: &msgs::TxAbort) -> Result<(), MsgHandleErrInternal> {
5224+
// TODO - Actually implement
5225+
Err(MsgHandleErrInternal::send_err_msg_no_close("Interactive transaction construction not supported".to_owned(),
5226+
msg.channel_id.clone()))
5227+
}
5228+
51615229
/// Process pending events from the `chain::Watch`, returning whether any events were processed.
51625230
fn process_pending_monitor_events(&self) -> bool {
51635231
let mut failed_channels = Vec::new();
@@ -5964,11 +6032,21 @@ impl<M: Deref , T: Deref , K: Deref , F: Deref , L: Deref >
59646032
let _ = handle_error!(self, self.internal_open_channel(counterparty_node_id, their_features, msg), *counterparty_node_id);
59656033
}
59666034

6035+
fn handle_open_channel_v2(&self, counterparty_node_id: &PublicKey, their_features: InitFeatures, msg: &msgs::OpenChannelV2) {
6036+
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
6037+
let _ = handle_error!(self, self.internal_open_channel_v2(counterparty_node_id, their_features, msg), *counterparty_node_id);
6038+
}
6039+
59676040
fn handle_accept_channel(&self, counterparty_node_id: &PublicKey, their_features: InitFeatures, msg: &msgs::AcceptChannel) {
59686041
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
59696042
let _ = handle_error!(self, self.internal_accept_channel(counterparty_node_id, their_features, msg), *counterparty_node_id);
59706043
}
59716044

6045+
fn handle_accept_channel_v2(&self, counterparty_node_id: &PublicKey, their_features: InitFeatures, msg: &msgs::AcceptChannelV2) {
6046+
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
6047+
let _ = handle_error!(self, self.internal_accept_channel_v2(counterparty_node_id, their_features, msg), *counterparty_node_id);
6048+
}
6049+
59726050
fn handle_funding_created(&self, counterparty_node_id: &PublicKey, msg: &msgs::FundingCreated) {
59736051
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
59746052
let _ = handle_error!(self, self.internal_funding_created(counterparty_node_id, msg), *counterparty_node_id);
@@ -6076,10 +6154,21 @@ impl<M: Deref , T: Deref , K: Deref , F: Deref , L: Deref >
60766154
pending_msg_events.retain(|msg| {
60776155
match msg {
60786156
&events::MessageSendEvent::SendAcceptChannel { ref node_id, .. } => node_id != counterparty_node_id,
6157+
&events::MessageSendEvent::SendAcceptChannelV2 { ref node_id, .. } => node_id != counterparty_node_id,
60796158
&events::MessageSendEvent::SendOpenChannel { ref node_id, .. } => node_id != counterparty_node_id,
6159+
&events::MessageSendEvent::SendOpenChannelV2 { ref node_id, .. } => node_id != counterparty_node_id,
60806160
&events::MessageSendEvent::SendFundingCreated { ref node_id, .. } => node_id != counterparty_node_id,
60816161
&events::MessageSendEvent::SendFundingSigned { ref node_id, .. } => node_id != counterparty_node_id,
60826162
&events::MessageSendEvent::SendChannelReady { ref node_id, .. } => node_id != counterparty_node_id,
6163+
&events::MessageSendEvent::SendTxAddInput { ref node_id, .. } => node_id != counterparty_node_id,
6164+
&events::MessageSendEvent::SendTxAddOutput { ref node_id, .. } => node_id != counterparty_node_id,
6165+
&events::MessageSendEvent::SendTxRemoveInput { ref node_id, .. } => node_id != counterparty_node_id,
6166+
&events::MessageSendEvent::SendTxRemoveOutput { ref node_id, .. } => node_id != counterparty_node_id,
6167+
&events::MessageSendEvent::SendTxComplete { ref node_id, .. } => node_id != counterparty_node_id,
6168+
&events::MessageSendEvent::SendTxSignatures { ref node_id, .. } => node_id != counterparty_node_id,
6169+
&events::MessageSendEvent::SendTxInitRbf { ref node_id, .. } => node_id != counterparty_node_id,
6170+
&events::MessageSendEvent::SendTxAckRbf { ref node_id, .. } => node_id != counterparty_node_id,
6171+
&events::MessageSendEvent::SendTxAbort { ref node_id, .. } => node_id != counterparty_node_id,
60836172
&events::MessageSendEvent::SendAnnouncementSignatures { ref node_id, .. } => node_id != counterparty_node_id,
60846173
&events::MessageSendEvent::UpdateHTLCs { ref node_id, .. } => node_id != counterparty_node_id,
60856174
&events::MessageSendEvent::SendRevokeAndACK { ref node_id, .. } => node_id != counterparty_node_id,
@@ -6206,6 +6295,51 @@ impl<M: Deref , T: Deref , K: Deref , F: Deref , L: Deref >
62066295
fn provided_init_features(&self, _their_init_features: &PublicKey) -> InitFeatures {
62076296
provided_init_features()
62086297
}
6298+
6299+
fn handle_tx_add_input(&self, counterparty_node_id: &PublicKey, msg: &msgs::TxAddInput) {
6300+
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
6301+
let _ = handle_error!(self, self.internal_tx_add_input(counterparty_node_id, msg), *counterparty_node_id);
6302+
}
6303+
6304+
fn handle_tx_add_output(&self, counterparty_node_id: &PublicKey, msg: &msgs::TxAddOutput) {
6305+
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
6306+
let _ = handle_error!(self, self.internal_tx_add_output(counterparty_node_id, msg), *counterparty_node_id);
6307+
}
6308+
6309+
fn handle_tx_remove_input(&self, counterparty_node_id: &PublicKey, msg: &msgs::TxRemoveInput) {
6310+
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
6311+
let _ = handle_error!(self, self.internal_tx_remove_input(counterparty_node_id, msg), *counterparty_node_id);
6312+
}
6313+
6314+
fn handle_tx_remove_output(&self, counterparty_node_id: &PublicKey, msg: &msgs::TxRemoveOutput) {
6315+
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
6316+
let _ = handle_error!(self, self.internal_tx_remove_output(counterparty_node_id, msg), *counterparty_node_id);
6317+
}
6318+
6319+
fn handle_tx_complete(&self, counterparty_node_id: &PublicKey, msg: &msgs::TxComplete) {
6320+
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
6321+
let _ = handle_error!(self, self.internal_tx_complete(counterparty_node_id, msg), *counterparty_node_id);
6322+
}
6323+
6324+
fn handle_tx_signatures(&self, counterparty_node_id: &PublicKey, msg: &msgs::TxSignatures) {
6325+
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
6326+
let _ = handle_error!(self, self.internal_tx_signatures(counterparty_node_id, msg), *counterparty_node_id);
6327+
}
6328+
6329+
fn handle_tx_init_rbf(&self, counterparty_node_id: &PublicKey, msg: &msgs::TxInitRbf) {
6330+
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
6331+
let _ = handle_error!(self, self.internal_tx_init_rbf(counterparty_node_id, msg), *counterparty_node_id);
6332+
}
6333+
6334+
fn handle_tx_ack_rbf(&self, counterparty_node_id: &PublicKey, msg: &msgs::TxAckRbf) {
6335+
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
6336+
let _ = handle_error!(self, self.internal_tx_ack_rbf(counterparty_node_id, msg), *counterparty_node_id);
6337+
}
6338+
6339+
fn handle_tx_abort(&self, counterparty_node_id: &PublicKey, msg: &msgs::TxAbort) {
6340+
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
6341+
let _ = handle_error!(self, self.internal_tx_abort(counterparty_node_id, msg), *counterparty_node_id);
6342+
}
62096343
}
62106344

62116345
/// Fetches the set of [`NodeFeatures`] flags which are provided by or required by

lightning/src/ln/msgs.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,8 +1052,12 @@ pub trait ChannelMessageHandler : MessageSendEventsProvider {
10521052
//Channel init:
10531053
/// Handle an incoming open_channel message from the given peer.
10541054
fn handle_open_channel(&self, their_node_id: &PublicKey, their_features: InitFeatures, msg: &OpenChannel);
1055+
/// Handle an incoming open_channel2 message from the given peer.
1056+
fn handle_open_channel_v2(&self, their_node_id: &PublicKey, their_features: InitFeatures, msg: &OpenChannelV2);
10551057
/// Handle an incoming accept_channel message from the given peer.
10561058
fn handle_accept_channel(&self, their_node_id: &PublicKey, their_features: InitFeatures, msg: &AcceptChannel);
1059+
/// Handle an incoming accept_channel2 message from the given peer.
1060+
fn handle_accept_channel_v2(&self, their_node_id: &PublicKey, their_features: InitFeatures, msg: &AcceptChannelV2);
10571061
/// Handle an incoming funding_created message from the given peer.
10581062
fn handle_funding_created(&self, their_node_id: &PublicKey, msg: &FundingCreated);
10591063
/// Handle an incoming funding_signed message from the given peer.
@@ -1067,6 +1071,26 @@ pub trait ChannelMessageHandler : MessageSendEventsProvider {
10671071
/// Handle an incoming closing_signed message from the given peer.
10681072
fn handle_closing_signed(&self, their_node_id: &PublicKey, msg: &ClosingSigned);
10691073

1074+
// Interactive channel construction
1075+
/// Handle an incoming tx_add_input message from the given peer.
1076+
fn handle_tx_add_input(&self, their_node_id: &PublicKey, msg: &TxAddInput);
1077+
/// Handle an incoming tx_add_output message from the given peer.
1078+
fn handle_tx_add_output(&self, their_node_id: &PublicKey, msg: &TxAddOutput);
1079+
/// Handle an incoming tx_remove_input message from the given peer.
1080+
fn handle_tx_remove_input(&self, their_node_id: &PublicKey, msg: &TxRemoveInput);
1081+
/// Handle an incoming tx_remove_output message from the given peer.
1082+
fn handle_tx_remove_output(&self, their_node_id: &PublicKey, msg: &TxRemoveOutput);
1083+
/// Handle an incoming tx_complete message from the given peer.
1084+
fn handle_tx_complete(&self, their_node_id: &PublicKey, msg: &TxComplete);
1085+
/// Handle an incoming tx_signatures message from the given peer.
1086+
fn handle_tx_signatures(&self, their_node_id: &PublicKey, msg: &TxSignatures);
1087+
/// Handle an incoming tx_init_rbf message from the given peer.
1088+
fn handle_tx_init_rbf(&self, their_node_id: &PublicKey, msg: &TxInitRbf);
1089+
/// Handle an incoming tx_ack_rbf message from the given peer.
1090+
fn handle_tx_ack_rbf(&self, their_node_id: &PublicKey, msg: &TxAckRbf);
1091+
/// Handle an incoming tx_abort message from the given peer.
1092+
fn handle_tx_abort(&self, their_node_id: &PublicKey, msg: &TxAbort);
1093+
10701094
// HTLC handling:
10711095
/// Handle an incoming update_add_htlc message from the given peer.
10721096
fn handle_update_add_htlc(&self, their_node_id: &PublicKey, msg: &UpdateAddHTLC);

0 commit comments

Comments
 (0)