InboundOnionCheck,
// The forwarding node's payload is encoded as a receive, i.e. the next hop HMAC is [0; 32].
ForwardPayloadEncodedAsReceive,
+ // Fail a check on the outbound channel. In this case, our next-hop peer is offline.
+ OutboundChannelCheck,
}
#[test]
fn forward_checks_failure() {
do_forward_checks_failure(ForwardCheckFail::InboundOnionCheck);
do_forward_checks_failure(ForwardCheckFail::ForwardPayloadEncodedAsReceive);
+ do_forward_checks_failure(ForwardCheckFail::OutboundChannelCheck);
}
fn do_forward_checks_failure(check: ForwardCheckFail) {
onion_payloads.pop();
update_add.onion_routing_packet = onion_utils::construct_onion_packet(onion_payloads, onion_keys, [0; 32], &payment_hash).unwrap();
},
+ ForwardCheckFail::OutboundChannelCheck => {
+ // The intro node will see that the next-hop peer is disconnected and fail the HTLC backwards.
+ nodes[1].node.peer_disconnected(&nodes[2].node.get_our_node_id());
+ },
}
nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
check_added_monitors!(nodes[1], 0);
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, InboundOnionErr, NextPacketDetails};
use crate::ln::msgs;
use crate::ln::onion_utils;
-use crate::ln::onion_utils::HTLCFailReason;
+use crate::ln::onion_utils::{HTLCFailReason, INVALID_ONION_BLINDING};
use crate::ln::msgs::{ChannelMessageHandler, DecodeError, LightningError};
#[cfg(test)]
use crate::ln::outbound_payment;
msg, &self.node_signer, &self.logger, &self.secp_ctx
)?;
+ let is_blinded = match next_hop {
+ onion_utils::Hop::Forward {
+ next_hop_data: msgs::InboundOnionPayload::BlindedForward { .. }, ..
+ } => true,
+ _ => false, // TODO: update this when we support receiving to multi-hop blinded paths
+ };
+
macro_rules! return_err {
($msg: expr, $err_code: expr, $data: expr) => {
{
log_info!(self.logger, "Failed to accept/forward incoming HTLC: {}", $msg);
+ let (err_code, err_data) = if is_blinded {
+ (INVALID_ONION_BLINDING, &[0; 32][..])
+ } else { ($err_code, $data) };
return Err(HTLCFailureMsg::Relay(msgs::UpdateFailHTLC {
channel_id: msg.channel_id,
htlc_id: msg.htlc_id,
- reason: HTLCFailReason::reason($err_code, $data.to_vec())
+ reason: HTLCFailReason::reason(err_code, err_data.to_vec())
.get_encrypted_failure_packet(&shared_secret, &None),
}));
}