|
|
|
@ -10,7 +10,7 @@ from socket import socket
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
from wowstash.blueprints.wallet import wallet_bp
|
|
|
|
|
from wowstash.library.docker import docker
|
|
|
|
|
from wowstash.library.elasticsearch import send_es
|
|
|
|
|
from wowstash.library.helpers import capture_event
|
|
|
|
|
from wowstash.library.jsonrpc import Wallet, to_atomic
|
|
|
|
|
from wowstash.library.cache import cache
|
|
|
|
|
from wowstash.forms import Send, Delete, Restore
|
|
|
|
@ -29,6 +29,7 @@ def setup():
|
|
|
|
|
if restore_form.validate_on_submit():
|
|
|
|
|
c = docker.create_wallet(current_user.id, restore_form.seed.data)
|
|
|
|
|
cache.store_data(f'init_wallet_{current_user.id}', 30, c)
|
|
|
|
|
capture_event(current_user.id, 'restore_wallet')
|
|
|
|
|
current_user.wallet_created = True
|
|
|
|
|
db.session.commit()
|
|
|
|
|
return redirect(url_for('wallet.loading'))
|
|
|
|
@ -81,7 +82,7 @@ def dashboard():
|
|
|
|
|
seed = wallet.seed()
|
|
|
|
|
spend_key = wallet.spend_key()
|
|
|
|
|
view_key = wallet.view_key()
|
|
|
|
|
send_es({'type': 'load_dashboard', 'user': current_user.email})
|
|
|
|
|
capture_event(current_user.id, 'load_dashboard')
|
|
|
|
|
return render_template(
|
|
|
|
|
'wallet/dashboard.html',
|
|
|
|
|
transfers=all_transfers,
|
|
|
|
@ -115,6 +116,7 @@ def connect():
|
|
|
|
|
current_user.wallet_container = wallet
|
|
|
|
|
current_user.wallet_start = datetime.utcnow()
|
|
|
|
|
db.session.commit()
|
|
|
|
|
capture_event(current_user.id, 'start_wallet')
|
|
|
|
|
data = {
|
|
|
|
|
'result': 'success',
|
|
|
|
|
'message': 'Wallet has been connected'
|
|
|
|
@ -133,6 +135,7 @@ def create():
|
|
|
|
|
if current_user.wallet_created is False:
|
|
|
|
|
c = docker.create_wallet(current_user.id)
|
|
|
|
|
cache.store_data(f'init_wallet_{current_user.id}', 30, c)
|
|
|
|
|
capture_event(current_user.id, 'create_wallet')
|
|
|
|
|
current_user.wallet_created = True
|
|
|
|
|
db.session.commit()
|
|
|
|
|
return redirect(url_for('wallet.loading'))
|
|
|
|
@ -173,13 +176,13 @@ def send():
|
|
|
|
|
# Check if Wownero wallet is available
|
|
|
|
|
if wallet.connected is False:
|
|
|
|
|
flash('Wallet RPC interface is unavailable at this time. Try again later.')
|
|
|
|
|
send_es({'type': 'tx_fail_rpc_unavailable', 'user': user.email})
|
|
|
|
|
capture_event(user.id, 'tx_fail_rpc_unavailable')
|
|
|
|
|
return redirect(redirect_url)
|
|
|
|
|
|
|
|
|
|
# Quick n dirty check to see if address is WOW
|
|
|
|
|
if len(address) not in [97, 108]:
|
|
|
|
|
flash('Invalid Wownero address provided.')
|
|
|
|
|
send_es({'type': 'tx_fail_address_invalid', 'user': user.email})
|
|
|
|
|
capture_event(user.id, 'tx_fail_address_invalid')
|
|
|
|
|
return redirect(redirect_url)
|
|
|
|
|
|
|
|
|
|
# Check if we're sweeping or not
|
|
|
|
@ -191,7 +194,7 @@ def send():
|
|
|
|
|
amount = to_atomic(Decimal(send_form.amount.data))
|
|
|
|
|
except:
|
|
|
|
|
flash('Invalid Wownero amount specified.')
|
|
|
|
|
send_es({'type': 'tx_fail_amount_invalid', 'user': user.email})
|
|
|
|
|
capture_event(user.id, 'tx_fail_amount_invalid')
|
|
|
|
|
return redirect(redirect_url)
|
|
|
|
|
|
|
|
|
|
# Send transfer
|
|
|
|
@ -202,10 +205,10 @@ def send():
|
|
|
|
|
msg = tx['message'].capitalize()
|
|
|
|
|
msg_lower = tx['message'].replace(' ', '_').lower()
|
|
|
|
|
flash(f'There was a problem sending the transaction: {msg}')
|
|
|
|
|
send_es({'type': f'tx_fail_{msg_lower}', 'user': user.email})
|
|
|
|
|
capture_event(user.id, f'tx_fail_{msg_lower}')
|
|
|
|
|
else:
|
|
|
|
|
flash('Successfully sent transfer.')
|
|
|
|
|
send_es({'type': 'tx_success', 'user': user.email})
|
|
|
|
|
capture_event(user.id, 'tx_success')
|
|
|
|
|
|
|
|
|
|
return redirect(redirect_url)
|
|
|
|
|
else:
|
|
|
|
|