@@ -3484,9 +3484,15 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3484
3484
log_bytes!( payment_hash. 0 ) , total_value, $payment_data. total_msat) ;
3485
3485
fail_htlc!( claimable_htlc, payment_hash) ;
3486
3486
} else if total_value == $payment_data. total_msat {
3487
+ let phantom_shared_secret = claimable_htlc. prev_hop. phantom_shared_secret;
3487
3488
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
+ }
3488
3494
new_events. push( events:: Event :: PaymentReceived {
3489
- receiver_node_id: Some ( self . our_network_pubkey ) ,
3495
+ receiver_node_id: Some ( receiver_node_id ) ,
3490
3496
payment_hash,
3491
3497
purpose: purpose( ) ,
3492
3498
amount_msat: total_value,
@@ -3527,9 +3533,16 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3527
3533
match channel_state. claimable_htlcs . entry ( payment_hash) {
3528
3534
hash_map:: Entry :: Vacant ( e) => {
3529
3535
let purpose = events:: PaymentPurpose :: SpontaneousPayment ( preimage) ;
3536
+ let phantom_shared_secret = & claimable_htlc. prev_hop . phantom_shared_secret . clone ( ) ;
3530
3537
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
+ }
3531
3544
new_events. push ( events:: Event :: PaymentReceived {
3532
- receiver_node_id : Some ( self . our_network_pubkey ) ,
3545
+ receiver_node_id,
3533
3546
payment_hash,
3534
3547
amount_msat : outgoing_amt_msat,
3535
3548
purpose,
@@ -4196,6 +4209,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4196
4209
let mut claimed_any_htlcs = false ;
4197
4210
let mut channel_state_lock = self . channel_state . lock ( ) . unwrap ( ) ;
4198
4211
let channel_state = & mut * channel_state_lock;
4212
+ let mut receiver_node_id = Some ( self . our_network_pubkey ) ;
4199
4213
for htlc in sources. iter ( ) {
4200
4214
let chan_id = match self . short_to_chan_info . read ( ) . unwrap ( ) . get ( & htlc. prev_hop . short_channel_id ) {
4201
4215
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
4227
4241
break ;
4228
4242
}
4229
4243
}
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
+ }
4230
4250
4231
4251
claimable_amt_msat += htlc. value ;
4232
4252
}
@@ -4276,7 +4296,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4276
4296
4277
4297
if claimed_any_htlcs {
4278
4298
self . pending_events . lock ( ) . unwrap ( ) . push ( events:: Event :: PaymentClaimed {
4279
- receiver_node_id : Some ( self . our_network_pubkey ) ,
4299
+ receiver_node_id,
4280
4300
payment_hash,
4281
4301
purpose : payment_purpose,
4282
4302
amount_msat : claimable_amt_msat,
@@ -7490,6 +7510,13 @@ impl<'a, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
7490
7510
if let Some ( ( payment_purpose, claimable_htlcs) ) = claimable_htlcs. remove ( & payment_hash) {
7491
7511
log_info ! ( args. logger, "Re-claiming HTLCs with payment hash {} as we've released the preimage to a ChannelMonitor!" , log_bytes!( payment_hash. 0 ) ) ;
7492
7512
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
+ }
7493
7520
for claimable_htlc in claimable_htlcs {
7494
7521
claimable_amt_msat += claimable_htlc. value ;
7495
7522
@@ -7517,7 +7544,7 @@ impl<'a, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
7517
7544
}
7518
7545
}
7519
7546
pending_events_read. push ( events:: Event :: PaymentClaimed {
7520
- receiver_node_id : Some ( our_network_pubkey ) ,
7547
+ receiver_node_id,
7521
7548
payment_hash,
7522
7549
purpose : payment_purpose,
7523
7550
amount_msat : claimable_amt_msat,
0 commit comments