lnbits-legend/lnbits/extensions/cashu/__init__.py

55 lines
1.3 KiB
Python
Raw Normal View History

2022-09-16 13:20:42 +01:00
import asyncio
from fastapi import APIRouter
2022-10-10 12:42:34 +03:00
from fastapi.staticfiles import StaticFiles
2022-09-16 13:20:42 +01:00
from lnbits.db import Database
from lnbits.helpers import template_renderer
from lnbits.tasks import catch_everything_and_restart
2022-09-30 12:25:48 +01:00
db = Database("ext_cashu")
2022-09-16 13:20:42 +01:00
2022-10-12 23:16:39 +02:00
import sys
sys.path.append("/Users/cc/git/cashu")
from cashu.mint.ledger import Ledger
from .crud import LedgerCrud
# db = Database("ext_cashu", LNBITS_DATA_FOLDER)
ledger = Ledger(
db=db,
# seed=MINT_PRIVATE_KEY,
seed="asd",
derivation_path="0/0/0/1",
crud=LedgerCrud,
)
cashu_ext: APIRouter = APIRouter(prefix="/api/v1/cashu", tags=["cashu"])
# from cashu.mint.router import router as cashu_router
# cashu_ext.include_router(router=cashu_router)
2022-09-16 13:20:42 +01:00
2022-10-10 12:42:34 +03:00
cashu_static_files = [
{
"path": "/cashu/static",
"app": StaticFiles(directory="lnbits/extensions/cashu/static"),
"name": "cashu_static",
}
]
2022-10-07 11:17:02 +03:00
2022-09-16 13:20:42 +01:00
def cashu_renderer():
return template_renderer(["lnbits/extensions/cashu/templates"])
2022-10-07 11:17:02 +03:00
2022-10-12 23:16:39 +02:00
from .tasks import wait_for_paid_invoices, startup_cashu_mint
2022-09-16 13:20:42 +01:00
from .views import * # noqa
from .views_api import * # noqa
2022-10-07 11:17:02 +03:00
2022-09-16 13:20:42 +01:00
def cashu_start():
loop = asyncio.get_event_loop()
2022-10-12 23:16:39 +02:00
loop.create_task(catch_everything_and_restart(startup_cashu_mint))
2022-09-16 13:20:42 +01:00
loop.create_task(catch_everything_and_restart(wait_for_paid_invoices))