From 7888b71f8dc93c9553892f1b9bb0c8cc9d4c882d Mon Sep 17 00:00:00 2001 From: Peter Rounce Date: Thu, 23 Feb 2023 12:10:49 +0000 Subject: [PATCH 1/5] add day_max to /updateboltcard --- db/db.go | 6 +++--- docs/DOCKER_INSTALL.md | 2 +- internalapi/updateboltcard.go | 17 +++++++++++++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/db/db.go b/db/db.go index 0d8c17a..9d489db 100644 --- a/db/db.go +++ b/db/db.go @@ -835,7 +835,7 @@ func Wipe_card(card_name string) (*Card_wipe_info, error) { return &card_wipe_info, nil } -func Update_card(card_name string, tx_limit_sats int, lnurlw_enable bool) error { +func Update_card(card_name string, lnurlw_enable bool, tx_limit_sats int, day_limit_sats int) error { lnurlw_enable_yn := "N" if lnurlw_enable { @@ -850,10 +850,10 @@ func Update_card(card_name string, tx_limit_sats int, lnurlw_enable bool) error defer db.Close() - sqlStatement := `UPDATE cards SET tx_limit_sats = $2, lnurlw_enable = $3 ` + + sqlStatement := `UPDATE cards SET lnurlw_enable = $2, tx_limit_sats = $3, day_limit_sats = $4 ` + `WHERE card_name = $1;` - res, err := db.Exec(sqlStatement, card_name, tx_limit_sats, lnurlw_enable_yn) + res, err := db.Exec(sqlStatement, card_name, lnurlw_enable_yn, tx_limit_sats, day_limit_sats) if err != nil { return err diff --git a/docs/DOCKER_INSTALL.md b/docs/DOCKER_INSTALL.md index 8145361..33e8156 100644 --- a/docs/DOCKER_INSTALL.md +++ b/docs/DOCKER_INSTALL.md @@ -56,5 +56,5 @@ Run `$ docker ps` to list containers and get container names/ids #### running internal API commands - `docker exec boltcard_main curl 'localhost:9001/createboltcard?card_name=card_5&enable=false&tx_max=1000&day_max=10000&uid_privacy=true&allow_neg_bal=true'` -- `docker exec boltcard_main curl 'localhost:9001/updateboltcard?card_name=card_5&enable=true&tx_max=100'` +- `docker exec boltcard_main curl 'localhost:9001/updateboltcard?card_name=card_5&enable=true&tx_max=100&day_max=1000'` - `docker exec boltcard_main curl 'localhost:9001/wipeboltcard?card_name=card_5'` diff --git a/internalapi/updateboltcard.go b/internalapi/updateboltcard.go index b754456..72b5e37 100644 --- a/internalapi/updateboltcard.go +++ b/internalapi/updateboltcard.go @@ -16,6 +16,15 @@ func Updateboltcard(w http.ResponseWriter, r *http.Request) { return } + enable_flag_str := r.URL.Query().Get("enable") + enable_flag, err := strconv.ParseBool(enable_flag_str) + if err != nil { + msg := "updateboltcard: enable is not a valid boolean" + log.Warn(msg) + resp_err.Write_message(w, msg) + return + } + tx_max_str := r.URL.Query().Get("tx_max") tx_max, err := strconv.Atoi(tx_max_str) if err != nil { @@ -25,10 +34,10 @@ func Updateboltcard(w http.ResponseWriter, r *http.Request) { return } - enable_flag_str := r.URL.Query().Get("enable") - enable_flag, err := strconv.ParseBool(enable_flag_str) + day_max_str := r.URL.Query().Get("day_max") + day_max, err := strconv.Atoi(day_max_str) if err != nil { - msg := "updateboltcard: enable is not a valid boolean" + msg := "updateboltcard: day_max is not a valid integer" log.Warn(msg) resp_err.Write_message(w, msg) return @@ -59,7 +68,7 @@ func Updateboltcard(w http.ResponseWriter, r *http.Request) { // update the card record - err = db.Update_card(card_name, tx_max, enable_flag) + err = db.Update_card(card_name, enable_flag, tx_max, day_max) if err != nil { log.Warn(err.Error()) return From 77f9a7daa051cf0013aa1ff2163449156f5d6f98 Mon Sep 17 00:00:00 2001 From: Peter Rounce Date: Thu, 23 Feb 2023 13:50:49 +0000 Subject: [PATCH 2/5] add anchors --- docs/FAQ.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/docs/FAQ.md b/docs/FAQ.md index 8289c09..ef30e43 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -1,29 +1,27 @@ -# FAQ - -> How do you bech32 encode a string on the card ? +# How do you bech32 encode a string on the card ? The LNURLw that comes from the bolt card is not bech32 encoded. It uses [LUD-17](https://github.com/fiatjaf/lnurl-rfc/blob/luds/17.md). -> How do I generate a random key value ? +# How do I generate a random key value ? This will give you a new 128 bit random key as a 32 character hex value. `$ hexdump -vn16 -e'4/4 "%08x" 1 "\n"' /dev/random` -> Why do I get a payment failure with NO_ROUTE ? +# Why do I get a payment failure with NO_ROUTE ? This is due to your payment lightning node not finding a route to the merchant lightning node. It may help to open well funded channels to other well connected nodes. It may also help to increase your maximum network fee in your service variables, **FEE_LIMIT_SAT** / **FEE_LIMIT_PERCENT** . It can be useful to test paying invoices directly from your lightning node. -> Why do my payments take so long ? +# Why do my payments take so long ? This is due to the time taken for your payment lightning node to find a route. It can be improved by opening channels using clearnet rather than on the tor network. It may also help to improve your lightning node hardware or software setup. It can be useful to test paying invoices directly from your lightning node. -> Can I use the same lightning node for the customer (bolt card) and the merchant (POS) ? +# Can I use the same lightning node for the customer (bolt card) and the merchant (POS) ? When tested with LND in Nov 2022, the paying (customer, bolt card) lightning node must be a separate instance to the invoicing (merchant, POS) lightning node. From fe0854b39777b563eeb11d7a5fc9fe420610da84 Mon Sep 17 00:00:00 2001 From: Peter Rounce Date: Thu, 23 Feb 2023 13:51:43 +0000 Subject: [PATCH 3/5] add key creation link --- docs/SETTINGS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/SETTINGS.md b/docs/SETTINGS.md index 31cc6b4..2cc42e1 100644 --- a/docs/SETTINGS.md +++ b/docs/SETTINGS.md @@ -9,7 +9,7 @@ Here are the descriptions of values available to use in the `settings` table: | --- | --- | --- | | LOG_LEVEL | DEBUG | system logs are verbose to enable easier debug | | | PRODUCTION | system logs are minimal | -| AES_DECRYPT_KEY | | hex encoded 128 bit AES key | +| AES_DECRYPT_KEY | | hex encoded 128 bit AES key - see [FAQ](FAQ.md#how-do-i-generate-a-random-key-value-)| | HOST_DOMAIN | yourdomain.com | the domain for hosting lnurlw & lnurlp services | | MIN_WITHDRAW_SATS | 1 | minimum satoshis for lnurlw response | | MAX_WITHDRAW_SATS | 1000000 | maximum satoshis for lnurlw response | From 002dfd2c4ea1d3bae5313d17d917c20829d62424 Mon Sep 17 00:00:00 2001 From: Peter Rounce Date: Thu, 23 Feb 2023 13:55:19 +0000 Subject: [PATCH 4/5] Update SETTINGS.md --- docs/SETTINGS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/SETTINGS.md b/docs/SETTINGS.md index 2cc42e1..d651fc6 100644 --- a/docs/SETTINGS.md +++ b/docs/SETTINGS.md @@ -27,3 +27,6 @@ Here are the descriptions of values available to use in the `settings` table: | AWS_SES_SECRET | | Amazon Web Services - Simple Email Service - access secret | | AWS_SES_EMAIL_FROM | | Amazon Web Services - Simple Email Service - email from field | | EMAIL_MAX_TXS | | maximum number of transactions to include in the email body | +| FUNCTION_LNDHUB | DISABLE | system level switch for using LNDHUB in place of LND | +| LNDHUB_URL | | URL for the LNDHUB service | +| FUNCTION_INTERNAL_API | | system level switch for activating the internal API | From 4042c4174a427c8d777be1bc7a285c7d09ca2236 Mon Sep 17 00:00:00 2001 From: Peter Rounce Date: Thu, 23 Feb 2023 13:55:44 +0000 Subject: [PATCH 5/5] Update SETTINGS.md --- docs/SETTINGS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/SETTINGS.md b/docs/SETTINGS.md index d651fc6..e42df0b 100644 --- a/docs/SETTINGS.md +++ b/docs/SETTINGS.md @@ -29,4 +29,4 @@ Here are the descriptions of values available to use in the `settings` table: | EMAIL_MAX_TXS | | maximum number of transactions to include in the email body | | FUNCTION_LNDHUB | DISABLE | system level switch for using LNDHUB in place of LND | | LNDHUB_URL | | URL for the LNDHUB service | -| FUNCTION_INTERNAL_API | | system level switch for activating the internal API | +| FUNCTION_INTERNAL_API | DISABLE | system level switch for activating the internal API |