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

Fix cancel on waiting payment #428

Merged
merged 1 commit into from
Jan 16, 2025
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
15 changes: 8 additions & 7 deletions src/app/cancel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,6 @@ pub async fn cancel_pay_hold_invoice(
my_keys: &Keys,
request_id: Option<u64>,
) -> Result<()> {
if order.hash.is_some() {
// We return funds to seller
if let Some(hash) = order.hash.as_ref() {
ln_client.cancel_hold_invoice(hash).await?;
info!("Order Id {}: Funds returned to seller", &order.id);
}
}
let user_pubkey = event.rumor.pubkey.to_string();

let (seller_pubkey, buyer_pubkey) = match (&order.seller_pubkey, &order.buyer_pubkey) {
Expand All @@ -298,6 +291,14 @@ pub async fn cancel_pay_hold_invoice(
return Ok(());
}

if order.hash.is_some() {
// We cancel the hold invoice, if it was paid those funds return to seller
if let Some(hash) = order.hash.as_ref() {
ln_client.cancel_hold_invoice(hash).await?;
info!("Order Id {}: Hold invoice canceled", &order.id);
}
}

if order.creator_pubkey == seller_pubkey.to_string() {
// We publish a new replaceable kind nostr event with the status updated
// and update on local database the status and new event id
Expand Down
Loading