@@ -4352,25 +4352,22 @@ where
43524352
43534353 fn can_forward_htlc_to_outgoing_channel(
43544354 &self, chan: &mut FundedChannel<SP>, msg: &msgs::UpdateAddHTLC, next_packet: &NextPacketDetails
4355- ) -> Result<(), (&'static str, LocalHTLCFailureReason) > {
4355+ ) -> Result<(), LocalHTLCFailureReason> {
43564356 if !chan.context.should_announce() && !self.default_configuration.accept_forwards_to_priv_channels {
43574357 // Note that the behavior here should be identical to the above block - we
43584358 // should NOT reveal the existence or non-existence of a private channel if
43594359 // we don't allow forwards outbound over them.
4360- return Err(("Refusing to forward to a private channel based on our config.",
4361- LocalHTLCFailureReason::PrivateChannelForward));
4360+ return Err(LocalHTLCFailureReason::PrivateChannelForward);
43624361 }
43634362 if let HopConnector::ShortChannelId(outgoing_scid) = next_packet.outgoing_connector {
43644363 if chan.funding.get_channel_type().supports_scid_privacy() && outgoing_scid != chan.context.outbound_scid_alias() {
43654364 // `option_scid_alias` (referred to in LDK as `scid_privacy`) means
43664365 // "refuse to forward unless the SCID alias was used", so we pretend
43674366 // we don't have the channel here.
4368- return Err(("Refusing to forward over real channel SCID as our counterparty requested.",
4369- LocalHTLCFailureReason::RealSCIDForward));
4367+ return Err(LocalHTLCFailureReason::RealSCIDForward);
43704368 }
43714369 } else {
4372- return Err(("Cannot forward by Node ID without SCID.",
4373- LocalHTLCFailureReason::InvalidTrampolineForward));
4370+ return Err(LocalHTLCFailureReason::InvalidTrampolineForward);
43744371 }
43754372
43764373 // Note that we could technically not return an error yet here and just hope
@@ -4380,16 +4377,13 @@ where
43804377 // on a small/per-node/per-channel scale.
43814378 if !chan.context.is_live() {
43824379 if !chan.context.is_enabled() {
4383- return Err(("Forwarding channel has been disconnected for some time.",
4384- LocalHTLCFailureReason::ChannelDisabled));
4380+ return Err(LocalHTLCFailureReason::ChannelDisabled);
43854381 } else {
4386- return Err(("Forwarding channel is not in a ready state.",
4387- LocalHTLCFailureReason::ChannelNotReady));
4382+ return Err(LocalHTLCFailureReason::ChannelNotReady);
43884383 }
43894384 }
43904385 if next_packet.outgoing_amt_msat < chan.context.get_counterparty_htlc_minimum_msat() {
4391- return Err(("HTLC amount was below the htlc_minimum_msat",
4392- LocalHTLCFailureReason::AmountBelowMinimum));
4386+ return Err(LocalHTLCFailureReason::AmountBelowMinimum);
43934387 }
43944388 chan.htlc_satisfies_config(msg, next_packet.outgoing_amt_msat, next_packet.outgoing_cltv_value)?;
43954389
@@ -4420,12 +4414,11 @@ where
44204414
44214415 fn can_forward_htlc(
44224416 &self, msg: &msgs::UpdateAddHTLC, next_packet_details: &NextPacketDetails
4423- ) -> Result<(), (&'static str, LocalHTLCFailureReason) > {
4417+ ) -> Result<(), LocalHTLCFailureReason> {
44244418 let outgoing_scid = match next_packet_details.outgoing_connector {
44254419 HopConnector::ShortChannelId(scid) => scid,
44264420 HopConnector::Trampoline(_) => {
4427- return Err(("Cannot forward by Node ID without SCID.",
4428- LocalHTLCFailureReason::InvalidTrampolineForward));
4421+ return Err(LocalHTLCFailureReason::InvalidTrampolineForward);
44294422 }
44304423 };
44314424 match self.do_funded_channel_callback(outgoing_scid, |chan: &mut FundedChannel<SP>| {
@@ -4440,8 +4433,7 @@ where
44404433 fake_scid::is_valid_intercept(&self.fake_scid_rand_bytes, outgoing_scid, &self.chain_hash)) ||
44414434 fake_scid::is_valid_phantom(&self.fake_scid_rand_bytes, outgoing_scid, &self.chain_hash)
44424435 {} else {
4443- return Err(("Don't have available channel for forwarding as requested.",
4444- LocalHTLCFailureReason::UnknownNextPeer));
4436+ return Err(LocalHTLCFailureReason::UnknownNextPeer);
44454437 }
44464438 }
44474439 }
@@ -4453,7 +4445,7 @@ where
44534445 }
44544446
44554447 fn htlc_failure_from_update_add_err(
4456- &self, msg: &msgs::UpdateAddHTLC, counterparty_node_id: &PublicKey, err_msg: &'static str,
4448+ &self, msg: &msgs::UpdateAddHTLC, counterparty_node_id: &PublicKey,
44574449 reason: LocalHTLCFailureReason, is_intro_node_blinded_forward: bool,
44584450 shared_secret: &[u8; 32]
44594451 ) -> HTLCFailureMsg {
@@ -4477,7 +4469,7 @@ where
44774469
44784470 log_info!(
44794471 WithContext::from(&self.logger, Some(*counterparty_node_id), Some(msg.channel_id), Some(msg.payment_hash)),
4480- "Failed to accept/forward incoming HTLC: {}", err_msg
4472+ "Failed to accept/forward incoming HTLC: {:? }", reason,
44814473 );
44824474 // If `msg.blinding_point` is set, we must always fail with malformed.
44834475 if msg.blinding_point.is_some() {
@@ -5820,9 +5812,9 @@ where
58205812 )
58215813 }) {
58225814 Some(Ok(_)) => {},
5823- Some(Err((err, reason) )) => {
5815+ Some(Err(reason)) => {
58245816 let htlc_fail = self.htlc_failure_from_update_add_err(
5825- &update_add_htlc, &incoming_counterparty_node_id, err, reason,
5817+ &update_add_htlc, &incoming_counterparty_node_id, reason,
58265818 is_intro_node_blinded_forward, &shared_secret,
58275819 );
58285820 let failure_type = get_htlc_failure_type(outgoing_scid_opt, update_add_htlc.payment_hash);
@@ -5835,11 +5827,11 @@ where
58355827
58365828 // Now process the HTLC on the outgoing channel if it's a forward.
58375829 if let Some(next_packet_details) = next_packet_details_opt.as_ref() {
5838- if let Err((err, reason) ) = self.can_forward_htlc(
5830+ if let Err(reason) = self.can_forward_htlc(
58395831 &update_add_htlc, next_packet_details
58405832 ) {
58415833 let htlc_fail = self.htlc_failure_from_update_add_err(
5842- &update_add_htlc, &incoming_counterparty_node_id, err, reason,
5834+ &update_add_htlc, &incoming_counterparty_node_id, reason,
58435835 is_intro_node_blinded_forward, &shared_secret,
58445836 );
58455837 let failure_type = get_htlc_failure_type(outgoing_scid_opt, update_add_htlc.payment_hash);
0 commit comments