mirror of
https://github.com/lnbits/lnbits.git
synced 2025-09-20 04:21:20 +02:00
fix: rebase clean-up
This commit is contained in:
@@ -7,8 +7,8 @@ from lnbits.core.services import create_invoice
|
||||
from lnbits.core.views.api import api_payment
|
||||
from lnbits.helpers import urlsafe_short_hash
|
||||
|
||||
from . import db
|
||||
from ..watchonly.crud import get_config, get_fresh_address
|
||||
from . import db
|
||||
from .helpers import fetch_onchain_balance
|
||||
from .models import Charges, CreateCharge, SatsPayThemes
|
||||
|
||||
@@ -26,9 +26,6 @@ async def create_charge(user: str, data: CreateCharge) -> Charges:
|
||||
onchainaddress = onchain.address
|
||||
else:
|
||||
onchainaddress = None
|
||||
data.extra = json.dumps(
|
||||
{"mempool_endpoint": "https://mempool.space", "network": "Mainnet"}
|
||||
)
|
||||
if data.lnbitswallet:
|
||||
payment_hash, payment_request = await create_invoice(
|
||||
wallet_id=data.lnbitswallet,
|
||||
@@ -81,7 +78,6 @@ async def create_charge(user: str, data: CreateCharge) -> Charges:
|
||||
data.extra,
|
||||
),
|
||||
)
|
||||
logger.debug(await get_charge(charge_id))
|
||||
return await get_charge(charge_id)
|
||||
|
||||
|
||||
@@ -96,7 +92,6 @@ async def update_charge(charge_id: str, **kwargs) -> Optional[Charges]:
|
||||
|
||||
async def get_charge(charge_id: str) -> Charges:
|
||||
row = await db.fetchone("SELECT * FROM satspay.charges WHERE id = ?", (charge_id,))
|
||||
|
||||
return Charges.from_row(row) if row else None
|
||||
|
||||
|
||||
|
@@ -38,6 +38,7 @@ async def m002_add_charge_extra_data(db):
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
async def m003_add_themes_table(db):
|
||||
"""
|
||||
Themes table
|
||||
|
@@ -320,11 +320,9 @@
|
||||
mixins: [windowMixin],
|
||||
data() {
|
||||
return {
|
||||
customCss: '',
|
||||
charge: JSON.parse('{{charge_data | tojson}}'),
|
||||
mempoolEndpoint: '{{mempool_endpoint}}',
|
||||
network: '{{network}}',
|
||||
css_id: '{{ charge_data.css_id }}',
|
||||
pendingFunds: 0,
|
||||
ws: null,
|
||||
newProgress: 0.4,
|
||||
@@ -347,16 +345,6 @@
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
startPaymentNotifier() {
|
||||
this.cancelListener()
|
||||
if (!this.lnbitswallet) return
|
||||
this.cancelListener = LNbits.events.onInvoicePaid(
|
||||
this.wallet,
|
||||
payment => {
|
||||
this.checkInvoiceBalance()
|
||||
}
|
||||
)
|
||||
},
|
||||
checkBalances: async function () {
|
||||
if (!this.charge.payment_request && this.charge.hasOnchainStaleBalance)
|
||||
return
|
||||
@@ -463,7 +451,6 @@
|
||||
await this.getCustomCss()
|
||||
if (this.charge.payment_request) this.payInvoice()
|
||||
// Remove a user defined theme
|
||||
console.log(this.charge.custom_css)
|
||||
if (this.charge.custom_css) {
|
||||
document.body.setAttribute('data-theme', '')
|
||||
}
|
||||
|
@@ -952,7 +952,6 @@
|
||||
}
|
||||
},
|
||||
created: async function () {
|
||||
console.log(this.admin)
|
||||
if (this.admin == 'True') {
|
||||
await this.getThemes()
|
||||
}
|
||||
|
@@ -17,8 +17,6 @@ from lnbits.settings import LNBITS_ADMIN_USERS
|
||||
from . import satspay_ext, satspay_renderer
|
||||
from .crud import get_charge, get_theme
|
||||
|
||||
from loguru import logger
|
||||
|
||||
templates = Jinja2Templates(directory="templates")
|
||||
|
||||
|
||||
@@ -39,15 +37,14 @@ async def display(request: Request, charge_id: str):
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.NOT_FOUND, detail="Charge link does not exist."
|
||||
)
|
||||
extra = json.loads(charge.extra)
|
||||
|
||||
return satspay_renderer().TemplateResponse(
|
||||
"satspay/display.html",
|
||||
{
|
||||
"request": request,
|
||||
"charge_data": public_charge(charge),
|
||||
"mempool_endpoint": extra["mempool_endpoint"],
|
||||
"network": extra["network"],
|
||||
"mempool_endpoint": charge.config.mempool_endpoint,
|
||||
"network": charge.config.network,
|
||||
},
|
||||
)
|
||||
|
||||
|
@@ -7,30 +7,27 @@ from loguru import logger
|
||||
from starlette.exceptions import HTTPException
|
||||
|
||||
from lnbits.core.crud import get_wallet
|
||||
from lnbits.decorators import (WalletTypeInfo, get_key_type, require_admin_key,
|
||||
require_invoice_key)
|
||||
from lnbits.decorators import (
|
||||
WalletTypeInfo,
|
||||
get_key_type,
|
||||
require_admin_key,
|
||||
require_invoice_key,
|
||||
)
|
||||
from lnbits.extensions.satspay import satspay_ext
|
||||
from lnbits.settings import LNBITS_ADMIN_EXTENSIONS, LNBITS_ADMIN_USERS
|
||||
|
||||
from lnbits.settings import (
|
||||
LNBITS_ADMIN_EXTENSIONS,
|
||||
LNBITS_ADMIN_USERS,
|
||||
)
|
||||
|
||||
from .crud import (
|
||||
check_address_balance,
|
||||
create_charge,
|
||||
delete_charge,
|
||||
delete_theme,
|
||||
get_charge,
|
||||
get_charges,
|
||||
get_theme,
|
||||
get_themes,
|
||||
delete_theme,
|
||||
save_theme,
|
||||
update_charge,
|
||||
)
|
||||
|
||||
from .models import CreateCharge, SatsPayThemes
|
||||
from .helpers import call_webhook, public_charge
|
||||
from .models import CreateCharge, SatsPayThemes
|
||||
|
||||
@@ -136,17 +133,6 @@ async def api_charge_balance(charge_id):
|
||||
extra = {**charge.config.dict(), **resp}
|
||||
await update_charge(charge_id=charge.id, extra=json.dumps(extra))
|
||||
|
||||
if charge.paid and charge.webhook:
|
||||
async with httpx.AsyncClient() as client:
|
||||
try:
|
||||
r = await client.post(
|
||||
charge.webhook,
|
||||
json=public_charge(charge),
|
||||
timeout=40,
|
||||
)
|
||||
except AssertionError:
|
||||
charge.webhook = None
|
||||
|
||||
return {**public_charge(charge)}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user