@@ -57,7 +57,7 @@ use crate::types::features::{Bolt12InvoiceFeatures, ChannelFeatures, ChannelType
5757#[cfg(any(feature = "_test_utils", test))]
5858use crate::types::features::Bolt11InvoiceFeatures;
5959use 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 };
6161use crate::ln::msgs;
6262use crate::ln::onion_utils::{self};
6363use crate::ln::onion_utils::{HTLCFailReason, INVALID_ONION_BLINDING};
@@ -87,6 +87,7 @@ use crate::util::string::UntrustedString;
8787use crate::util::ser::{BigSize, FixedLengthReader, LengthReadable, Readable, ReadableArgs, MaybeReadable, Writeable, Writer, VecWriter};
8888use crate::util::logger::{Level, Logger, WithContext};
8989use crate::util::errors::APIError;
90+
9091#[cfg(async_payments)] use {
9192 crate::offers::offer::Amount,
9293 crate::offers::static_invoice::{DEFAULT_RELATIVE_EXPIRY as STATIC_INVOICE_DEFAULT_RELATIVE_EXPIRY, StaticInvoice, StaticInvoiceBuilder},
@@ -6262,10 +6263,7 @@ where
62626263 macro_rules! fail_htlc {
62636264 ($htlc: expr, $payment_hash: expr) => {
62646265 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);
62696267 failed_forwards.push((HTLCSource::PreviousHopData(HTLCPreviousHopData {
62706268 short_channel_id: $htlc.prev_hop.short_channel_id,
62716269 user_channel_id: $htlc.prev_hop.user_channel_id,
@@ -6278,7 +6276,7 @@ where
62786276 blinded_failure,
62796277 cltv_expiry: Some(cltv_expiry),
62806278 }), payment_hash,
6281- HTLCFailReason::reason(0x4000 | 15, htlc_msat_height_data ),
6279+ HTLCFailReason::reason(0x4000 | 15, err_data ),
62826280 HTLCDestination::FailedPayment { payment_hash: $payment_hash },
62836281 ));
62846282 continue 'next_forwardable_htlc;
@@ -7231,10 +7229,9 @@ where
72317229 }
72327230 } else {
72337231 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);
72367233 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 );
72387235 let receiver = HTLCDestination::FailedPayment { payment_hash };
72397236 self.fail_htlc_backwards_internal(&source, &payment_hash, &reason, receiver);
72407237 }
@@ -11822,11 +11819,8 @@ where
1182211819 // number of blocks we generally consider it to take to do a commitment update,
1182311820 // just give up on it and fail the HTLC.
1182411821 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-
1182811822 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) ),
1183011824 HTLCDestination::FailedPayment { payment_hash: payment_hash.clone() }));
1183111825 false
1183211826 } else { true }
0 commit comments