mirror of
https://github.com/lnbits/lnbits.git
synced 2025-09-27 12:26:19 +02:00
Satsdice loading, needs finishing
This commit is contained in:
@@ -6,7 +6,7 @@ from lnbits.db import Database
|
||||
from lnbits.helpers import template_renderer
|
||||
from lnbits.tasks import catch_everything_and_restart
|
||||
|
||||
db = Database("satsdice_ext")
|
||||
db = Database("ext_satsdice")
|
||||
|
||||
satsdice_ext: APIRouter = APIRouter(prefix="/satsdice", tags=["satsdice"])
|
||||
|
||||
@@ -22,9 +22,8 @@ def satsdice_renderer():
|
||||
from .views_api import * # noqa
|
||||
from .views import * # noqa
|
||||
from .lnurl import * # noqa
|
||||
from .tasks import wait_for_paid_invoices
|
||||
|
||||
|
||||
def satsdice_start():
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.create_task(catch_everything_and_restart(wait_for_paid_invoices))
|
||||
# def satsdice_start():
|
||||
# loop = asyncio.get_event_loop()
|
||||
# loop.create_task(catch_everything_and_restart(wait_for_paid_invoices))
|
||||
|
@@ -9,6 +9,8 @@ from .models import (
|
||||
satsdiceLink,
|
||||
satsdicePayment,
|
||||
CreateSatsDiceLink,
|
||||
CreateSatsDicePayment,
|
||||
CreateSatsDiceWithdraw,
|
||||
)
|
||||
from lnbits.helpers import urlsafe_short_hash
|
||||
|
||||
|
@@ -18,7 +18,7 @@
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}api/v1/links -H "X-Api-Key: {{
|
||||
g.user.wallets[0].inkey }}"
|
||||
user.wallets[0].inkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
@@ -45,7 +45,7 @@
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}api/v1/links/<satsdice_id> -H
|
||||
"X-Api-Key: {{ g.user.wallets[0].inkey }}"
|
||||
"X-Api-Key: {{ user.wallets[0].inkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
@@ -78,7 +78,7 @@
|
||||
"max_satsdiceable": <integer>, "uses": <integer>,
|
||||
"wait_time": <integer>, "is_unique": <boolean>}' -H
|
||||
"Content-type: application/json" -H "X-Api-Key: {{
|
||||
g.user.wallets[0].adminkey }}"
|
||||
user.wallets[0].adminkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
@@ -114,7 +114,7 @@
|
||||
"max_satsdiceable": <integer>, "uses": <integer>,
|
||||
"wait_time": <integer>, "is_unique": <boolean>}' -H
|
||||
"Content-type: application/json" -H "X-Api-Key: {{
|
||||
g.user.wallets[0].adminkey }}"
|
||||
user.wallets[0].adminkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
@@ -138,7 +138,7 @@
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X DELETE {{ request.url_root }}api/v1/links/<satsdice_id>
|
||||
-H "X-Api-Key: {{ g.user.wallets[0].adminkey }}"
|
||||
-H "X-Api-Key: {{ user.wallets[0].adminkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
@@ -166,7 +166,7 @@
|
||||
<code
|
||||
>curl -X GET {{ request.url_root
|
||||
}}api/v1/links/<the_hash>/<lnurl_id> -H "X-Api-Key: {{
|
||||
g.user.wallets[0].inkey }}"
|
||||
user.wallets[0].inkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
|
@@ -92,9 +92,9 @@
|
||||
<q-card-section class="q-pa-none">
|
||||
<q-separator></q-separator>
|
||||
<q-list>
|
||||
{% include "lnurlp/_api_docs.html" %}
|
||||
{% include "satsdice/_api_docs.html" %}
|
||||
<q-separator></q-separator>
|
||||
{% include "lnurlp/_lnurl.html" %}
|
||||
{% include "satsdice/_lnurl.html" %}
|
||||
</q-list>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
|
@@ -15,8 +15,9 @@ from fastapi.templating import Jinja2Templates
|
||||
from starlette.exceptions import HTTPException
|
||||
from starlette.responses import HTMLResponse
|
||||
from lnbits.core.models import User, Payment
|
||||
from .views_api import api_get_jukebox_device_check
|
||||
|
||||
from fastapi.params import Depends
|
||||
from fastapi.param_functions import Query
|
||||
|
||||
templates = Jinja2Templates(directory="templates")
|
||||
|
||||
@@ -38,7 +39,7 @@ async def display(link_id):
|
||||
chance=link.chance,
|
||||
multiplier=link.multiplier,
|
||||
lnurl=link.lnurl,
|
||||
unique=True,{"request": request, "user": user.dict()}
|
||||
unique=True,
|
||||
)
|
||||
|
||||
|
||||
@@ -57,7 +58,7 @@ async def displaywin(link_id, payment_hash):
|
||||
multiplier=satsdicelink.multiplier,
|
||||
lnurl=withdrawLink.lnurl,
|
||||
paid=False,
|
||||
lost=False
|
||||
lost=False,
|
||||
)
|
||||
|
||||
payment = await get_standalone_payment(payment_hash) or abort(
|
||||
@@ -72,8 +73,7 @@ async def displaywin(link_id, payment_hash):
|
||||
if payment.pending == 1:
|
||||
print("pending")
|
||||
return satsdice_renderer().TemplateResponse(
|
||||
"satsdice/error.html",
|
||||
link=satsdicelink.id, paid=False, lost=False
|
||||
"satsdice/error.html", link=satsdicelink.id, paid=False, lost=False
|
||||
)
|
||||
|
||||
await update_satsdice_payment(payment_hash, paid=1)
|
||||
@@ -85,8 +85,7 @@ async def displaywin(link_id, payment_hash):
|
||||
if paylink.lost == 1:
|
||||
print("lost")
|
||||
return satsdice_renderer().TemplateResponse(
|
||||
"satsdice/error.html",
|
||||
link=satsdicelink.id, paid=False, lost=True
|
||||
"satsdice/error.html", link=satsdicelink.id, paid=False, lost=True
|
||||
)
|
||||
rand = random.randint(0, 100)
|
||||
chance = satsdicelink.chance
|
||||
@@ -94,8 +93,7 @@ async def displaywin(link_id, payment_hash):
|
||||
await update_satsdice_payment(payment_hash, lost=1)
|
||||
|
||||
return satsdice_renderer().TemplateResponse(
|
||||
"satsdice/error.html",
|
||||
link=satsdicelink.id, paid=False, lost=True
|
||||
"satsdice/error.html", link=satsdicelink.id, paid=False, lost=True
|
||||
)
|
||||
|
||||
withdrawLink = await create_satsdice_withdraw(
|
||||
@@ -131,5 +129,5 @@ async def img(link_id):
|
||||
"Cache-Control": "no-cache, no-store, must-revalidate",
|
||||
"Pragma": "no-cache",
|
||||
"Expires": "0",
|
||||
}
|
||||
},
|
||||
)
|
||||
|
@@ -5,10 +5,12 @@ from starlette.exceptions import HTTPException
|
||||
from starlette.responses import HTMLResponse, JSONResponse # type: ignore
|
||||
from lnbits.core.crud import get_user
|
||||
from lnbits.decorators import api_validate_post_request
|
||||
from .models import CreateSatsDiceLink, CreateSatsDiceWithdraws
|
||||
from .models import CreateSatsDiceLink, CreateSatsDiceWithdraws, CreateSatsDicePayment
|
||||
from . import satsdice_ext
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.params import Depends
|
||||
from typing import Optional
|
||||
from fastapi.param_functions import Query
|
||||
from .crud import (
|
||||
create_satsdice_pay,
|
||||
get_satsdice_pay,
|
||||
|
Reference in New Issue
Block a user