@@ -3,7 +3,7 @@ use bitcoin::secp256k1::{self, PublicKey, Secp256k1, SecretKey};
3
3
#[ allow( unused_imports) ]
4
4
use crate :: prelude:: * ;
5
5
6
- use crate :: blinded_path:: { BlindedHop , BlindedPath , IntroductionNode , NodeIdLookUp } ;
6
+ use crate :: blinded_path:: { BlindedHop , BlindedPath , IntroductionNode , NextMessageHop , NodeIdLookUp } ;
7
7
use crate :: blinded_path:: utils;
8
8
use crate :: io;
9
9
use crate :: io:: Cursor ;
@@ -20,7 +20,7 @@ use core::ops::Deref;
20
20
/// route, they are encoded into [`BlindedHop::encrypted_payload`].
21
21
pub ( crate ) struct ForwardTlvs {
22
22
/// The next hop in the onion message's path.
23
- pub ( crate ) next_hop : NextHop ,
23
+ pub ( crate ) next_hop : NextMessageHop ,
24
24
/// Senders to a blinded path use this value to concatenate the route they find to the
25
25
/// introduction node with the blinded path.
26
26
pub ( crate ) next_blinding_override : Option < PublicKey > ,
@@ -34,20 +34,11 @@ pub(crate) struct ReceiveTlvs {
34
34
pub ( crate ) path_id : Option < [ u8 ; 32 ] > ,
35
35
}
36
36
37
- /// The next hop to forward the onion message along its path.
38
- #[ derive( Debug ) ]
39
- pub enum NextHop {
40
- /// The node id of the next hop.
41
- NodeId ( PublicKey ) ,
42
- /// The short channel id leading to the next hop.
43
- ShortChannelId ( u64 ) ,
44
- }
45
-
46
37
impl Writeable for ForwardTlvs {
47
38
fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , io:: Error > {
48
39
let ( next_node_id, short_channel_id) = match self . next_hop {
49
- NextHop :: NodeId ( pubkey) => ( Some ( pubkey) , None ) ,
50
- NextHop :: ShortChannelId ( scid) => ( None , Some ( scid) ) ,
40
+ NextMessageHop :: NodeId ( pubkey) => ( Some ( pubkey) , None ) ,
41
+ NextMessageHop :: ShortChannelId ( scid) => ( None , Some ( scid) ) ,
51
42
} ;
52
43
// TODO: write padding
53
44
encode_tlv_stream ! ( writer, {
@@ -75,7 +66,7 @@ pub(super) fn blinded_hops<T: secp256k1::Signing + secp256k1::Verification>(
75
66
) -> Result < Vec < BlindedHop > , secp256k1:: Error > {
76
67
let blinded_tlvs = unblinded_path. iter ( )
77
68
. skip ( 1 ) // The first node's TLVs contains the next node's pubkey
78
- . map ( |pk| ForwardTlvs { next_hop : NextHop :: NodeId ( * pk) , next_blinding_override : None } )
69
+ . map ( |pk| ForwardTlvs { next_hop : NextMessageHop :: NodeId ( * pk) , next_blinding_override : None } )
79
70
. map ( |tlvs| ControlTlvs :: Forward ( tlvs) )
80
71
. chain ( core:: iter:: once ( ControlTlvs :: Receive ( ReceiveTlvs { path_id : None } ) ) ) ;
81
72
102
93
readable : ControlTlvs :: Forward ( ForwardTlvs { next_hop, next_blinding_override } )
103
94
} ) => {
104
95
let next_node_id = match next_hop {
105
- NextHop :: NodeId ( pubkey) => pubkey,
106
- NextHop :: ShortChannelId ( scid) => match node_id_lookup. next_node_id ( scid) {
96
+ NextMessageHop :: NodeId ( pubkey) => pubkey,
97
+ NextMessageHop :: ShortChannelId ( scid) => match node_id_lookup. next_node_id ( scid) {
107
98
Some ( pubkey) => pubkey,
108
99
None => return Err ( ( ) ) ,
109
100
} ,
0 commit comments