Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve representation of in-progress lnurlw transactions #1323

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion src/fiat_topup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,47 @@ impl FiatTopup {
amount_msat: collectable_amount,
description: None,
})) {
Ok(breez_sdk_core::LnUrlWithdrawResult::Ok { data }) => data.invoice.payment_hash,
Ok(breez_sdk_core::LnUrlWithdrawResult::Ok { data }) => {
match offer.offer_kind.clone() {
OfferKind::Pocket { id, .. } => self
.support
.offer_manager
.hide_topup(id)
.map_runtime_error_to(RuntimeErrorCode::OfferServiceUnavailable)?,
};
self.support
.store_payment_info(&data.invoice.payment_hash, Some(offer.offer_kind.clone()));
let channel_opening_fee_msat = if let Some(payment_amount_msat) =
data.invoice.amount_msat
{
let lsp_fee_params = {
self.support
.task_manager
.lock_unwrap()
.get_cheaper_lsp_fee()?
};
let lsp_fee_calculation_result = self.support.calculate_lsp_fee_for_amount(
payment_amount_msat.as_msats().to_amount_up(&None).sats,
lsp_fee_params,
)?;
Some(lsp_fee_calculation_result.lsp_fee.to_msats())
} else {
None
};

self.support
.data_store
.lock_unwrap()
.store_created_invoice(
&data.invoice.payment_hash,
&data.invoice.bolt11,
&channel_opening_fee_msat,
data.invoice.timestamp + data.invoice.expiry,
)
.map_to_permanent_failure("Failed to persist invoice in lnurl-withdraw flow")?;

data.invoice.payment_hash
}
Ok(breez_sdk_core::LnUrlWithdrawResult::Timeout { .. }) => runtime_error!(
RuntimeErrorCode::OfferServiceUnavailable,
"Failed to withdraw offer due to timeout on submitting invoice"
Expand Down
Loading