import monero.address from monero.seed import Seed from quart import Blueprint, render_template, request, flash, redirect, url_for from quart_auth import login_required, current_user from lws.helpers import lws from lws.models import Wallet, get_random_words bp = Blueprint("wallet", "wallet") @bp.route("/wallet/add", methods=["GET", "POST"]) @login_required async def add(): form = await request.form if form: address = None label = form.get("label") seed = form.get("seed") restore_height = form.get("restore_height", None) try: seed = Seed(seed) except ValueError: await flash("Invalid mnemonic seed") return "" lws._init() address = str(seed.public_address()) svk = str(seed.secret_view_key()) lws.add_wallet(address, svk) if restore_height != "-1": lws.rescan(address, str(restore_height)) w = Wallet( address=seed.public_address(), label=label if label else get_random_words() ) w.save() return redirect(url_for("htmx.show_wallets")) @bp.route("/wallet/
/rescan/