Skip to content

Commit 516bf96

Browse files
committed
Add hold times to update_fulfill_htlc
1 parent 34fd047 commit 516bf96

File tree

10 files changed

+409
-110
lines changed

10 files changed

+409
-110
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: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,8 @@ 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+
/// The hold times as reported by each hop.
1084+
hold_times: Option<Vec<u32>>,
10831085
},
10841086
/// Indicates an outbound HTLC we sent failed, likely due to an intermediary node being unable to
10851087
/// handle the HTLC.
@@ -1816,13 +1818,19 @@ impl Writeable for Event {
18161818
(4, funding_info, required),
18171819
})
18181820
},
1819-
&Event::PaymentPathSuccessful { ref payment_id, ref payment_hash, ref path } => {
1821+
&Event::PaymentPathSuccessful {
1822+
ref payment_id,
1823+
ref payment_hash,
1824+
ref path,
1825+
ref hold_times,
1826+
} => {
18201827
13u8.write(writer)?;
18211828
write_tlv_fields!(writer, {
18221829
(0, payment_id, required),
18231830
(2, payment_hash, option),
18241831
(4, path.hops, required_vec),
18251832
(6, path.blinded_tail, option),
1833+
(8, hold_times, option),
18261834
})
18271835
},
18281836
&Event::PaymentFailed { ref payment_id, ref payment_hash, ref reason } => {
@@ -2311,11 +2319,13 @@ impl MaybeReadable for Event {
23112319
(2, payment_hash, option),
23122320
(4, path, required_vec),
23132321
(6, blinded_tail, option),
2322+
(8, hold_times, option),
23142323
});
23152324
Ok(Some(Event::PaymentPathSuccessful {
23162325
payment_id: payment_id.0.unwrap(),
23172326
payment_hash,
23182327
path: Path { hops: path, blinded_tail },
2328+
hold_times,
23192329
}))
23202330
};
23212331
f()

0 commit comments

Comments
 (0)