@@ -4352,25 +4352,22 @@ where
4352
4352
4353
4353
fn can_forward_htlc_to_outgoing_channel(
4354
4354
&self, chan: &mut FundedChannel<SP>, msg: &msgs::UpdateAddHTLC, next_packet: &NextPacketDetails
4355
- ) -> Result<(), (&'static str, LocalHTLCFailureReason) > {
4355
+ ) -> Result<(), LocalHTLCFailureReason> {
4356
4356
if !chan.context.should_announce() && !self.default_configuration.accept_forwards_to_priv_channels {
4357
4357
// Note that the behavior here should be identical to the above block - we
4358
4358
// should NOT reveal the existence or non-existence of a private channel if
4359
4359
// 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);
4362
4361
}
4363
4362
if let HopConnector::ShortChannelId(outgoing_scid) = next_packet.outgoing_connector {
4364
4363
if chan.funding.get_channel_type().supports_scid_privacy() && outgoing_scid != chan.context.outbound_scid_alias() {
4365
4364
// `option_scid_alias` (referred to in LDK as `scid_privacy`) means
4366
4365
// "refuse to forward unless the SCID alias was used", so we pretend
4367
4366
// 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);
4370
4368
}
4371
4369
} else {
4372
- return Err(("Cannot forward by Node ID without SCID.",
4373
- LocalHTLCFailureReason::InvalidTrampolineForward));
4370
+ return Err(LocalHTLCFailureReason::InvalidTrampolineForward);
4374
4371
}
4375
4372
4376
4373
// Note that we could technically not return an error yet here and just hope
@@ -4380,16 +4377,13 @@ where
4380
4377
// on a small/per-node/per-channel scale.
4381
4378
if !chan.context.is_live() {
4382
4379
if !chan.context.is_enabled() {
4383
- return Err(("Forwarding channel has been disconnected for some time.",
4384
- LocalHTLCFailureReason::ChannelDisabled));
4380
+ return Err(LocalHTLCFailureReason::ChannelDisabled);
4385
4381
} else {
4386
- return Err(("Forwarding channel is not in a ready state.",
4387
- LocalHTLCFailureReason::ChannelNotReady));
4382
+ return Err(LocalHTLCFailureReason::ChannelNotReady);
4388
4383
}
4389
4384
}
4390
4385
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);
4393
4387
}
4394
4388
chan.htlc_satisfies_config(msg, next_packet.outgoing_amt_msat, next_packet.outgoing_cltv_value)?;
4395
4389
@@ -4420,12 +4414,11 @@ where
4420
4414
4421
4415
fn can_forward_htlc(
4422
4416
&self, msg: &msgs::UpdateAddHTLC, next_packet_details: &NextPacketDetails
4423
- ) -> Result<(), (&'static str, LocalHTLCFailureReason) > {
4417
+ ) -> Result<(), LocalHTLCFailureReason> {
4424
4418
let outgoing_scid = match next_packet_details.outgoing_connector {
4425
4419
HopConnector::ShortChannelId(scid) => scid,
4426
4420
HopConnector::Trampoline(_) => {
4427
- return Err(("Cannot forward by Node ID without SCID.",
4428
- LocalHTLCFailureReason::InvalidTrampolineForward));
4421
+ return Err(LocalHTLCFailureReason::InvalidTrampolineForward);
4429
4422
}
4430
4423
};
4431
4424
match self.do_funded_channel_callback(outgoing_scid, |chan: &mut FundedChannel<SP>| {
@@ -4440,8 +4433,7 @@ where
4440
4433
fake_scid::is_valid_intercept(&self.fake_scid_rand_bytes, outgoing_scid, &self.chain_hash)) ||
4441
4434
fake_scid::is_valid_phantom(&self.fake_scid_rand_bytes, outgoing_scid, &self.chain_hash)
4442
4435
{} else {
4443
- return Err(("Don't have available channel for forwarding as requested.",
4444
- LocalHTLCFailureReason::UnknownNextPeer));
4436
+ return Err(LocalHTLCFailureReason::UnknownNextPeer);
4445
4437
}
4446
4438
}
4447
4439
}
@@ -4453,7 +4445,7 @@ where
4453
4445
}
4454
4446
4455
4447
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,
4457
4449
reason: LocalHTLCFailureReason, is_intro_node_blinded_forward: bool,
4458
4450
shared_secret: &[u8; 32]
4459
4451
) -> HTLCFailureMsg {
@@ -4477,7 +4469,7 @@ where
4477
4469
4478
4470
log_info!(
4479
4471
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,
4481
4473
);
4482
4474
// If `msg.blinding_point` is set, we must always fail with malformed.
4483
4475
if msg.blinding_point.is_some() {
@@ -5820,9 +5812,9 @@ where
5820
5812
)
5821
5813
}) {
5822
5814
Some(Ok(_)) => {},
5823
- Some(Err((err, reason) )) => {
5815
+ Some(Err(reason)) => {
5824
5816
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,
5826
5818
is_intro_node_blinded_forward, &shared_secret,
5827
5819
);
5828
5820
let failure_type = get_htlc_failure_type(outgoing_scid_opt, update_add_htlc.payment_hash);
@@ -5835,11 +5827,11 @@ where
5835
5827
5836
5828
// Now process the HTLC on the outgoing channel if it's a forward.
5837
5829
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(
5839
5831
&update_add_htlc, next_packet_details
5840
5832
) {
5841
5833
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,
5843
5835
is_intro_node_blinded_forward, &shared_secret,
5844
5836
);
5845
5837
let failure_type = get_htlc_failure_type(outgoing_scid_opt, update_add_htlc.payment_hash);
0 commit comments