Skip to content

Commit f5668f5

Browse files
committed
Add hold times to update_fulfill_htlc
1 parent b6cc0d7 commit f5668f5

File tree

11 files changed

+432
-114
lines changed

11 files changed

+432
-114
lines changed

fuzz/src/process_onion_failure.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
115115
let path = Path { hops, blinded_tail };
116116

117117
let htlc_source = HTLCSource::OutboundRoute {
118-
path,
118+
path: path.clone(),
119119
session_priv,
120120
first_hop_htlc_msat: 0,
121121
payment_id,
@@ -133,8 +133,19 @@ fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
133133
} else {
134134
None
135135
};
136-
let encrypted_packet = OnionErrorPacket { data: failure_data.into(), attribution_data };
136+
let encrypted_packet =
137+
OnionErrorPacket { data: failure_data.into(), attribution_data: attribution_data.clone() };
137138
lightning::ln::process_onion_failure(&secp_ctx, &logger, &htlc_source, encrypted_packet);
139+
140+
if let Some(attribution_data) = attribution_data {
141+
lightning::ln::process_onion_success(
142+
&secp_ctx,
143+
&logger,
144+
&path,
145+
&session_priv,
146+
attribution_data,
147+
);
148+
}
138149
}
139150

140151
/// Method that needs to be added manually, {name}_test

lightning-background-processor/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2732,6 +2732,7 @@ mod tests {
27322732
payment_id: PaymentId([42; 32]),
27332733
payment_hash: None,
27342734
path: path.clone(),
2735+
hold_times: None,
27352736
});
27362737
let event = $receive.expect("PaymentPathSuccessful not handled within deadline");
27372738
match event {

lightning/src/events/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,9 @@ pub enum Event {
10801080
///
10811081
/// May contain a closed channel if the HTLC sent along the path was fulfilled on chain.
10821082
path: Path,
1083+
1084+
/// The hold times as reported by each hop.
1085+
hold_times: Option<Vec<u32>>,
10831086
},
10841087
/// Indicates an outbound HTLC we sent failed, likely due to an intermediary node being unable to
10851088
/// handle the HTLC.
@@ -1816,13 +1819,19 @@ impl Writeable for Event {
18161819
(4, funding_info, required),
18171820
})
18181821
},
1819-
&Event::PaymentPathSuccessful { ref payment_id, ref payment_hash, ref path } => {
1822+
&Event::PaymentPathSuccessful {
1823+
ref payment_id,
1824+
ref payment_hash,
1825+
ref path,
1826+
ref hold_times,
1827+
} => {
18201828
13u8.write(writer)?;
18211829
write_tlv_fields!(writer, {
18221830
(0, payment_id, required),
18231831
(2, payment_hash, option),
18241832
(4, path.hops, required_vec),
18251833
(6, path.blinded_tail, option),
1834+
(8, hold_times, option),
18261835
})
18271836
},
18281837
&Event::PaymentFailed { ref payment_id, ref payment_hash, ref reason } => {
@@ -2311,11 +2320,13 @@ impl MaybeReadable for Event {
23112320
(2, payment_hash, option),
23122321
(4, path, required_vec),
23132322
(6, blinded_tail, option),
2323+
(8, hold_times, option),
23142324
});
23152325
Ok(Some(Event::PaymentPathSuccessful {
23162326
payment_id: payment_id.0.unwrap(),
23172327
payment_hash,
23182328
path: Path { hops: path, blinded_tail },
2329+
hold_times,
23192330
}))
23202331
};
23212332
f()

0 commit comments

Comments
 (0)