SatSale

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 5f55ac27f4cf370e62262f80027a6a1a0395440e
parent 8f10bf0c4cbaa9edd1f3d6287b60dabcee5399a5
Author: Kristaps Kaupe <kristaps@blogiem.lv>
Date:   Sun, 11 Sep 2022 15:35:44 +0300

Add configurable "store name"

Diffstat:
Mconfig.py | 1+
Mconfig.toml | 4++++
Mnode/clightning.py | 2+-
Msatsale.py | 6+++++-
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),