9
9
10
10
//! Creating blinded paths and related utilities live here.
11
11
12
- pub mod payment;
13
12
pub mod message;
13
+ pub mod payment;
14
14
pub ( crate ) mod utils;
15
15
16
16
use bitcoin:: secp256k1:: PublicKey ;
@@ -90,7 +90,9 @@ impl NodeIdLookUp for EmptyNodeIdLookUp {
90
90
91
91
impl Deref for EmptyNodeIdLookUp {
92
92
type Target = EmptyNodeIdLookUp ;
93
- fn deref ( & self ) -> & Self { self }
93
+ fn deref ( & self ) -> & Self {
94
+ self
95
+ }
94
96
}
95
97
96
98
/// An encrypted payload and node id corresponding to a hop in a payment or onion message path, to
@@ -108,20 +110,18 @@ pub struct BlindedHop {
108
110
109
111
impl BlindedPath {
110
112
pub ( super ) fn public_introduction_node_id < ' a > (
111
- & self , network_graph : & ' a ReadOnlyNetworkGraph
113
+ & self , network_graph : & ' a ReadOnlyNetworkGraph ,
112
114
) -> Option < & ' a NodeId > {
113
115
match & self . introduction_node {
114
116
IntroductionNode :: NodeId ( pubkey) => {
115
117
let node_id = NodeId :: from_pubkey ( pubkey) ;
116
118
network_graph. nodes ( ) . get_key_value ( & node_id) . map ( |( key, _) | key)
117
119
} ,
118
120
IntroductionNode :: DirectedShortChannelId ( direction, scid) => {
119
- network_graph
120
- . channel ( * scid)
121
- . map ( |c| match direction {
122
- Direction :: NodeOne => & c. node_one ,
123
- Direction :: NodeTwo => & c. node_two ,
124
- } )
121
+ network_graph. channel ( * scid) . map ( |c| match direction {
122
+ Direction :: NodeOne => & c. node_one ,
123
+ Direction :: NodeTwo => & c. node_two ,
124
+ } )
125
125
} ,
126
126
}
127
127
}
@@ -155,7 +155,7 @@ impl Readable for BlindedPath {
155
155
let introduction_node = match first_byte {
156
156
0 => IntroductionNode :: DirectedShortChannelId ( Direction :: NodeOne , Readable :: read ( r) ?) ,
157
157
1 => IntroductionNode :: DirectedShortChannelId ( Direction :: NodeTwo , Readable :: read ( r) ?) ,
158
- 2 | 3 => {
158
+ 2 | 3 => {
159
159
let mut bytes = [ 0 ; 33 ] ;
160
160
bytes[ 0 ] = first_byte;
161
161
r. read_exact ( & mut bytes[ 1 ..] ) ?;
@@ -165,16 +165,14 @@ impl Readable for BlindedPath {
165
165
} ;
166
166
let blinding_point = Readable :: read ( r) ?;
167
167
let num_hops: u8 = Readable :: read ( r) ?;
168
- if num_hops == 0 { return Err ( DecodeError :: InvalidValue ) }
168
+ if num_hops == 0 {
169
+ return Err ( DecodeError :: InvalidValue ) ;
170
+ }
169
171
let mut blinded_hops: Vec < BlindedHop > = Vec :: with_capacity ( num_hops. into ( ) ) ;
170
172
for _ in 0 ..num_hops {
171
173
blinded_hops. push ( Readable :: read ( r) ?) ;
172
174
}
173
- Ok ( BlindedPath {
174
- introduction_node,
175
- blinding_point,
176
- blinded_hops,
177
- } )
175
+ Ok ( BlindedPath { introduction_node, blinding_point, blinded_hops } )
178
176
}
179
177
}
180
178
0 commit comments