@@ -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 incomplete vector for events created/serialized using LDK version 0.1.0 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 incomplete vector for events created/serialized using LDK version 0.1.0 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,29 @@ 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+ // Marked as legacy in version 0.2.0; superseded by `via_channel_ids`, which
1553+ // includes all channel IDs used in the payment instead of only the last one.
1554+ ( 3 , via_channel_id_legacy, option) ,
15481555 ( 4 , amount_msat, required) ,
1549- ( 5 , via_user_channel_id, option) ,
1556+ // Marked as legacy in version 0.2.0 for the same reason as `via_channel_id_legacy`;
1557+ // superseded by `via_user_channel_ids`.
1558+ ( 5 , via_user_channel_id_legacy, option) ,
15501559 // Type 6 was `user_payment_id` on 0.0.103 and earlier
15511560 ( 7 , claim_deadline, option) ,
15521561 ( 8 , payment_preimage, option) ,
15531562 ( 9 , onion_fields, option) ,
15541563 ( 10 , skimmed_fee_opt, option) ,
15551564 ( 11 , payment_context, option) ,
15561565 ( 13 , payment_id, option) ,
1566+ ( 15 , * via_channel_ids, optional_vec) ,
1567+ ( 17 , * via_user_channel_ids, optional_vec) ,
15571568 } ) ;
15581569 } ,
15591570 & Event :: PaymentSent { ref payment_id, ref payment_preimage, ref payment_hash, ref amount_msat, ref fee_paid_msat } => {
@@ -1849,41 +1860,54 @@ impl MaybeReadable for Event {
18491860 let mut counterparty_skimmed_fee_msat_opt = None ;
18501861 let mut receiver_node_id = None ;
18511862 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 ;
1863+ let mut via_channel_id_legacy = None ;
18531864 let mut claim_deadline = None ;
1854- let mut via_user_channel_id = None ;
1865+ let mut via_user_channel_id_legacy = None ;
18551866 let mut onion_fields = None ;
18561867 let mut payment_context = None ;
18571868 let mut payment_id = None ;
1869+ let mut via_channel_ids_opt = None ;
1870+ let mut via_user_channel_ids_opt = None ;
18581871 read_tlv_fields ! ( reader, {
18591872 ( 0 , payment_hash, required) ,
18601873 ( 1 , receiver_node_id, option) ,
18611874 ( 2 , payment_secret, option) ,
1862- ( 3 , via_channel_id , option) ,
1875+ ( 3 , via_channel_id_legacy , option) ,
18631876 ( 4 , amount_msat, required) ,
1864- ( 5 , via_user_channel_id , option) ,
1877+ ( 5 , via_user_channel_id_legacy , option) ,
18651878 ( 6 , _user_payment_id, option) ,
18661879 ( 7 , claim_deadline, option) ,
18671880 ( 8 , payment_preimage, option) ,
18681881 ( 9 , onion_fields, option) ,
18691882 ( 10 , counterparty_skimmed_fee_msat_opt, option) ,
18701883 ( 11 , payment_context, option) ,
18711884 ( 13 , payment_id, option) ,
1885+ ( 15 , via_channel_ids_opt, optional_vec) ,
1886+ ( 17 , via_user_channel_ids_opt, optional_vec) ,
18721887 } ) ;
18731888 let purpose = match payment_secret {
18741889 Some ( secret) => PaymentPurpose :: from_parts ( payment_preimage, secret, payment_context)
18751890 . map_err ( |( ) | msgs:: DecodeError :: InvalidValue ) ?,
18761891 None if payment_preimage. is_some ( ) => PaymentPurpose :: SpontaneousPayment ( payment_preimage. unwrap ( ) ) ,
18771892 None => return Err ( msgs:: DecodeError :: InvalidValue ) ,
18781893 } ;
1894+
1895+ let via_channel_ids = via_channel_ids_opt
1896+ . or_else ( || via_channel_id_legacy. map ( |id| vec ! [ id] ) )
1897+ . unwrap_or_default ( ) ;
1898+
1899+ let via_user_channel_ids = via_user_channel_ids_opt
1900+ . or_else ( || via_user_channel_id_legacy. map ( |id| vec ! [ id] ) )
1901+ . unwrap_or_default ( ) ;
1902+
18791903 Ok ( Some ( Event :: PaymentClaimable {
18801904 receiver_node_id,
18811905 payment_hash,
18821906 amount_msat,
18831907 counterparty_skimmed_fee_msat : counterparty_skimmed_fee_msat_opt. unwrap_or ( 0 ) ,
18841908 purpose,
1885- via_channel_id ,
1886- via_user_channel_id ,
1909+ via_channel_ids ,
1910+ via_user_channel_ids ,
18871911 claim_deadline,
18881912 onion_fields,
18891913 payment_id,
0 commit comments