Skip to content

Commit f49e04d

Browse files
Expose onion message module as public
And fix warnings
1 parent 0624cf9 commit f49e04d

File tree

4 files changed

+7
-14
lines changed

4 files changed

+7
-14
lines changed

lightning/src/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,7 @@ pub mod util;
7979
pub mod chain;
8080
pub mod ln;
8181
pub mod routing;
82-
#[cfg(fuzzing)]
8382
pub mod onion_message;
84-
#[cfg(not(fuzzing))]
85-
#[allow(unused)]
86-
mod onion_message; // To be exposed after sending/receiving OMs is supported in PeerManager.
8783

8884
#[cfg(feature = "std")]
8985
/// Re-export of either `core2::io` or `std::io`, depending on the `std` feature flag.

lightning/src/onion_message/functional_tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ fn too_big_packet_error() {
124124
#[test]
125125
fn invalid_blinded_route_error() {
126126
// Make sure we error as expected if a provided blinded route has 0 or 1 hops.
127-
let mut nodes = create_nodes(3);
127+
let nodes = create_nodes(3);
128128

129129
// 0 hops
130130
let secp_ctx = Secp256k1::new();
@@ -143,7 +143,7 @@ fn invalid_blinded_route_error() {
143143

144144
#[test]
145145
fn reply_path() {
146-
let mut nodes = create_nodes(4);
146+
let nodes = create_nodes(4);
147147
let secp_ctx = Secp256k1::new();
148148

149149
// Destination::Node

lightning/src/onion_message/messenger.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use super::utils;
2424
use util::events::OnionMessageProvider;
2525
use util::logger::Logger;
2626

27-
use core::mem;
2827
use core::ops::Deref;
2928
use sync::{Arc, Mutex};
3029
use prelude::*;
@@ -35,9 +34,7 @@ use prelude::*;
3534
///
3635
/// # Example
3736
///
38-
// Needs to be `ignore` until the `onion_message` module is made public, otherwise this is a test
39-
// failure.
40-
/// ```ignore
37+
/// ```
4138
/// # extern crate bitcoin;
4239
/// # use bitcoin::hashes::_export::_core::time::Duration;
4340
/// # use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey};
@@ -66,7 +63,7 @@ use prelude::*;
6663
///
6764
/// // Send an empty onion message to a node id.
6865
/// let intermediate_hops = [hop_node_id1, hop_node_id2];
69-
/// onion_messenger.send_onion_message(&intermediate_hops, Destination::Node(destination_node_id));
66+
/// onion_messenger.send_onion_message(&intermediate_hops, Destination::Node(destination_node_id), None);
7067
///
7168
/// // Create a blinded route to yourself, for someone to send an onion message to.
7269
/// # let your_node_id = hop_node_id1;
@@ -75,7 +72,7 @@ use prelude::*;
7572
///
7673
/// // Send an empty onion message to a blinded route.
7774
/// # let intermediate_hops = [hop_node_id1, hop_node_id2];
78-
/// onion_messenger.send_onion_message(&intermediate_hops, Destination::BlindedRoute(blinded_route));
75+
/// onion_messenger.send_onion_message(&intermediate_hops, Destination::BlindedRoute(blinded_route), None);
7976
/// ```
8077
///
8178
/// [offers]: <https://github.com/lightning/bolts/pull/798>

lightning/src/onion_message/packet.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl LengthReadable for Packet {
7474
while read_idx < hop_data_len {
7575
let mut read_buffer = [0; READ_BUFFER_SIZE];
7676
let read_amt = cmp::min(hop_data_len - read_idx, READ_BUFFER_SIZE);
77-
r.read_exact(&mut read_buffer[..read_amt]);
77+
r.read_exact(&mut read_buffer[..read_amt])?;
7878
hop_data.extend_from_slice(&read_buffer[..read_amt]);
7979
read_idx += read_amt;
8080
}
@@ -170,7 +170,7 @@ impl Writeable for (Payload, [u8; 32]) {
170170

171171
// Uses the provided secret to simultaneously decode and decrypt the control TLVs.
172172
impl ReadableArgs<SharedSecret> for Payload {
173-
fn read<R: Read>(mut r: &mut R, encrypted_tlvs_ss: SharedSecret) -> Result<Self, DecodeError> {
173+
fn read<R: Read>(r: &mut R, encrypted_tlvs_ss: SharedSecret) -> Result<Self, DecodeError> {
174174
let v: BigSize = Readable::read(r)?;
175175
let mut rd = FixedLengthReader::new(r, v.0);
176176
let mut reply_path: Option<BlindedRoute> = None;

0 commit comments

Comments
 (0)