Skip to content

Commit

Permalink
Fix cancel on waiting payment (#428)
Browse files Browse the repository at this point in the history
  • Loading branch information
grunch authored Jan 16, 2025
1 parent 8c369bc commit ca361b4
Showing 1 changed file with 8 additions and 7 deletions.
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

0 comments on commit ca361b4

Please sign in to comment.