trying oob mgmt

master
lza_menace 2 years ago
parent 3901851835
commit 1af4fab245

@ -2,11 +2,12 @@ from os import environ as env
from secrets import token_urlsafe
from dotenv import load_dotenv
# load_dotenv()
DEBUG = 1 == env.get("DEBUG", 1)
if DEBUG:
load_dotenv()
HOST = env.get("HOST", "127.0.0.1")
TEMPLATES_AUTO_RELOAD = True
DEBUG = 1 == env.get("DEBUG", 1)
QUART_ENV = env.get("QUART_ENV", "development")
SECRET_KEY = env.get("SECRET_KEY", token_urlsafe(12))
QUART_AUTH_DURATION = 60 * 60 # 1 hour

@ -8,3 +8,8 @@ bp = Blueprint('filters', 'filters')
@bp.app_template_filter('atomic')
def atomic(amt):
return float(from_atomic(amt))
@bp.app_template_filter('shorten')
def shorten(s):
return f"{s[:6]}...{s[-6:]}"

@ -19,3 +19,19 @@ class LWS:
except Exception as e:
print(f"Failed to list accounts: {e}")
return {}
def get_address_txs(self, address, view_key):
endpoint = f"{config.LWS_URL}/get_address_txs"
data = {
"address": address,
"view_key": view_key
}
try:
req = requests.post(endpoint, json=data, timeout=5)
req.raise_for_status()
if req.ok:
return req.json()
return {}
except Exception as e:
print(f"Failed to get wallet info {address}: {e}")
return False

@ -12,9 +12,6 @@ bp = Blueprint('meta', 'meta')
@bp.route("/")
@login_required
async def index():
admin = User.select().first()
if not admin:
return redirect("/setup")
wallets = Wallet.select().order_by(Wallet.date.desc())
lws = LWS(admin.view_key)
return await render_template(

@ -8,6 +8,17 @@ from lws.models import Wallet, User
bp = Blueprint('wallet', 'wallet')
# @bp.route("/")
# accept_requests: {"type": "import"|"create", "addresses":[...]}
# add_account: {"address": ..., "key": ...}
# list_accounts: {}
# list_requests: {}
# modify_account_status: {"status": "active"|"hidden"|"inactive", "addresses":[...]}
# reject_requests: {"type": "import"|"create", "addresses":[...]}
# rescan: {"height":..., "addresses":[...]}
@bp.route("/wallets")
@login_required
async def list():

@ -6,10 +6,28 @@
<hr>
<p>LWS Admin: {{ config.LWS_ADMIN_URL }}</p>
<p>LWS RPC: {{ config.LWS_URL }}</p>
<!-- <p>{{ wallets.count() }} wallet{% if wallets.count() > 1 %}s{% endif %} being scanned by LWS</p> -->
<h3>Active Accounts</h3>
{% for a in lws_accounts['active'] %}
<li>{{ a['address'] }} - {{ a['scan_height'] }}</li>
{% endfor %}
<table class="striped">
<thead>
<tr>
<th>Status</th>
<th>Address</th>
<th>Height</th>
</tr>
</thead>
<tbody>
{% for a in lws_accounts %}
{% if a != 'hidden' %}
{% for acc in lws_accounts[a] %}
<tr>
<td>{{ a | upper }}</td>
<td>{{ acc['address'] | shorten }}</td>
<td>{{ acc['scan_height'] }}</td>
</tr>
{% endfor %}
{% endif %}
{% endfor %}
</tbody>
</table>
{% endblock %}

Loading…
Cancel
Save