Skip to content

Commit 9e8a122

Browse files
Add failure mode info to BlindedForward struct.
See added docs.
1 parent 909cef1 commit 9e8a122

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ pub struct BlindedForward {
201201
/// onion payload if we're the introduction node. Useful for calculating the next hop's
202202
/// [`msgs::UpdateAddHTLC::blinding_point`].
203203
pub inbound_blinding_point: PublicKey,
204-
// Another field will be added here when we support forwarding as a non-intro node.
204+
/// If needed, this determines how this HTLC should be failed backwards, based on whether we are
205+
/// the introduction node.
206+
pub failure: BlindedFailure,
205207
}
206208

207209
impl PendingHTLCRouting {
@@ -9486,6 +9488,7 @@ impl_writeable_tlv_based!(PhantomRouteHints, {
94869488

94879489
impl_writeable_tlv_based!(BlindedForward, {
94889490
(0, inbound_blinding_point, required),
9491+
(2, failure, (default_value, BlindedFailure::FromIntroductionNode)),
94899492
});
94909493

94919494
impl_writeable_tlv_based_enum!(PendingHTLCRouting,

lightning/src/ln/onion_payment.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::blinded_path;
1212
use crate::blinded_path::payment::{PaymentConstraints, PaymentRelay};
1313
use crate::chain::channelmonitor::{HTLC_FAIL_BACK_BUFFER, LATENCY_GRACE_PERIOD_BLOCKS};
1414
use crate::ln::PaymentHash;
15-
use crate::ln::channelmanager::{BlindedForward, CLTV_FAR_FAR_AWAY, HTLCFailureMsg, MIN_CLTV_EXPIRY_DELTA, PendingHTLCInfo, PendingHTLCRouting};
15+
use crate::ln::channelmanager::{BlindedFailure, BlindedForward, CLTV_FAR_FAR_AWAY, HTLCFailureMsg, MIN_CLTV_EXPIRY_DELTA, PendingHTLCInfo, PendingHTLCRouting};
1616
use crate::ln::features::BlindedHopFeatures;
1717
use crate::ln::msgs;
1818
use crate::ln::onion_utils;
@@ -106,7 +106,11 @@ pub(super) fn create_fwd_pending_htlc_info(
106106
onion_packet: outgoing_packet,
107107
short_channel_id,
108108
blinded: intro_node_blinding_point.or(msg.blinding_point)
109-
.map(|bp| BlindedForward { inbound_blinding_point: bp }),
109+
.map(|bp| BlindedForward {
110+
inbound_blinding_point: bp,
111+
failure: intro_node_blinding_point
112+
.map_or(BlindedFailure::FromBlindedNode, |_| BlindedFailure::FromIntroductionNode),
113+
}),
110114
},
111115
payment_hash: msg.payment_hash,
112116
incoming_shared_secret: shared_secret,

0 commit comments

Comments
 (0)