@@ -4343,25 +4343,22 @@ where
4343
4343
4344
4344
fn can_forward_htlc_to_outgoing_channel(
4345
4345
&self, chan: &mut FundedChannel<SP>, msg: &msgs::UpdateAddHTLC, next_packet: &NextPacketDetails
4346
- ) -> Result<(), (&'static str, LocalHTLCFailureReason) > {
4346
+ ) -> Result<(), LocalHTLCFailureReason> {
4347
4347
if !chan.context.should_announce() && !self.default_configuration.accept_forwards_to_priv_channels {
4348
4348
// Note that the behavior here should be identical to the above block - we
4349
4349
// should NOT reveal the existence or non-existence of a private channel if
4350
4350
// 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);
4353
4352
}
4354
4353
if let HopConnector::ShortChannelId(outgoing_scid) = next_packet.outgoing_connector {
4355
4354
if chan.funding.get_channel_type().supports_scid_privacy() && outgoing_scid != chan.context.outbound_scid_alias() {
4356
4355
// `option_scid_alias` (referred to in LDK as `scid_privacy`) means
4357
4356
// "refuse to forward unless the SCID alias was used", so we pretend
4358
4357
// 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);
4361
4359
}
4362
4360
} else {
4363
- return Err(("Cannot forward by Node ID without SCID.",
4364
- LocalHTLCFailureReason::InvalidTrampolineForward));
4361
+ return Err(LocalHTLCFailureReason::InvalidTrampolineForward);
4365
4362
}
4366
4363
4367
4364
// Note that we could technically not return an error yet here and just hope
@@ -4371,16 +4368,13 @@ where
4371
4368
// on a small/per-node/per-channel scale.
4372
4369
if !chan.context.is_live() {
4373
4370
if !chan.context.is_enabled() {
4374
- return Err(("Forwarding channel has been disconnected for some time.",
4375
- LocalHTLCFailureReason::ChannelDisabled));
4371
+ return Err(LocalHTLCFailureReason::ChannelDisabled);
4376
4372
} else {
4377
- return Err(("Forwarding channel is not in a ready state.",
4378
- LocalHTLCFailureReason::ChannelNotReady));
4373
+ return Err(LocalHTLCFailureReason::ChannelNotReady);
4379
4374
}
4380
4375
}
4381
4376
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);
4384
4378
}
4385
4379
chan.htlc_satisfies_config(msg, next_packet.outgoing_amt_msat, next_packet.outgoing_cltv_value)?;
4386
4380
@@ -4411,12 +4405,11 @@ where
4411
4405
4412
4406
fn can_forward_htlc(
4413
4407
&self, msg: &msgs::UpdateAddHTLC, next_packet_details: &NextPacketDetails
4414
- ) -> Result<(), (&'static str, LocalHTLCFailureReason) > {
4408
+ ) -> Result<(), LocalHTLCFailureReason> {
4415
4409
let outgoing_scid = match next_packet_details.outgoing_connector {
4416
4410
HopConnector::ShortChannelId(scid) => scid,
4417
4411
HopConnector::Trampoline(_) => {
4418
- return Err(("Cannot forward by Node ID without SCID.",
4419
- LocalHTLCFailureReason::InvalidTrampolineForward));
4412
+ return Err(LocalHTLCFailureReason::InvalidTrampolineForward);
4420
4413
}
4421
4414
};
4422
4415
match self.do_funded_channel_callback(outgoing_scid, |chan: &mut FundedChannel<SP>| {
@@ -4431,8 +4424,7 @@ where
4431
4424
fake_scid::is_valid_intercept(&self.fake_scid_rand_bytes, outgoing_scid, &self.chain_hash)) ||
4432
4425
fake_scid::is_valid_phantom(&self.fake_scid_rand_bytes, outgoing_scid, &self.chain_hash)
4433
4426
{} else {
4434
- return Err(("Don't have available channel for forwarding as requested.",
4435
- LocalHTLCFailureReason::UnknownNextPeer));
4427
+ return Err(LocalHTLCFailureReason::UnknownNextPeer);
4436
4428
}
4437
4429
}
4438
4430
}
@@ -4444,7 +4436,7 @@ where
4444
4436
}
4445
4437
4446
4438
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,
4448
4440
reason: LocalHTLCFailureReason, is_intro_node_blinded_forward: bool,
4449
4441
shared_secret: &[u8; 32]
4450
4442
) -> HTLCFailureMsg {
@@ -4468,7 +4460,7 @@ where
4468
4460
4469
4461
log_info!(
4470
4462
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, reason,
4472
4464
);
4473
4465
// If `msg.blinding_point` is set, we must always fail with malformed.
4474
4466
if msg.blinding_point.is_some() {
@@ -5810,9 +5802,9 @@ where
5810
5802
)
5811
5803
}) {
5812
5804
Some(Ok(_)) => {},
5813
- Some(Err((err, reason) )) => {
5805
+ Some(Err(reason)) => {
5814
5806
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,
5816
5808
is_intro_node_blinded_forward, &shared_secret,
5817
5809
);
5818
5810
let htlc_destination = get_failed_htlc_destination(outgoing_scid_opt, update_add_htlc.payment_hash);
@@ -5825,11 +5817,11 @@ where
5825
5817
5826
5818
// Now process the HTLC on the outgoing channel if it's a forward.
5827
5819
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(
5829
5821
&update_add_htlc, next_packet_details
5830
5822
) {
5831
5823
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,
5833
5825
is_intro_node_blinded_forward, &shared_secret,
5834
5826
);
5835
5827
let htlc_destination = get_failed_htlc_destination(outgoing_scid_opt, update_add_htlc.payment_hash);
0 commit comments