Skip to content

Commit 3ccf064

Browse files
authored
Merge pull request #3129 from optout21/splicing-msgs-update
Update splice messages according to new spec draft
2 parents b3223ab + 43a6ee3 commit 3ccf064

17 files changed

+131
-93
lines changed

fuzz/src/bin/gen_target.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,6 @@ GEN_TEST msg_tx_abort msg_targets::
7474

7575
GEN_TEST msg_stfu msg_targets::
7676

77-
GEN_TEST msg_splice msg_targets::
77+
GEN_TEST msg_splice_init msg_targets::
7878
GEN_TEST msg_splice_ack msg_targets::
7979
GEN_TEST msg_splice_locked msg_targets::

fuzz/src/bin/msg_splice_target.rs renamed to fuzz/src/bin/msg_splice_init_target.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ compile_error!("Fuzz targets need cfg=hashes_fuzz");
2323
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");
2424

2525
extern crate lightning_fuzz;
26-
use lightning_fuzz::msg_targets::msg_splice::*;
26+
use lightning_fuzz::msg_targets::msg_splice_init::*;
2727

2828
#[cfg(feature = "afl")]
2929
#[macro_use] extern crate afl;
3030
#[cfg(feature = "afl")]
3131
fn main() {
3232
fuzz!(|data| {
33-
msg_splice_run(data.as_ptr(), data.len());
33+
msg_splice_init_run(data.as_ptr(), data.len());
3434
});
3535
}
3636

