@@ -79,6 +79,28 @@ impl_writeable_tlv_based_enum!(PaymentPurpose,
79
79
( 2 , SpontaneousPayment )
80
80
) ;
81
81
82
+ /// Information about an HTLC that is part of a payment that can be claimed.
83
+ #[ derive( Clone , Debug , PartialEq , Eq ) ]
84
+ pub struct ClaimedHTLC {
85
+ /// The SCID over which the HTLC was received.
86
+ pub short_channel_id : u64 ,
87
+ /// The HTLC's ID.
88
+ pub htlc_id : u64 ,
89
+ /// The block height at which this HTLC expires.
90
+ pub cltv_expiry : u32 ,
91
+ /// The amount (in msats) of this part of an MPP.
92
+ pub value : u64 ,
93
+ /// The sender-indented sum total of all MPP parts.
94
+ pub total_msat : u64 ,
95
+ }
96
+ impl_writeable_tlv_based ! ( ClaimedHTLC , {
97
+ ( 0 , short_channel_id, required) ,
98
+ ( 1 , htlc_id, required) ,
99
+ ( 2 , cltv_expiry, required) ,
100
+ ( 3 , value, required) ,
101
+ ( 4 , total_msat, required) ,
102
+ } ) ;
103
+
82
104
/// When the payment path failure took place and extra details about it. [`PathFailure::OnPath`] may
83
105
/// contain a [`NetworkUpdate`] that needs to be applied to the [`NetworkGraph`].
84
106
///
@@ -454,6 +476,8 @@ pub enum Event {
454
476
/// The purpose of the claimed payment, i.e. whether the payment was for an invoice or a
455
477
/// spontaneous payment.
456
478
purpose : PaymentPurpose ,
479
+ /// The HTLCs that comprise the claimed payment.
480
+ htlcs : Vec < ClaimedHTLC > ,
457
481
} ,
458
482
/// Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target
459
483
/// and we got back the payment preimage for it).
@@ -999,13 +1023,14 @@ impl Writeable for Event {
999
1023
// We never write the OpenChannelRequest events as, upon disconnection, peers
1000
1024
// drop any channels which have not yet exchanged funding_signed.
1001
1025
} ,
1002
- & Event :: PaymentClaimed { ref payment_hash, ref amount_msat, ref purpose, ref receiver_node_id } => {
1026
+ & Event :: PaymentClaimed { ref payment_hash, ref amount_msat, ref purpose, ref receiver_node_id, ref htlcs } => {
1003
1027
19u8 . write ( writer) ?;
1004
1028
write_tlv_fields ! ( writer, {
1005
1029
( 0 , payment_hash, required) ,
1006
1030
( 1 , receiver_node_id, option) ,
1007
1031
( 2 , purpose, required) ,
1008
1032
( 4 , amount_msat, required) ,
1033
+ ( 5 , htlcs. clone( ) , optional_vec) ,
1009
1034
} ) ;
1010
1035
} ,
1011
1036
& Event :: ProbeSuccessful { ref payment_id, ref payment_hash, ref path } => {
@@ -1325,17 +1350,20 @@ impl MaybeReadable for Event {
1325
1350
let mut purpose = UpgradableRequired ( None ) ;
1326
1351
let mut amount_msat = 0 ;
1327
1352
let mut receiver_node_id = None ;
1353
+ let mut htlcs: Option < Vec < ClaimedHTLC > > = Some ( vec ! [ ] ) ;
1328
1354
read_tlv_fields ! ( reader, {
1329
1355
( 0 , payment_hash, required) ,
1330
1356
( 1 , receiver_node_id, option) ,
1331
1357
( 2 , purpose, upgradable_required) ,
1332
1358
( 4 , amount_msat, required) ,
1359
+ ( 5 , htlcs, optional_vec) ,
1333
1360
} ) ;
1334
1361
Ok ( Some ( Event :: PaymentClaimed {
1335
1362
receiver_node_id,
1336
1363
payment_hash,
1337
1364
purpose : _init_tlv_based_struct_field ! ( purpose, upgradable_required) ,
1338
1365
amount_msat,
1366
+ htlcs : htlcs. unwrap_or ( vec ! [ ] ) ,
1339
1367
} ) )
1340
1368
} ;
1341
1369
f ( )
0 commit comments