@@ -16,7 +16,7 @@ use bitcoin::hashes::sha256::Hash as Sha256;
16
16
use bitcoin:: secp256k1:: { self , PublicKey , Scalar , Secp256k1 , SecretKey } ;
17
17
18
18
use crate :: blinded_path:: BlindedPath ;
19
- use crate :: blinded_path:: message:: { advance_path_by_one, ForwardTlvs , ReceiveTlvs } ;
19
+ use crate :: blinded_path:: message:: { advance_path_by_one, ForwardTlvs , NextHop , ReceiveTlvs } ;
20
20
use crate :: blinded_path:: utils;
21
21
use crate :: events:: { Event , EventHandler , EventsProvider } ;
22
22
use crate :: sign:: { EntropySource , NodeSigner , Recipient } ;
@@ -538,7 +538,7 @@ pub trait CustomOnionMessageHandler {
538
538
#[ derive( Debug ) ]
539
539
pub enum PeeledOnion < T : OnionMessageContents > {
540
540
/// Forwarded onion, with the next node id and a new onion
541
- Forward ( PublicKey , OnionMessage ) ,
541
+ Forward ( NextHop , OnionMessage ) ,
542
542
/// Received onion message, with decrypted contents, path_id, and reply path
543
543
Receive ( ParsedOnionMessageContents < T > , Option < [ u8 ; 32 ] > , Option < BlindedPath > )
544
544
}
@@ -647,9 +647,9 @@ where
647
647
Ok ( PeeledOnion : : Receive ( message, path_id, reply_path) )
648
648
} ,
649
649
Ok ( ( Payload : : Forward ( ForwardControlTlvs :: Unblinded ( ForwardTlvs {
650
- next_node_id , next_blinding_override
650
+ next_hop , next_blinding_override
651
651
} ) ) , Some ( ( next_hop_hmac, new_packet_bytes) ) ) ) => {
652
- // TODO: we need to check whether `next_node_id ` is our node, in which case this is a dummy
652
+ // TODO: we need to check whether `next_hop ` is our node, in which case this is a dummy
653
653
// blinded hop and this onion message is destined for us. In this situation, we should keep
654
654
// unwrapping the onion layers to get to the final payload. Since we don't have the option
655
655
// of creating blinded paths with dummy hops currently, we should be ok to not handle this
@@ -685,7 +685,7 @@ where
685
685
onion_routing_packet : outgoing_packet,
686
686
} ;
687
687
688
- Ok ( PeeledOnion :: Forward ( next_node_id , onion_message) )
688
+ Ok ( PeeledOnion :: Forward ( next_hop , onion_message) )
689
689
} ,
690
690
Err ( e) => {
691
691
log_trace ! ( logger, "Errored decoding onion message packet: {:?}" , e) ;
@@ -961,7 +961,12 @@ where
961
961
} ,
962
962
}
963
963
} ,
964
- Ok ( PeeledOnion :: Forward ( next_node_id, onion_message) ) => {
964
+ Ok ( PeeledOnion :: Forward ( next_hop, onion_message) ) => {
965
+ let next_node_id = match next_hop {
966
+ NextHop :: NodeId ( pubkey) => pubkey,
967
+ NextHop :: ShortChannelId ( _) => todo ! ( ) ,
968
+ } ;
969
+
965
970
let mut message_recipients = self . message_recipients . lock ( ) . unwrap ( ) ;
966
971
if outbound_buffer_full ( & next_node_id, & message_recipients) {
967
972
log_trace ! (
@@ -1146,7 +1151,7 @@ fn packet_payloads_and_keys<T: OnionMessageContents, S: secp256k1::Signing + sec
1146
1151
if let Some ( ss) = prev_control_tlvs_ss. take ( ) {
1147
1152
payloads. push ( ( Payload :: Forward ( ForwardControlTlvs :: Unblinded (
1148
1153
ForwardTlvs {
1149
- next_node_id : unblinded_pk_opt. unwrap ( ) ,
1154
+ next_hop : NextHop :: NodeId ( unblinded_pk_opt. unwrap ( ) ) ,
1150
1155
next_blinding_override : None ,
1151
1156
}
1152
1157
) ) , ss) ) ;
@@ -1156,7 +1161,7 @@ fn packet_payloads_and_keys<T: OnionMessageContents, S: secp256k1::Signing + sec
1156
1161
} else if let Some ( ( intro_node_id, blinding_pt) ) = intro_node_id_blinding_pt. take ( ) {
1157
1162
if let Some ( control_tlvs_ss) = prev_control_tlvs_ss. take ( ) {
1158
1163
payloads. push ( ( Payload :: Forward ( ForwardControlTlvs :: Unblinded ( ForwardTlvs {
1159
- next_node_id : intro_node_id,
1164
+ next_hop : NextHop :: NodeId ( intro_node_id) ,
1160
1165
next_blinding_override : Some ( blinding_pt) ,
1161
1166
} ) ) , control_tlvs_ss) ) ;
1162
1167
}
0 commit comments