@@ -7658,7 +7658,9 @@ where
7658
7658
7659
7659
match self.create_inbound_payment(Some(amount_msats), relative_expiry, None) {
7660
7660
Ok((payment_hash, payment_secret)) => {
7661
- let payment_paths = self.create_blinded_payment_paths(amount_msats, payment_secret);
7661
+ let payment_paths = self.create_blinded_payment_paths(amount_msats, payment_secret)
7662
+ .map_err(|_| Bolt12SemanticError::MissingPaths)?;
7663
+
7662
7664
#[cfg(not(feature = "no-std"))]
7663
7665
let builder = refund.respond_using_derived_keys(
7664
7666
payment_paths, payment_hash, expanded_key, entropy
@@ -7819,49 +7821,9 @@ where
7819
7821
.and_then(|paths| paths.into_iter().next().ok_or(()))
7820
7822
}
7821
7823
7822
- /// Creates multi-hop blinded payment paths for the given `amount_msats` by delegating to
7823
- /// [`Router::create_blinded_payment_paths`]. If the router returns an error or no paths,
7824
- /// creates a one-hop blinded payment path instead.
7825
- fn create_blinded_payment_paths(
7826
- &self, amount_msats: u64, payment_secret: PaymentSecret
7827
- ) -> Vec<(BlindedPayInfo, BlindedPath)> {
7828
- self.create_multi_hop_blinded_payment_paths(amount_msats, payment_secret)
7829
- .ok()
7830
- .and_then(|paths| (!paths.is_empty()).then(|| paths))
7831
- .unwrap_or_else(|| vec![self.create_one_hop_blinded_payment_path(payment_secret)])
7832
- }
7833
-
7834
- /// Creates a one-hop blinded payment path with [`ChannelManager::get_our_node_id`] as the
7835
- /// introduction node.
7836
- fn create_one_hop_blinded_payment_path(
7837
- &self, payment_secret: PaymentSecret
7838
- ) -> (BlindedPayInfo, BlindedPath) {
7839
- let entropy_source = self.entropy_source.deref();
7840
- let secp_ctx = &self.secp_ctx;
7841
-
7842
- let payee_node_id = self.get_our_node_id();
7843
- let max_cltv_expiry = self.best_block.read().unwrap().height() + LATENCY_GRACE_PERIOD_BLOCKS;
7844
- let payee_tlvs = ReceiveTlvs {
7845
- payment_secret,
7846
- payment_constraints: PaymentConstraints {
7847
- max_cltv_expiry,
7848
- htlc_minimum_msat: 1,
7849
- },
7850
- };
7851
- // TODO: Err for overflow?
7852
- BlindedPath::one_hop_for_payment(
7853
- payee_node_id, payee_tlvs, entropy_source, secp_ctx
7854
- ).unwrap()
7855
- }
7856
-
7857
7824
/// Creates multi-hop blinded payment paths for the given `amount_msats` by delegating to
7858
7825
/// [`Router::create_blinded_payment_paths`].
7859
- ///
7860
- /// May return no paths if no peers [support route blinding] or whose channels don't have enough
7861
- /// inbound liquidity.
7862
- ///
7863
- /// [support route blinding]: crate::ln::features::InitFeatures::supports_route_blinding
7864
- fn create_multi_hop_blinded_payment_paths(
7826
+ fn create_blinded_payment_paths(
7865
7827
&self, amount_msats: u64, payment_secret: PaymentSecret
7866
7828
) -> Result<Vec<(BlindedPayInfo, BlindedPath)>, ()> {
7867
7829
let entropy_source = self.entropy_source.deref();
@@ -9133,9 +9095,15 @@ where
9133
9095
9134
9096
match self.create_inbound_payment(Some(amount_msats), relative_expiry, None) {
9135
9097
Ok((payment_hash, payment_secret)) if invoice_request.keys.is_some() => {
9136
- let payment_paths = self.create_blinded_payment_paths(
9098
+ let payment_paths = match self.create_blinded_payment_paths(
9137
9099
amount_msats, payment_secret
9138
- );
9100
+ ) {
9101
+ Ok(payment_paths) => payment_paths,
9102
+ Err(()) => {
9103
+ let error = Bolt12SemanticError::MissingPaths;
9104
+ return Some(OffersMessage::InvoiceError(error.into()));
9105
+ },
9106
+ };
9139
9107
#[cfg(not(feature = "no-std"))]
9140
9108
let builder = invoice_request.respond_using_derived_keys(
9141
9109
payment_paths, payment_hash
@@ -9154,9 +9122,16 @@ where
9154
9122
}
9155
9123
},
9156
9124
Ok((payment_hash, payment_secret)) => {
9157
- let payment_paths = self.create_blinded_payment_paths(
9125
+ let payment_paths = match self.create_blinded_payment_paths(
9158
9126
amount_msats, payment_secret
9159
- );
9127
+ ) {
9128
+ Ok(payment_paths) => payment_paths,
9129
+ Err(()) => {
9130
+ let error = Bolt12SemanticError::MissingPaths;
9131
+ return Some(OffersMessage::InvoiceError(error.into()));
9132
+ },
9133
+ };
9134
+
9160
9135
#[cfg(not(feature = "no-std"))]
9161
9136
let builder = invoice_request.respond_with(payment_paths, payment_hash);
9162
9137
#[cfg(feature = "no-std")]
0 commit comments