Skip to content

Commit

Permalink
f build refund with only Some(quantity)
Browse files Browse the repository at this point in the history
  • Loading branch information
slanesuke committed Jul 31, 2024
1 parent 50cb560 commit 1b0f4da
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/payment/bolt12.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ impl Bolt12Payment {
let retry_strategy = Retry::Timeout(LDK_PAYMENT_RETRY_TIMEOUT);
let max_total_routing_fee_msat = None;

let refund = self
let mut refund_builder = self
.channel_manager
.create_refund_builder(
amount_msat,
Expand All @@ -338,14 +338,17 @@ impl Bolt12Payment {
.map_err(|e| {
log_error!(self.logger, "Failed to create refund builder: {:?}", e);
Error::RefundCreationFailed
})?
.quantity(quantity.unwrap_or(1))
.build()
.map_err(|e| {
log_error!(self.logger, "Failed to create refund: {:?}", e);
Error::RefundCreationFailed
})?;

if let Some(qty) = quantity {
refund_builder = refund_builder.quantity(qty);
}

let refund = refund_builder.build().map_err(|e| {
log_error!(self.logger, "Failed to create refund: {:?}", e);
Error::RefundCreationFailed
})?;

log_info!(self.logger, "Offering refund of {}msat", amount_msat);

let kind = PaymentKind::Bolt12Refund {
Expand Down

0 comments on commit 1b0f4da

Please sign in to comment.