@@ -774,10 +774,12 @@ pub enum Event {
774
774
/// Information for claiming this received payment, based on whether the purpose of the
775
775
/// payment is to pay an invoice or to send a spontaneous payment.
776
776
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 > ,
781
783
/// The block height at which this payment will be failed back and will no longer be
782
784
/// eligible for claiming.
783
785
///
@@ -1506,7 +1508,7 @@ impl Writeable for Event {
1506
1508
// drop any channels which have not yet exchanged funding_signed.
1507
1509
} ,
1508
1510
& 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 ,
1510
1512
ref claim_deadline, ref onion_fields, ref payment_id,
1511
1513
} => {
1512
1514
1u8 . write ( writer) ?;
@@ -1540,20 +1542,25 @@ impl Writeable for Event {
1540
1542
}
1541
1543
let skimmed_fee_opt = if counterparty_skimmed_fee_msat == 0 { None }
1542
1544
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 ( ) ;
1543
1548
write_tlv_fields ! ( writer, {
1544
1549
( 0 , payment_hash, required) ,
1545
1550
( 1 , receiver_node_id, option) ,
1546
1551
( 2 , payment_secret, option) ,
1547
- ( 3 , via_channel_id , option) ,
1552
+ ( 3 , via_channel_id_legacy , option) ,
1548
1553
( 4 , amount_msat, required) ,
1549
- ( 5 , via_user_channel_id , option) ,
1554
+ ( 5 , via_user_channel_id_legacy , option) ,
1550
1555
// Type 6 was `user_payment_id` on 0.0.103 and earlier
1551
1556
( 7 , claim_deadline, option) ,
1552
1557
( 8 , payment_preimage, option) ,
1553
1558
( 9 , onion_fields, option) ,
1554
1559
( 10 , skimmed_fee_opt, option) ,
1555
1560
( 11 , payment_context, option) ,
1556
1561
( 13 , payment_id, option) ,
1562
+ ( 15 , * via_channel_ids, optional_vec) ,
1563
+ ( 17 , * via_user_channel_ids, optional_vec) ,
1557
1564
} ) ;
1558
1565
} ,
1559
1566
& 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 {
1849
1856
let mut counterparty_skimmed_fee_msat_opt = None ;
1850
1857
let mut receiver_node_id = None ;
1851
1858
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 ;
1853
1860
let mut claim_deadline = None ;
1854
- let mut via_user_channel_id = None ;
1861
+ let mut via_user_channel_id_legacy = None ;
1855
1862
let mut onion_fields = None ;
1856
1863
let mut payment_context = None ;
1857
1864
let mut payment_id = None ;
1865
+ let mut via_channel_ids_opt = None ;
1866
+ let mut via_user_channel_ids_opt = None ;
1858
1867
read_tlv_fields ! ( reader, {
1859
1868
( 0 , payment_hash, required) ,
1860
1869
( 1 , receiver_node_id, option) ,
1861
1870
( 2 , payment_secret, option) ,
1862
- ( 3 , via_channel_id , option) ,
1871
+ ( 3 , via_channel_id_legacy , option) ,
1863
1872
( 4 , amount_msat, required) ,
1864
- ( 5 , via_user_channel_id , option) ,
1873
+ ( 5 , via_user_channel_id_legacy , option) ,
1865
1874
( 6 , _user_payment_id, option) ,
1866
1875
( 7 , claim_deadline, option) ,
1867
1876
( 8 , payment_preimage, option) ,
1868
1877
( 9 , onion_fields, option) ,
1869
1878
( 10 , counterparty_skimmed_fee_msat_opt, option) ,
1870
1879
( 11 , payment_context, option) ,
1871
1880
( 13 , payment_id, option) ,
1881
+ ( 15 , via_channel_ids_opt, optional_vec) ,
1882
+ ( 17 , via_user_channel_ids_opt, optional_vec) ,
1872
1883
} ) ;
1873
1884
let purpose = match payment_secret {
1874
1885
Some ( secret) => PaymentPurpose :: from_parts ( payment_preimage, secret, payment_context)
1875
1886
. map_err ( |( ) | msgs:: DecodeError :: InvalidValue ) ?,
1876
1887
None if payment_preimage. is_some ( ) => PaymentPurpose :: SpontaneousPayment ( payment_preimage. unwrap ( ) ) ,
1877
1888
None => return Err ( msgs:: DecodeError :: InvalidValue ) ,
1878
1889
} ;
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
+
1879
1899
Ok ( Some ( Event :: PaymentClaimable {
1880
1900
receiver_node_id,
1881
1901
payment_hash,
1882
1902
amount_msat,
1883
1903
counterparty_skimmed_fee_msat : counterparty_skimmed_fee_msat_opt. unwrap_or ( 0 ) ,
1884
1904
purpose,
1885
- via_channel_id ,
1886
- via_user_channel_id ,
1905
+ via_channel_ids ,
1906
+ via_user_channel_ids ,
1887
1907
claim_deadline,
1888
1908
onion_fields,
1889
1909
payment_id,
0 commit comments