Merge branch 'main' into universalwebsocket

This commit is contained in:
Arc
2022-11-29 11:12:28 +00:00
committed by GitHub
8 changed files with 30 additions and 27 deletions

View File

@@ -11,8 +11,10 @@ from urllib.parse import ParseResult, parse_qs, urlencode, urlparse, urlunparse
import httpx import httpx
import pyqrcode import pyqrcode
from fastapi import (Depends, Header, Query, Request, WebSocket, from fastapi import (Depends, Header, Query, Request, WebSocket,
WebSocketDisconnect) WebSocketDisconnect)
from fastapi.exceptions import HTTPException from fastapi.exceptions import HTTPException
from fastapi.params import Body from fastapi.params import Body
from loguru import logger from loguru import logger
@@ -565,8 +567,8 @@ class DecodePayment(BaseModel):
data: str data: str
@core_app.post("/api/v1/payments/decode") @core_app.post("/api/v1/payments/decode", status_code=HTTPStatus.OK)
async def api_payments_decode(data: DecodePayment): async def api_payments_decode(data: DecodePayment, response: Response):
payment_str = data.data payment_str = data.data
try: try:
if payment_str[:5] == "LNURL": if payment_str[:5] == "LNURL":
@@ -587,6 +589,7 @@ async def api_payments_decode(data: DecodePayment):
"min_final_cltv_expiry": invoice.min_final_cltv_expiry, "min_final_cltv_expiry": invoice.min_final_cltv_expiry,
} }
except: except:
response.status_code = HTTPStatus.BAD_REQUEST
return {"message": "Failed to decode"} return {"message": "Failed to decode"}

View File

@@ -8,7 +8,7 @@ async def m001_initial(db):
id {db.serial_primary_key}, id {db.serial_primary_key},
wallet TEXT NOT NULL, wallet TEXT NOT NULL,
description TEXT NOT NULL, description TEXT NOT NULL,
amount INTEGER NOT NULL, amount {db.big_int} NOT NULL,
served_meta INTEGER NOT NULL, served_meta INTEGER NOT NULL,
served_pr INTEGER NOT NULL served_pr INTEGER NOT NULL
); );

View File

@@ -22,7 +22,7 @@ async def m001_initial(db):
description TEXT NOT NULL, description TEXT NOT NULL,
image TEXT, -- image/png;base64,... image TEXT, -- image/png;base64,...
enabled BOOLEAN NOT NULL DEFAULT true, enabled BOOLEAN NOT NULL DEFAULT true,
price INTEGER NOT NULL, price {db.big_int} NOT NULL,
unit TEXT NOT NULL DEFAULT 'sat' unit TEXT NOT NULL DEFAULT 'sat'
); );
""" """

View File

