import monero.address 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: label = form.get("label") address = form.get("address", "") view_key = form.get("view_key", "") restore_height = form.get("restore_height", None) valid_view_key = False if not address: await flash("must provide an address") return redirect("/wallet/add") if not view_key: await flash("must provide a view_key") return redirect("/wallet/add") try: _a = monero.address.Address(address) valid_view_key = _a.check_private_view_key(view_key) except ValueError: await flash("Invalid Monero address") return redirect("/wallet/add") if not valid_view_key: await flash("Invalid view key provided for address") return redirect("/wallet/add") lws.add_wallet(address, view_key) if restore_height != "-1": lws.rescan(address, int(restore_height)) w = Wallet( address=address, view_key=view_key, label=label if label else get_random_words() ) w.save() await flash("wallet added") return redirect(f"/") else: return "" @bp.route("/wallet/
/rescan/") @login_required async def rescan(address, height): lws.rescan(address, int(height)) return redirect(url_for("htmx.show_wallets")) @bp.route("/wallet/
/") @login_required async def modify(address, status): lws.modify_wallet(address, status) return redirect(url_for("htmx.show_wallets")) @bp.route("/wallet/
/approve") @login_required async def accept(address): lws.accept_request(address) return redirect(url_for("htmx.show_wallets")) @bp.route("/wallet/
/deny") @login_required async def reject(address): lws.reject_request(address) return redirect(url_for("htmx.show_wallets")) @bp.route("/wallet/
/label/