Skip to content

Commit 5093ee6

Browse files
committed
Create TrampolineHop struct.
1 parent f551634 commit 5093ee6

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

lightning/src/routing/router.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,41 @@ impl_writeable_tlv_based!(RouteHop, {
382382
(10, cltv_expiry_delta, required),
383383
});
384384

385+
/// A Trampoline hop in a route, and additional metadata about it. "Hop" is defined as a node.
386+
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
387+
pub struct TrampolineHop {
388+
/// The node_id of the node at this hop.
389+
pub pubkey: PublicKey,
390+
/// The node_announcement features of the node at this hop. For the last hop, these may be
391+
/// amended to match the features present in the invoice this node generated.
392+
pub node_features: NodeFeatures,
393+
/// The channel_announcement features of the channel that should be used from the previous hop
394+
/// to reach this node.
395+
pub channel_features: ChannelFeatures,
396+
/// The fee taken on this hop (for paying for the use of the *next* channel in the path).
397+
/// If this is the last hop in [`Path::hops`]:
398+
/// * if we're sending to a [`BlindedPath`], this is the fee paid for use of the entire blinded path
399+
/// * otherwise, this is the full value of this [`Path`]'s part of the payment
400+
///
401+
/// [`BlindedPath`]: crate::blinded_path::BlindedPath
402+
pub fee_msat: u64,
403+
/// The CLTV delta added for this hop.
404+
/// If this is the last hop in [`Path::hops`]:
405+
/// * if we're sending to a [`BlindedPath`], this is the CLTV delta for the entire blinded path
406+
/// * otherwise, this is the CLTV delta expected at the destination
407+
///
408+
/// [`BlindedPath`]: crate::blinded_path::BlindedPath
409+
pub cltv_expiry_delta: u32,
410+
}
411+
412+
impl_writeable_tlv_based!(TrampolineHop, {
413+
(0, pubkey, required),
414+
(2, node_features, required),
415+
(6, channel_features, required),
416+
(8, fee_msat, required),
417+
(10, cltv_expiry_delta, required),
418+
});
419+
385420
/// The blinded portion of a [`Path`], if we're routing to a recipient who provided blinded paths in
386421
/// their [`Bolt12Invoice`].
387422
///

0 commit comments

Comments
 (0)