Skip to content

Commit 2db0a82

Browse files
committed
f: use match syntax
1 parent 5bfa529 commit 2db0a82

File tree

1 file changed

+34
-18
lines changed

1 file changed

+34
-18
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8883,15 +8883,21 @@ macro_rules! create_offer_builder { ($self: ident, $builder: ty) => {
88838883
let nonce = Nonce::from_entropy_source(entropy);
88848884
let context = OffersContext::InvoiceRequest { nonce };
88858885

8886-
let mut builder = OfferBuilder::deriving_signing_pubkey(node_id, expanded_key, nonce, secp_ctx)
8887-
.chain_hash($self.chain_hash);
8888-
if let Some(params) = params {
8889-
let path = $self.create_blinded_paths(params, context)
8890-
.and_then(|paths| paths.into_iter().next().ok_or(()))
8891-
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
8886+
let builder = match params {
8887+
Some(params) => {
8888+
let path = $self
8889+
.create_blinded_paths(params, context)
8890+
.and_then(|paths| paths.into_iter().next().ok_or(()))
8891+
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
88928892

8893-
builder = builder.path(path);
8894-
}
8893+
OfferBuilder::deriving_signing_pubkey(node_id, expanded_key, nonce, secp_ctx)
8894+
.chain_hash($self.chain_hash)
8895+
.path(path)
8896+
}
8897+
8898+
None => OfferBuilder::deriving_signing_pubkey(node_id, expanded_key, nonce, secp_ctx)
8899+
.chain_hash($self.chain_hash),
8900+
};
88958901

88968902
Ok(builder.into())
88978903
}
@@ -8956,18 +8962,28 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => {
89568962
let nonce = Nonce::from_entropy_source(entropy);
89578963
let context = OffersContext::OutboundPayment { payment_id, nonce, hmac: None };
89588964

8959-
let mut builder = RefundBuilder::deriving_payer_id(
8960-
node_id, expanded_key, nonce, secp_ctx, amount_msats, payment_id
8961-
)?
8962-
.chain_hash($self.chain_hash)
8963-
.absolute_expiry(absolute_expiry);
8965+
let builder = match params {
8966+
Some(params) => {
8967+
let path = $self
8968+
.create_blinded_paths(params, context)
8969+
.and_then(|paths| paths.into_iter().next().ok_or(()))
8970+
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
89648971

8965-
if let Some(params) = params {
8966-
let path = $self.create_blinded_paths(params, context)
8967-
.and_then(|paths| paths.into_iter().next().ok_or(()))
8968-
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
8972+
RefundBuilder::deriving_payer_id(
8973+
node_id, expanded_key, nonce, secp_ctx,
8974+
amount_msats, payment_id,
8975+
)?
8976+
.chain_hash($self.chain_hash)
8977+
.absolute_expiry(absolute_expiry)
8978+
.path(path)
8979+
}
89698980

8970-
builder = builder.path(path);
8981+
None => RefundBuilder::deriving_payer_id(
8982+
node_id, expanded_key, nonce, secp_ctx,
8983+
amount_msats, payment_id,
8984+
)?
8985+
.chain_hash($self.chain_hash)
8986+
.absolute_expiry(absolute_expiry),
89718987
};
89728988

89738989
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop($self);

0 commit comments

Comments
 (0)