commit 88dfb8f898d61ac8159616cbc9b7e6ff7b8d1e74
parent 0fbad0df3bad16ccd5a2669641c1216fd0310d61
Author: Nick <nick@nickfarrow.com>
Date: Tue, 13 Sep 2022 22:51:59 +1000
Merge pull request #97 from kristapsk/store-name
Add configurable "store name"
Diffstat:
4 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/config.py b/config.py
@@ -107,6 +107,7 @@ pollrate = get_opt("pollrate", 15)
payment_timeout = get_opt("payment_timeout", 60 * 60)
required_confirmations = get_opt("required_confirmations", 2)
connection_attempts = get_opt("connection_attempts", 3)
+store_name = get_opt("store_name", "SatSale")
redirect = get_opt("redirect", "https://github.com/nickfarrow/satsale")
bitcoin_rate_multiplier = get_opt("bitcoin_rate_multiplier", 1.00)
allowed_underpay_amount = get_opt("allowed_underpay_amount", 0.00000001)
diff --git a/config.toml b/config.toml
@@ -87,6 +87,10 @@ connection_attempts = 15
# Console log level (DEBUG, INFO, WARNING, ERROR)
loglevel = "DEBUG"
+# This can be set to store name or whatever. Will be used as a prefix
+# for invoice ids.
+store_name = "SatSale"
+
# Generic redirect url after payment
redirect = "https://github.com/nickfarrow/satsale"
diff --git a/node/clightning.py b/node/clightning.py
@@ -78,7 +78,7 @@ class clightning:
# Multiplying by 10^8 to convert to satoshi units
msats_amount = int(float(btc_amount) * 10 ** (3 + 8))
lnd_invoice = self.clightning.invoice(
- msats_amount, label, "SatSale-{}".format(label), expiry
+ msats_amount, label, label, expiry
)
return lnd_invoice["bolt11"], lnd_invoice["payment_hash"]
diff --git a/satsale.py b/satsale.py
@@ -163,8 +163,12 @@ class create_payment(Resource):
)
return {"message": "Amount below dust limit."}, 406
+ if config.store_name:
+ invoice_uuid = "{}-{}".format(config.store_name, str(uuid.uuid4().hex))
+ else:
+ invoice_uuid = str(uuid.uuid4().hex)
invoice = {
- "uuid": str(uuid.uuid4().hex),
+ "uuid": invoice_uuid,
"base_currency": currency,
"base_value": base_amount,
"btc_value": btc_amount_format(btc_value),