@@ -20,19 +20,20 @@ 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:: 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
use crate :: blinded_path:: message:: {
30
- BlindedMessagePath , ForwardTlvs , MessageContext , MessageForwardNode , NextMessageHop ,
30
+ BlindedMessagePath , DummyTlvs , ForwardTlvs , MessageContext , MessageForwardNode , NextMessageHop ,
31
31
ReceiveTlvs ,
32
32
} ;
33
33
use crate :: blinded_path:: utils;
34
34
use crate :: blinded_path:: { IntroductionNode , NodeIdLookUp } ;
35
35
use crate :: events:: { Event , EventHandler , EventsProvider , ReplayEvent } ;
36
+ use crate :: ln:: channelmanager:: Verification ;
36
37
use crate :: ln:: msgs:: {
37
38
self , BaseMessageHandler , MessageSendEvent , OnionMessage , OnionMessageHandler , SocketAddress ,
38
39
} ;
@@ -1122,18 +1123,52 @@ where
1122
1123
Err ( ( ) )
1123
1124
} ,
1124
1125
} ,
1126
+ Ok ( (
1127
+ Payload :: Dummy ( DummyControlTlvs :: Unblinded ( DummyTlvs { dummy_tlvs, authentication } ) ) ,
1128
+ Some ( ( next_hop_hmac, new_packet_bytes) ) ,
1129
+ ) ) => {
1130
+ let expanded_key = node_signer. get_inbound_payment_key ( ) ;
1131
+ dummy_tlvs. verify_data ( authentication. 0 , authentication. 1 , & expanded_key) ?;
1132
+
1133
+ let packet_pubkey = msg. onion_routing_packet . public_key ;
1134
+ let new_pubkey_opt =
1135
+ onion_utils:: next_hop_pubkey ( & secp_ctx, packet_pubkey, & onion_decode_ss) ;
1136
+ let new_pubkey = match new_pubkey_opt {
1137
+ Ok ( pk) => pk,
1138
+ Err ( e) => {
1139
+ log_trace ! ( logger, "Failed to compute next hop packet pubkey: {}" , e) ;
1140
+ return Err ( ( ) ) ;
1141
+ } ,
1142
+ } ;
1143
+ let outgoing_packet = Packet {
1144
+ version : 0 ,
1145
+ public_key : new_pubkey,
1146
+ hop_data : new_packet_bytes,
1147
+ hmac : next_hop_hmac,
1148
+ } ;
1149
+ let onion_message = OnionMessage {
1150
+ blinding_point : match onion_utils:: next_hop_pubkey (
1151
+ & secp_ctx,
1152
+ msg. blinding_point ,
1153
+ control_tlvs_ss. as_ref ( ) ,
1154
+ ) {
1155
+ Ok ( bp) => bp,
1156
+ Err ( e) => {
1157
+ log_trace ! ( logger, "Failed to compute next blinding point: {}" , e) ;
1158
+ return Err ( ( ) ) ;
1159
+ } ,
1160
+ } ,
1161
+ onion_routing_packet : outgoing_packet,
1162
+ } ;
1163
+ peel_onion_message ( & onion_message, secp_ctx, node_signer, logger, custom_handler)
1164
+ } ,
1125
1165
Ok ( (
1126
1166
Payload :: Forward ( ForwardControlTlvs :: Unblinded ( ForwardTlvs {
1127
1167
next_hop,
1128
1168
next_blinding_override,
1129
1169
} ) ) ,
1130
1170
Some ( ( next_hop_hmac, new_packet_bytes) ) ,
1131
1171
) ) => {
1132
- // TODO: we need to check whether `next_hop` is our node, in which case this is a dummy
1133
- // blinded hop and this onion message is destined for us. In this situation, we should keep
1134
- // unwrapping the onion layers to get to the final payload. Since we don't have the option
1135
- // of creating blinded paths with dummy hops currently, we should be ok to not handle this
1136
- // for now.
1137
1172
let packet_pubkey = msg. onion_routing_packet . public_key ;
1138
1173
let new_pubkey_opt =
1139
1174
onion_utils:: next_hop_pubkey ( & secp_ctx, packet_pubkey, & onion_decode_ss) ;
0 commit comments