reformat with gofmt

This commit is contained in:
Peter Rounce 2023-01-29 10:33:34 +00:00
parent d82c17e0a1
commit 7816566d59
9 changed files with 221 additions and 216 deletions

View file

@ -27,7 +27,7 @@ func db_open() (*sql.DB, error) {
return db, nil return db, nil
} }
func db_get_setting(setting_name string) (string) { func db_get_setting(setting_name string) string {
setting_value := "" setting_value := ""
@ -74,13 +74,19 @@ func db_insert_card(one_time_code string, k0_auth_key string, k2_cmac_key string
allow_neg_bal_ptr bool) error { allow_neg_bal_ptr bool) error {
lnurlw_enable_yn := "N" lnurlw_enable_yn := "N"
if lnurlw_enable { lnurlw_enable_yn = "Y" } if lnurlw_enable {
lnurlw_enable_yn = "Y"
}
uid_privacy_yn := "N" uid_privacy_yn := "N"
if uid_privacy { uid_privacy_yn = "Y" } if uid_privacy {
uid_privacy_yn = "Y"
}
allow_neg_bal_yn := "N" allow_neg_bal_yn := "N"
if allow_neg_bal_ptr { allow_neg_bal_yn = "Y" } if allow_neg_bal_ptr {
allow_neg_bal_yn = "Y"
}
db, err := db_open() db, err := db_open()
if err != nil { if err != nil {

View file

@ -65,7 +65,7 @@ func db_open() (*sql.DB, error) {
return db, nil return db, nil
} }
func db_get_setting(setting_name string) (string) { func db_get_setting(setting_name string) string {
setting_value := "" setting_value := ""

View file

@ -2,14 +2,14 @@ package main
import ( import (
"context" "context"
"crypto/sha256"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
log "github.com/sirupsen/logrus"
"io" "io"
"io/ioutil" "io/ioutil"
log "github.com/sirupsen/logrus"
"strconv" "strconv"
"time" "time"
"crypto/sha256"
decodepay "github.com/fiatjaf/ln-decodepay" decodepay "github.com/fiatjaf/ln-decodepay"
lnrpc "github.com/lightningnetwork/lnd/lnrpc" lnrpc "github.com/lightningnetwork/lnd/lnrpc"
@ -106,7 +106,7 @@ func add_invoice(amount_sat int64, metadata string) (payment_request string, r_h
// https://api.lightning.community/?shell#subscribesingleinvoice // https://api.lightning.community/?shell#subscribesingleinvoice
func monitor_invoice_state(r_hash []byte) () { func monitor_invoice_state(r_hash []byte) {
// SubscribeSingleInvoice // SubscribeSingleInvoice
@ -154,7 +154,7 @@ func monitor_invoice_state(r_hash []byte) () {
log.Fields{ log.Fields{
"r_hash": hex.EncodeToString(r_hash), "r_hash": hex.EncodeToString(r_hash),
"invoice_state": invoice_state, "invoice_state": invoice_state,
},).Info("invoice state updated") }).Info("invoice state updated")
db_update_receipt_state(hex.EncodeToString(r_hash), invoice_state) db_update_receipt_state(hex.EncodeToString(r_hash), invoice_state)
} }

View file

@ -1,11 +1,11 @@
package main package main
import ( import (
log "github.com/sirupsen/logrus" "encoding/hex"
"github.com/gorilla/mux" "github.com/gorilla/mux"
log "github.com/sirupsen/logrus"
"net/http" "net/http"
"strconv" "strconv"
"encoding/hex"
) )
func lnurlp_callback(w http.ResponseWriter, r *http.Request) { func lnurlp_callback(w http.ResponseWriter, r *http.Request) {
@ -31,7 +31,7 @@ func lnurlp_callback(w http.ResponseWriter, r *http.Request) {
"card_id": card_id, "card_id": card_id,
"amount": amount, "amount": amount,
"req.Host": r.Host, "req.Host": r.Host,
},).Info("lnurlp_callback") }).Info("lnurlp_callback")
domain := db_get_setting("HOST_DOMAIN") domain := db_get_setting("HOST_DOMAIN")
if r.Host != domain { if r.Host != domain {
@ -47,7 +47,7 @@ func lnurlp_callback(w http.ResponseWriter, r *http.Request) {
return return
} }
amount_sat := amount_msat / 1000; amount_sat := amount_msat / 1000
metadata := "[[\"text/identifier\",\"" + name + "@" + domain + "\"],[\"text/plain\",\"bolt card deposit\"]]" metadata := "[[\"text/identifier\",\"" + name + "@" + domain + "\"],[\"text/plain\",\"bolt card deposit\"]]"
pr, r_hash, err := add_invoice(amount_sat, metadata) pr, r_hash, err := add_invoice(amount_sat, metadata)
@ -66,7 +66,7 @@ func lnurlp_callback(w http.ResponseWriter, r *http.Request) {
go monitor_invoice_state(r_hash) go monitor_invoice_state(r_hash)
log.Debug("sending 'status OK' response"); log.Debug("sending 'status OK' response")
jsonData := []byte(`{` + jsonData := []byte(`{` +
`"status":"OK",` + `"status":"OK",` +

View file

@ -1,8 +1,8 @@
package main package main
import ( import (
log "github.com/sirupsen/logrus"
"github.com/gorilla/mux" "github.com/gorilla/mux"
log "github.com/sirupsen/logrus"
"net/http" "net/http"
) )
@ -19,7 +19,7 @@ func lnurlp_response(w http.ResponseWriter, r *http.Request) {
"url_path": r.URL.Path, "url_path": r.URL.Path,
"name": name, "name": name,
"r.Host": r.Host, "r.Host": r.Host,
},).Info("lnurlp_response") }).Info("lnurlp_response")
// look up domain setting (HOST_DOMAIN) // look up domain setting (HOST_DOMAIN)

View file

@ -1,8 +1,8 @@
package main package main
import ( import (
log "github.com/sirupsen/logrus"
"github.com/gorilla/mux" "github.com/gorilla/mux"
log "github.com/sirupsen/logrus"
"net/http" "net/http"
"time" "time"
) )

View file

@ -27,7 +27,7 @@ func db_open() (*sql.DB, error) {
return db, nil return db, nil
} }
func db_get_setting(setting_name string) (string) { func db_get_setting(setting_name string) string {
setting_value := "" setting_value := ""

View file

@ -3,9 +3,9 @@ package main
import ( import (
"flag" "flag"
"fmt" "fmt"
"strconv"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
qrcode "github.com/skip2/go-qrcode" qrcode "github.com/skip2/go-qrcode"
"strconv"
) )
type card_wipe_info struct { type card_wipe_info struct {
@ -29,7 +29,6 @@ func main() {
return return
} }
// check if card_name exists // check if card_name exists
card_count, err := db_get_card_name_count(*card_name_ptr) card_count, err := db_get_card_name_count(*card_name_ptr)
@ -63,7 +62,7 @@ func main() {
`"k4": "` + card_wipe_info_values.k4 + `",` + `"k4": "` + card_wipe_info_values.k4 + `",` +
`"uid": "` + card_wipe_info_values.uid + `",` + `"uid": "` + card_wipe_info_values.uid + `",` +
`"version": 1` + `"version": 1` +
`}`; `}`
fmt.Println() fmt.Println()
q, err := qrcode.New(qr, qrcode.Medium) q, err := qrcode.New(qr, qrcode.Medium)