@@ -3484,9 +3484,15 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
34843484 log_bytes!( payment_hash. 0 ) , total_value, $payment_data. total_msat) ;
34853485 fail_htlc!( claimable_htlc, payment_hash) ;
34863486 } else if total_value == $payment_data. total_msat {
3487+ let phantom_shared_secret = claimable_htlc. prev_hop. phantom_shared_secret;
34873488 htlcs. push( claimable_htlc) ;
3489+ let mut receiver_node_id = self . our_network_pubkey;
3490+ if phantom_shared_secret. is_some( ) {
3491+ receiver_node_id = self . keys_manager. get_node_id( Recipient :: PhantomNode )
3492+ . expect( "Failed to get node_id for phantom node recipient" ) ;
3493+ }
34883494 new_events. push( events:: Event :: PaymentReceived {
3489- receiver_node_id: Some ( self . our_network_pubkey ) ,
3495+ receiver_node_id: Some ( receiver_node_id ) ,
34903496 payment_hash,
34913497 purpose: purpose( ) ,
34923498 amount_msat: total_value,
@@ -3527,9 +3533,16 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
35273533 match channel_state. claimable_htlcs . entry ( payment_hash) {
35283534 hash_map:: Entry :: Vacant ( e) => {
35293535 let purpose = events:: PaymentPurpose :: SpontaneousPayment ( preimage) ;
3536+ let phantom_shared_secret = & claimable_htlc. prev_hop . phantom_shared_secret . clone ( ) ;
35303537 e. insert ( ( purpose. clone ( ) , vec ! [ claimable_htlc] ) ) ;
3538+ let mut receiver_node_id = Some ( self . our_network_pubkey ) ;
3539+ if phantom_shared_secret. is_some ( ) {
3540+ let phantom_pubkey = self . keys_manager . get_node_id ( Recipient :: PhantomNode )
3541+ . expect ( "Failed to get node_id for phantom node recipient" ) ;
3542+ receiver_node_id = Some ( phantom_pubkey)
3543+ }
35313544 new_events. push ( events:: Event :: PaymentReceived {
3532- receiver_node_id : Some ( self . our_network_pubkey ) ,
3545+ receiver_node_id,
35333546 payment_hash,
35343547 amount_msat : outgoing_amt_msat,
35353548 purpose,
@@ -4196,6 +4209,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
41964209 let mut claimed_any_htlcs = false ;
41974210 let mut channel_state_lock = self . channel_state . lock ( ) . unwrap ( ) ;
41984211 let channel_state = & mut * channel_state_lock;
4212+ let mut receiver_node_id = Some ( self . our_network_pubkey ) ;
41994213 for htlc in sources. iter ( ) {
42004214 let chan_id = match self . short_to_chan_info . read ( ) . unwrap ( ) . get ( & htlc. prev_hop . short_channel_id ) {
42014215 Some ( ( _cp_id, chan_id) ) => chan_id. clone ( ) ,
@@ -4227,6 +4241,12 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
42274241 break ;
42284242 }
42294243 }
4244+ let phantom_shared_secret = htlc. prev_hop . phantom_shared_secret ;
4245+ if phantom_shared_secret. is_some ( ) {
4246+ let phantom_pubkey = self . keys_manager . get_node_id ( Recipient :: PhantomNode )
4247+ . expect ( "Failed to get node_id for phantom node recipient" ) ;
4248+ receiver_node_id = Some ( phantom_pubkey)
4249+ }
42304250
42314251 claimable_amt_msat += htlc. value ;
42324252 }
@@ -4276,7 +4296,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
42764296
42774297 if claimed_any_htlcs {
42784298 self . pending_events . lock ( ) . unwrap ( ) . push ( events:: Event :: PaymentClaimed {
4279- receiver_node_id : Some ( self . our_network_pubkey ) ,
4299+ receiver_node_id,
42804300 payment_hash,
42814301 purpose : payment_purpose,
42824302 amount_msat : claimable_amt_msat,
@@ -7490,6 +7510,13 @@ impl<'a, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
74907510 if let Some ( ( payment_purpose, claimable_htlcs) ) = claimable_htlcs. remove ( & payment_hash) {
74917511 log_info ! ( args. logger, "Re-claiming HTLCs with payment hash {} as we've released the preimage to a ChannelMonitor!" , log_bytes!( payment_hash. 0 ) ) ;
74927512 let mut claimable_amt_msat = 0 ;
7513+ let mut receiver_node_id = Some ( our_network_pubkey) ;
7514+ let phantom_shared_secret = claimable_htlcs[ 0 ] . prev_hop . phantom_shared_secret ;
7515+ if phantom_shared_secret. is_some ( ) {
7516+ let phantom_pubkey = args. keys_manager . get_node_id ( Recipient :: PhantomNode )
7517+ . expect ( "Failed to get node_id for phantom node recipient" ) ;
7518+ receiver_node_id = Some ( phantom_pubkey)
7519+ }
74937520 for claimable_htlc in claimable_htlcs {
74947521 claimable_amt_msat += claimable_htlc. value ;
74957522
@@ -7517,7 +7544,7 @@ impl<'a, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
75177544 }
75187545 }
75197546 pending_events_read. push ( events:: Event :: PaymentClaimed {
7520- receiver_node_id : Some ( our_network_pubkey ) ,
7547+ receiver_node_id,
75217548 payment_hash,
75227549 purpose : payment_purpose,
75237550 amount_msat : claimable_amt_msat,
0 commit comments