can import, migration dont work yet

This commit is contained in:
callebtc
2022-10-12 20:52:35 +02:00
parent 65cba2aa84
commit 8721694785
4 changed files with 18 additions and 9 deletions

View File

@@ -0,0 +1 @@

View File

@@ -22,7 +22,8 @@ def main(
ssl_keyfile: str = None,
ssl_certfile: str = None,
):
"""Launched with `poetry run mint` at root level"""
"""This routine starts the uvicorn server if the Cashu mint is
launched with `poetry run mint` at root level"""
# this beautiful beast parses all command line arguments and passes them to the uvicorn server
d = dict()
for a in ctx.args:

View File

@@ -16,7 +16,8 @@ from cashu.core.base import (
SplitRequest,
)
from cashu.core.errors import CashuError
from cashu.mint import ledger
from cashu.mint.startup import ledger
router: APIRouter = APIRouter()
@@ -24,7 +25,7 @@ router: APIRouter = APIRouter()
@router.get("/keys")
async def keys() -> dict[int, str]:
"""Get the public keys of the mint"""
return await ledger.get_keyset()
return ledger.get_keyset()
@router.get("/keysets")

View File

@@ -1,3 +1,6 @@
# startup routine of the standalone app. These are the steps that need
# to be taken by external apps importing the cashu mint.
import asyncio
from loguru import logger
@@ -7,17 +10,20 @@ from cashu.core.settings import CASHU_DIR, LIGHTNING
from cashu.lightning import WALLET
from cashu.mint import migrations
from cashu.core.settings import MINT_PRIVATE_KEY
from cashu.mint.ledger import Ledger
from cashu.core.settings import MINT_PRIVATE_KEY
from cashu.core.db import Database
ledger = Ledger(
db=Database("mint", "data/mint"),
seed=MINT_PRIVATE_KEY,
# seed="asd",
derivation_path="0/0/0/0",
)
async def start_mint_init():
ledger = Ledger(
db=Database("mint", "data/mint"),
seed=MINT_PRIVATE_KEY,
derivation_path="0/0/0/0",
)
await migrate_databases(ledger.db, migrations)
await ledger.load_used_proofs()
await ledger.init_keysets()