From a5ba3391f8dd61515385bfcf3d946a1c6b731f0a Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 23 Jan 2024 01:16:46 +0000 Subject: [PATCH] [bindings] No-export `RouteHopCandidate` lifetime'd fields The bindings cannot express lifetimes, so exposing any field which is a reference (and not `clone`-able, at least for garbage collected language bindings) is unsafe for those expecting a high-level interface. Thus, we simply no-export the `RouteHopCandidate` inner struct fields which are references (there are relevant accessors for them anyway). --- lightning/src/routing/router.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 1bf90883..7ca9d4b7 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -1146,8 +1146,12 @@ pub struct FirstHopCandidate<'a> { /// has been funded and is able to pay), and accessor methods may panic otherwise. /// /// [`find_route`] validates this prior to constructing a [`CandidateRouteHop`]. + /// + /// This is not exported to bindings users as lifetimes are not expressable in most languages. pub details: &'a ChannelDetails, /// The node id of the payer, which is also the source side of this candidate route hop. + /// + /// This is not exported to bindings users as lifetimes are not expressable in most languages. pub payer_node_id: &'a NodeId, } @@ -1156,6 +1160,8 @@ pub struct FirstHopCandidate<'a> { pub struct PublicHopCandidate<'a> { /// Information about the channel, including potentially its capacity and /// direction-specific information. + /// + /// This is not exported to bindings users as lifetimes are not expressable in most languages. pub info: DirectedChannelInfo<'a>, /// The short channel ID of the channel, i.e. the identifier by which we refer to this /// channel. @@ -1166,8 +1172,12 @@ pub struct PublicHopCandidate<'a> { #[derive(Clone, Debug)] pub struct PrivateHopCandidate<'a> { /// Information about the private hop communicated via BOLT 11. + /// + /// This is not exported to bindings users as lifetimes are not expressable in most languages. pub hint: &'a RouteHintHop, /// Node id of the next hop in BOLT 11 route hint. + /// + /// This is not exported to bindings users as lifetimes are not expressable in most languages. pub target_node_id: &'a NodeId } @@ -1176,6 +1186,8 @@ pub struct PrivateHopCandidate<'a> { pub struct BlindedPathCandidate<'a> { /// Information about the blinded path including the fee, HTLC amount limits, and /// cryptographic material required to build an HTLC through the given path. + /// + /// This is not exported to bindings users as lifetimes are not expressable in most languages. pub hint: &'a (BlindedPayInfo, BlindedPath), /// Index of the hint in the original list of blinded hints. /// @@ -1191,6 +1203,8 @@ pub struct OneHopBlindedPathCandidate<'a> { /// cryptographic material required to build an HTLC terminating with the given path. /// /// Note that the [`BlindedPayInfo`] is ignored here. + /// + /// This is not exported to bindings users as lifetimes are not expressable in most languages. pub hint: &'a (BlindedPayInfo, BlindedPath), /// Index of the hint in the original list of blinded hints. /// -- 2.30.2