From 8795d8c9eb834e384dce8b2a92a02eb88cf02ed8 Mon Sep 17 00:00:00 2001 From: lza_menace Date: Wed, 3 May 2023 23:28:13 -0700 Subject: [PATCH] adding init script and mnemonic util --- Makefile | 2 +- init_lws_admin.sh | 8 +++++ lws-web/lws/app.py | 39 +++++++++++++++-------- lws-web/lws/static/main.css | 5 +++ lws-web/lws/templates/includes/base.html | 8 +++-- lws-web/lws/templates/index.html | 2 +- lws-web/lws/templates/setup.html | 13 ++++++-- lws-web/lws/templates/utils/index.html | 6 ++++ lws-web/lws/templates/utils/mnemonic.html | 31 ++++++++++++++++++ lws-web/lws/templates/wallet/list.html | 1 + lws-web/lws/templates/wallet/show.html | 1 + 11 files changed, 95 insertions(+), 21 deletions(-) create mode 100755 init_lws_admin.sh create mode 100644 lws-web/lws/static/main.css create mode 100644 lws-web/lws/templates/utils/index.html create mode 100644 lws-web/lws/templates/utils/mnemonic.html diff --git a/Makefile b/Makefile index a61e185..70e597e 100644 --- a/Makefile +++ b/Makefile @@ -3,4 +3,4 @@ init: git clone https://github.com/lalanza808/docker-monero-node build: - docker-compose build \ No newline at end of file + docker-compose build diff --git a/init_lws_admin.sh b/init_lws_admin.sh new file mode 100755 index 0000000..065d8c7 --- /dev/null +++ b/init_lws_admin.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +if [[ "$(docker-compose exec -ti monero-lws monero-lws-admin list_admin)" == '{}' ]]; +then + docker-compose exec -ti monero-lws monero-lws-admin create_admin; +else + docker-compose exec -ti monero-lws monero-lws-admin list_admin; +fi \ No newline at end of file diff --git a/lws-web/lws/app.py b/lws-web/lws/app.py index 59c91c9..2e25a8d 100644 --- a/lws-web/lws/app.py +++ b/lws-web/lws/app.py @@ -1,5 +1,6 @@ import requests import monero.address +import monero.seed from quart import Quart, render_template, redirect, request, flash, jsonify from quart_auth import ( AuthUser, AuthManager, login_required, login_user, logout_user, current_user, Unauthorized @@ -38,18 +39,30 @@ async def index(): wallets=wallets ) -@app.route("/debug") -async def debug(): - admin = User.get(1) - data = { - "auth": admin.view_key, - "params": { - "height": 2836540, - "addresses": ["46pSfwbyukuduh13pqUo7R6S5W8Uk2EnqcKuPg4T9KaoHVSFQ5Qb33nBEN6xVxpeKG1TgYoxo4GxhJm2JFYN1sHJBEH1MwY"] - } - } - r = requests.post("http://127.0.0.1:8081/rescan", json=data) - return jsonify(r.json()) + +@app.route("/utils") +async def utils(): + return await render_template("utils/index.html") + + +@app.route("/utils/mnemonic", methods=["GET", "POST"]) +async def utils_mnemonic(): + form = await request.form + if form: + seed = form.get("seed", "") + if not seed: + await flash("must provide mnemonic seed") + return redirect("/utils/mnemonic") + try: + s = monero.seed.Seed(seed) + return await render_template( + "utils/mnemonic.html", + results=s + ) + except Exception as e: + print(f"failed to read mnemonic seed: {e}") + await flash("failed to parse mnemonic seed") + return await render_template("utils/mnemonic.html") @app.route("/login", methods=["GET", "POST"]) @@ -82,7 +95,7 @@ async def login(): @app.route("/logout") async def logout(): - if current_user.is_authenticated: + if await current_user.is_authenticated: logout_user() return redirect("/") diff --git a/lws-web/lws/static/main.css b/lws-web/lws/static/main.css new file mode 100644 index 0000000..81965c8 --- /dev/null +++ b/lws-web/lws/static/main.css @@ -0,0 +1,5 @@ +.key { + color: #666; + font-size: .9em; + user-select: all; +} \ No newline at end of file diff --git a/lws-web/lws/templates/includes/base.html b/lws-web/lws/templates/includes/base.html index f13f249..26950a5 100644 --- a/lws-web/lws/templates/includes/base.html +++ b/lws-web/lws/templates/includes/base.html @@ -19,16 +19,18 @@ - + + -->