@@ -57,7 +57,7 @@ use crate::types::features::{Bolt12InvoiceFeatures, ChannelFeatures, ChannelType
57
57
#[cfg(any(feature = "_test_utils", test))]
58
58
use crate::types::features::Bolt11InvoiceFeatures;
59
59
use crate::routing::router::{BlindedTail, InFlightHtlcs, Path, Payee, PaymentParameters, RouteParameters, RouteParametersConfig, Router, FixedRouter, Route};
60
- use crate::ln::onion_payment::{check_incoming_htlc_cltv, create_recv_pending_htlc_info, create_fwd_pending_htlc_info, decode_incoming_update_add_htlc_onion, HopConnector, InboundHTLCErr, NextPacketDetails};
60
+ use crate::ln::onion_payment::{check_incoming_htlc_cltv, create_recv_pending_htlc_info, create_fwd_pending_htlc_info, decode_incoming_update_add_htlc_onion, HopConnector, InboundHTLCErr, NextPacketDetails, invalid_payment_err_data };
61
61
use crate::ln::msgs;
62
62
use crate::ln::onion_utils::{self};
63
63
use crate::ln::onion_utils::{HTLCFailReason, INVALID_ONION_BLINDING};
@@ -87,6 +87,7 @@ 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
+
90
91
#[cfg(async_payments)] use {
91
92
crate::offers::offer::Amount,
92
93
crate::offers::static_invoice::{DEFAULT_RELATIVE_EXPIRY as STATIC_INVOICE_DEFAULT_RELATIVE_EXPIRY, StaticInvoice, StaticInvoiceBuilder},
@@ -6262,10 +6263,7 @@ where
6262
6263
macro_rules! fail_htlc {
6263
6264
($htlc: expr, $payment_hash: expr) => {
6264
6265
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
- );
6266
+ let err_data = invalid_payment_err_data($htlc.value, self.best_block.read().unwrap().height);
6269
6267
failed_forwards.push((HTLCSource::PreviousHopData(HTLCPreviousHopData {
6270
6268
short_channel_id: $htlc.prev_hop.short_channel_id,
6271
6269
user_channel_id: $htlc.prev_hop.user_channel_id,
@@ -6278,7 +6276,7 @@ where
6278
6276
blinded_failure,
6279
6277
cltv_expiry: Some(cltv_expiry),
6280
6278
}), payment_hash,
6281
- HTLCFailReason::reason(0x4000 | 15, htlc_msat_height_data ),
6279
+ HTLCFailReason::reason(0x4000 | 15, err_data ),
6282
6280
HTLCDestination::FailedPayment { payment_hash: $payment_hash },
6283
6281
));
6284
6282
continue 'next_forwardable_htlc;
@@ -7231,10 +7229,9 @@ where
7231
7229
}
7232
7230
} else {
7233
7231
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());
7232
+ let err_data = invalid_payment_err_data(htlc.value, self.best_block.read().unwrap().height);
7236
7233
let source = HTLCSource::PreviousHopData(htlc.prev_hop);
7237
- let reason = HTLCFailReason::reason(0x4000 | 15, htlc_msat_height_data );
7234
+ let reason = HTLCFailReason::reason(0x4000 | 15, err_data );
7238
7235
let receiver = HTLCDestination::FailedPayment { payment_hash };
7239
7236
self.fail_htlc_backwards_internal(&source, &payment_hash, &reason, receiver);
7240
7237
}
@@ -11822,11 +11819,8 @@ where
11822
11819
// number of blocks we generally consider it to take to do a commitment update,
11823
11820
// just give up on it and fail the HTLC.
11824
11821
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
11822
timed_out_htlcs.push((HTLCSource::PreviousHopData(htlc.prev_hop.clone()), payment_hash.clone(),
11829
- HTLCFailReason::reason(0x4000 | 15, htlc_msat_height_data ),
11823
+ HTLCFailReason::reason(0x4000 | 15, invalid_payment_err_data(htlc.value, height) ),
11830
11824
HTLCDestination::FailedPayment { payment_hash: payment_hash.clone() }));
11831
11825
false
11832
11826
} else { true }
0 commit comments