Add the tx limit and daily limit check in the lndhub payment function

This commit is contained in:
Chloe Jung 2023-03-28 11:27:19 +13:00
parent 500eb9e8cd
commit 96d9c3ba0d

View file

@ -38,6 +38,25 @@ func lndhub_payment(w http.ResponseWriter, p *db.Payment, bolt11 decodepay.Bolt1
return 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 //lndhub.auth API call
//the login JSON is held in the Card_name field //the login JSON is held in the Card_name field
// as "login:password" // as "login:password"