@@ -774,10 +774,12 @@ pub enum Event {
774774 /// Information for claiming this received payment, based on whether the purpose of the
775775 /// payment is to pay an invoice or to send a spontaneous payment.
776776 purpose : PaymentPurpose ,
777- /// The `channel_id` indicating over which channel we received the payment.
778- via_channel_id : Option < ChannelId > ,
779- /// The `user_channel_id` indicating over which channel we received the payment.
780- via_user_channel_id : Option < u128 > ,
777+ /// The `channel_id`(s) over which the payment was received.
778+ /// This will be an empty vector for events created/serialised using LDK version 0.0.112 and prior.
779+ via_channel_ids : Vec < ChannelId > ,
780+ /// The `user_channel_id`(s) corresponding to the channels over which the payment was received.
781+ /// This will be an empty vector for HTLC events created/serialised using LDK version 0.0.112 and prior.
782+ via_user_channel_ids : Vec < u128 > ,
781783 /// The block height at which this payment will be failed back and will no longer be
782784 /// eligible for claiming.
783785 ///
@@ -1506,7 +1508,7 @@ impl Writeable for Event {
15061508 // drop any channels which have not yet exchanged funding_signed.
15071509 } ,
15081510 & Event :: PaymentClaimable { ref payment_hash, ref amount_msat, counterparty_skimmed_fee_msat,
1509- ref purpose, ref receiver_node_id, ref via_channel_id , ref via_user_channel_id ,
1511+ ref purpose, ref receiver_node_id, ref via_channel_ids , ref via_user_channel_ids ,
15101512 ref claim_deadline, ref onion_fields, ref payment_id,
15111513 } => {
15121514 1u8 . write ( writer) ?;
@@ -1540,20 +1542,25 @@ impl Writeable for Event {
15401542 }
15411543 let skimmed_fee_opt = if counterparty_skimmed_fee_msat == 0 { None }
15421544 else { Some ( counterparty_skimmed_fee_msat) } ;
1545+
1546+ let via_channel_id_legacy = via_channel_ids. last ( ) . cloned ( ) ;
1547+ let via_user_channel_id_legacy = via_user_channel_ids. last ( ) . cloned ( ) ;
15431548 write_tlv_fields ! ( writer, {
15441549 ( 0 , payment_hash, required) ,
15451550 ( 1 , receiver_node_id, option) ,
15461551 ( 2 , payment_secret, option) ,
1547- ( 3 , via_channel_id , option) ,
1552+ ( 3 , via_channel_id_legacy , option) ,
15481553 ( 4 , amount_msat, required) ,
1549- ( 5 , via_user_channel_id , option) ,
1554+ ( 5 , via_user_channel_id_legacy , option) ,
15501555 // Type 6 was `user_payment_id` on 0.0.103 and earlier
15511556 ( 7 , claim_deadline, option) ,
15521557 ( 8 , payment_preimage, option) ,
15531558 ( 9 , onion_fields, option) ,
15541559 ( 10 , skimmed_fee_opt, option) ,
15551560 ( 11 , payment_context, option) ,
15561561 ( 13 , payment_id, option) ,
1562+ ( 15 , * via_channel_ids, optional_vec) ,
1563+ ( 17 , * via_user_channel_ids, optional_vec) ,
15571564 } ) ;
15581565 } ,
15591566 & Event :: PaymentSent { ref payment_id, ref payment_preimage, ref payment_hash, ref amount_msat, ref fee_paid_msat } => {
@@ -1849,41 +1856,54 @@ impl MaybeReadable for Event {
18491856 let mut counterparty_skimmed_fee_msat_opt = None ;
18501857 let mut receiver_node_id = None ;
18511858 let mut _user_payment_id = None :: < u64 > ; // Used in 0.0.103 and earlier, no longer written in 0.0.116+.
1852- let mut via_channel_id = None ;
1859+ let mut via_channel_id_legacy = None ;
18531860 let mut claim_deadline = None ;
1854- let mut via_user_channel_id = None ;
1861+ let mut via_user_channel_id_legacy = None ;
18551862 let mut onion_fields = None ;
18561863 let mut payment_context = None ;
18571864 let mut payment_id = None ;
1865+ let mut via_channel_ids_opt = None ;
1866+ let mut via_user_channel_ids_opt = None ;
18581867 read_tlv_fields ! ( reader, {
18591868 ( 0 , payment_hash, required) ,
18601869 ( 1 , receiver_node_id, option) ,
18611870 ( 2 , payment_secret, option) ,
1862- ( 3 , via_channel_id , option) ,
1871+ ( 3 , via_channel_id_legacy , option) ,
18631872 ( 4 , amount_msat, required) ,
1864- ( 5 , via_user_channel_id , option) ,
1873+ ( 5 , via_user_channel_id_legacy , option) ,
18651874 ( 6 , _user_payment_id, option) ,
18661875 ( 7 , claim_deadline, option) ,
18671876 ( 8 , payment_preimage, option) ,
18681877 ( 9 , onion_fields, option) ,
18691878 ( 10 , counterparty_skimmed_fee_msat_opt, option) ,
18701879 ( 11 , payment_context, option) ,
18711880 ( 13 , payment_id, option) ,
1881+ ( 15 , via_channel_ids_opt, optional_vec) ,
1882+ ( 17 , via_user_channel_ids_opt, optional_vec) ,
18721883 } ) ;
18731884 let purpose = match payment_secret {
18741885 Some ( secret) => PaymentPurpose :: from_parts ( payment_preimage, secret, payment_context)
18751886 . map_err ( |( ) | msgs:: DecodeError :: InvalidValue ) ?,
18761887 None if payment_preimage. is_some ( ) => PaymentPurpose :: SpontaneousPayment ( payment_preimage. unwrap ( ) ) ,
18771888 None => return Err ( msgs:: DecodeError :: InvalidValue ) ,
18781889 } ;
1890+
1891+ let via_channel_ids = via_channel_ids_opt
1892+ . or_else ( || via_channel_id_legacy. map ( |id| vec ! [ id] ) )
1893+ . unwrap_or_default ( ) ;
1894+
1895+ let via_user_channel_ids = via_user_channel_ids_opt
1896+ . or_else ( || via_user_channel_id_legacy. map ( |id| vec ! [ id] ) )
1897+ . unwrap_or_default ( ) ;
1898+
18791899 Ok ( Some ( Event :: PaymentClaimable {
18801900 receiver_node_id,
18811901 payment_hash,
18821902 amount_msat,
18831903 counterparty_skimmed_fee_msat : counterparty_skimmed_fee_msat_opt. unwrap_or ( 0 ) ,
18841904 purpose,
1885- via_channel_id ,
1886- via_user_channel_id ,
1905+ via_channel_ids ,
1906+ via_user_channel_ids ,
18871907 claim_deadline,
18881908 onion_fields,
18891909 payment_id,
0 commit comments