From 38cfc3393507f21ab4c294f3e8f46af5438f25c3 Mon Sep 17 00:00:00 2001 From: Peter Rounce Date: Fri, 24 Mar 2023 13:36:16 +0000 Subject: [PATCH] format files --- lndhub/lndhub.go | 68 +++++++++++++++++++-------------------- lnurlw/lnurlw_callback.go | 2 +- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/lndhub/lndhub.go b/lndhub/lndhub.go index 0012e82..d21e609 100644 --- a/lndhub/lndhub.go +++ b/lndhub/lndhub.go @@ -12,53 +12,53 @@ import ( ) type LndhubPayInvoiceRequest struct { - Invoice string `json:"invoice"` - FreeAmount string `json:"freeamount"` - LoginId string `json:"loginid"` + Invoice string `json:"invoice"` + FreeAmount string `json:"freeamount"` + LoginId string `json:"loginid"` } func PayInvoice(cardPaymentId int, invoice string, amountSats int, loginId string, accessToken string) { - lndhub_url := db.Get_setting("LNDHUB_URL") + lndhub_url := db.Get_setting("LNDHUB_URL") client := &http.Client{} - //lndhub.payinvoice API call - var payInvoiceRequest LndhubPayInvoiceRequest - payInvoiceRequest.Invoice = invoice - payInvoiceRequest.FreeAmount = strconv.Itoa(amountSats) - payInvoiceRequest.LoginId = loginId + //lndhub.payinvoice API call + var payInvoiceRequest LndhubPayInvoiceRequest + payInvoiceRequest.Invoice = invoice + payInvoiceRequest.FreeAmount = strconv.Itoa(amountSats) + payInvoiceRequest.LoginId = loginId - req_payinvoice, err := json.Marshal(payInvoiceRequest) - log.Info(string(req_payinvoice)) - if err != nil { - log.WithFields(log.Fields{"card_payment_id": cardPaymentId}).Warn(err) - return - } + req_payinvoice, err := json.Marshal(payInvoiceRequest) + log.Info(string(req_payinvoice)) + if err != nil { + log.WithFields(log.Fields{"card_payment_id": cardPaymentId}).Warn(err) + return + } - req, err := http.NewRequest("POST", lndhub_url+"/payinvoice", bytes.NewBuffer(req_payinvoice)) - if err != nil { - log.WithFields(log.Fields{"card_payment_id": cardPaymentId}).Warn(err) - return - } + req, err := http.NewRequest("POST", lndhub_url+"/payinvoice", bytes.NewBuffer(req_payinvoice)) + if err != nil { + log.WithFields(log.Fields{"card_payment_id": cardPaymentId}).Warn(err) + return + } - req.Header.Add("Access-Control-Allow-Origin", "*") - req.Header.Add("Content-Type", "application/json") - req.Header.Add("Authorization", "Bearer " + accessToken) + req.Header.Add("Access-Control-Allow-Origin", "*") + req.Header.Add("Content-Type", "application/json") + req.Header.Add("Authorization", "Bearer "+accessToken) - res2, err := client.Do(req) - if err != nil { - log.WithFields(log.Fields{"card_payment_id": cardPaymentId}).Warn(err) - return - } + res2, err := client.Do(req) + if err != nil { + log.WithFields(log.Fields{"card_payment_id": cardPaymentId}).Warn(err) + return + } - defer res2.Body.Close() + defer res2.Body.Close() - b2, err := io.ReadAll(res2.Body) - if err != nil { - log.WithFields(log.Fields{"card_payment_id": cardPaymentId}).Warn(err) - return - } + b2, err := io.ReadAll(res2.Body) + if err != nil { + log.WithFields(log.Fields{"card_payment_id": cardPaymentId}).Warn(err) + return + } log.Info(string(b2)) } diff --git a/lnurlw/lnurlw_callback.go b/lnurlw/lnurlw_callback.go index 49c682b..a2e2a0f 100644 --- a/lnurlw/lnurlw_callback.go +++ b/lnurlw/lnurlw_callback.go @@ -104,7 +104,7 @@ func lndhub_payment(w http.ResponseWriter, p *db.Payment, bolt11 decodepay.Bolt1 // {"status": "ERROR", "reason": "error details..."} // JSON response and then attempts to pay the invoices asynchronously. - go lndhub.PayInvoice(p.Card_payment_id, param_pr, int(bolt11.MSatoshi / 1000), card_name_parts[0], auth_keys.AccessToken) + go lndhub.PayInvoice(p.Card_payment_id, param_pr, int(bolt11.MSatoshi/1000), card_name_parts[0], auth_keys.AccessToken) log.Debug("sending 'status OK' response")