|
|
@ -1,11 +1,12 @@
|
|
|
|
import monero.address
|
|
|
|
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 quart_auth import login_required, current_user
|
|
|
|
|
|
|
|
|
|
|
|
from lws.helpers import lws
|
|
|
|
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"])
|
|
|
|
@bp.route("/wallet/add", methods=["GET", "POST"])
|
|
|
@ -13,6 +14,7 @@ bp = Blueprint('wallet', 'wallet')
|
|
|
|
async def add():
|
|
|
|
async def add():
|
|
|
|
form = await request.form
|
|
|
|
form = await request.form
|
|
|
|
if form:
|
|
|
|
if form:
|
|
|
|
|
|
|
|
label = form.get("label")
|
|
|
|
address = form.get("address", "")
|
|
|
|
address = form.get("address", "")
|
|
|
|
view_key = form.get("view_key", "")
|
|
|
|
view_key = form.get("view_key", "")
|
|
|
|
restore_height = form.get("restore_height", None)
|
|
|
|
restore_height = form.get("restore_height", None)
|
|
|
@ -35,16 +37,23 @@ async def add():
|
|
|
|
lws.add_wallet(address, view_key)
|
|
|
|
lws.add_wallet(address, view_key)
|
|
|
|
if restore_height != "-1":
|
|
|
|
if restore_height != "-1":
|
|
|
|
lws.rescan(address, int(restore_height))
|
|
|
|
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")
|
|
|
|
await flash("wallet added")
|
|
|
|
return redirect(f"/")
|
|
|
|
return redirect(f"/")
|
|
|
|
return await render_template("wallet/add.html")
|
|
|
|
else:
|
|
|
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/wallet/rescan")
|
|
|
|
@bp.route("/wallet/rescan")
|
|
|
|
@login_required
|
|
|
|
@login_required
|
|
|
|
async def rescan():
|
|
|
|
async def rescan():
|
|
|
|
address = request.args.get('address')
|
|
|
|
address = request.args.get("address")
|
|
|
|
height = request.args.get('height')
|
|
|
|
height = request.args.get("height")
|
|
|
|
if not address or not height:
|
|
|
|
if not address or not height:
|
|
|
|
await flash("you need to provide both address and height")
|
|
|
|
await flash("you need to provide both address and height")
|
|
|
|
return redirect("/")
|
|
|
|
return redirect("/")
|
|
|
@ -55,33 +64,35 @@ async def rescan():
|
|
|
|
return redirect(f"/")
|
|
|
|
return redirect(f"/")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/wallet/<address>/disable")
|
|
|
|
@bp.route("/wallet/<address>/<status>")
|
|
|
|
@login_required
|
|
|
|
@login_required
|
|
|
|
async def disable(address):
|
|
|
|
async def modify(address, status):
|
|
|
|
lws.modify_wallet(address, False)
|
|
|
|
lws.modify_wallet(address, status)
|
|
|
|
await flash(f"{address} disabled in LWS")
|
|
|
|
await flash(f"{address} {status} in LWS")
|
|
|
|
return redirect(f"/")
|
|
|
|
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
|
|
|
|
@login_required
|
|
|
|
async def accept(address):
|
|
|
|
async def accept(address):
|
|
|
|
lws.accept_request(address)
|
|
|
|
lws.accept_request(address)
|
|
|
|
await flash(f"{address} accepted")
|
|
|
|
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
|
|
|
|
@login_required
|
|
|
|
async def reject(address):
|
|
|
|
async def reject(address):
|
|
|
|
lws.reject_request(address)
|
|
|
|
lws.reject_request(address)
|
|
|
|
await flash(f"{address} rejected")
|
|
|
|
await flash(f"{address} denied")
|
|
|
|
return redirect(f"/")
|
|
|
|
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"))
|
|
|
|