@@ -342,6 +342,13 @@ pub enum Event {
342
342
/// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
343
343
/// [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards
344
344
PaymentReceived {
345
+ /// The node that received the payment.
346
+ /// This is useful to identify payments which were received via [phantom node payments].
347
+ /// This field will always be filled in when the event was generated by LDK versions
348
+ /// 0.0.113 and above.
349
+ ///
350
+ /// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
351
+ receiver_node_id : Option < PublicKey > ,
345
352
/// The hash for which the preimage should be handed to the ChannelManager. Note that LDK will
346
353
/// not stop you from registering duplicate payment hashes for inbound payments.
347
354
payment_hash : PaymentHash ,
@@ -366,6 +373,13 @@ pub enum Event {
366
373
///
367
374
/// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
368
375
PaymentClaimed {
376
+ /// The node that received the payment.
377
+ /// This is useful to identify payments which were received via [phantom node payments].
378
+ /// This field will always be filled in when the event was generated by LDK versions
379
+ /// 0.0.113 and above.
380
+ ///
381
+ /// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
382
+ receiver_node_id : Option < PublicKey > ,
369
383
/// The payment hash of the claimed payment. Note that LDK will not stop you from
370
384
/// registering duplicate payment hashes for inbound payments.
371
385
payment_hash : PaymentHash ,
@@ -739,7 +753,7 @@ impl Writeable for Event {
739
753
// We never write out FundingGenerationReady events as, upon disconnection, peers
740
754
// drop any channels which have not yet exchanged funding_signed.
741
755
} ,
742
- & Event :: PaymentReceived { ref payment_hash, ref amount_msat, ref purpose } => {
756
+ & Event :: PaymentReceived { ref payment_hash, ref amount_msat, ref purpose, ref receiver_node_id } => {
743
757
1u8 . write ( writer) ?;
744
758
let mut payment_secret = None ;
745
759
let payment_preimage;
@@ -754,6 +768,7 @@ impl Writeable for Event {
754
768
}
755
769
write_tlv_fields ! ( writer, {
756
770
( 0 , payment_hash, required) ,
771
+ ( 1 , receiver_node_id, option) ,
757
772
( 2 , payment_secret, option) ,
758
773
( 4 , amount_msat, required) ,
759
774
( 6 , 0u64 , required) , // user_payment_id required for compatibility with 0.0.103 and earlier
@@ -854,10 +869,11 @@ impl Writeable for Event {
854
869
// We never write the OpenChannelRequest events as, upon disconnection, peers
855
870
// drop any channels which have not yet exchanged funding_signed.
856
871
} ,
857
- & Event :: PaymentClaimed { ref payment_hash, ref amount_msat, ref purpose } => {
872
+ & Event :: PaymentClaimed { ref payment_hash, ref amount_msat, ref purpose, ref receiver_node_id } => {
858
873
19u8 . write ( writer) ?;
859
874
write_tlv_fields ! ( writer, {
860
875
( 0 , payment_hash, required) ,
876
+ ( 1 , receiver_node_id, option) ,
861
877
( 2 , purpose, required) ,
862
878
( 4 , amount_msat, required) ,
863
879
} ) ;
@@ -923,9 +939,11 @@ impl MaybeReadable for Event {
923
939
let mut payment_preimage = None ;
924
940
let mut payment_secret = None ;
925
941
let mut amount_msat = 0 ;
942
+ let mut receiver_node_id = None ;
926
943
let mut _user_payment_id = None :: < u64 > ; // For compatibility with 0.0.103 and earlier
927
944
read_tlv_fields ! ( reader, {
928
945
( 0 , payment_hash, required) ,
946
+ ( 1 , receiver_node_id, option) ,
929
947
( 2 , payment_secret, option) ,
930
948
( 4 , amount_msat, required) ,
931
949
( 6 , _user_payment_id, option) ,
@@ -940,6 +958,7 @@ impl MaybeReadable for Event {
940
958
None => return Err ( msgs:: DecodeError :: InvalidValue ) ,
941
959
} ;
942
960
Ok ( Some ( Event :: PaymentReceived {
961
+ receiver_node_id,
943
962
payment_hash,
944
963
amount_msat,
945
964
purpose,
@@ -1117,13 +1136,16 @@ impl MaybeReadable for Event {
1117
1136
let mut payment_hash = PaymentHash ( [ 0 ; 32 ] ) ;
1118
1137
let mut purpose = None ;
1119
1138
let mut amount_msat = 0 ;
1139
+ let mut receiver_node_id = None ;
1120
1140
read_tlv_fields ! ( reader, {
1121
1141
( 0 , payment_hash, required) ,
1142
+ ( 1 , receiver_node_id, option) ,
1122
1143
( 2 , purpose, ignorable) ,
1123
1144
( 4 , amount_msat, required) ,
1124
1145
} ) ;
1125
1146
if purpose. is_none ( ) { return Ok ( None ) ; }
1126
1147
Ok ( Some ( Event :: PaymentClaimed {
1148
+ receiver_node_id,
1127
1149
payment_hash,
1128
1150
purpose : purpose. unwrap ( ) ,
1129
1151
amount_msat,
0 commit comments