2020-08-31 05:10:28 +01:00
|
|
|
from io import BytesIO
|
|
|
|
from base64 import b64encode
|
|
|
|
from qrcode import make as qrcode_make
|
2020-08-27 06:50:08 +01:00
|
|
|
from flask import request, render_template, session, redirect, url_for, current_app
|
|
|
|
from flask_login import login_required, current_user
|
|
|
|
from wowstash.blueprints.wallet import wallet_bp
|
|
|
|
from wowstash.library.jsonrpc import wallet, daemon
|
|
|
|
from wowstash.factory import login_manager
|
|
|
|
from wowstash.models import User
|
|
|
|
|
|
|
|
|
|
|
|
@wallet_bp.route("/wallet/dashboard")
|
|
|
|
@login_required
|
|
|
|
def dashboard():
|
2020-08-30 20:27:35 +01:00
|
|
|
all_transfers = list()
|
2020-08-31 05:10:28 +01:00
|
|
|
_address_qr = BytesIO()
|
2020-08-27 06:50:08 +01:00
|
|
|
user = User.query.get(current_user.id)
|
|
|
|
wallet_height = wallet.height()['height']
|
|
|
|
daemon_height = daemon.height()['height']
|
2020-08-30 20:27:35 +01:00
|
|
|
subaddress = wallet.get_address(0, user.subaddress_index)
|
|
|
|
balances = wallet.get_balance(0, user.subaddress_index)
|
|
|
|
transfers = wallet.get_transfers(0, user.subaddress_index)
|
|
|
|
for type in transfers:
|
|
|
|
for tx in transfers[type]:
|
|
|
|
all_transfers.append(tx)
|
2020-08-31 05:10:28 +01:00
|
|
|
|
|
|
|
qr_uri = f'wownero:{subaddress}?tx_description="{current_user.email}"'
|
|
|
|
address_qr = qrcode_make(qr_uri).save(_address_qr)
|
|
|
|
qrcode = b64encode(_address_qr.getvalue()).decode()
|
2020-08-27 06:50:08 +01:00
|
|
|
return render_template(
|
2020-08-27 09:06:38 +01:00
|
|
|
"wallet/dashboard.html",
|
2020-08-27 06:50:08 +01:00
|
|
|
wallet_height=wallet_height,
|
2020-08-30 20:27:35 +01:00
|
|
|
daemon_height=daemon_height,
|
|
|
|
subaddress=subaddress,
|
|
|
|
balances=balances,
|
2020-08-31 05:10:28 +01:00
|
|
|
all_transfers=all_transfers,
|
|
|
|
qrcode=qrcode
|
2020-08-27 06:50:08 +01:00
|
|
|
)
|