@@ -40,7 +40,7 @@ fn main() {
4040
fn main() {
4141
loop {
4242
fuzz!(|data| {
43-
msg_splice_run(data.as_ptr(), data.len());
43+
msg_splice_init_run(data.as_ptr(), data.len());
4444
});
4545
}
4646
}
@@ -49,7 +49,7 @@ fn main() {
4949
#[macro_use] extern crate libfuzzer_sys;
5050
#[cfg(feature = "libfuzzer_fuzz")]
5151
fuzz_target!(|data: &[u8]| {
52-
msg_splice_run(data.as_ptr(), data.len());
52+
msg_splice_init_run(data.as_ptr(), data.len());
5353
});
5454

5555
#[cfg(feature = "stdin_fuzz")]
@@ -58,7 +58,7 @@ fn main() {
5858

5959
let mut data = Vec::with_capacity(8192);
6060
std::io::stdin().read_to_end(&mut data).unwrap();
61-
msg_splice_run(data.as_ptr(), data.len());
61+
msg_splice_init_run(data.as_ptr(), data.len());
6262
}
6363

6464
#[test]
@@ -70,11 +70,11 @@ fn run_test_cases() {
7070
use std::sync::{atomic, Arc};
7171
{
7272
let data: Vec<u8> = vec![0];
73-
msg_splice_run(data.as_ptr(), data.len());
73+
msg_splice_init_run(data.as_ptr(), data.len());
7474
}
7575
let mut threads = Vec::new();
7676
let threads_running = Arc::new(atomic::AtomicUsize::new(0));
77-
if let Ok(tests) = fs::read_dir("test_cases/msg_splice") {
77+
if let Ok(tests) = fs::read_dir("test_cases/msg_splice_init") {
7878
for test in tests {
7979
let mut data: Vec<u8> = Vec::new();
8080
let path = test.unwrap().path();
@@ -89,7 +89,7 @@ fn run_test_cases() {
8989

9090
let panic_logger = string_logger.clone();
9191
let res = if ::std::panic::catch_unwind(move || {
92-
msg_splice_test(&data, panic_logger);
92+
msg_splice_init_test(&data, panic_logger);
9393
}).is_err() {
9494
Some(string_logger.into_string())
9595
} else { None };

fuzz/src/msg_targets/gen_target.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,6 @@ GEN_TEST lightning::ln::msgs::TxAbort test_msg_simple ""
6464

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

67-
GEN_TEST lightning::ln::msgs::Splice test_msg_simple ""
67+
GEN_TEST lightning::ln::msgs::SpliceInit test_msg_simple ""
6868
GEN_TEST lightning::ln::msgs::SpliceAck test_msg_simple ""
6969
GEN_TEST lightning::ln::msgs::SpliceLocked test_msg_simple ""

fuzz/src/msg_targets/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ pub mod msg_tx_init_rbf;
4343
pub mod msg_tx_ack_rbf;
4444
pub mod msg_tx_abort;
4545
pub mod msg_stfu;
46-
pub mod msg_splice;
46+
pub mod msg_splice_init;
4747
pub mod msg_splice_ack;
4848
pub mod msg_splice_locked;

fuzz/src/msg_targets/msg_splice.rs renamed to fuzz/src/msg_targets/msg_splice_init.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ use crate::msg_targets::utils::VecWriter;
1616
use crate::utils::test_logger;
1717

1818
#[inline]
19-
pub fn msg_splice_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
20-
test_msg_simple!(lightning::ln::msgs::Splice, data);
19+
pub fn msg_splice_init_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
20+
test_msg_simple!(lightning::ln::msgs::SpliceInit, data);
2121
}
2222

2323
#[no_mangle]
24-
pub extern "C" fn msg_splice_run(data: *const u8, datalen: usize) {
24+
pub extern "C" fn msg_splice_init_run(data: *const u8, datalen: usize) {
2525
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
26-
test_msg_simple!(lightning::ln::msgs::Splice, data);
26+
test_msg_simple!(lightning::ln::msgs::SpliceInit, data);
2727
}

fuzz/targets.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ void msg_tx_init_rbf_run(const unsigned char* data, size_t data_len);
5959
void msg_tx_ack_rbf_run(const unsigned char* data, size_t data_len);
6060
void msg_tx_abort_run(const unsigned char* data, size_t data_len);
6161
void msg_stfu_run(const unsigned char* data, size_t data_len);
62-
void msg_splice_run(const unsigned char* data, size_t data_len);
62+
void msg_splice_init_run(const unsigned char* data, size_t data_len);
6363
void msg_splice_ack_run(const unsigned char* data, size_t data_len);
6464
void msg_splice_locked_run(const unsigned char* data, size_t data_len);

lightning-net-tokio/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ mod tests {
625625
fn handle_accept_channel_v2(&self, _their_node_id: &PublicKey, _msg: &AcceptChannelV2) {}
626626
fn handle_stfu(&self, _their_node_id: &PublicKey, _msg: &Stfu) {}
627627
#[cfg(splicing)]
628-
fn handle_splice(&self, _their_node_id: &PublicKey, _msg: &Splice) {}
628+
fn handle_splice_init(&self, _their_node_id: &PublicKey, _msg: &SpliceInit) {}
629629
#[cfg(splicing)]
630630
fn handle_splice_ack(&self, _their_node_id: &PublicKey, _msg: &SpliceAck) {}
631631
#[cfg(splicing)]

lightning/src/events/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,12 +2059,12 @@ pub enum MessageSendEvent {
20592059
/// The message which should be sent.
20602060
msg: msgs::Stfu,
20612061
},
2062-
/// Used to indicate that a splice message should be sent to the peer with the given node id.
2063-
SendSplice {
2062+
/// Used to indicate that a splice_init message should be sent to the peer with the given node id.
2063+
SendSpliceInit {
20642064
/// The node_id of the node which should receive this message
20652065
node_id: PublicKey,
20662066
/// The message which should be sent.
2067-
msg: msgs::Splice,
2067+
msg: msgs::SpliceInit,
20682068
},
20692069
/// Used to indicate that a splice_ack message should be sent to the peer with the given node id.
20702070
SendSpliceAck {

lightning/src/ln/channel.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7272,6 +7272,7 @@ impl<SP: Deref> Channel<SP> where
72727272
channel_id: self.context.channel_id,
72737273
signature,
72747274
htlc_signatures,
7275+
batch: None,
72757276
#[cfg(taproot)]
72767277
partial_signature_with_nonce: None,
72777278
}, (counterparty_commitment_txid, commitment_stats.htlcs_included)))

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9693,7 +9693,7 @@ where
96939693
}
96949694

96959695
#[cfg(splicing)]
9696-
fn handle_splice(&self, counterparty_node_id: &PublicKey, msg: &msgs::Splice) {
9696+
fn handle_splice_init(&self, counterparty_node_id: &PublicKey, msg: &msgs::SpliceInit) {
96979697
let _: Result<(), _> = handle_error!(self, Err(MsgHandleErrInternal::send_err_msg_no_close(
96989698
"Splicing not supported".to_owned(),
96999699
msg.channel_id.clone())), *counterparty_node_id);
@@ -9900,7 +9900,7 @@ where
99009900
// Quiescence
99019901
&events::MessageSendEvent::SendStfu { .. } => false,
99029902
// Splicing
9903-
&events::MessageSendEvent::SendSplice { .. } => false,
9903+
&events::MessageSendEvent::SendSpliceInit { .. } => false,
99049904
&events::MessageSendEvent::SendSpliceAck { .. } => false,
99059905
&events::MessageSendEvent::SendSpliceLocked { .. } => false,
99069906
// Interactive Transaction Construction

lightning/src/ln/functional_test_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ pub fn remove_first_msg_event_to_node(msg_node_id: &PublicKey, msg_events: &mut
915915
MessageSendEvent::SendStfu { node_id, .. } => {
916916
node_id == msg_node_id
917917
},
918-
MessageSendEvent::SendSplice { node_id, .. } => {
918+
MessageSendEvent::SendSpliceInit { node_id, .. } => {
919919
node_id == msg_node_id
920920
},
921921
MessageSendEvent::SendSpliceAck { node_id, .. } => {

lightning/src/ln/functional_tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,7 @@ fn test_update_fee_that_funder_cannot_afford() {
783783
channel_id: chan.2,
784784
signature: res.0,
785785
htlc_signatures: res.1,
786+
batch: None,
786787
#[cfg(taproot)]
787788
partial_signature_with_nonce: None,
788789
};
@@ -1532,6 +1533,7 @@ fn test_fee_spike_violation_fails_htlc() {
15321533
channel_id: chan.2,
15331534
signature: res.0,
15341535
htlc_signatures: res.1,
1536+
batch: None,
15351537
#[cfg(taproot)]
15361538
partial_signature_with_nonce: None,
15371539
};

lightning/src/ln/interactivetxs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,7 @@ impl InteractiveTxConstructor {
12061206
prevtx,
12071207
prevtx_out: input.previous_output.vout,
12081208
sequence: input.sequence.to_consensus_u32(),
1209+
shared_input_txid: None,
12091210
};
12101211
do_state_transition!(self, sent_tx_add_input, &msg)?;
12111212
Ok(InteractiveTxMessageSend::TxAddInput(msg))

0 commit comments

Comments
 (0)