Skip to content

Commit

Permalink
fix: check phd has valid payment id
Browse files Browse the repository at this point in the history
  • Loading branch information
thesimplekid committed Nov 21, 2024
1 parent 39b2207 commit 2e01239
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions crates/cdk-phoenixd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#![warn(rustdoc::bare_urls)]

use std::pin::Pin;
use std::str::FromStr;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;

Expand Down Expand Up @@ -268,6 +269,19 @@ impl MintLightning for Phoenixd {
&self,
payment_id: &str,
) -> Result<PayInvoiceResponse, Self::Err> {
// We can only check the status of the payment if we have the payment id not if we only have a payment hash.
// In phd this is a uuid, that we get after getting a response from the pay invoice
if let Err(_err) = uuid::Uuid::from_str(payment_id) {
tracing::warn!("Could not check status of payment, no payment id");
return Ok(PayInvoiceResponse {
payment_lookup_id: payment_id.to_string(),
payment_preimage: None,
status: MeltQuoteState::Unknown,
total_spent: Amount::ZERO,
unit: CurrencyUnit::Sat,
});
}

let res = self.phoenixd_api.get_outgoing_invoice(payment_id).await;

let state = match res {
Expand Down

0 comments on commit 2e01239

Please sign in to comment.