Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: lightningdevkit/rust-lightning
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f2b80afff6cdd613fc918ae6f3514d5716925a61
Choose a base ref
..
head repository: lightningdevkit/rust-lightning
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2cc608a7698670daef0650cbe6164948bad84a2b
Choose a head ref
Showing with 4,657 additions and 2,292 deletions.
  1. +3 −0 ci/ci-tests.sh
  2. +1 −0 fuzz/README.md
  3. +3 −3 fuzz/src/chanmon_consistency.rs
  4. +2 −2 fuzz/src/full_stack.rs
  5. +21 −18 fuzz/src/msg_targets/utils.rs
  6. +6 −3 fuzz/src/onion_message.rs
  7. +5 −4 fuzz/src/router.rs
  8. +5 −5 lightning-custom-message/src/lib.rs
  9. +243 −2 lightning-invoice/src/de.rs
  10. +27 −1 lightning-invoice/src/lib.rs
  11. +32 −5 lightning-liquidity/src/lsps0/ser.rs
  12. +54 −4 lightning-liquidity/src/lsps1/msgs.rs
  13. +5 −3 lightning-liquidity/src/manager.rs
  14. +57 −53 lightning-types/src/features.rs
  15. +9 −2 lightning/src/blinded_path/message.rs
  16. +72 −0 lightning/src/blinded_path/payment.rs
  17. +3 −3 lightning/src/chain/chainmonitor.rs
  18. +352 −278 lightning/src/chain/channelmonitor.rs
  19. +1 −1 lightning/src/chain/mod.rs
  20. +1 −1 lightning/src/chain/onchaintx.rs
  21. +7 −7 lightning/src/crypto/streams.rs
  22. +31 −17 lightning/src/events/bump_transaction.rs
  23. +3 −0 lightning/src/lib.rs
  24. +0 −6 lightning/src/ln/async_signer_tests.rs
  25. +144 −0 lightning/src/ln/blinded_payment_tests.rs
  26. +0 −218 lightning/src/ln/bolt11_payment.rs
  27. +159 −0 lightning/src/ln/bolt11_payment_tests.rs
  28. +83 −66 lightning/src/ln/chan_utils.rs
  29. +693 −351 lightning/src/ln/channel.rs
  30. +494 −498 lightning/src/ln/channelmanager.rs
  31. +1 −1 lightning/src/ln/dual_funding_tests.rs
  32. +25 −7 lightning/src/ln/functional_test_utils.rs
  33. +117 −74 lightning/src/ln/functional_tests.rs
  34. +6 −12 lightning/src/ln/invoice_utils.rs
  35. +6 −1 lightning/src/ln/mod.rs
  36. +5 −5 lightning/src/ln/monitor_tests.rs
  37. +356 −81 lightning/src/ln/msgs.rs
  38. +0 −1 lightning/src/ln/offers_tests.rs
  39. +195 −71 lightning/src/ln/onion_payment.rs
  40. +50 −18 lightning/src/ln/onion_route_tests.rs
  41. +686 −183 lightning/src/ln/onion_utils.rs
  42. +61 −0 lightning/src/ln/outbound_payment.rs
  43. +4 −2 lightning/src/ln/peer_handler.rs
  44. +73 −2 lightning/src/ln/reload_tests.rs
  45. +13 −5 lightning/src/ln/shutdown_tests.rs
  46. +192 −0 lightning/src/ln/splicing_tests.rs
  47. +153 −85 lightning/src/ln/wire.rs
  48. +12 −10 lightning/src/offers/invoice.rs
  49. +5 −4 lightning/src/offers/invoice_request.rs
  50. +13 −10 lightning/src/offers/offer.rs
  51. +13 −9 lightning/src/offers/refund.rs
  52. +1 −1 lightning/src/offers/static_invoice.rs
  53. +3 −3 lightning/src/onion_message/packet.rs
  54. +3 −2 lightning/src/routing/gossip.rs
  55. +27 −0 lightning/src/routing/router.rs
  56. +1 −1 lightning/src/routing/scoring.rs
  57. +2 −2 lightning/src/sign/ecdsa.rs
  58. +20 −34 lightning/src/sign/mod.rs
  59. +0 −6 lightning/src/sign/taproot.rs
  60. +4 −2 lightning/src/util/anchor_channel_reserves.rs
  61. +0 −12 lightning/src/util/atomic_counter.rs
  62. +4 −7 lightning/src/util/config.rs
  63. +2 −17 lightning/src/util/dyn_signer.rs
  64. +50 −34 lightning/src/util/ser.rs
  65. +12 −10 lightning/src/util/ser_macros.rs
  66. +6 −28 lightning/src/util/test_channel_signer.rs
  67. +15 −1 lightning/src/util/test_utils.rs
  68. +5 −0 pending_changelog/3638-0.2-upgrade-without-counterparty-node-id-in-monitor-not-supported.txt
