From b1c75813a0fcd7c157c231c136193b3f18773536 Mon Sep 17 00:00:00 2001 From: calle <93376500+callebtc@users.noreply.github.com> Date: Thu, 24 Mar 2022 12:50:57 +0100 Subject: [PATCH 1/6] fix decodepay (#568) --- lnbits/core/views/api.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lnbits/core/views/api.py b/lnbits/core/views/api.py index 31622d8e..0e88b5c8 100644 --- a/lnbits/core/views/api.py +++ b/lnbits/core/views/api.py @@ -125,7 +125,7 @@ async def api_payments(wallet: WalletTypeInfo = Depends(get_key_type)): class CreateInvoiceData(BaseModel): out: Optional[bool] = True amount: float = Query(None, ge=0) - memo: str = None + memo: Optional[str] = None unit: Optional[str] = "sat" description_hash: Optional[str] = None lnurl_callback: Optional[str] = None @@ -513,15 +513,19 @@ async def api_lnurlscan(code: str): return params +class DecodePayment(BaseModel): + data: str + + @core_app.post("/api/v1/payments/decode") -async def api_payments_decode(data: str = Query(None)): - print(data) +async def api_payments_decode(data: DecodePayment): + payment_str = data.data try: - if data[:5] == "LNURL": - url = lnurl.decode(data) + if payment_str[:5] == "LNURL": + url = lnurl.decode(payment_str) return {"domain": url} else: - invoice = bolt11.decode(data) + invoice = bolt11.decode(payment_str) return { "payment_hash": invoice.payment_hash, "amount_msat": invoice.amount_msat, From 946ebc350ee0bf0a9fb654c12a0e95569b6d045f Mon Sep 17 00:00:00 2001 From: Axel Hodler Date: Sun, 27 Mar 2022 17:03:24 +0200 Subject: [PATCH 2/6] fail early if LNBITS_DATA_FOLDER missing --- lnbits/db.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lnbits/db.py b/lnbits/db.py index 02850958..7bbfa5c5 100644 --- a/lnbits/db.py +++ b/lnbits/db.py @@ -130,9 +130,15 @@ class Database(Compat): ) ) else: - self.path = os.path.join(LNBITS_DATA_FOLDER, f"{self.name}.sqlite3") - database_uri = f"sqlite:///{self.path}" - self.type = SQLITE + if os.path.isdir(LNBITS_DATA_FOLDER): + self.path = os.path.join(LNBITS_DATA_FOLDER, f"{self.name}.sqlite3") + database_uri = f"sqlite:///{self.path}" + self.type = SQLITE + else: + raise NotADirectoryError( + f"LNBITS_DATA_FOLDER named {LNBITS_DATA_FOLDER} was not created" + f" - please 'mkdir {LNBITS_DATA_FOLDER}' and try again" + ) self.schema = self.name if self.name.startswith("ext_"): From a94444ae2ce663d12a3773386492fbc169b84f12 Mon Sep 17 00:00:00 2001 From: rimthekid Date: Wed, 30 Mar 2022 05:22:48 -0700 Subject: [PATCH 3/6] add IRT --- lnbits/utils/exchange_rates.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lnbits/utils/exchange_rates.py b/lnbits/utils/exchange_rates.py index 53a5a80b..4de1da8a 100644 --- a/lnbits/utils/exchange_rates.py +++ b/lnbits/utils/exchange_rates.py @@ -71,6 +71,7 @@ currencies = { "IMP": "Isle of Man Pound", "INR": "Indian Rupee", "IQD": "Iraqi Dinar", + "IRT": "Iranian Toman", "ISK": "Icelandic Króna", "JEP": "Jersey Pound", "JMD": "Jamaican Dollar", @@ -179,6 +180,12 @@ class Provider(NamedTuple): exchange_rate_providers = { + "exir": Provider( + "Exir", + "exir.io", + "https://api.exir.io/v1/ticker?symbol={from}-{to}", + lambda data, replacements: data["last"], + ), "bitfinex": Provider( "Bitfinex", "bitfinex.com", From c5c76468cb717db160a509620b49f1312bd037a9 Mon Sep 17 00:00:00 2001 From: Ashkan Jalali <55811147+ashkanjalaliQ@users.noreply.github.com> Date: Fri, 1 Apr 2022 20:05:53 +0430 Subject: [PATCH 4/6] add "IRT" currency to TPos extention --- lnbits/extensions/tpos/templates/tpos/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/lnbits/extensions/tpos/templates/tpos/index.html b/lnbits/extensions/tpos/templates/tpos/index.html index b7e6daa1..7eb19307 100644 --- a/lnbits/extensions/tpos/templates/tpos/index.html +++ b/lnbits/extensions/tpos/templates/tpos/index.html @@ -222,6 +222,7 @@ 'INR', 'IQD', 'IRR', + 'IRT' 'ISK', 'JEP', 'JMD', From 810b91861998694a01100e53e58fcb1ffc46ed86 Mon Sep 17 00:00:00 2001 From: arcbtc Date: Sat, 2 Apr 2022 00:36:50 +0100 Subject: [PATCH 5/6] quick fix --- lnbits/extensions/tpos/templates/tpos/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lnbits/extensions/tpos/templates/tpos/index.html b/lnbits/extensions/tpos/templates/tpos/index.html index 7eb19307..a8971211 100644 --- a/lnbits/extensions/tpos/templates/tpos/index.html +++ b/lnbits/extensions/tpos/templates/tpos/index.html @@ -222,7 +222,7 @@ 'INR', 'IQD', 'IRR', - 'IRT' + 'IRT', 'ISK', 'JEP', 'JMD', From 2f381960a07d62e5da16e721bedd77e881095b82 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Tue, 5 Apr 2022 08:44:38 -0300 Subject: [PATCH 6/6] fix sparko invoice checking ("expired" was being considered as "paid"). --- lnbits/wallets/spark.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lnbits/wallets/spark.py b/lnbits/wallets/spark.py index 9404de6f..00bf6d3c 100644 --- a/lnbits/wallets/spark.py +++ b/lnbits/wallets/spark.py @@ -152,9 +152,11 @@ class SparkWallet(Wallet): if not r or not r.get("invoices"): return PaymentStatus(None) - if r["invoices"][0]["status"] == "unpaid": + + if r["invoices"][0]["status"] == "paid": + return PaymentStatus(True) + else: return PaymentStatus(False) - return PaymentStatus(True) async def get_payment_status(self, checking_id: str) -> PaymentStatus: # check if it's 32 bytes hex