@@ -61,7 +61,6 @@ use crate::ln::wire::Encode;
61
61
use crate::offers::invoice::{BlindedPayInfo, Bolt12Invoice, DEFAULT_RELATIVE_EXPIRY, DerivedSigningPubkey, ExplicitSigningPubkey, InvoiceBuilder, UnsignedBolt12Invoice};
62
62
use crate::offers::invoice_error::InvoiceError;
63
63
use crate::offers::invoice_request::{DerivedPayerId, InvoiceRequestBuilder};
64
- use crate::offers::merkle::SignError;
65
64
use crate::offers::offer::{Offer, OfferBuilder};
66
65
use crate::offers::parse::Bolt12SemanticError;
67
66
use crate::offers::refund::{Refund, RefundBuilder};
@@ -10356,7 +10355,7 @@ where
10356
10355
self.highest_seen_timestamp.load(Ordering::Acquire) as u64
10357
10356
);
10358
10357
10359
- if invoice_request.keys.is_some() {
10358
+ let response = if invoice_request.keys.is_some() {
10360
10359
#[cfg(feature = "std")]
10361
10360
let builder = invoice_request.respond_using_derived_keys(
10362
10361
payment_paths, payment_hash
@@ -10365,42 +10364,35 @@ where
10365
10364
let builder = invoice_request.respond_using_derived_keys_no_std(
10366
10365
payment_paths, payment_hash, created_at
10367
10366
);
10368
- let builder: Result<InvoiceBuilder<DerivedSigningPubkey>, _> =
10369
- builder.map(|b| b.into());
10370
- match builder.and_then(|b| b.allow_mpp().build_and_sign(secp_ctx)) {
10371
- Ok(invoice) => Some(OffersMessage::Invoice(invoice)),
10372
- Err(error) => Some(OffersMessage::InvoiceError(error.into())),
10373
- }
10367
+ builder
10368
+ .map(InvoiceBuilder::<DerivedSigningPubkey>::from)
10369
+ .and_then(|builder| builder.allow_mpp().build_and_sign(secp_ctx))
10370
+ .map_err(InvoiceError::from)
10374
10371
} else {
10375
10372
#[cfg(feature = "std")]
10376
10373
let builder = invoice_request.respond_with(payment_paths, payment_hash);
10377
10374
#[cfg(not(feature = "std"))]
10378
10375
let builder = invoice_request.respond_with_no_std(
10379
10376
payment_paths, payment_hash, created_at
10380
10377
);
10381
- let builder: Result<InvoiceBuilder<ExplicitSigningPubkey>, _> =
10382
- builder .map(|b| b.into());
10383
- let response = builder .and_then(|builder| builder.allow_mpp().build())
10384
- .map_err(|e| OffersMessage::InvoiceError(e.into()) )
10378
+ builder
10379
+ .map(InvoiceBuilder::<ExplicitSigningPubkey>::from)
10380
+ .and_then(|builder| builder.allow_mpp().build())
10381
+ .map_err(InvoiceError::from )
10385
10382
.and_then(|invoice| {
10386
10383
#[cfg(c_bindings)]
10387
10384
let mut invoice = invoice;
10388
- match invoice.sign(|invoice: &UnsignedBolt12Invoice|
10389
- self.node_signer.sign_bolt12_invoice(invoice)
10390
- ) {
10391
- Ok(invoice) => Ok(OffersMessage::Invoice(invoice)),
10392
- Err(SignError::Signing) => Err(OffersMessage::InvoiceError(
10393
- InvoiceError::from_string("Failed signing invoice".to_string())
10394
- )),
10395
- Err(SignError::Verification(_)) => Err(OffersMessage::InvoiceError(
10396
- InvoiceError::from_string("Failed invoice signature verification".to_string())
10397
- )),
10398
- }
10399
- });
10400
- match response {
10401
- Ok(invoice) => Some(invoice),
10402
- Err(error) => Some(error),
10403
- }
10385
+ invoice
10386
+ .sign(|invoice: &UnsignedBolt12Invoice|
10387
+ self.node_signer.sign_bolt12_invoice(invoice)
10388
+ )
10389
+ .map_err(InvoiceError::from)
10390
+ })
10391
+ };
10392
+
10393
+ match response {
10394
+ Ok(invoice) => Some(OffersMessage::Invoice(invoice)),
10395
+ Err(error) => Some(OffersMessage::InvoiceError(error.into())),
10404
10396
}
10405
10397
},
10406
10398
OffersMessage::Invoice(invoice) => {
0 commit comments