fix: check phd has valid payment id

This commit is contained in:
thesimplekid
2024-10-02 11:11:17 +02:00
parent 39b2207ea6
commit 2e01239683

View File

@@ -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;
@@ -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 {