@@ -87,6 +87,8 @@ use crate::util::string::UntrustedString;
87
87
use crate::util::ser::{BigSize, FixedLengthReader, LengthReadable, Readable, ReadableArgs, MaybeReadable, Writeable, Writer, VecWriter};
88
88
use crate::util::logger::{Level, Logger, WithContext};
89
89
use crate::util::errors::APIError;
90
+ use super::onion_payment::invalid_payment_err_data;
91
+
90
92
#[cfg(async_payments)] use {
91
93
crate::offers::offer::Amount,
92
94
crate::offers::static_invoice::{DEFAULT_RELATIVE_EXPIRY as STATIC_INVOICE_DEFAULT_RELATIVE_EXPIRY, StaticInvoice, StaticInvoiceBuilder},
@@ -6262,10 +6264,7 @@ where
6262
6264
macro_rules! fail_htlc {
6263
6265
($htlc: expr, $payment_hash: expr) => {
6264
6266
debug_assert!(!committed_to_claimable);
6265
- let mut htlc_msat_height_data = $htlc.value.to_be_bytes().to_vec();
6266
- htlc_msat_height_data.extend_from_slice(
6267
- &self.best_block.read().unwrap().height.to_be_bytes(),
6268
- );
6267
+ let err_data = invalid_payment_err_data($htlc.value, self.best_block.read().unwrap().height);
6269
6268
failed_forwards.push((HTLCSource::PreviousHopData(HTLCPreviousHopData {
6270
6269
short_channel_id: $htlc.prev_hop.short_channel_id,
6271
6270
user_channel_id: $htlc.prev_hop.user_channel_id,
@@ -6278,7 +6277,7 @@ where
6278
6277
blinded_failure,
6279
6278
cltv_expiry: Some(cltv_expiry),
6280
6279
}), payment_hash,
6281
- HTLCFailReason::reason(0x4000 | 15, htlc_msat_height_data ),
6280
+ HTLCFailReason::reason(0x4000 | 15, err_data ),
6282
6281
HTLCDestination::FailedPayment { payment_hash: $payment_hash },
6283
6282
));
6284
6283
continue 'next_forwardable_htlc;
@@ -7231,10 +7230,9 @@ where
7231
7230
}
7232
7231
} else {
7233
7232
for htlc in sources {
7234
- let mut htlc_msat_height_data = htlc.value.to_be_bytes().to_vec();
7235
- htlc_msat_height_data.extend_from_slice(&self.best_block.read().unwrap().height.to_be_bytes());
7233
+ let err_data = invalid_payment_err_data(htlc.value, self.best_block.read().unwrap().height);
7236
7234
let source = HTLCSource::PreviousHopData(htlc.prev_hop);
7237
- let reason = HTLCFailReason::reason(0x4000 | 15, htlc_msat_height_data );
7235
+ let reason = HTLCFailReason::reason(0x4000 | 15, err_data );
7238
7236
let receiver = HTLCDestination::FailedPayment { payment_hash };
7239
7237
self.fail_htlc_backwards_internal(&source, &payment_hash, &reason, receiver);
7240
7238
}
@@ -11822,11 +11820,8 @@ where
11822
11820
// number of blocks we generally consider it to take to do a commitment update,
11823
11821
// just give up on it and fail the HTLC.
11824
11822
if height >= htlc.cltv_expiry - HTLC_FAIL_BACK_BUFFER {
11825
- let mut htlc_msat_height_data = htlc.value.to_be_bytes().to_vec();
11826
- htlc_msat_height_data.extend_from_slice(&height.to_be_bytes());
11827
-
11828
11823
timed_out_htlcs.push((HTLCSource::PreviousHopData(htlc.prev_hop.clone()), payment_hash.clone(),
11829
- HTLCFailReason::reason(0x4000 | 15, htlc_msat_height_data ),
11824
+ HTLCFailReason::reason(0x4000 | 15, invalid_payment_err_data(htlc.value, height) ),
11830
11825
HTLCDestination::FailedPayment { payment_hash: payment_hash.clone() }));
11831
11826
false
11832
11827
} else { true }
0 commit comments