@@ -4343,25 +4343,22 @@ where
43434343
43444344 fn can_forward_htlc_to_outgoing_channel(
43454345 &self, chan: &mut FundedChannel<SP>, msg: &msgs::UpdateAddHTLC, next_packet: &NextPacketDetails
4346- ) -> Result<(), (&'static str, LocalHTLCFailureReason) > {
4346+ ) -> Result<(), LocalHTLCFailureReason> {
43474347 if !chan.context.should_announce() && !self.default_configuration.accept_forwards_to_priv_channels {
43484348 // Note that the behavior here should be identical to the above block - we
43494349 // should NOT reveal the existence or non-existence of a private channel if
43504350 // we don't allow forwards outbound over them.
4351- return Err(("Refusing to forward to a private channel based on our config.",
4352- LocalHTLCFailureReason::PrivateChannelForward));
4351+ return Err(LocalHTLCFailureReason::PrivateChannelForward);
43534352 }
43544353 if let HopConnector::ShortChannelId(outgoing_scid) = next_packet.outgoing_connector {
43554354 if chan.funding.get_channel_type().supports_scid_privacy() && outgoing_scid != chan.context.outbound_scid_alias() {
43564355 // `option_scid_alias` (referred to in LDK as `scid_privacy`) means
43574356 // "refuse to forward unless the SCID alias was used", so we pretend
43584357 // we don't have the channel here.
4359- return Err(("Refusing to forward over real channel SCID as our counterparty requested.",
4360- LocalHTLCFailureReason::RealSCIDForward));
4358+ return Err(LocalHTLCFailureReason::RealSCIDForward);
43614359 }
43624360 } else {
4363- return Err(("Cannot forward by Node ID without SCID.",
4364- LocalHTLCFailureReason::InvalidTrampolineForward));
4361+ return Err(LocalHTLCFailureReason::InvalidTrampolineForward);
43654362 }
43664363
43674364 // Note that we could technically not return an error yet here and just hope
@@ -4371,16 +4368,13 @@ where
43714368 // on a small/per-node/per-channel scale.
43724369 if !chan.context.is_live() {
43734370 if !chan.context.is_enabled() {
4374- return Err(("Forwarding channel has been disconnected for some time.",
4375- LocalHTLCFailureReason::ChannelDisabled));
4371+ return Err(LocalHTLCFailureReason::ChannelDisabled);
43764372 } else {
4377- return Err(("Forwarding channel is not in a ready state.",
4378- LocalHTLCFailureReason::ChannelNotReady));
4373+ return Err(LocalHTLCFailureReason::ChannelNotReady);
43794374 }
43804375 }
43814376 if next_packet.outgoing_amt_msat < chan.context.get_counterparty_htlc_minimum_msat() {
4382- return Err(("HTLC amount was below the htlc_minimum_msat",
4383- LocalHTLCFailureReason::AmountBelowMinimum));
4377+ return Err(LocalHTLCFailureReason::AmountBelowMinimum);
43844378 }
43854379 chan.htlc_satisfies_config(msg, next_packet.outgoing_amt_msat, next_packet.outgoing_cltv_value)?;
43864380
@@ -4411,12 +4405,11 @@ where
44114405
44124406 fn can_forward_htlc(
44134407 &self, msg: &msgs::UpdateAddHTLC, next_packet_details: &NextPacketDetails
4414- ) -> Result<(), (&'static str, LocalHTLCFailureReason) > {
4408+ ) -> Result<(), LocalHTLCFailureReason> {
44154409 let outgoing_scid = match next_packet_details.outgoing_connector {
44164410 HopConnector::ShortChannelId(scid) => scid,
44174411 HopConnector::Trampoline(_) => {
4418- return Err(("Cannot forward by Node ID without SCID.",
4419- LocalHTLCFailureReason::InvalidTrampolineForward));
4412+ return Err(LocalHTLCFailureReason::InvalidTrampolineForward);
44204413 }
44214414 };
44224415 match self.do_funded_channel_callback(outgoing_scid, |chan: &mut FundedChannel<SP>| {
@@ -4431,8 +4424,7 @@ where
44314424 fake_scid::is_valid_intercept(&self.fake_scid_rand_bytes, outgoing_scid, &self.chain_hash)) ||
44324425 fake_scid::is_valid_phantom(&self.fake_scid_rand_bytes, outgoing_scid, &self.chain_hash)
44334426 {} else {
4434- return Err(("Don't have available channel for forwarding as requested.",
4435- LocalHTLCFailureReason::UnknownNextPeer));
4427+ return Err(LocalHTLCFailureReason::UnknownNextPeer);
44364428 }
44374429 }
44384430 }
@@ -4444,7 +4436,7 @@ where
44444436 }
44454437
44464438 fn htlc_failure_from_update_add_err(
4447- &self, msg: &msgs::UpdateAddHTLC, counterparty_node_id: &PublicKey, err_msg: &'static str,
4439+ &self, msg: &msgs::UpdateAddHTLC, counterparty_node_id: &PublicKey,
44484440 reason: LocalHTLCFailureReason, is_intro_node_blinded_forward: bool,
44494441 shared_secret: &[u8; 32]
44504442 ) -> HTLCFailureMsg {
@@ -4468,7 +4460,7 @@ where
44684460
44694461 log_info!(
44704462 WithContext::from(&self.logger, Some(*counterparty_node_id), Some(msg.channel_id), Some(msg.payment_hash)),
4471- "Failed to accept/forward incoming HTLC: {}", err_msg
4463+ "Failed to accept/forward incoming HTLC: {:? }", reason,
44724464 );
44734465 // If `msg.blinding_point` is set, we must always fail with malformed.
44744466 if msg.blinding_point.is_some() {
@@ -5810,9 +5802,9 @@ where
58105802 )
58115803 }) {
58125804 Some(Ok(_)) => {},
5813- Some(Err((err, reason) )) => {
5805+ Some(Err(reason)) => {
58145806 let htlc_fail = self.htlc_failure_from_update_add_err(
5815- &update_add_htlc, &incoming_counterparty_node_id, err, reason,
5807+ &update_add_htlc, &incoming_counterparty_node_id, reason,
58165808 is_intro_node_blinded_forward, &shared_secret,
58175809 );
58185810 let htlc_destination = get_failed_htlc_destination(outgoing_scid_opt, update_add_htlc.payment_hash);
@@ -5825,11 +5817,11 @@ where
58255817
58265818 // Now process the HTLC on the outgoing channel if it's a forward.
58275819 if let Some(next_packet_details) = next_packet_details_opt.as_ref() {
5828- if let Err((err, reason) ) = self.can_forward_htlc(
5820+ if let Err(reason) = self.can_forward_htlc(
58295821 &update_add_htlc, next_packet_details
58305822 ) {
58315823 let htlc_fail = self.htlc_failure_from_update_add_err(
5832- &update_add_htlc, &incoming_counterparty_node_id, err, reason,
5824+ &update_add_htlc, &incoming_counterparty_node_id, reason,
58335825 is_intro_node_blinded_forward, &shared_secret,
58345826 );
58355827 let htlc_destination = get_failed_htlc_destination(outgoing_scid_opt, update_add_htlc.payment_hash);
0 commit comments