Skip to content

Commit 7f9df8d

Browse files
committed
Drop unused type parameter on BlindedRoute::new
I'm not sure why rustc didn't complain about the unused parameter or why we're allowed to get away without explicitly bounding the `Sign` in the `KeysInterface`, but the current code requires all `BlindedPath` construction to explicitly turbofish an unused type.
1 parent 07af2f7 commit 7f9df8d

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

lightning/src/onion_message/blinded_route.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
1212
use bitcoin::secp256k1::{self, PublicKey, Secp256k1, SecretKey};
1313

14-
use chain::keysinterface::{KeysInterface, Sign};
14+
use chain::keysinterface::KeysInterface;
1515
use super::utils;
1616
use ln::msgs::DecodeError;
1717
use util::chacha20poly1305rfc::ChaChaPolyWriteAdapter;
@@ -55,7 +55,7 @@ impl BlindedRoute {
5555
///
5656
/// Errors if less than two hops are provided or if `node_pk`(s) are invalid.
5757
// TODO: make all payloads the same size with padding + add dummy hops
58-
pub fn new<Signer: Sign, K: KeysInterface, T: secp256k1::Signing + secp256k1::Verification>
58+
pub fn new<K: KeysInterface, T: secp256k1::Signing + secp256k1::Verification>
5959
(node_pks: &[PublicKey], keys_manager: &K, secp_ctx: &Secp256k1<T>) -> Result<Self, ()>
6060
{
6161
if node_pks.len() < 2 { return Err(()) }

lightning/src/onion_message/functional_tests.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ fn two_unblinded_two_blinded() {
9898
let nodes = create_nodes(5);
9999

100100
let secp_ctx = Secp256k1::new();
101-
let blinded_route = BlindedRoute::new::<EnforcingSigner, _, _>(&[nodes[3].get_node_pk(), nodes[4].get_node_pk()], &*nodes[4].keys_manager, &secp_ctx).unwrap();
101+
let blinded_route = BlindedRoute::new(&[nodes[3].get_node_pk(), nodes[4].get_node_pk()], &*nodes[4].keys_manager, &secp_ctx).unwrap();
102102

103103
nodes[0].messenger.send_onion_message(&[nodes[1].get_node_pk(), nodes[2].get_node_pk()], Destination::BlindedRoute(blinded_route), None).unwrap();
104104
pass_along_path(&nodes, None);
@@ -109,7 +109,7 @@ fn three_blinded_hops() {
109109
let nodes = create_nodes(4);
110110

111111
let secp_ctx = Secp256k1::new();
112-
let blinded_route = BlindedRoute::new::<EnforcingSigner, _, _>(&[nodes[1].get_node_pk(), nodes[2].get_node_pk(), nodes[3].get_node_pk()], &*nodes[3].keys_manager, &secp_ctx).unwrap();
112+
let blinded_route = BlindedRoute::new(&[nodes[1].get_node_pk(), nodes[2].get_node_pk(), nodes[3].get_node_pk()], &*nodes[3].keys_manager, &secp_ctx).unwrap();
113113

114114
nodes[0].messenger.send_onion_message(&[], Destination::BlindedRoute(blinded_route), None).unwrap();
115115
pass_along_path(&nodes, None);
@@ -133,13 +133,13 @@ fn invalid_blinded_route_error() {
133133

134134
// 0 hops
135135
let secp_ctx = Secp256k1::new();
136-
let mut blinded_route = BlindedRoute::new::<EnforcingSigner, _, _>(&[nodes[1].get_node_pk(), nodes[2].get_node_pk()], &*nodes[2].keys_manager, &secp_ctx).unwrap();
136+
let mut blinded_route = BlindedRoute::new(&[nodes[1].get_node_pk(), nodes[2].get_node_pk()], &*nodes[2].keys_manager, &secp_ctx).unwrap();
137137
blinded_route.blinded_hops.clear();
138138
let err = nodes[0].messenger.send_onion_message(&[], Destination::BlindedRoute(blinded_route), None).unwrap_err();
139139
assert_eq!(err, SendError::TooFewBlindedHops);
140140

141141
// 1 hop
142-
let mut blinded_route = BlindedRoute::new::<EnforcingSigner, _, _>(&[nodes[1].get_node_pk(), nodes[2].get_node_pk()], &*nodes[2].keys_manager, &secp_ctx).unwrap();
142+
let mut blinded_route = BlindedRoute::new(&[nodes[1].get_node_pk(), nodes[2].get_node_pk()], &*nodes[2].keys_manager, &secp_ctx).unwrap();
143143
blinded_route.blinded_hops.remove(0);
144144
assert_eq!(blinded_route.blinded_hops.len(), 1);
145145
let err = nodes[0].messenger.send_onion_message(&[], Destination::BlindedRoute(blinded_route), None).unwrap_err();
@@ -152,7 +152,7 @@ fn reply_path() {
152152
let secp_ctx = Secp256k1::new();
153153

154154
// Destination::Node
155-
let reply_path = BlindedRoute::new::<EnforcingSigner, _, _>(&[nodes[2].get_node_pk(), nodes[1].get_node_pk(), nodes[0].get_node_pk()], &*nodes[0].keys_manager, &secp_ctx).unwrap();
155+
let reply_path = BlindedRoute::new(&[nodes[2].get_node_pk(), nodes[1].get_node_pk(), nodes[0].get_node_pk()], &*nodes[0].keys_manager, &secp_ctx).unwrap();
156156
nodes[0].messenger.send_onion_message(&[nodes[1].get_node_pk(), nodes[2].get_node_pk()], Destination::Node(nodes[3].get_node_pk()), Some(reply_path)).unwrap();
157157
pass_along_path(&nodes, None);
158158
// Make sure the last node successfully decoded the reply path.
@@ -161,8 +161,8 @@ fn reply_path() {
161161
format!("Received an onion message with path_id: None and reply_path").to_string(), 1);
162162

163163
// Destination::BlindedRoute
164-
let blinded_route = BlindedRoute::new::<EnforcingSigner, _, _>(&[nodes[1].get_node_pk(), nodes[2].get_node_pk(), nodes[3].get_node_pk()], &*nodes[3].keys_manager, &secp_ctx).unwrap();
165-
let reply_path = BlindedRoute::new::<EnforcingSigner, _, _>(&[nodes[2].get_node_pk(), nodes[1].get_node_pk(), nodes[0].get_node_pk()], &*nodes[0].keys_manager, &secp_ctx).unwrap();
164+
let blinded_route = BlindedRoute::new(&[nodes[1].get_node_pk(), nodes[2].get_node_pk(), nodes[3].get_node_pk()], &*nodes[3].keys_manager, &secp_ctx).unwrap();
165+
let reply_path = BlindedRoute::new(&[nodes[2].get_node_pk(), nodes[1].get_node_pk(), nodes[0].get_node_pk()], &*nodes[0].keys_manager, &secp_ctx).unwrap();
166166

167167
nodes[0].messenger.send_onion_message(&[], Destination::BlindedRoute(blinded_route), Some(reply_path)).unwrap();
168168
pass_along_path(&nodes, None);

lightning/src/onion_message/messenger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ use prelude::*;
7171
/// // Create a blinded route to yourself, for someone to send an onion message to.
7272
/// # let your_node_id = hop_node_id1;
7373
/// let hops = [hop_node_id3, hop_node_id4, your_node_id];
74-
/// let blinded_route = BlindedRoute::new::<InMemorySigner, _, _>(&hops, &keys_manager, &secp_ctx).unwrap();
74+
/// let blinded_route = BlindedRoute::new(&hops, &keys_manager, &secp_ctx).unwrap();
7575
///
7676
/// // Send an empty onion message to a blinded route.
7777
/// # let intermediate_hops = [hop_node_id1, hop_node_id2];

0 commit comments

Comments
 (0)