|
|
|
@ -1,11 +1,12 @@
|
|
|
|
|
import monero.address
|
|
|
|
|
from quart import Blueprint, render_template, request, flash, redirect
|
|
|
|
|
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 = Blueprint("wallet", "wallet")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/wallet/add", methods=["GET", "POST"])
|
|
|
|
@ -13,6 +14,7 @@ bp = Blueprint('wallet', 'wallet')
|
|
|
|
|
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)
|
|
|
|
@ -35,16 +37,23 @@ async def 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"/")
|
|
|
|
|
return await render_template("wallet/add.html")
|
|
|
|
|
else:
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/wallet/rescan")
|
|
|
|
|
@login_required
|
|
|
|
|
async def rescan():
|
|
|
|
|
address = request.args.get('address')
|
|
|
|
|
height = request.args.get('height')
|
|
|
|
|
address = request.args.get("address")
|
|
|
|
|
height = request.args.get("height")
|
|
|
|
|
if not address or not height:
|
|
|
|
|
await flash("you need to provide both address and height")
|
|
|
|
|
return redirect("/")
|
|
|
|
@ -55,33 +64,35 @@ async def rescan():
|
|
|
|
|
return redirect(f"/")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/wallet/<address>/disable")
|
|
|
|
|
@bp.route("/wallet/<address>/<status>")
|
|
|
|
|
@login_required
|
|
|
|
|
async def disable(address):
|
|
|
|
|
lws.modify_wallet(address, False)
|
|
|
|
|
await flash(f"{address} disabled in LWS")
|
|
|
|
|
return redirect(f"/")
|
|
|
|
|
|
|
|
|
|
async def modify(address, status):
|
|
|
|
|
lws.modify_wallet(address, status)
|
|
|
|
|
await flash(f"{address} {status} in LWS")
|
|
|
|
|
return redirect(url_for("htmx.show_wallets"))
|
|
|
|
|
|
|
|
|
|
@bp.route("/wallet/<address>/enable")
|
|
|
|
|
@login_required
|
|
|
|
|
async def enable(address):
|
|
|
|
|
lws.modify_wallet(address, True)
|
|
|
|
|
await flash(f"{address} enabled in LWS")
|
|
|
|
|
return redirect(f"/")
|
|
|
|
|
|
|
|
|
|
@bp.route("/wallet/<address>/accept")
|
|
|
|
|
@bp.route("/wallet/<address>/approve")
|
|
|
|
|
@login_required
|
|
|
|
|
async def accept(address):
|
|
|
|
|
lws.accept_request(address)
|
|
|
|
|
await flash(f"{address} accepted")
|
|
|
|
|
return redirect(f"/")
|
|
|
|
|
return redirect(url_for("htmx.show_wallets"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/wallet/<address>/reject")
|
|
|
|
|
@bp.route("/wallet/<address>/deny")
|
|
|
|
|
@login_required
|
|
|
|
|
async def reject(address):
|
|
|
|
|
lws.reject_request(address)
|
|
|
|
|
await flash(f"{address} rejected")
|
|
|
|
|
return redirect(f"/")
|
|
|
|
|
await flash(f"{address} denied")
|
|
|
|
|
return redirect(url_for("htmx.show_wallets"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/wallet/<address>/label/<label>")
|
|
|
|
|
@login_required
|
|
|
|
|
async def label(address, label):
|
|
|
|
|
w = Wallet.select().where(Wallet.address == address).first()
|
|
|
|
|
if w and label:
|
|
|
|
|
w.label = label
|
|
|
|
|
w.save()
|
|
|
|
|
return redirect(url_for("htmx.show_wallets"))
|
|
|
|
|