@@ -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};
@@ -9451,7 +9450,7 @@ where
9451
9450
self.highest_seen_timestamp.load(Ordering::Acquire) as u64
9452
9451
);
9453
9452
9454
- if invoice_request.keys.is_some() {
9453
+ let response = if invoice_request.keys.is_some() {
9455
9454
#[cfg(feature = "std")]
9456
9455
let builder = invoice_request.respond_using_derived_keys(
9457
9456
payment_paths, payment_hash
@@ -9460,42 +9459,35 @@ where
9460
9459
let builder = invoice_request.respond_using_derived_keys_no_std(
9461
9460
payment_paths, payment_hash, created_at
9462
9461
);
9463
- let builder: Result<InvoiceBuilder<DerivedSigningPubkey>, _> =
9464
- builder.map(|b| b.into());
9465
- match builder.and_then(|b| b.allow_mpp().build_and_sign(secp_ctx)) {
9466
- Ok(invoice) => Some(OffersMessage::Invoice(invoice)),
9467
- Err(error) => Some(OffersMessage::InvoiceError(error.into())),
9468
- }
9462
+ builder
9463
+ .map(InvoiceBuilder::<DerivedSigningPubkey>::from)
9464
+ .and_then(|builder| builder.allow_mpp().build_and_sign(secp_ctx))
9465
+ .map_err(InvoiceError::from)
9469
9466
} else {
9470
9467
#[cfg(feature = "std")]
9471
9468
let builder = invoice_request.respond_with(payment_paths, payment_hash);
9472
9469
#[cfg(not(feature = "std"))]
9473
9470
let builder = invoice_request.respond_with_no_std(
9474
9471
payment_paths, payment_hash, created_at
9475
9472
);
9476
- let builder: Result<InvoiceBuilder<ExplicitSigningPubkey>, _> =
9477
- builder .map(|b| b.into());
9478
- let response = builder .and_then(|builder| builder.allow_mpp().build())
9479
- .map_err(|e| OffersMessage::InvoiceError(e.into()) )
9473
+ builder
9474
+ .map(InvoiceBuilder::<ExplicitSigningPubkey>::from)
9475
+ .and_then(|builder| builder.allow_mpp().build())
9476
+ .map_err(InvoiceError::from )
9480
9477
.and_then(|invoice| {
9481
9478
#[cfg(c_bindings)]
9482
9479
let mut invoice = invoice;
9483
- match invoice.sign(|invoice: &UnsignedBolt12Invoice|
9484
- self.node_signer.sign_bolt12_invoice(invoice)
9485
- ) {
9486
- Ok(invoice) => Ok(OffersMessage::Invoice(invoice)),
9487
- Err(SignError::Signing) => Err(OffersMessage::InvoiceError(
9488
- InvoiceError::from_string("Failed signing invoice".to_string())
9489
- )),
9490
- Err(SignError::Verification(_)) => Err(OffersMessage::InvoiceError(
9491
- InvoiceError::from_string("Failed invoice signature verification".to_string())
9492
- )),
9493
- }
9494
- });
9495
- match response {
9496
- Ok(invoice) => Some(invoice),
9497
- Err(error) => Some(error),
9498
- }
9480
+ invoice
9481
+ .sign(|invoice: &UnsignedBolt12Invoice|
9482
+ self.node_signer.sign_bolt12_invoice(invoice)
9483
+ )
9484
+ .map_err(InvoiceError::from)
9485
+ })
9486
+ };
9487
+
9488
+ match response {
9489
+ Ok(invoice) => Some(OffersMessage::Invoice(invoice)),
9490
+ Err(error) => Some(OffersMessage::InvoiceError(error.into())),
9499
9491
}
9500
9492
},
9501
9493
OffersMessage::Invoice(invoice) => {
0 commit comments