Răsfoiți Sursa

feat: cln as msats (#982)

* feat: cln as msats

* fix(logging): correct bolt12 payment amount units and reduce log noise

- Fix CLN bolt12 payment logging to display msats instead of sats
- Add tower_http filter to reduce integration test log verbosity
- Use correct payment amount variable in mint quote pubsub notifications
thesimplekid 1 lună în urmă
părinte
comite
b6f7a75fba

+ 5 - 6
crates/cdk-cln/src/lib.rs

@@ -193,7 +193,6 @@ impl MintPayment for Cln {
                                     continue;
                                 }
                             };
-                            let amount_sats = amount_msats.msat() / 1000;
 
                             let payment_hash = Hash::from_bytes_ref(payment_hash.as_ref());
 
@@ -211,8 +210,8 @@ impl MintPayment for Cln {
                                     {
                                         Ok(Some(invoice)) => {
                                             if let Some(local_offer_id) = invoice.local_offer_id {
-                                                tracing::info!("CLN: Received bolt12 payment of {} sats for offer {}", 
-                                                             amount_sats, local_offer_id);
+                                                tracing::info!("CLN: Received bolt12 payment of {} msats for offer {}", 
+                                                             amount_msats.msat(), local_offer_id);
                                                 PaymentIdentifier::OfferId(local_offer_id.to_string())
                                             } else {
                                                 tracing::warn!("CLN: BOLT12 invoice has no local_offer_id, skipping");
@@ -239,11 +238,11 @@ impl MintPayment for Cln {
 
                             let response = WaitPaymentResponse {
                                 payment_identifier: request_lookup_id,
-                                payment_amount: amount_sats.into(),
-                                unit: CurrencyUnit::Sat,
+                                payment_amount: amount_msats.msat().into(),
+                                unit: CurrencyUnit::Msat,
                                 payment_id: payment_hash.to_string()
                             };
-                            tracing::info!("CLN: Created WaitPaymentResponse with amount {} sats", amount_sats);
+                            tracing::info!("CLN: Created WaitPaymentResponse with amount {} msats", amount_msats.msat());
 
                             break Some((response, (cln_client, last_pay_idx, cancel_token, is_active)));
                                 }

+ 2 - 1
crates/cdk-integration-tests/src/cli.rs

@@ -29,9 +29,10 @@ pub fn init_logging(enable_logging: bool, log_level: tracing::Level) {
         let h2_filter = "h2=warn";
         let rustls_filter = "rustls=warn";
         let reqwest_filter = "reqwest=warn";
+        let tower_filter = "tower_http=warn";
 
         let env_filter = EnvFilter::new(format!(
-            "{default_filter},{sqlx_filter},{hyper_filter},{h2_filter},{rustls_filter},{reqwest_filter}"
+            "{default_filter},{sqlx_filter},{hyper_filter},{h2_filter},{rustls_filter},{reqwest_filter},{tower_filter}"
         ));
 
         // Ok if successful, Err if already initialized

+ 1 - 1
crates/cdk/src/mint/mod.rs

@@ -588,7 +588,7 @@ impl Mint {
                     PaymentMethod::Bolt12 => {
                         pubsub_manager.mint_quote_bolt12_status(
                             mint_quote.clone(),
-                            wait_payment_response.payment_amount,
+                            payment_amount_quote_unit,
                             Amount::ZERO,
                         );
                     }