Skip to content

Commit

Permalink
Expose onion message module as public
Browse files Browse the repository at this point in the history
And fix warnings
  • Loading branch information
valentinewallace committed Aug 31, 2022
1 parent 0624cf9 commit f49e04d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
4 changes: 0 additions & 4 deletions lightning/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,7 @@ pub mod util;
pub mod chain;
pub mod ln;
pub mod routing;
#[cfg(fuzzing)]
pub mod onion_message;
#[cfg(not(fuzzing))]
#[allow(unused)]
mod onion_message; // To be exposed after sending/receiving OMs is supported in PeerManager.

#[cfg(feature = "std")]
/// Re-export of either `core2::io` or `std::io`, depending on the `std` feature flag.
Expand Down
4 changes: 2 additions & 2 deletions lightning/src/onion_message/functional_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fn too_big_packet_error() {
#[test]
fn invalid_blinded_route_error() {
// Make sure we error as expected if a provided blinded route has 0 or 1 hops.
let mut nodes = create_nodes(3);
let nodes = create_nodes(3);

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

#[test]
fn reply_path() {
let mut nodes = create_nodes(4);
let nodes = create_nodes(4);
let secp_ctx = Secp256k1::new();

// Destination::Node
Expand Down
9 changes: 3 additions & 6 deletions lightning/src/onion_message/messenger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use super::utils;
use util::events::OnionMessageProvider;
use util::logger::Logger;

use core::mem;
use core::ops::Deref;
use sync::{Arc, Mutex};
use prelude::*;
Expand All @@ -35,9 +34,7 @@ use prelude::*;
///
/// # Example
///
// Needs to be `ignore` until the `onion_message` module is made public, otherwise this is a test
// failure.
/// ```ignore
/// ```
/// # extern crate bitcoin;
/// # use bitcoin::hashes::_export::_core::time::Duration;
/// # use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey};
Expand Down Expand Up @@ -66,7 +63,7 @@ use prelude::*;
///
/// // Send an empty onion message to a node id.
/// let intermediate_hops = [hop_node_id1, hop_node_id2];
/// onion_messenger.send_onion_message(&intermediate_hops, Destination::Node(destination_node_id));
/// onion_messenger.send_onion_message(&intermediate_hops, Destination::Node(destination_node_id), None);
///
/// // Create a blinded route to yourself, for someone to send an onion message to.
/// # let your_node_id = hop_node_id1;
Expand All @@ -75,7 +72,7 @@ use prelude::*;
///
/// // Send an empty onion message to a blinded route.
/// # let intermediate_hops = [hop_node_id1, hop_node_id2];
/// onion_messenger.send_onion_message(&intermediate_hops, Destination::BlindedRoute(blinded_route));
/// onion_messenger.send_onion_message(&intermediate_hops, Destination::BlindedRoute(blinded_route), None);
/// ```
///
/// [offers]: <https://github.com/lightning/bolts/pull/798>
Expand Down
4 changes: 2 additions & 2 deletions lightning/src/onion_message/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl LengthReadable for Packet {
while read_idx < hop_data_len {
let mut read_buffer = [0; READ_BUFFER_SIZE];
let read_amt = cmp::min(hop_data_len - read_idx, READ_BUFFER_SIZE);
r.read_exact(&mut read_buffer[..read_amt]);
r.read_exact(&mut read_buffer[..read_amt])?;
hop_data.extend_from_slice(&read_buffer[..read_amt]);
read_idx += read_amt;
}
Expand Down Expand Up @@ -170,7 +170,7 @@ impl Writeable for (Payload, [u8; 32]) {

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

0 comments on commit f49e04d

Please sign in to comment.