55// http://opensource.org/licenses/MIT>, at your option. You may not use this file except in
66// accordance with one or both of these licenses.
77
8- use crate :: types:: { DynStore , Sweeper , TlvEntries , Wallet } ;
8+ use crate :: types:: { CustomTlvRecord , DynStore , Sweeper , Wallet } ;
99
1010use crate :: {
1111 hex_utils, BumpTransactionEventHandler , ChannelManager , Config , Error , Graph , PeerInfo ,
@@ -103,7 +103,7 @@ pub enum Event {
103103 /// The value, in thousandths of a satoshi, that has been received.
104104 amount_msat : u64 ,
105105 /// Custom TLV records received on the payment
106- custom_records : Option < TlvEntries > ,
106+ custom_records : Vec < CustomTlvRecord > ,
107107 } ,
108108 /// A payment has been forwarded.
109109 PaymentForwarded {
@@ -171,7 +171,7 @@ pub enum Event {
171171 /// eligible for claiming.
172172 claim_deadline : Option < u32 > ,
173173 /// Custom TLV records attached to the payment
174- custom_records : Option < TlvEntries > ,
174+ custom_records : Vec < CustomTlvRecord > ,
175175 } ,
176176 /// A channel has been created and is pending confirmation on-chain.
177177 ChannelPending {
@@ -228,7 +228,7 @@ impl_writeable_tlv_based_enum!(Event,
228228 ( 0 , payment_hash, required) ,
229229 ( 1 , payment_id, option) ,
230230 ( 2 , amount_msat, required) ,
231- ( 3 , custom_records, option ) ,
231+ ( 3 , custom_records, optional_vec ) ,
232232 } ,
233233 ( 3 , ChannelReady ) => {
234234 ( 0 , channel_id, required) ,
@@ -253,7 +253,7 @@ impl_writeable_tlv_based_enum!(Event,
253253 ( 2 , payment_id, required) ,
254254 ( 4 , claimable_amount_msat, required) ,
255255 ( 6 , claim_deadline, option) ,
256- ( 8 , custom_records, option ) ,
256+ ( 8 , custom_records, optional_vec ) ,
257257 } ,
258258 ( 7 , PaymentForwarded ) => {
259259 ( 0 , prev_channel_id, required) ,
@@ -650,19 +650,17 @@ where
650650 "We would have registered the preimage if we knew"
651651 ) ;
652652
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 ( ) ;
653658 let event = Event :: PaymentClaimable {
654659 payment_id,
655660 payment_hash,
656661 claimable_amount_msat : amount_msat,
657662 claim_deadline,
658- custom_records : onion_fields. map ( |cf| {
659- TlvEntries (
660- cf. custom_tlvs ( )
661- . into_iter ( )
662- . map ( |tlv| tlv. into ( ) )
663- . collect ( ) ,
664- )
665- } ) ,
663+ custom_records,
666664 } ;
667665 match self . event_queue . add_event ( event) {
668666 Ok ( _) => return Ok ( ( ) ) ,
@@ -889,9 +887,9 @@ where
889887 payment_id : Some ( payment_id) ,
890888 payment_hash,
891889 amount_msat,
892- custom_records : onion_fields. map ( |cf| {
893- TlvEntries ( cf. custom_tlvs ( ) . into_iter ( ) . map ( |tlv| tlv. into ( ) ) . collect ( ) )
894- } ) ,
890+ custom_records : onion_fields
891+ . map ( |cf| cf. custom_tlvs ( ) . into_iter ( ) . map ( |tlv| tlv. into ( ) ) . collect ( ) )
892+ . unwrap_or_default ( ) ,
895893 } ;
896894 match self . event_queue . add_event ( event) {
897895 Ok ( _) => return Ok ( ( ) ) ,
0 commit comments