Skip to content

Commit

Permalink
Update splice messages according to new spec draft
Browse files Browse the repository at this point in the history
  • Loading branch information
optout21 committed Jun 17, 2024
1 parent 07f3380 commit 7423566
Show file tree
Hide file tree
Showing 13 changed files with 115 additions and 79 deletions.
2 changes: 1 addition & 1 deletion fuzz/src/msg_targets/gen_target.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ GEN_TEST lightning::ln::msgs::TxAbort test_msg_simple ""

GEN_TEST lightning::ln::msgs::Stfu test_msg_simple ""

GEN_TEST lightning::ln::msgs::Splice test_msg_simple ""
GEN_TEST lightning::ln::msgs::SpliceInit test_msg_simple ""
GEN_TEST lightning::ln::msgs::SpliceAck test_msg_simple ""
GEN_TEST lightning::ln::msgs::SpliceLocked test_msg_simple ""
4 changes: 2 additions & 2 deletions fuzz/src/msg_targets/msg_splice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ use crate::utils::test_logger;

#[inline]
pub fn msg_splice_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
test_msg_simple!(lightning::ln::msgs::Splice, data);
test_msg_simple!(lightning::ln::msgs::SpliceInit, data);
}

#[no_mangle]
pub extern "C" fn msg_splice_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
test_msg_simple!(lightning::ln::msgs::Splice, data);
test_msg_simple!(lightning::ln::msgs::SpliceInit, data);
}
2 changes: 1 addition & 1 deletion lightning-net-tokio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ mod tests {
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(&self, _their_node_id: &PublicKey, _msg: &Splice) {}
fn handle_splice_init(&self, _their_node_id: &PublicKey, _msg: &SpliceInit) {}
#[cfg(splicing)]
fn handle_splice_ack(&self, _their_node_id: &PublicKey, _msg: &SpliceAck) {}
#[cfg(splicing)]
Expand Down
6 changes: 3 additions & 3 deletions lightning/src/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2057,12 +2057,12 @@ pub enum MessageSendEvent {
/// The message which should be sent.
msg: msgs::Stfu,
},
/// Used to indicate that a splice message should be sent to the peer with the given node id.
SendSplice {
/// Used to indicate that a splice_init message should be sent to the peer with the given node id.
SendSpliceInit {
/// The node_id of the node which should receive this message
node_id: PublicKey,
/// The message which should be sent.
msg: msgs::Splice,
msg: msgs::SpliceInit,
},
/// Used to indicate that a splice_ack message should be sent to the peer with the given node id.
SendSpliceAck {
Expand Down
1 change: 1 addition & 0 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7135,6 +7135,7 @@ impl<SP: Deref> Channel<SP> where
channel_id: self.context.channel_id,
signature,
htlc_signatures,
batch: None,
#[cfg(taproot)]
partial_signature_with_nonce: None,
}, (counterparty_commitment_txid, commitment_stats.htlcs_included)))
Expand Down
4 changes: 2 additions & 2 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9652,7 +9652,7 @@ where
}

#[cfg(splicing)]
fn handle_splice(&self, counterparty_node_id: &PublicKey, msg: &msgs::Splice) {
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);
Expand Down Expand Up @@ -9859,7 +9859,7 @@ where
// Quiescence
&events::MessageSendEvent::SendStfu { .. } => false,
// Splicing
&events::MessageSendEvent::SendSplice { .. } => false,
&events::MessageSendEvent::SendSpliceInit { .. } => false,
&events::MessageSendEvent::SendSpliceAck { .. } => false,
&events::MessageSendEvent::SendSpliceLocked { .. } => false,
// Interactive Transaction Construction
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/ln/functional_test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ pub fn remove_first_msg_event_to_node(msg_node_id: &PublicKey, msg_events: &mut
MessageSendEvent::SendStfu { node_id, .. } => {
node_id == msg_node_id
},
MessageSendEvent::SendSplice { node_id, .. } => {
MessageSendEvent::SendSpliceInit { node_id, .. } => {
node_id == msg_node_id
},
MessageSendEvent::SendSpliceAck { node_id, .. } => {
Expand Down
2 changes: 2 additions & 0 deletions lightning/src/ln/functional_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,7 @@ fn test_update_fee_that_funder_cannot_afford() {
channel_id: chan.2,
signature: res.0,
htlc_signatures: res.1,
batch: None,
#[cfg(taproot)]
partial_signature_with_nonce: None,
};
Expand Down Expand Up @@ -1532,6 +1533,7 @@ fn test_fee_spike_violation_fails_htlc() {
channel_id: chan.2,
signature: res.0,
htlc_signatures: res.1,
batch: None,
#[cfg(taproot)]
partial_signature_with_nonce: None,
};
Expand Down
1 change: 1 addition & 0 deletions lightning/src/ln/interactivetxs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,7 @@ impl InteractiveTxConstructor {
prevtx,
prevtx_out: input.previous_output.vout,
sequence: input.sequence.to_consensus_u32(),
shared_input_txid: None,
};
do_state_transition!(self, sent_tx_add_input, &msg)?;
Ok(InteractiveTxMessageSend::TxAddInput(msg))
Expand Down
Loading

0 comments on commit 7423566

Please sign in to comment.