3 changes: 3 additions & 0 deletions ci/ci-tests.sh
Original file line number Diff line number Diff line change
@@ -21,6 +21,9 @@ PIN_RELEASE_DEPS # pin the release dependencies in our main workspace
# The addr2line v0.21 crate (a dependency of `backtrace` starting with 0.3.69) relies on rustc 1.65
[ "$RUSTC_MINOR_VERSION" -lt 65 ] && cargo update -p backtrace --precise "0.3.68" --verbose

# The once_cell v1.21.0 crate (a dependency of `proptest`) relies on rustc 1.70
[ "$RUSTC_MINOR_VERSION" -lt 70 ] && cargo update -p once_cell --precise "1.20.3" --verbose

# proptest 1.3.0 requires rustc 1.64.0
[ "$RUSTC_MINOR_VERSION" -lt 64 ] && cargo update -p proptest --precise "1.2.0" --verbose

1 change: 1 addition & 0 deletions fuzz/README.md
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ easily.
We support multiple fuzzing engines such as `honggfuzz`, `libFuzzer` and `AFL`. You typically won't
need to run the entire suite of different fuzzing tools. For local execution, `honggfuzz`should be
more than sufficient.
> MacOS users should prefer using `libFuzzer` since `honggfuzz` is not actively maintained for MacOS based systems
### Setup
#### Honggfuzz
6 changes: 3 additions & 3 deletions fuzz/src/chanmon_consistency.rs
Original file line number Diff line number Diff line change
@@ -67,7 +67,7 @@ use lightning::types::payment::{PaymentHash, PaymentPreimage, PaymentSecret};
use lightning::util::config::UserConfig;
use lightning::util::hash_tables::*;
use lightning::util::logger::Logger;
use lightning::util::ser::{Readable, ReadableArgs, Writeable, Writer};
use lightning::util::ser::{LengthReadable, ReadableArgs, Writeable, Writer};
use lightning::util::test_channel_signer::{EnforcementState, TestChannelSigner};

