From 96d9c3ba0d03f608cce0b3ee7b8f8644bf32e6e6 Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Tue, 28 Mar 2023 11:27:19 +1300 Subject: [PATCH] Add the tx limit and daily limit check in the lndhub payment function --- lnurlw/lnurlw_callback.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lnurlw/lnurlw_callback.go b/lnurlw/lnurlw_callback.go index a2e2a0f..dfdba52 100644 --- a/lnurlw/lnurlw_callback.go +++ b/lnurlw/lnurlw_callback.go @@ -38,6 +38,25 @@ func lndhub_payment(w http.ResponseWriter, p *db.Payment, bolt11 decodepay.Bolt1 return } + //check the tx limit + if invoice_sats > c.Tx_limit_sats { + log.WithFields(log.Fields{"card_payment_id": p.Card_payment_id}).Info("invoice_sats: ", invoice_sats) + log.WithFields(log.Fields{"card_payment_id": p.Card_payment_id}).Info("tx_limit_sats: ", c.Tx_limit_sats) + log.WithFields(log.Fields{"card_payment_id": p.Card_payment_id}).Info("over tx_limit_sats!") + resp_err.Write(w) + return + } + + //check the daily limit + if day_total_sats+invoice_sats > c.Day_limit_sats { + log.WithFields(log.Fields{"card_payment_id": p.Card_payment_id}).Info("invoice_sats: ", invoice_sats) + log.WithFields(log.Fields{"card_payment_id": p.Card_payment_id}).Info("day_total_sats: ", day_total_sats) + log.WithFields(log.Fields{"card_payment_id": p.Card_payment_id}).Info("day_limit_sats: ", c.Day_limit_sats) + log.WithFields(log.Fields{"card_payment_id": p.Card_payment_id}).Info("over day_limit_sats!") + resp_err.Write(w) + return + } + //lndhub.auth API call //the login JSON is held in the Card_name field // as "login:password"