Skip to content

Commit c37d109

Browse files
Add failure mode info to BlindedForward struct.
See added docs.
1 parent f09ac19 commit c37d109

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

lightning/src/ln/channelmanager.rs

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

208210
impl PendingHTLCRouting {
@@ -9500,6 +9502,7 @@ impl_writeable_tlv_based!(PhantomRouteHints, {
95009502

95019503
impl_writeable_tlv_based!(BlindedForward, {
95029504
(0, inbound_blinding_point, required),
9505+
(1, failure, (default_value, BlindedFailure::FromIntroductionNode)),
95039506
});
95049507

95059508
impl_writeable_tlv_based_enum!(PendingHTLCRouting,

lightning/src/ln/onion_payment.rs

Lines changed: 7 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,12 @@ 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(|_| BlindedFailure::FromIntroductionNode)
113+
.unwrap_or(BlindedFailure::FromBlindedNode),
114+
}),
110115
},
111116
payment_hash: msg.payment_hash,
112117
incoming_shared_secret: shared_secret,

0 commit comments

Comments
 (0)