htmx
lza_menace 6 months ago
parent b0ca32fdab
commit 1921691040

@ -19,4 +19,7 @@ LWS_URL = env.get("LWS_URL", "http://127.0.0.1:8080")
LWS_ADMIN_URL = env.get("LWS_ADMIN_URL", "http://127.0.0.1:8081")
# Monerod
MONEROD_URL = env.get("MONEROD_URL", "http://singapore.node.xmr.pm:18089")
MONEROD_URL = env.get("MONEROD_URL", "http://singapore.node.xmr.pm:18089")
# MyMonero
MYMONERO_URL = env.get("MYMONERO_URL", "http://localhost:9110")

@ -11,6 +11,7 @@ bp = Blueprint('htmx', 'htmx', url_prefix="/htmx")
@bp.route("/create_wallet")
async def create_wallet():
"""Creating a new wallet with newly generated seeds"""
seed = Seed()
return await render_template(
"htmx/create_wallet.html",
@ -24,10 +25,12 @@ async def create_wallet():
@bp.route("/import_wallet")
async def import_wallet():
"""Importing an existing wallet"""
return await render_template("htmx/import_wallet.html")
@bp.route("/label_wallet")
async def label_wallet():
"""Changing the label on a stored wallet"""
address = request.args.get("address")
label = request.args.get("label")
return await render_template(
@ -38,6 +41,7 @@ async def label_wallet():
@bp.route("/set_height")
async def set_height():
"""Setting a new height to scan from"""
address = request.args.get("address")
height = request.args.get("height")
return await render_template(
@ -49,12 +53,13 @@ async def set_height():
@bp.route("/show_wallets")
@login_required
async def show_wallets():
"""Showing all wallets in the database in a table"""
admin = User.select().first()
lws.init(admin.view_key)
accounts = lws.list_accounts()
if 'hidden' in accounts:
del accounts["hidden"]
# make wallets if they don't exist
# save wallets if they don't exist in the db
for status in accounts:
for account in accounts[status]:
w = Wallet.select().where(Wallet.address == account["address"]).first()

@ -45,21 +45,21 @@ async def rescan(address, height):
return redirect(url_for("htmx.show_wallets"))
@bp.route("/wallet/<address>/<status>")
@bp.route("/wallet/<address>/modify/<status>")
@login_required
async def modify(address, status):
lws.modify_wallet(address, status)
return redirect(url_for("htmx.show_wallets"))
@bp.route("/wallet/<address>/approve")
@bp.route("/wallet/<address>/accept")
@login_required
async def accept(address):
lws.accept_request(address)
return redirect(url_for("htmx.show_wallets"))
@bp.route("/wallet/<address>/deny")
@bp.route("/wallet/<address>/reject")
@login_required
async def reject(address):
lws.reject_request(address)

@ -1,5 +1,5 @@
<div id="create_wallet">
<form hx-target="#show_wallets" hx-post="{{ url_for('wallet.add') }}" action="#" hx-confirm="hope you saved the seed">
<form hx-target="#show_wallets" hx-post="{{ url_for('wallet.add') }}" action="#">
<label for="label">Label</label>
<input type="text" name="label" />
<p>Seed: <span class="key">{{ seed }}</span></p>
@ -11,8 +11,8 @@
<input type="text" name="address" value="{{ address }}" class="hidden" />
<input type="text" name="view_key" value="{{ svk }}" class="hidden" />
<input type="number" name="restore_height" value="-1" class="hidden" />
<button onsubmit="cancelCreate()" type="submit">Create</button>
<button onclick="cancelCreate()">Cancel</button>
<button onsubmit="cancelCreate()" type="submit">Create</button>
</form>
<script>
function cancelCreate() {

@ -7,8 +7,8 @@
<input type="password" name="seed" />
<label for="restore_height">Restore Height</label>
<input type="number" name="restore_height" value="-1" />
<button onsubmit="cancelImport()" type="submit">Import</button>
<button onclick="cancelImport()">Cancel</button>
<button onsubmit="cancelImport()" type="submit">Import</button>
</form>
<script>
function cancelImport() {

@ -20,8 +20,8 @@
</td>
<td>
<!-- <a hx-get="/htmx/import_wallet" hx-target="#walletForm" class="button primary outline"></a> -->
<a href="/wallet/{{ request['address'] }}/approve" class="button primary outline">Approve</a>
<a href="/wallet/{{ request['address'] }}/deny" class="button secondary outline">Deny</a>
<button class="button primary" hx-target="#show_wallets" hx-get="{{ url_for('wallet.accept', address=request['address']) }}" hx-swap="innerHTML">Accept</button>
<button class="button error" hx-target="#show_wallets" hx-get="{{ url_for('wallet.reject', address=request['address']) }}" hx-swap="innerHTML">Reject</button>
</td>
<td>{{ request['address'] | shorten }}</td>
<td>{{ request['start_height'] }}</td>
@ -43,9 +43,10 @@
</td>
<td>
{% if status == 'active' %}
<button class="button primary outline" hx-target="#show_wallets" hx-get="/wallet/{{ account['address'] }}/inactive" hx-swap="innerHTML" >Deactivate</button>
<button class="button dark outline" hx-target="#show_wallets" hx-get="{{ url_for('wallet.modify', address=account['address'], status='inactive') }}" hx-swap="innerHTML">Deactivate</button>
{% else %}
<button class="button primary outline" hx-target="#show_wallets" hx-get="/wallet/{{ account['address'] }}/active" hx-swap="innerHTML" >Activate</button>
<button class="button primary outline" hx-target="#show_wallets" hx-get="{{ url_for('wallet.modify', address=account['address'], status='active') }}" hx-swap="innerHTML" >Activate</button>
<button class="button error" hx-target="#show_wallets" hx-get="{{ url_for('wallet.modify', address=account['address'], status='hidden') }}" hx-swap="innerHTML" >Hide</button>
{% endif %}
</td>
<td>{{ account['address'] | shorten }}</td>

@ -5,6 +5,7 @@
<h1>Monero Lightwallet Server</h1>
<p>LWS Admin: {{ config.LWS_ADMIN_URL }}</p>
<p>LWS RPC: {{ config.LWS_URL }}</p>
<p>Monero Web Wallet: <a href="{{ config.MYMONERO_URL }}" target="_blank">{{ config.MYMONERO_URL }}</a></p>
<div>
<a hx-get="/htmx/import_wallet" hx-target="#walletForm" class="button primary outline">Import Wallet</a>
@ -14,6 +15,11 @@
<div>
<h3>Accounts</h3>
<p>
The below Monero accounts are stored in LWS;
only active accounts will be synced.
Accounts created in the web wallet must be approved here before use.
</p>
<div hx-get="/htmx/show_wallets" hx-target="#show_wallets" class="button outline" hx-indicator="#refresh_loader" onclick="handleRefresh()">
Refresh
<i class="fa-solid fa-rotate-right indicator" id="refresh_loader"></i>

Loading…
Cancel
Save