From 41a6e083b168e8cdb48a51a14cb1559c40fe8f55 Mon Sep 17 00:00:00 2001 From: thesimplekid Date: Tue, 24 Sep 2024 13:29:27 +0200 Subject: [PATCH] feat: check for change in payment lookup id --- crates/cdk-axum/src/router_handlers.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/cdk-axum/src/router_handlers.rs b/crates/cdk-axum/src/router_handlers.rs index d65c67dca..a935add4c 100644 --- a/crates/cdk-axum/src/router_handlers.rs +++ b/crates/cdk-axum/src/router_handlers.rs @@ -321,6 +321,23 @@ pub async fn post_melt_bolt11( // Since it will not fail and even if it does the ln payment has already been paid, proofs should still be burned let amount_spent = to_unit(pre.total_spent, &pre.unit, "e.unit).unwrap_or_default(); + let payment_lookup_id = pre.payment_lookup_id; + + if payment_lookup_id != quote.request_lookup_id { + tracing::info!( + "Payment lookup id changed post payment from {} to {}", + quote.request_lookup_id, + payment_lookup_id + ); + + let mut melt_quote = quote; + melt_quote.request_lookup_id = payment_lookup_id; + + if let Err(err) = state.mint.localstore.add_melt_quote(melt_quote).await { + tracing::warn!("Could not update payment lookup id: {}", err); + } + } + (pre.payment_preimage, amount_spent) } };