From 7203c6983ab4006dfa3d0dd969f7acde6e8f769b Mon Sep 17 00:00:00 2001 From: thesimplekid Date: Tue, 24 Sep 2024 13:23:00 +0200 Subject: [PATCH] refactor: rename payment_invoice to payment look up id --- crates/cdk-cln/src/lib.rs | 6 +++--- crates/cdk-fake-wallet/src/lib.rs | 4 ++-- crates/cdk-lnbits/src/lib.rs | 4 ++-- crates/cdk-lnd/src/lib.rs | 8 ++++---- crates/cdk-phoenixd/src/lib.rs | 4 ++-- crates/cdk-strike/src/lib.rs | 6 ++---- crates/cdk/src/cdk_lightning/mod.rs | 2 +- 7 files changed, 16 insertions(+), 18 deletions(-) diff --git a/crates/cdk-cln/src/lib.rs b/crates/cdk-cln/src/lib.rs index 03c26d723..0d0604193 100644 --- a/crates/cdk-cln/src/lib.rs +++ b/crates/cdk-cln/src/lib.rs @@ -219,7 +219,7 @@ impl MintLightning for Cln { }; PayInvoiceResponse { payment_preimage: Some(hex::encode(pay_response.payment_preimage.to_vec())), - payment_hash: pay_response.payment_hash.to_string(), + payment_lookup_id: pay_response.payment_hash.to_string(), status, total_spent: to_unit( pay_response.amount_sent_msat.msat(), @@ -356,7 +356,7 @@ impl MintLightning for Cln { let status = cln_pays_status_to_mint_state(pays_response.status); Ok(PayInvoiceResponse { - payment_hash: pays_response.payment_hash.to_string(), + payment_lookup_id: pays_response.payment_hash.to_string(), payment_preimage: pays_response.preimage.map(|p| hex::encode(p.to_vec())), status, total_spent: pays_response @@ -366,7 +366,7 @@ impl MintLightning for Cln { }) } None => Ok(PayInvoiceResponse { - payment_hash: payment_hash.to_string(), + payment_lookup_id: payment_hash.to_string(), payment_preimage: None, status: MeltQuoteState::Unknown, total_spent: Amount::ZERO, diff --git a/crates/cdk-fake-wallet/src/lib.rs b/crates/cdk-fake-wallet/src/lib.rs index 0875c5929..4f23fdf15 100644 --- a/crates/cdk-fake-wallet/src/lib.rs +++ b/crates/cdk-fake-wallet/src/lib.rs @@ -126,7 +126,7 @@ impl MintLightning for FakeWallet { ) -> Result { Ok(PayInvoiceResponse { payment_preimage: Some("".to_string()), - payment_hash: "".to_string(), + payment_lookup_id: "".to_string(), status: MeltQuoteState::Paid, total_spent: melt_quote.amount, unit: melt_quote.unit, @@ -208,7 +208,7 @@ impl MintLightning for FakeWallet { ) -> Result { Ok(PayInvoiceResponse { payment_preimage: Some("".to_string()), - payment_hash: request_lookup_id.to_string(), + payment_lookup_id: request_lookup_id.to_string(), status: MeltQuoteState::Paid, total_spent: Amount::ZERO, unit: self.get_settings().unit, diff --git a/crates/cdk-lnbits/src/lib.rs b/crates/cdk-lnbits/src/lib.rs index 5ee83ea79..02fb4ecbf 100644 --- a/crates/cdk-lnbits/src/lib.rs +++ b/crates/cdk-lnbits/src/lib.rs @@ -189,7 +189,7 @@ impl MintLightning for LNbits { let total_spent = Amount::from((invoice_info.amount + invoice_info.fee).unsigned_abs()); Ok(PayInvoiceResponse { - payment_hash: pay_response.payment_hash, + payment_lookup_id: pay_response.payment_hash, payment_preimage: Some(invoice_info.payment_hash), status, total_spent, @@ -280,7 +280,7 @@ impl MintLightning for LNbits { })?; let pay_response = PayInvoiceResponse { - payment_hash: payment.details.payment_hash, + payment_lookup_id: payment.details.payment_hash, payment_preimage: Some(payment.preimage), status: lnbits_to_melt_status(&payment.details.status, payment.details.pending), total_spent: Amount::from( diff --git a/crates/cdk-lnd/src/lib.rs b/crates/cdk-lnd/src/lib.rs index 63317c24d..a1a1e5f1f 100644 --- a/crates/cdk-lnd/src/lib.rs +++ b/crates/cdk-lnd/src/lib.rs @@ -207,7 +207,7 @@ impl MintLightning for Lnd { }; Ok(PayInvoiceResponse { - payment_hash: hex::encode(payment_response.payment_hash), + payment_lookup_id: hex::encode(payment_response.payment_hash), payment_preimage, status, total_spent: total_amount.into(), @@ -309,7 +309,7 @@ impl MintLightning for Lnd { let response = match status { PaymentStatus::Unknown => PayInvoiceResponse { - payment_hash: payment_hash.to_string(), + payment_lookup_id: payment_hash.to_string(), payment_preimage: Some(update.payment_preimage), status: MeltQuoteState::Unknown, total_spent: Amount::ZERO, @@ -320,14 +320,14 @@ impl MintLightning for Lnd { continue; } PaymentStatus::Succeeded => PayInvoiceResponse { - payment_hash: payment_hash.to_string(), + payment_lookup_id: payment_hash.to_string(), payment_preimage: Some(update.payment_preimage), status: MeltQuoteState::Paid, total_spent: Amount::from((update.value_sat + update.fee_sat) as u64), unit: CurrencyUnit::Sat, }, PaymentStatus::Failed => PayInvoiceResponse { - payment_hash: payment_hash.to_string(), + payment_lookup_id: payment_hash.to_string(), payment_preimage: Some(update.payment_preimage), status: MeltQuoteState::Unpaid, total_spent: Amount::ZERO, diff --git a/crates/cdk-phoenixd/src/lib.rs b/crates/cdk-phoenixd/src/lib.rs index a27f58670..f1fafea8b 100644 --- a/crates/cdk-phoenixd/src/lib.rs +++ b/crates/cdk-phoenixd/src/lib.rs @@ -185,7 +185,7 @@ impl MintLightning for Phoenixd { let bolt11: Bolt11Invoice = melt_quote.request.parse()?; Ok(PayInvoiceResponse { - payment_hash: bolt11.payment_hash().to_string(), + payment_lookup_id: bolt11.payment_hash().to_string(), payment_preimage: Some(pay_response.payment_preimage), status: MeltQuoteState::Paid, total_spent: total_spent_sats, @@ -253,7 +253,7 @@ impl MintLightning for Phoenixd { let total_spent = res.sent + (res.fees + 999) / 1000; PayInvoiceResponse { - payment_hash: res.payment_hash, + payment_lookup_id: res.payment_hash, payment_preimage: Some(res.preimage), status, total_spent: total_spent.into(), diff --git a/crates/cdk-strike/src/lib.rs b/crates/cdk-strike/src/lib.rs index 0d3385981..e347f89eb 100644 --- a/crates/cdk-strike/src/lib.rs +++ b/crates/cdk-strike/src/lib.rs @@ -172,10 +172,8 @@ impl MintLightning for Strike { let total_spent = from_strike_amount(pay_response.total_amount, &melt_quote.unit)?.into(); - let bolt11: Bolt11Invoice = melt_quote.request.parse()?; - Ok(PayInvoiceResponse { - payment_hash: bolt11.payment_hash().to_string(), + payment_lookup_id: pay_response.payment_id, payment_preimage: None, status: state, total_spent, @@ -252,7 +250,7 @@ impl MintLightning for Strike { }; PayInvoiceResponse { - payment_hash: invoice.payment_id, + payment_lookup_id: invoice.payment_id, payment_preimage: None, status: state, total_spent: from_strike_amount(invoice.total_amount, &self.unit)?.into(), diff --git a/crates/cdk/src/cdk_lightning/mod.rs b/crates/cdk/src/cdk_lightning/mod.rs index 6fe13b5f8..663eee45f 100644 --- a/crates/cdk/src/cdk_lightning/mod.rs +++ b/crates/cdk/src/cdk_lightning/mod.rs @@ -113,7 +113,7 @@ pub struct CreateInvoiceResponse { #[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)] pub struct PayInvoiceResponse { /// Payment hash - pub payment_hash: String, + pub payment_lookup_id: String, /// Payment Preimage pub payment_preimage: Option, /// Status