@@ -83,6 +83,42 @@ impl< G: Deref<Target = NetworkGraph<L>> + Clone, L: Deref, S: Deref, SP: Sized,
83
83
& random_seed_bytes
84
84
)
85
85
}
86
+
87
+ fn create_blinded_payment_paths <
88
+ ES : EntropySource + ?Sized , T : secp256k1:: Signing + secp256k1:: Verification
89
+ > (
90
+ & self , recipient : PublicKey , first_hops : Vec < ChannelDetails > , tlvs : ReceiveTlvs ,
91
+ amount_msats : u64 , entropy_source : & ES , secp_ctx : & Secp256k1 < T >
92
+ ) -> Result < Vec < ( BlindedPayInfo , BlindedPath ) > , ( ) > {
93
+ first_hops. into_iter ( )
94
+ . filter ( |details| details. is_public )
95
+ . filter ( |details| details. counterparty . features . supports_route_blinding ( ) )
96
+ . filter ( |details| amount_msats >= details. inbound_htlc_minimum_msat . unwrap_or ( 0 ) )
97
+ . filter ( |details| amount_msats <= details. inbound_htlc_maximum_msat . unwrap_or ( 0 ) )
98
+ . map ( |details| {
99
+ let short_channel_id = details. get_inbound_payment_scid ( ) . unwrap ( ) ;
100
+ let payment_relay: PaymentRelay = details. counterparty . forwarding_info . unwrap ( ) . into ( ) ;
101
+ let payment_constraints = PaymentConstraints {
102
+ max_cltv_expiry : tlvs. payment_constraints . max_cltv_expiry
103
+ + payment_relay. cltv_expiry_delta as u32 ,
104
+ htlc_minimum_msat : details. inbound_htlc_minimum_msat . unwrap_or ( 0 ) ,
105
+ } ;
106
+ let forward_node = ForwardNode {
107
+ tlvs : ForwardTlvs {
108
+ short_channel_id,
109
+ payment_relay,
110
+ payment_constraints,
111
+ features : BlindedHopFeatures :: empty ( ) ,
112
+ } ,
113
+ node_id : details. counterparty . node_id ,
114
+ htlc_maximum_msat : details. inbound_htlc_maximum_msat . unwrap_or ( 0 ) ,
115
+ } ;
116
+ BlindedPath :: new_for_payment (
117
+ & [ forward_node] , recipient, tlvs. clone ( ) , u64:: MAX , entropy_source, secp_ctx
118
+ )
119
+ } )
120
+ . collect ( )
121
+ }
86
122
}
87
123
88
124
impl < G : Deref < Target = NetworkGraph < L > > + Clone , L : Deref , S : Deref , SP : Sized , Sc : ScoreLookUp < ScoreParams = SP > > MessageRouter for DefaultRouter < G , L , S , SP , Sc > where
@@ -134,44 +170,12 @@ pub trait Router: MessageRouter {
134
170
/// Creates [`BlindedPath`]s for payment to the `recipient` node. The channels in `first_hops`
135
171
/// are assumed to be with the `recipient`'s peers. The payment secret and any constraints are
136
172
/// given in `tlvs`.
137
- ///
138
- /// The default implementation returns two-hop payment paths for each channel in `first_hops`
139
- /// with the `recipient` node (i.e., the channel counterparty is the introduction point).
140
173
fn create_blinded_payment_paths <
141
174
ES : EntropySource + ?Sized , T : secp256k1:: Signing + secp256k1:: Verification
142
175
> (
143
176
& self , recipient : PublicKey , first_hops : Vec < ChannelDetails > , tlvs : ReceiveTlvs ,
144
177
amount_msats : u64 , entropy_source : & ES , secp_ctx : & Secp256k1 < T >
145
- ) -> Result < Vec < ( BlindedPayInfo , BlindedPath ) > , ( ) > {
146
- first_hops. into_iter ( )
147
- . filter ( |details| details. is_public )
148
- . filter ( |details| details. counterparty . features . supports_route_blinding ( ) )
149
- . filter ( |details| amount_msats >= details. inbound_htlc_minimum_msat . unwrap_or ( 0 ) )
150
- . filter ( |details| amount_msats <= details. inbound_htlc_maximum_msat . unwrap_or ( 0 ) )
151
- . map ( |details| {
152
- let short_channel_id = details. get_inbound_payment_scid ( ) . unwrap ( ) ;
153
- let payment_relay: PaymentRelay = details. counterparty . forwarding_info . unwrap ( ) . into ( ) ;
154
- let payment_constraints = PaymentConstraints {
155
- max_cltv_expiry : tlvs. payment_constraints . max_cltv_expiry
156
- + payment_relay. cltv_expiry_delta as u32 ,
157
- htlc_minimum_msat : details. inbound_htlc_minimum_msat . unwrap_or ( 0 ) ,
158
- } ;
159
- let forward_node = ForwardNode {
160
- tlvs : ForwardTlvs {
161
- short_channel_id,
162
- payment_relay,
163
- payment_constraints,
164
- features : BlindedHopFeatures :: empty ( ) ,
165
- } ,
166
- node_id : details. counterparty . node_id ,
167
- htlc_maximum_msat : details. inbound_htlc_maximum_msat . unwrap_or ( 0 ) ,
168
- } ;
169
- BlindedPath :: new_for_payment (
170
- & [ forward_node] , recipient, tlvs. clone ( ) , u64:: MAX , entropy_source, secp_ctx
171
- )
172
- } )
173
- . collect ( )
174
- }
178
+ ) -> Result < Vec < ( BlindedPayInfo , BlindedPath ) > , ( ) > ;
175
179
}
176
180
177
181
/// [`ScoreLookUp`] implementation that factors in in-flight HTLC liquidity.
0 commit comments