@@ -20,21 +20,22 @@ use super::async_payments::AsyncPaymentsMessage;
2020use super :: async_payments:: AsyncPaymentsMessageHandler ;
2121use super :: dns_resolution:: { DNSResolverMessage , DNSResolverMessageHandler } ;
2222use super :: offers:: { OffersMessage , OffersMessageHandler } ;
23- use super :: packet:: OnionMessageContents ;
2423use super :: packet:: ParsedOnionMessageContents ;
24+ use super :: packet:: { DummyControlTlvs , OnionMessageContents } ;
2525use super :: packet:: {
2626 ForwardControlTlvs , Packet , Payload , ReceiveControlTlvs , BIG_PACKET_HOP_DATA_LEN ,
2727 SMALL_PACKET_HOP_DATA_LEN ,
2828} ;
2929#[ cfg( async_payments) ]
3030use crate :: blinded_path:: message:: AsyncPaymentsContext ;
3131use crate :: blinded_path:: message:: {
32- BlindedMessagePath , DNSResolverContext , ForwardTlvs , MessageContext , MessageForwardNode ,
32+ BlindedMessagePath , DNSResolverContext , DummyTlvs , ForwardTlvs , MessageContext , MessageForwardNode ,
3333 NextMessageHop , OffersContext , ReceiveTlvs ,
3434} ;
3535use crate :: blinded_path:: utils;
3636use crate :: blinded_path:: { IntroductionNode , NodeIdLookUp } ;
3737use crate :: events:: { Event , EventHandler , EventsProvider , ReplayEvent } ;
38+ use crate :: ln:: channelmanager:: Verification ;
3839use crate :: ln:: msgs:: {
3940 self , BaseMessageHandler , MessageSendEvent , OnionMessage , OnionMessageHandler , SocketAddress ,
4041} ;
@@ -1140,18 +1141,52 @@ where
11401141 Err ( ( ) )
11411142 } ,
11421143 } ,
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+ } ,
11431183 Ok ( (
11441184 Payload :: Forward ( ForwardControlTlvs :: Unblinded ( ForwardTlvs {
11451185 next_hop,
11461186 next_blinding_override,
11471187 } ) ) ,
11481188 Some ( ( next_hop_hmac, new_packet_bytes) ) ,
11491189 ) ) => {
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.
11551190 let packet_pubkey = msg. onion_routing_packet . public_key ;
11561191 let new_pubkey_opt =
11571192 onion_utils:: next_hop_pubkey ( & secp_ctx, packet_pubkey, & onion_decode_ss) ;
0 commit comments