Add failure mode info to BlindedForward struct.

See added docs.
This commit is contained in:
Valentine Wallace 2023-12-18 14:36:57 -05:00
parent f09ac1931f
commit c37d10944e
No known key found for this signature in database
GPG key ID: FD3E106A2CE099B4
2 changed files with 11 additions and 3 deletions

View file

@ -202,7 +202,9 @@ pub struct BlindedForward {
/// onion payload if we're the introduction node. Useful for calculating the next hop's /// onion payload if we're the introduction node. Useful for calculating the next hop's
/// [`msgs::UpdateAddHTLC::blinding_point`]. /// [`msgs::UpdateAddHTLC::blinding_point`].
pub inbound_blinding_point: PublicKey, pub inbound_blinding_point: PublicKey,
// Another field will be added here when we support forwarding as a non-intro node. /// If needed, this determines how this HTLC should be failed backwards, based on whether we are
/// the introduction node.
pub failure: BlindedFailure,
} }
impl PendingHTLCRouting { impl PendingHTLCRouting {
@ -9500,6 +9502,7 @@ impl_writeable_tlv_based!(PhantomRouteHints, {
impl_writeable_tlv_based!(BlindedForward, { impl_writeable_tlv_based!(BlindedForward, {
(0, inbound_blinding_point, required), (0, inbound_blinding_point, required),
(1, failure, (default_value, BlindedFailure::FromIntroductionNode)),
}); });
impl_writeable_tlv_based_enum!(PendingHTLCRouting, impl_writeable_tlv_based_enum!(PendingHTLCRouting,

View file

@ -12,7 +12,7 @@ use crate::blinded_path;
use crate::blinded_path::payment::{PaymentConstraints, PaymentRelay}; use crate::blinded_path::payment::{PaymentConstraints, PaymentRelay};
use crate::chain::channelmonitor::{HTLC_FAIL_BACK_BUFFER, LATENCY_GRACE_PERIOD_BLOCKS}; use crate::chain::channelmonitor::{HTLC_FAIL_BACK_BUFFER, LATENCY_GRACE_PERIOD_BLOCKS};
use crate::ln::PaymentHash; use crate::ln::PaymentHash;
use crate::ln::channelmanager::{BlindedForward, CLTV_FAR_FAR_AWAY, HTLCFailureMsg, MIN_CLTV_EXPIRY_DELTA, PendingHTLCInfo, PendingHTLCRouting}; use crate::ln::channelmanager::{BlindedFailure, BlindedForward, CLTV_FAR_FAR_AWAY, HTLCFailureMsg, MIN_CLTV_EXPIRY_DELTA, PendingHTLCInfo, PendingHTLCRouting};
use crate::ln::features::BlindedHopFeatures; use crate::ln::features::BlindedHopFeatures;
use crate::ln::msgs; use crate::ln::msgs;
use crate::ln::onion_utils; use crate::ln::onion_utils;
@ -106,7 +106,12 @@ pub(super) fn create_fwd_pending_htlc_info(
onion_packet: outgoing_packet, onion_packet: outgoing_packet,
short_channel_id, short_channel_id,
blinded: intro_node_blinding_point.or(msg.blinding_point) blinded: intro_node_blinding_point.or(msg.blinding_point)
.map(|bp| BlindedForward { inbound_blinding_point: bp }), .map(|bp| BlindedForward {
inbound_blinding_point: bp,
failure: intro_node_blinding_point
.map(|_| BlindedFailure::FromIntroductionNode)
.unwrap_or(BlindedFailure::FromBlindedNode),
}),
}, },
payment_hash: msg.payment_hash, payment_hash: msg.payment_hash,
incoming_shared_secret: shared_secret, incoming_shared_secret: shared_secret,