@@ -20,21 +20,22 @@ use super::async_payments::AsyncPaymentsMessage;
20
20
use super :: async_payments:: AsyncPaymentsMessageHandler ;
21
21
use super :: dns_resolution:: { DNSResolverMessage , DNSResolverMessageHandler } ;
22
22
use super :: offers:: { OffersMessage , OffersMessageHandler } ;
23
- use super :: packet:: OnionMessageContents ;
24
23
use super :: packet:: ParsedOnionMessageContents ;
24
+ use super :: packet:: { DummyControlTlvs , OnionMessageContents } ;
25
25
use super :: packet:: {
26
26
ForwardControlTlvs , Packet , Payload , ReceiveControlTlvs , BIG_PACKET_HOP_DATA_LEN ,
27
27
SMALL_PACKET_HOP_DATA_LEN ,
28
28
} ;
29
29
#[ cfg( async_payments) ]
30
30
use crate :: blinded_path:: message:: AsyncPaymentsContext ;
31
31
use crate :: blinded_path:: message:: {
32
- BlindedMessagePath , DNSResolverContext , ForwardTlvs , MessageContext , MessageForwardNode ,
33
- NextMessageHop , OffersContext , ReceiveTlvs ,
32
+ BlindedMessagePath , DNSResolverContext , DummyTlvs , ForwardTlvs , MessageContext ,
33
+ MessageForwardNode , NextMessageHop , OffersContext , ReceiveTlvs ,
34
34
} ;
35
35
use crate :: blinded_path:: utils;
36
36
use crate :: blinded_path:: { IntroductionNode , NodeIdLookUp } ;
37
37
use crate :: events:: { Event , EventHandler , EventsProvider , ReplayEvent } ;
38
+ use crate :: ln:: channelmanager:: Verification ;
38
39
use crate :: ln:: msgs:: {
39
40
self , BaseMessageHandler , MessageSendEvent , OnionMessage , OnionMessageHandler , SocketAddress ,
40
41
} ;
@@ -1140,18 +1141,52 @@ where
1140
1141
Err ( ( ) )
1141
1142
} ,
1142
1143
} ,
1144
+ Ok ( (
1145
+ Payload :: Dummy ( DummyControlTlvs :: Unblinded ( DummyTlvs { dummy_tlvs, authentication } ) ) ,
1146
+ Some ( ( next_hop_hmac, new_packet_bytes) ) ,
1147
+ ) ) => {
1148
+ let expanded_key = node_signer. get_inbound_payment_key ( ) ;
1149
+ dummy_tlvs. verify_data ( authentication. 0 , authentication. 1 , & expanded_key) ?;
1150
+
1151
+ let packet_pubkey = msg. onion_routing_packet . public_key ;
1152
+ let new_pubkey_opt =
1153
+ onion_utils:: next_hop_pubkey ( & secp_ctx, packet_pubkey, & onion_decode_ss) ;
1154
+ let new_pubkey = match new_pubkey_opt {
1155
+ Ok ( pk) => pk,
1156
+ Err ( e) => {
1157
+ log_trace ! ( logger, "Failed to compute next hop packet pubkey: {}" , e) ;
1158
+ return Err ( ( ) ) ;
1159
+ } ,
1160
+ } ;
1161
+ let outgoing_packet = Packet {
1162
+ version : 0 ,
1163
+ public_key : new_pubkey,
1164
+ hop_data : new_packet_bytes,
1165
+ hmac : next_hop_hmac,
1166
+ } ;
1167
+ let onion_message = OnionMessage {
1168
+ blinding_point : match onion_utils:: next_hop_pubkey (
1169
+ & secp_ctx,
1170
+ msg. blinding_point ,
1171
+ control_tlvs_ss. as_ref ( ) ,
1172
+ ) {
1173
+ Ok ( bp) => bp,
1174
+ Err ( e) => {
1175
+ log_trace ! ( logger, "Failed to compute next blinding point: {}" , e) ;
1176
+ return Err ( ( ) ) ;
1177
+ } ,
1178
+ } ,
1179
+ onion_routing_packet : outgoing_packet,
1180
+ } ;
1181
+ peel_onion_message ( & onion_message, secp_ctx, node_signer, logger, custom_handler)
1182
+ } ,
1143
1183
Ok ( (
1144
1184
Payload :: Forward ( ForwardControlTlvs :: Unblinded ( ForwardTlvs {
1145
1185
next_hop,
1146
1186
next_blinding_override,
1147
1187
} ) ) ,
1148
1188
Some ( ( next_hop_hmac, new_packet_bytes) ) ,
1149
1189
) ) => {
1150
- // TODO: we need to check whether `next_hop` is our node, in which case this is a dummy
1151
- // blinded hop and this onion message is destined for us. In this situation, we should keep
1152
- // unwrapping the onion layers to get to the final payload. Since we don't have the option
1153
- // of creating blinded paths with dummy hops currently, we should be ok to not handle this
1154
- // for now.
1155
1190
let packet_pubkey = msg. onion_routing_packet . public_key ;
1156
1191
let new_pubkey_opt =
1157
1192
onion_utils:: next_hop_pubkey ( & secp_ctx, packet_pubkey, & onion_decode_ss) ;
0 commit comments