@@ -3,7 +3,7 @@ use bitcoin::secp256k1::{self, PublicKey, Secp256k1, SecretKey};
33#[ allow( unused_imports) ]
44use crate :: prelude:: * ;
55
6- use crate :: blinded_path:: { BlindedHop , BlindedPath , IntroductionNode , NodeIdLookUp } ;
6+ use crate :: blinded_path:: { BlindedHop , BlindedPath , IntroductionNode , NextMessageHop , NodeIdLookUp } ;
77use crate :: blinded_path:: utils;
88use crate :: io;
99use crate :: io:: Cursor ;
@@ -20,7 +20,7 @@ use core::ops::Deref;
2020/// route, they are encoded into [`BlindedHop::encrypted_payload`].
2121pub ( crate ) struct ForwardTlvs {
2222 /// The next hop in the onion message's path.
23- pub ( crate ) next_hop : NextHop ,
23+ pub ( crate ) next_hop : NextMessageHop ,
2424 /// Senders to a blinded path use this value to concatenate the route they find to the
2525 /// introduction node with the blinded path.
2626 pub ( crate ) next_blinding_override : Option < PublicKey > ,
@@ -34,20 +34,11 @@ pub(crate) struct ReceiveTlvs {
3434 pub ( crate ) path_id : Option < [ u8 ; 32 ] > ,
3535}
3636
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-
4637impl Writeable for ForwardTlvs {
4738 fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , io:: Error > {
4839 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) ) ,
5142 } ;
5243 // TODO: write padding
5344 encode_tlv_stream ! ( writer, {
@@ -75,7 +66,7 @@ pub(super) fn blinded_hops<T: secp256k1::Signing + secp256k1::Verification>(
7566) -> Result < Vec < BlindedHop > , secp256k1:: Error > {
7667 let blinded_tlvs = unblinded_path. iter ( )
7768 . 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 } )
7970 . map ( |tlvs| ControlTlvs :: Forward ( tlvs) )
8071 . chain ( core:: iter:: once ( ControlTlvs :: Receive ( ReceiveTlvs { path_id : None } ) ) ) ;
8172
10293 readable : ControlTlvs :: Forward ( ForwardTlvs { next_hop, next_blinding_override } )
10394 } ) => {
10495 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) {
10798 Some ( pubkey) => pubkey,
10899 None => return Err ( ( ) ) ,
109100 } ,
0 commit comments