mirror of
https://github.com/lnbits/lnbits.git
synced 2025-07-07 05:50:29 +02:00
Merge branch 'main' into fix/renameWallet
This commit is contained in:
@ -125,7 +125,7 @@ async def api_payments(wallet: WalletTypeInfo = Depends(get_key_type)):
|
|||||||
class CreateInvoiceData(BaseModel):
|
class CreateInvoiceData(BaseModel):
|
||||||
out: Optional[bool] = True
|
out: Optional[bool] = True
|
||||||
amount: float = Query(None, ge=0)
|
amount: float = Query(None, ge=0)
|
||||||
memo: str = None
|
memo: Optional[str] = None
|
||||||
unit: Optional[str] = "sat"
|
unit: Optional[str] = "sat"
|
||||||
description_hash: Optional[str] = None
|
description_hash: Optional[str] = None
|
||||||
lnurl_callback: Optional[str] = None
|
lnurl_callback: Optional[str] = None
|
||||||
@ -513,15 +513,19 @@ async def api_lnurlscan(code: str):
|
|||||||
return params
|
return params
|
||||||
|
|
||||||
|
|
||||||
|
class DecodePayment(BaseModel):
|
||||||
|
data: str
|
||||||
|
|
||||||
|
|
||||||
@core_app.post("/api/v1/payments/decode")
|
@core_app.post("/api/v1/payments/decode")
|
||||||
async def api_payments_decode(data: str = Query(None)):
|
async def api_payments_decode(data: DecodePayment):
|
||||||
print(data)
|
payment_str = data.data
|
||||||
try:
|
try:
|
||||||
if data[:5] == "LNURL":
|
if payment_str[:5] == "LNURL":
|
||||||
url = lnurl.decode(data)
|
url = lnurl.decode(payment_str)
|
||||||
return {"domain": url}
|
return {"domain": url}
|
||||||
else:
|
else:
|
||||||
invoice = bolt11.decode(data)
|
invoice = bolt11.decode(payment_str)
|
||||||
return {
|
return {
|
||||||
"payment_hash": invoice.payment_hash,
|
"payment_hash": invoice.payment_hash,
|
||||||
"amount_msat": invoice.amount_msat,
|
"amount_msat": invoice.amount_msat,
|
||||||
|
12
lnbits/db.py
12
lnbits/db.py
@ -130,9 +130,15 @@ class Database(Compat):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.path = os.path.join(LNBITS_DATA_FOLDER, f"{self.name}.sqlite3")
|
if os.path.isdir(LNBITS_DATA_FOLDER):
|
||||||
database_uri = f"sqlite:///{self.path}"
|
self.path = os.path.join(LNBITS_DATA_FOLDER, f"{self.name}.sqlite3")
|
||||||
self.type = SQLITE
|
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
|
self.schema = self.name
|
||||||
if self.name.startswith("ext_"):
|
if self.name.startswith("ext_"):
|
||||||
|
@ -222,6 +222,7 @@
|
|||||||
'INR',
|
'INR',
|
||||||
'IQD',
|
'IQD',
|
||||||
'IRR',
|
'IRR',
|
||||||
|
'IRT',
|
||||||
'ISK',
|
'ISK',
|
||||||
'JEP',
|
'JEP',
|
||||||
'JMD',
|
'JMD',
|
||||||
|
@ -71,6 +71,7 @@ currencies = {
|
|||||||
"IMP": "Isle of Man Pound",
|
"IMP": "Isle of Man Pound",
|
||||||
"INR": "Indian Rupee",
|
"INR": "Indian Rupee",
|
||||||
"IQD": "Iraqi Dinar",
|
"IQD": "Iraqi Dinar",
|
||||||
|
"IRT": "Iranian Toman",
|
||||||
"ISK": "Icelandic Króna",
|
"ISK": "Icelandic Króna",
|
||||||
"JEP": "Jersey Pound",
|
"JEP": "Jersey Pound",
|
||||||
"JMD": "Jamaican Dollar",
|
"JMD": "Jamaican Dollar",
|
||||||
@ -179,6 +180,12 @@ class Provider(NamedTuple):
|
|||||||
|
|
||||||
|
|
||||||
exchange_rate_providers = {
|
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": Provider(
|
||||||
"Bitfinex",
|
"Bitfinex",
|
||||||
"bitfinex.com",
|
"bitfinex.com",
|
||||||
|
@ -152,9 +152,11 @@ class SparkWallet(Wallet):
|
|||||||
|
|
||||||
if not r or not r.get("invoices"):
|
if not r or not r.get("invoices"):
|
||||||
return PaymentStatus(None)
|
return PaymentStatus(None)
|
||||||
if r["invoices"][0]["status"] == "unpaid":
|
|
||||||
|
if r["invoices"][0]["status"] == "paid":
|
||||||
|
return PaymentStatus(True)
|
||||||
|
else:
|
||||||
return PaymentStatus(False)
|
return PaymentStatus(False)
|
||||||
return PaymentStatus(True)
|
|
||||||
|
|
||||||
async def get_payment_status(self, checking_id: str) -> PaymentStatus:
|
async def get_payment_status(self, checking_id: str) -> PaymentStatus:
|
||||||
# check if it's 32 bytes hex
|
# check if it's 32 bytes hex
|
||||||
|
Reference in New Issue
Block a user