5
5
// http://opensource.org/licenses/MIT>, at your option. You may not use this file except in
6
6
// accordance with one or both of these licenses.
7
7
8
- use crate :: types:: { DynStore , Sweeper , Wallet } ;
8
+ use crate :: types:: { CustomTlvRecord , DynStore , Sweeper , Wallet } ;
9
9
10
10
use crate :: {
11
11
hex_utils, BumpTransactionEventHandler , ChannelManager , Config , Error , Graph , PeerInfo ,
@@ -102,6 +102,8 @@ pub enum Event {
102
102
payment_hash : PaymentHash ,
103
103
/// The value, in thousandths of a satoshi, that has been received.
104
104
amount_msat : u64 ,
105
+ /// Custom TLV records received on the payment
106
+ custom_records : Vec < CustomTlvRecord > ,
105
107
} ,
106
108
/// A payment has been forwarded.
107
109
PaymentForwarded {
@@ -168,6 +170,8 @@ pub enum Event {
168
170
/// The block height at which this payment will be failed back and will no longer be
169
171
/// eligible for claiming.
170
172
claim_deadline : Option < u32 > ,
173
+ /// Custom TLV records attached to the payment
174
+ custom_records : Vec < CustomTlvRecord > ,
171
175
} ,
172
176
/// A channel has been created and is pending confirmation on-chain.
173
177
ChannelPending {
@@ -224,6 +228,7 @@ impl_writeable_tlv_based_enum!(Event,
224
228
( 0 , payment_hash, required) ,
225
229
( 1 , payment_id, option) ,
226
230
( 2 , amount_msat, required) ,
231
+ ( 3 , custom_records, optional_vec) ,
227
232
} ,
228
233
( 3 , ChannelReady ) => {
229
234
( 0 , channel_id, required) ,
@@ -248,6 +253,7 @@ impl_writeable_tlv_based_enum!(Event,
248
253
( 2 , payment_id, required) ,
249
254
( 4 , claimable_amount_msat, required) ,
250
255
( 6 , claim_deadline, option) ,
256
+ ( 7 , custom_records, optional_vec) ,
251
257
} ,
252
258
( 7 , PaymentForwarded ) => {
253
259
( 0 , prev_channel_id, required) ,
@@ -542,7 +548,7 @@ where
542
548
via_channel_id : _,
543
549
via_user_channel_id : _,
544
550
claim_deadline,
545
- onion_fields : _ ,
551
+ onion_fields,
546
552
counterparty_skimmed_fee_msat,
547
553
} => {
548
554
let payment_id = PaymentId ( payment_hash. 0 ) ;
@@ -644,11 +650,17 @@ where
644
650
"We would have registered the preimage if we knew"
645
651
) ;
646
652
653
+ let custom_records = onion_fields
654
+ . map ( |cf| {
655
+ cf. custom_tlvs ( ) . into_iter ( ) . map ( |tlv| tlv. into ( ) ) . collect ( )
656
+ } )
657
+ . unwrap_or_default ( ) ;
647
658
let event = Event :: PaymentClaimable {
648
659
payment_id,
649
660
payment_hash,
650
661
claimable_amount_msat : amount_msat,
651
662
claim_deadline,
663
+ custom_records,
652
664
} ;
653
665
match self . event_queue . add_event ( event) {
654
666
Ok ( _) => return Ok ( ( ) ) ,
@@ -799,7 +811,7 @@ where
799
811
receiver_node_id : _,
800
812
htlcs : _,
801
813
sender_intended_total_msat : _,
802
- onion_fields : _ ,
814
+ onion_fields,
803
815
} => {
804
816
let payment_id = PaymentId ( payment_hash. 0 ) ;
805
817
log_info ! (
@@ -875,6 +887,9 @@ where
875
887
payment_id : Some ( payment_id) ,
876
888
payment_hash,
877
889
amount_msat,
890
+ custom_records : onion_fields
891
+ . map ( |cf| cf. custom_tlvs ( ) . into_iter ( ) . map ( |tlv| tlv. into ( ) ) . collect ( ) )
892
+ . unwrap_or_default ( ) ,
878
893
} ;
879
894
match self . event_queue . add_event ( event) {
880
895
Ok ( _) => return Ok ( ( ) ) ,
0 commit comments