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