@@ -3,14 +3,14 @@ async def m001_initial(db):
Initial paywalls table. Initial paywalls table.
""" """
await db.execute( await db.execute(
""" f"""
CREATE TABLE paywall.paywalls ( CREATE TABLE paywall.paywalls (
id TEXT PRIMARY KEY, id TEXT PRIMARY KEY,
wallet TEXT NOT NULL, wallet TEXT NOT NULL,
secret TEXT NOT NULL, secret TEXT NOT NULL,
url TEXT NOT NULL, url TEXT NOT NULL,
memo TEXT NOT NULL, memo TEXT NOT NULL,
amount INTEGER NOT NULL, amount {db.big_int} NOT NULL,
time TIMESTAMP NOT NULL DEFAULT """ time TIMESTAMP NOT NULL DEFAULT """
+ db.timestamp_now + db.timestamp_now
+ """ + """
@@ -25,14 +25,14 @@ async def m002_redux(db):
""" """
await db.execute("ALTER TABLE paywall.paywalls RENAME TO paywalls_old") await db.execute("ALTER TABLE paywall.paywalls RENAME TO paywalls_old")
await db.execute( await db.execute(
""" f"""
CREATE TABLE paywall.paywalls ( CREATE TABLE paywall.paywalls (
id TEXT PRIMARY KEY, id TEXT PRIMARY KEY,
wallet TEXT NOT NULL, wallet TEXT NOT NULL,
url TEXT NOT NULL, url TEXT NOT NULL,
memo TEXT NOT NULL, memo TEXT NOT NULL,
description TEXT NULL, description TEXT NULL,
amount INTEGER DEFAULT 0, amount {db.big_int} DEFAULT 0,
time TIMESTAMP NOT NULL DEFAULT """ time TIMESTAMP NOT NULL DEFAULT """
+ db.timestamp_now + db.timestamp_now
+ """, + """,

View File

@@ -3,14 +3,14 @@ async def m001_initial(db):
Creates an improved satsdice table and migrates the existing data. Creates an improved satsdice table and migrates the existing data.
""" """
await db.execute( await db.execute(
""" f"""
CREATE TABLE satsdice.satsdice_pay ( CREATE TABLE satsdice.satsdice_pay (
id TEXT PRIMARY KEY, id TEXT PRIMARY KEY,
wallet TEXT, wallet TEXT,
title TEXT, title TEXT,
min_bet INTEGER, min_bet INTEGER,
max_bet INTEGER, max_bet INTEGER,
amount INTEGER DEFAULT 0, amount {db.big_int} DEFAULT 0,
served_meta INTEGER NOT NULL, served_meta INTEGER NOT NULL,
served_pr INTEGER NOT NULL, served_pr INTEGER NOT NULL,
multiplier FLOAT, multiplier FLOAT,
@@ -28,11 +28,11 @@ async def m002_initial(db):
Creates an improved satsdice table and migrates the existing data. Creates an improved satsdice table and migrates the existing data.
""" """
await db.execute( await db.execute(
""" f"""
CREATE TABLE satsdice.satsdice_withdraw ( CREATE TABLE satsdice.satsdice_withdraw (
id TEXT PRIMARY KEY, id TEXT PRIMARY KEY,
satsdice_pay TEXT, satsdice_pay TEXT,
value INTEGER DEFAULT 1, value {db.big_int} DEFAULT 1,
unique_hash TEXT UNIQUE, unique_hash TEXT UNIQUE,
k1 TEXT, k1 TEXT,
open_time INTEGER, open_time INTEGER,
@@ -47,11 +47,11 @@ async def m003_initial(db):
Creates an improved satsdice table and migrates the existing data. Creates an improved satsdice table and migrates the existing data.
""" """
await db.execute( await db.execute(
""" f"""
CREATE TABLE satsdice.satsdice_payment ( CREATE TABLE satsdice.satsdice_payment (
payment_hash TEXT PRIMARY KEY, payment_hash TEXT PRIMARY KEY,
satsdice_pay TEXT, satsdice_pay TEXT,
value INTEGER, value {db.big_int},
paid BOOL DEFAULT FALSE, paid BOOL DEFAULT FALSE,
lost BOOL DEFAULT FALSE lost BOOL DEFAULT FALSE
); );

View File

@@ -4,7 +4,7 @@ async def m001_initial(db):
""" """
await db.execute( await db.execute(
""" f"""
CREATE TABLE satspay.charges ( CREATE TABLE satspay.charges (
id TEXT NOT NULL PRIMARY KEY, id TEXT NOT NULL PRIMARY KEY,
"user" TEXT, "user" TEXT,
@@ -18,8 +18,8 @@ async def m001_initial(db):
completelink TEXT, completelink TEXT,
completelinktext TEXT, completelinktext TEXT,
time INTEGER, time INTEGER,
amount INTEGER, amount {db.big_int},
balance INTEGER DEFAULT 0, balance {db.big_int} DEFAULT 0,
timestamp TIMESTAMP NOT NULL DEFAULT """ timestamp TIMESTAMP NOT NULL DEFAULT """
+ db.timestamp_now + db.timestamp_now
+ """ + """

View File

@@ -3,25 +3,25 @@ async def m001_initial(db):
Initial wallet table. Initial wallet table.
""" """
await db.execute( await db.execute(
""" f"""
CREATE TABLE watchonly.wallets ( CREATE TABLE watchonly.wallets (
id TEXT NOT NULL PRIMARY KEY, id TEXT NOT NULL PRIMARY KEY,
"user" TEXT, "user" TEXT,
masterpub TEXT NOT NULL, masterpub TEXT NOT NULL,
title TEXT NOT NULL, title TEXT NOT NULL,
address_no INTEGER NOT NULL DEFAULT 0, address_no INTEGER NOT NULL DEFAULT 0,
balance INTEGER NOT NULL balance {db.big_int} NOT NULL
); );
""" """
) )
await db.execute( await db.execute(
""" f"""
CREATE TABLE watchonly.addresses ( CREATE TABLE watchonly.addresses (
id TEXT NOT NULL PRIMARY KEY, id TEXT NOT NULL PRIMARY KEY,
address TEXT NOT NULL, address TEXT NOT NULL,
wallet TEXT NOT NULL, wallet TEXT NOT NULL,
amount INTEGER NOT NULL amount {db.big_int} NOT NULL
); );
""" """
) )

View File

@@ -3,13 +3,13 @@ async def m001_initial(db):
Creates an improved withdraw table and migrates the existing data. Creates an improved withdraw table and migrates the existing data.
""" """
await db.execute( await db.execute(
""" f"""
CREATE TABLE withdraw.withdraw_links ( CREATE TABLE withdraw.withdraw_links (
id TEXT PRIMARY KEY, id TEXT PRIMARY KEY,
wallet TEXT, wallet TEXT,
title TEXT, title TEXT,
min_withdrawable INTEGER DEFAULT 1, min_withdrawable {db.big_int} DEFAULT 1,
max_withdrawable INTEGER DEFAULT 1, max_withdrawable {db.big_int} DEFAULT 1,
uses INTEGER DEFAULT 1, uses INTEGER DEFAULT 1,
wait_time INTEGER, wait_time INTEGER,
is_unique INTEGER DEFAULT 0, is_unique INTEGER DEFAULT 0,
@@ -28,13 +28,13 @@ async def m002_change_withdraw_table(db):
Creates an improved withdraw table and migrates the existing data. Creates an improved withdraw table and migrates the existing data.
""" """
await db.execute( await db.execute(
""" f"""
CREATE TABLE withdraw.withdraw_link ( CREATE TABLE withdraw.withdraw_link (
id TEXT PRIMARY KEY, id TEXT PRIMARY KEY,
wallet TEXT, wallet TEXT,
title TEXT, title TEXT,
min_withdrawable INTEGER DEFAULT 1, min_withdrawable {db.big_int} DEFAULT 1,
max_withdrawable INTEGER DEFAULT 1, max_withdrawable {db.big_int} DEFAULT 1,
uses INTEGER DEFAULT 1, uses INTEGER DEFAULT 1,
wait_time INTEGER, wait_time INTEGER,
is_unique INTEGER DEFAULT 0, is_unique INTEGER DEFAULT 0,