Skip to content

Commit

Permalink
Handle InvoiceRequestFailed event
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Sep 29, 2023
1 parent c62af75 commit c4f99c3
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion mutiny-core/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,35 @@ impl<S: MutinyStorage> EventHandler<S> {
}
Event::HTLCIntercepted { .. } => {}
Event::BumpTransaction(event) => self.bump_tx_event_handler.handle_event(&event),
Event::InvoiceRequestFailed { .. } => {} // we do not support bolt 12
Event::InvoiceRequestFailed { payment_id } => {
match self
.persister
.read_payment_info(&payment_id.0, false, &self.logger)
{
Some(mut saved_payment_info) => {
saved_payment_info.status = HTLCStatus::Failed;
saved_payment_info.last_update = crate::utils::now().as_secs();
match self.persister.persist_payment_info(
&payment_id.0,
&saved_payment_info,
false,
) {
Ok(_) => (),
Err(e) => log_error!(
self.logger,
"ERROR: could not persist payment info: {e}"
),
}
}
None => {
// we failed in a payment that we didn't have saved? ...
log_warn!(
self.logger,
"WARN: payment failed but we did not have it stored"
);
}
}
}
}
}

Expand Down

0 comments on commit c4f99c3

Please sign in to comment.