use lightning_invoice::RawBolt11Invoice;
@@ -282,7 +282,7 @@ impl chain::Watch<TestChannelSigner> for TestChainMonitor {

fn release_pending_monitor_events(
&self,
) -> Vec<(OutPoint, ChannelId, Vec<MonitorEvent>, Option<PublicKey>)> {
) -> Vec<(OutPoint, ChannelId, Vec<MonitorEvent>, PublicKey)> {
return self.chain_monitor.release_pending_monitor_events();
}
}
@@ -1103,7 +1103,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
// update_fail_htlc as we do when we reject a payment.
let mut msg_ser = update_add.encode();
msg_ser[1000] ^= 0xff;
let new_msg = UpdateAddHTLC::read(&mut Cursor::new(&msg_ser)).unwrap();
let new_msg = UpdateAddHTLC::read_from_fixed_length_buffer(&mut &msg_ser[..]).unwrap();
dest.handle_update_add_htlc(nodes[$node].get_our_node_id(), &new_msg);
}
}
4 changes: 2 additions & 2 deletions fuzz/src/full_stack.rs
Original file line number Diff line number Diff line change
@@ -1141,7 +1141,7 @@ mod tests {
ext_from_hex("030020", &mut test);
// init message (type 16) with static_remotekey required, no channel_type/anchors/taproot, and other bits optional and mac
ext_from_hex(
"0010 00021aaa 0008aaa20aaa2a0a9aaa 03000000000000000000000000000000",
"0010 00021aaa 0008aaa208aa2a0a9aaa 03000000000000000000000000000000",
&mut test,
);

@@ -1245,7 +1245,7 @@ mod tests {
ext_from_hex("030120", &mut test);
// init message (type 16) with static_remotekey required, no channel_type/anchors/taproot, and other bits optional and mac
ext_from_hex(
"0010 00021aaa 0008aaa20aaa2a0a9aaa 01000000000000000000000000000000",
"0010 00021aaa 0008aaa208aa2a0a9aaa 01000000000000000000000000000000",
&mut test,
);

39 changes: 21 additions & 18 deletions fuzz/src/msg_targets/utils.rs
Original file line number Diff line number Diff line change
@@ -30,16 +30,16 @@ impl Writer for VecWriter {
#[macro_export]
macro_rules! test_msg {
($MsgType: path, $data: ident) => {{
use lightning::util::ser::{Readable, Writeable};
let mut r = ::lightning::io::Cursor::new($data);
if let Ok(msg) = <$MsgType as Readable>::read(&mut r) {
let p = r.position() as usize;
use lightning::util::ser::{LengthReadable, Writeable};
let mut r = &$data[..];
if let Ok(msg) = <$MsgType as LengthReadable>::read_from_fixed_length_buffer(&mut r) {
let p = $data.len() - r.len() as usize;
let mut w = VecWriter(Vec::new());
msg.write(&mut w).unwrap();

assert_eq!(w.0.len(), p);
assert_eq!(msg.serialized_length(), p);
assert_eq!(&r.into_inner()[..p], &w.0[..p]);
assert_eq!(&$data[..p], &w.0[..p]);
}
}};
}
@@ -49,15 +49,16 @@ macro_rules! test_msg {
#[macro_export]
macro_rules! test_msg_simple {
($MsgType: path, $data: ident) => {{
use lightning::util::ser::{Readable, Writeable};
let mut r = ::lightning::io::Cursor::new($data);
if let Ok(msg) = <$MsgType as Readable>::read(&mut r) {
use lightning::util::ser::{LengthReadable, Writeable};
if let Ok(msg) =
<$MsgType as LengthReadable>::read_from_fixed_length_buffer(&mut &$data[..])
{
let mut w = VecWriter(Vec::new());
msg.write(&mut w).unwrap();
assert_eq!(msg.serialized_length(), w.0.len());

let msg =
<$MsgType as Readable>::read(&mut ::lightning::io::Cursor::new(&w.0)).unwrap();
<$MsgType as LengthReadable>::read_from_fixed_length_buffer(&mut &w.0[..]).unwrap();
let mut w_two = VecWriter(Vec::new());
msg.write(&mut w_two).unwrap();
assert_eq!(&w.0[..], &w_two.0[..]);
@@ -70,12 +71,13 @@ macro_rules! test_msg_simple {
#[macro_export]
macro_rules! test_msg_exact {
($MsgType: path, $data: ident) => {{
use lightning::util::ser::{Readable, Writeable};
let mut r = ::lightning::io::Cursor::new($data);
if let Ok(msg) = <$MsgType as Readable>::read(&mut r) {
use lightning::util::ser::{LengthReadable, Writeable};
if let Ok(msg) =
<$MsgType as LengthReadable>::read_from_fixed_length_buffer(&mut &$data[..])
{
let mut w = VecWriter(Vec::new());
msg.write(&mut w).unwrap();
assert_eq!(&r.into_inner()[..], &w.0[..]);
assert_eq!(&$data[..], &w.0[..]);
assert_eq!(msg.serialized_length(), w.0.len());
}
}};
@@ -86,17 +88,18 @@ macro_rules! test_msg_exact {
#[macro_export]
macro_rules! test_msg_hole {
($MsgType: path, $data: ident, $hole: expr, $hole_len: expr) => {{
use lightning::util::ser::{Readable, Writeable};
let mut r = ::lightning::io::Cursor::new($data);
if let Ok(msg) = <$MsgType as Readable>::read(&mut r) {
use lightning::util::ser::{LengthReadable, Writeable};
if let Ok(msg) =
<$MsgType as LengthReadable>::read_from_fixed_length_buffer(&mut &$data[..])
{
let mut w = VecWriter(Vec::new());
msg.write(&mut w).unwrap();
let p = w.0.len() as usize;
assert_eq!(msg.serialized_length(), p);

assert_eq!(w.0.len(), p);
assert_eq!(&r.get_ref()[..$hole], &w.0[..$hole]);
assert_eq!(&r.get_ref()[$hole + $hole_len..p], &w.0[$hole + $hole_len..]);
assert_eq!(&$data[..$hole], &w.0[..$hole]);
assert_eq!(&$data[$hole + $hole_len..p], &w.0[$hole + $hole_len..]);
}
}};
}
9 changes: 6 additions & 3 deletions fuzz/src/onion_message.rs
Original file line number Diff line number Diff line change
@@ -26,20 +26,23 @@ use lightning::onion_message::packet::OnionMessageContents;
use lightning::sign::{EntropySource, NodeSigner, Recipient, SignerProvider};
use lightning::types::features::InitFeatures;
use lightning::util::logger::Logger;
use lightning::util::ser::{Readable, Writeable, Writer};
use lightning::util::ser::{LengthReadable, Writeable, Writer};
use lightning::util::test_channel_signer::TestChannelSigner;

use lightning_invoice::RawBolt11Invoice;

use crate::utils::test_logger;

use lightning::io::{self, Cursor};
use lightning::io;
use std::sync::atomic::{AtomicU64, Ordering};

#[inline]
/// Actual fuzz test, method signature and name are fixed
pub fn do_test<L: Logger>(data: &[u8], logger: &L) {
if let Ok(msg) = <msgs::OnionMessage as Readable>::read(&mut Cursor::new(data)) {
let mut reader = &data[..];
if let Ok(msg) =
<msgs::OnionMessage as LengthReadable>::read_from_fixed_length_buffer(&mut reader)
{
let mut secret_bytes = [1; 32];
secret_bytes[31] = 2;
let secret = SecretKey::from_slice(&secret_bytes).unwrap();
9 changes: 5 additions & 4 deletions fuzz/src/router.rs
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ use lightning::routing::utxo::{UtxoFuture, UtxoLookup, UtxoLookupError, UtxoResu
use lightning::types::features::{BlindedHopFeatures, Bolt12InvoiceFeatures};
use lightning::util::config::UserConfig;
use lightning::util::hash_tables::*;
use lightning::util::ser::Readable;
use lightning::util::ser::LengthReadable;

use bitcoin::hashes::Hash;
use bitcoin::network::Network;
@@ -146,10 +146,11 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {

macro_rules! decode_msg {
($MsgType: path, $len: expr) => {{
let mut reader = ::lightning::io::Cursor::new(get_slice!($len));
match <$MsgType>::read(&mut reader) {
let data = get_slice!($len);
let mut reader = &data[..];
match <$MsgType>::read_from_fixed_length_buffer(&mut reader) {
Ok(msg) => {
assert_eq!(reader.position(), $len as u64);
assert_eq!(reader.len(), $len);
msg
},
Err(e) => match e {
10 changes: 5 additions & 5 deletions lightning-custom-message/src/lib.rs
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@
//! use lightning::ln::peer_handler::CustomMessageHandler;
//! use lightning::ln::wire::{CustomMessageReader, self};
//! # use lightning::types::features::{InitFeatures, NodeFeatures};
//! use lightning::util::ser::Writeable;
//! use lightning::util::ser::{LengthLimitedRead, Writeable};
//! # use lightning::util::ser::Writer;
//!
//! // Assume that `FooHandler` and `BarHandler` are defined in one crate and `BazHandler` is
@@ -52,7 +52,7 @@
//! impl CustomMessageReader for FooHandler {
//! // ...
//! # type CustomMessage = Foo;
//! # fn read<R: io::Read>(
//! # fn read<R: LengthLimitedRead>(
//! # &self, _message_type: u16, _buffer: &mut R
//! # ) -> Result<Option<Self::CustomMessage>, DecodeError> {
//! # unimplemented!()
@@ -104,7 +104,7 @@
//! impl CustomMessageReader for BarHandler {
//! // ...
//! # type CustomMessage = Bar;
//! # fn read<R: io::Read>(
//! # fn read<R: LengthLimitedRead>(
//! # &self, _message_type: u16, _buffer: &mut R
//! # ) -> Result<Option<Self::CustomMessage>, DecodeError> {
//! # unimplemented!()
@@ -156,7 +156,7 @@
//! impl CustomMessageReader for BazHandler {
//! // ...
//! # type CustomMessage = Baz;
//! # fn read<R: io::Read>(
//! # fn read<R: LengthLimitedRead>(
//! # &self, _message_type: u16, _buffer: &mut R
//! # ) -> Result<Option<Self::CustomMessage>, DecodeError> {
//! # unimplemented!()
@@ -340,7 +340,7 @@ macro_rules! composite_custom_message_handler {

impl $crate::lightning::ln::wire::CustomMessageReader for $handler {
type CustomMessage = $message;
fn read<R: $crate::lightning::io::Read>(
fn read<R: $crate::lightning::util::ser::LengthLimitedRead>(
&self, message_type: u16, buffer: &mut R
) -> Result<Option<Self::CustomMessage>, $crate::lightning::ln::msgs::DecodeError> {
match message_type {
Loading