Verified Commit 850f1fbf authored by Jakob Moser's avatar Jakob Moser
Browse files

Remove vault from admin app

parent b412585e
Loading
Loading
Loading
Loading
+2 −21
Original line number Diff line number Diff line
@@ -4,10 +4,6 @@ from rich import print

from poolpay import db, paths
from poolpay.admin import app
from poolpay.admin.get_password import get_password
from poolpay.paths import socket_path
from poolpay.vault.Vault import Vault
from poolpay.wire.Client import Client


def parse_args() -> argparse.Namespace:
@@ -16,8 +12,8 @@ def parse_args() -> argparse.Namespace:
    )
    parser.add_argument(
        "action",
        choices=["ui", "unlock"],
        help="the action to be done: show the admin ui (default), or unlock the PoolPay main app over wire",
        choices=["ui"],
        help="the action to be done: show the admin ui (default)",
        default="ui",
        nargs="?",
    )
@@ -34,21 +30,6 @@ def run_app() -> None:


args = parse_args()
vault = Vault(paths.vault_file, paths.instance_dir)

if not vault.is_open:
    # Vault was not open, so we get the password, and in case the action was "unlock", we unlock it
    password = get_password()
    if args.action == "unlock":
        with Client(socket_path) as c:
            c.send({"action": "unlock", "password": password})
else:
    print("🔓 The PoolPay database is already [green]unlocked[/green].")
    password = None

if args.action == "ui":
    if password:
        with vault.open(password):
            run_app()
    else:
    run_app()