You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.0 KiB
Python

2 years ago
import monero.address
from monero.seed import Seed
from quart import Blueprint, request, flash, redirect, url_for
from quart_auth import login_required
2 years ago
from lws.helpers import lws
from lws.models import Wallet, get_random_words
2 years ago
bp = Blueprint("wallet", "wallet")
2 years ago
@bp.route("/wallet/add", methods=["GET", "POST"])
@login_required
async def add():
form = await request.form
if form:
label = form.get("label")
seed = form.get("seed")
restore_height = form.get("restore_height", None)
2 years ago
try:
seed = Seed(seed)
2 years ago
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, int(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"))
2 years ago
@bp.route("/wallet/<address>/rescan/<height>")
2 years ago
@login_required
async def rescan(address, height):
lws.rescan(address, int(height))
return redirect(url_for("htmx.show_wallets"))
1 year ago
@bp.route("/wallet/<address>/modify/<status>")
2 years ago
@login_required
async def modify(address, status):
lws.modify_wallet(address, status)
return redirect(url_for("htmx.show_wallets"))
2 years ago
1 year ago
@bp.route("/wallet/<address>/accept")
2 years ago
@login_required
async def accept(address):
lws.accept_request(address)
return redirect(url_for("htmx.show_wallets"))
1 year ago
@bp.route("/wallet/<address>/reject")
@login_required
async def reject(address):
lws.reject_request(address)
return redirect(url_for("htmx.show_wallets"))
2 years ago
@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"))