Compare commits

..

4 Commits

@ -10,15 +10,12 @@ export FLASK_ENV=production
mkdir -p $BASE
pgrep -F $BASE/gunicorn.pid
if [[ $? != 0 ]]; then
gunicorn \
--bind 127.0.0.1:4001 "wowstash.app:app" \
--bind 0.0.0.0:4001 "wowstash.app:app" \
--daemon \
--log-file $BASE/gunicorn.log \
--pid $BASE/gunicorn.pid \
--access-logfile $BASE/access.log \
--reload
sleep 1
echo "Starting gunicorn with pid $(cat $BASE/gunicorn.pid)"
fi

@ -5,9 +5,8 @@ services:
db:
image: postgres:9.6.15-alpine
container_name: wowstash_db
restart: unless-stopped
ports:
- 127.0.0.1:5432:5432
- 5432:5432
environment:
POSTGRES_PASSWORD: ${DB_PASS}
POSTGRES_USER: ${DB_USER}
@ -18,10 +17,10 @@ services:
image: redis:latest
container_name: wowstash_cache
ports:
- 127.0.0.1:6379:6379
- 6379:6379
grafana:
image: grafana/grafana:6.5.0
container_name: wowstash_ops
container_name: grafana
restart: unless-stopped
ports:
- 127.0.0.1:3001:3000

@ -3,8 +3,8 @@ from flask import request, render_template, session, redirect, url_for, flash
from flask_login import login_user, logout_user, current_user, login_required
from time import sleep
from wowstash.blueprints.auth import auth_bp
from wowstash.forms import Register, Login, Delete, ResetPassword
from wowstash.models import User, PasswordReset
from wowstash.forms import Register, Login, Delete
from wowstash.models import User
from wowstash.factory import db, bcrypt
from wowstash.library.docker import docker
from wowstash.library.helpers import capture_event
@ -95,29 +95,3 @@ def delete():
else:
flash('Please confirm deletion of the account')
return redirect(url_for('wallet.dashboard'))
@auth_bp.route("/reset/<string:hash>", methods=["GET", "POST"])
def reset(hash):
hash = PasswordReset.query.filter(PasswordReset.hash==hash).first()
if not hash:
flash('Invalid password reset hash')
return redirect(url_for('auth.login'))
if hash.hours_elapsed() > hash.expiration_hours or hash.expired:
flash('Reset hash has expired')
return redirect(url_for('auth.login'))
form = ResetPassword()
if form.validate_on_submit():
try:
user = User.query.get(hash.user)
user.password = bcrypt.generate_password_hash(form.password.data).decode('utf8')
hash.expired = True
db.session.commit()
flash('Password reset successfully')
return redirect(url_for('auth.login'))
except:
flash('Error resetting password')
return redirect(url_for('auth.login'))
return render_template('auth/reset.html', form=form)

@ -4,14 +4,8 @@ from wowstash.library.jsonrpc import daemon
from wowstash.library.cache import cache
from wowstash.library.db import Database
from wowstash.library.docker import Docker
from wowstash.library.helpers import post_discord_webhook
@meta_bp.errorhandler(500)
def internal_error(error):
post_discord_webhook(f'500 error: {error.original_exception}')
return render_template('meta/500.html', error=error)
@meta_bp.route('/')
def index():
return render_template('meta/index.html', node=daemon.info(), info=cache.get_coin_info())
@ -36,6 +30,8 @@ def health():
'docker': Docker().client.ping()
}), 200)
@meta_bp.route('/donate')
def donate():
return render_template('meta/donate.html')
# @app.errorhandler(404)
# def not_found(error):
# return make_response(jsonify({
# 'error': 'Page not found'
# }), 404)

@ -11,11 +11,11 @@ from datetime import datetime
from wowstash.blueprints.wallet import wallet_bp
from wowstash.library.docker import docker
from wowstash.library.helpers import capture_event
from wowstash.library.jsonrpc import Wallet, daemon, to_atomic
from wowstash.library.jsonrpc import Wallet, to_atomic
from wowstash.library.cache import cache
from wowstash.forms import Send, Delete, Restore
from wowstash.factory import db
from wowstash.models import User, DonatePrompt
from wowstash.models import User
from wowstash import config
@ -70,25 +70,6 @@ def dashboard():
sleep(1.5)
return redirect(url_for('wallet.loading'))
# Redirect to donate page if user isnt prompted for a bit
dp = DonatePrompt.query.filter(
DonatePrompt.user == current_user.id
).order_by(
DonatePrompt.date.desc()
).first()
if not dp:
d = DonatePrompt(user=current_user.id)
db.session.add(d)
db.session.commit()
return redirect(url_for('meta.donate'))
# If havent seen donate page in some time, show again
if dp.hours_elapsed() > 168:
d = DonatePrompt(user=current_user.id)
db.session.add(d)
db.session.commit()
return redirect(url_for('meta.donate'))
address = wallet.get_address()
transfers = wallet.get_transfers()
for type in transfers:
@ -105,9 +86,6 @@ def dashboard():
return render_template(
'wallet/dashboard.html',
transfers=all_transfers,
wallet_height=wallet.height(),
node_height=daemon.height(),
node_addr=config.DAEMON_HOST,
sorted_txes=get_sorted_txes(transfers),
balances=balances,
address=address,
@ -227,7 +205,7 @@ def send():
msg = tx['message'].capitalize()
msg_lower = tx['message'].replace(' ', '_').lower()
flash(f'There was a problem sending the transaction: {msg}')
capture_event(user.id, f'tx_fail_{msg_lower[0:50]}')
capture_event(user.id, f'tx_fail_{msg_lower}')
else:
flash('Successfully sent transfer.')
capture_event(user.id, 'tx_success')

@ -1,67 +1,23 @@
import click
from flask import Blueprint, url_for
from wowstash.library.jsonrpc import wallet
from wowstash.models import Transaction
from wowstash.factory import db
import wowstash.models
from wowstash.library.docker import docker
from wowstash.models import User, PasswordReset, Event
from wowstash.factory import db, bcrypt
# @app.errorhandler(404)
def not_found(error):
return make_response(jsonify({
'error': 'Page not found'
}), 404)
bp = Blueprint("cli", "cli", cli_group=None)
@bp.cli.command('clean_containers')
def clean_containers():
docker.cleanup()
@bp.cli.command('reset_wallet')
@click.argument('user_id')
def reset_wallet(user_id):
user = User.query.get(user_id)
user.clear_wallet_data()
print(f'Wallet data cleared for user {user.id}')
@bp.cli.command('init')
def init():
# @app.cli.command('initdb')
def init_db():
db.create_all()
@bp.cli.command('list_users')
def list_users():
users = User.query.all()
for i in users:
print(f'{i.id} - {i.email}')
@bp.cli.command('wipe_user')
@click.argument('user_id')
def wipe_user(user_id):
user = User.query.get(user_id)
if user:
events = Event.query.filter(Event.user == user.id)
for i in events:
print(f'[+] Deleting event {i.id} for user {user.id}')
db.session.delete(i)
print(f'[+] Deleting user {user.id}')
db.session.delete(user)
db.session.commit()
return True
else:
print('That user id does not exist')
return False
@bp.cli.command('reset_password')
@click.argument('user_email')
@click.argument('duration')
def reset_password(user_email, duration):
user = User.query.filter(User.email==user_email).first()
if not user:
click.echo('[!] Email address does not exist!')
return
pwr = PasswordReset(
user=user.id,
hash=PasswordReset().generate_hash(),
expiration_hours=duration
)
db.session.add(pwr)
db.session.commit()
click.echo(f'[+] Password reset link #{pwr.id} for {user_email} expires in {duration} hours: {url_for("auth.reset", hash=pwr.hash)}')
# @app.cli.command('send_transfers')
def send_transfers():
txes = Transaction.query.all()
for i in txes:
print(i)
# tx = wallet.transfer(
# 0, current_user.subaddress_index, address, amount
# )

@ -63,14 +63,31 @@ def create_app():
else:
return float(atomic)
# CLI
@app.cli.command('clean_containers')
def clean_containers():
from wowstash.library.docker import docker
docker.cleanup()
@app.cli.command('reset_wallet')
@click.argument('user_id')
def reset_wallet(user_id):
from wowstash.models import User
user = User.query.get(user_id)
user.clear_wallet_data()
print(f'Wallet data cleared for user {user.id}')
@app.cli.command('init')
def init():
import wowstash.models
db.create_all()
# Routes/blueprints
from wowstash.blueprints.auth import auth_bp
from wowstash.blueprints.wallet import wallet_bp
from wowstash.blueprints.meta import meta_bp
from wowstash.cli import bp as cli_bp
app.register_blueprint(meta_bp)
app.register_blueprint(auth_bp)
app.register_blueprint(wallet_bp)
app.register_blueprint(cli_bp)
return app

@ -1,6 +1,4 @@
from re import match as re_match
from re import fullmatch as re_fullmatch
from re import compile as re_compile
from flask_wtf import FlaskForm
from wtforms import StringField, BooleanField
from wtforms.validators import DataRequired, ValidationError
@ -13,12 +11,6 @@ class Register(FlaskForm):
terms_reviewed = BooleanField('Terms Reviewed:', validators=[DataRequired()], render_kw={"class": "form-control-span"})
privacy_reviewed = BooleanField('Privacy Policy Reviewed:', validators=[DataRequired()], render_kw={"class": "form-control-span"})
def validate_email(self, email):
regex = re_compile(r'([A-Za-z0-9]+[.-_])*[A-Za-z0-9]+@[A-Za-z0-9-]+(\.[A-Z|a-z]{2,})+')
if not re_fullmatch(regex, self.email.data):
raise ValidationError('This appears to be an invalid email. Contact admins if you feel this is incorrect.')
class Login(FlaskForm):
email = StringField('Email Address:', validators=[DataRequired()], render_kw={"placeholder": "Email", "class": "form-control", "type": "email"})
password = StringField('Password:', validators=[DataRequired()], render_kw={"placeholder": "Password", "class": "form-control", "type": "password"})
@ -40,11 +32,3 @@ class Restore(FlaskForm):
raise ValidationError('Invalid seed provided; must be alphanumeric characters only')
if len(self.seed.data.split()) != 25:
raise ValidationError("Invalid seed provided; must be standard Wownero 25 word format")
class ResetPassword(FlaskForm):
password = StringField('Password', validators=[DataRequired()], render_kw={"placeholder": "Password", "type": "password"})
password_confirmed = StringField('Confirm Password', validators=[DataRequired()], render_kw={"placeholder": "Confirm Password", "type": "password"})
def validate_password(self, password):
if self.password.data != self.password_confirmed.data:
raise ValidationError('Passwords do not match')

@ -31,7 +31,6 @@ class Docker(object):
--password {u.wallet_password} \
--daemon-address {config.DAEMON_PROTO}://{config.DAEMON_HOST}:{config.DAEMON_PORT} \
--daemon-login {config.DAEMON_USER}:{config.DAEMON_PASS} \
--trusted-daemon \
--electrum-seed '{seed}' \
--log-file /wallet/{u.id}-init.log \
--command refresh"
@ -44,7 +43,6 @@ class Docker(object):
--mnemonic-language English \
--daemon-address {config.DAEMON_PROTO}://{config.DAEMON_HOST}:{config.DAEMON_PORT} \
--daemon-login {config.DAEMON_USER}:{config.DAEMON_PASS} \
--trusted-daemon \
--log-file /wallet/{u.id}-init.log \
--command version
"""
@ -83,7 +81,6 @@ class Docker(object):
--password {u.wallet_password} \
--daemon-address {config.DAEMON_PROTO}://{config.DAEMON_HOST}:{config.DAEMON_PORT} \
--daemon-login {config.DAEMON_USER}:{config.DAEMON_PASS} \
--trusted-daemon \
--log-file /wallet/{u.id}-rpc.log
"""
try:

@ -1,8 +1,5 @@
import requests
from wowstash.models import Event
from wowstash.factory import db
from wowstash import config
def capture_event(user_id, event_type):
@ -13,11 +10,3 @@ def capture_event(user_id, event_type):
db.session.add(event)
db.session.commit()
return
def post_discord_webhook(text):
try:
r = requests.post(config.DISCORD_URL, data={"content": text})
r.raise_for_status()
return True
except:
return False

@ -1,6 +1,4 @@
from os import kill
from datetime import datetime
from secrets import token_urlsafe
from sqlalchemy import Column, Integer, DateTime, String, ForeignKey
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.sql import func
@ -67,41 +65,3 @@ class Event(db.Model):
def __repr__(self):
return self.id
class PasswordReset(db.Model):
__tablename__ = 'password_reset'
id = db.Column(db.Integer, primary_key=True)
user = db.Column(db.Integer, db.ForeignKey(User.id))
date = db.Column(db.DateTime, server_default=func.now())
hash = db.Column(db.String(80))
expiration_hours = db.Column(db.Integer)
expired = db.Column(db.Boolean, default=False)
def generate_hash(self):
return token_urlsafe(16)
def hours_elapsed(self):
now = datetime.utcnow()
diff = now - self.date
return diff.total_seconds() / 60 / 60
def __repr__(self):
return self.id
class DonatePrompt(db.Model):
__tablename__ = 'donate_prompts'
id = db.Column(db.Integer, primary_key=True)
user = db.Column(db.Integer, db.ForeignKey(User.id))
date = db.Column(db.DateTime, server_default=func.now())
def hours_elapsed(self):
now = datetime.utcnow()
diff = now - self.date
return diff.total_seconds() / 60 / 60
def __repr__(self):
return str(f'donate-prompt-{self.id}')

@ -1,67 +0,0 @@
<!DOCTYPE html>
<html lang="en">
{% include 'head.html' %}
<body id="page-top">
{% include 'navbar.html' %}
<!-- <header class="masthead">
<div class="container h-100">
<div class="row h-100">
<div class="col-lg-12 my-auto">
<div class="header-content mx-auto">
<h1 class="mb-4">Reset your password</h1>
<p>Wownero is a privacy centric cryptocurrency and is most safely managed on your own personal devices, on your own network, and with your own copy of the blockchain. This is a publicly accessible website, and while strict security measures are implemented on our servers, your account's security <strong>cannot</strong> be guaranteed. </p>
<p>If you decide to use this site for managing your funds, you do so at your own risk and are bound by the terms and conditions of this site. Practice good operational security and do not use this site for large amounts of funds.</p>
<div>
<a href="{{ url_for('meta.faq') }}">FAQ</a> -
<a href="{{ url_for('meta.terms') }}">Terms</a> -
<a href="{{ url_for('meta.privacy') }}">Privacy</a>
</div><br>
<a href="#register" class="btn btn-outline btn-xl js-scroll-trigger">Proceed</a>
</div>
</div>
</div>
</div>
</header> -->
<section class="section1" id="reset">
<div class="container">
<div class="section-heading text-center">
<form method="POST" action="">
{{ form.csrf_token }}
{% for f in form %}
{% if f.name != 'csrf_token' %}
{% if f.type == 'BooleanField' %}
<div class="form-group-span">
{{ f.label }}
{{ f }}
</div>
{% else %}
<div class="form-group">
{{ f.label }}
{{ f }}
</div>
{% endif %}
{% endif %}
{% endfor %}
<ul>
{% for field, errors in form.errors.items() %}
<li>{{ form[field].label }}: {{ ', '.join(errors) }}</li>
{% endfor %}
</ul>
<input type="submit" value="Reset" class="btn btn-link btn-outline-inverse btn-xl">
</form>
</div>
</div>
</section>
{% include 'footer.html' %}
{% include 'scripts.html' %}
</body>
</html>

@ -1,29 +1,9 @@
{% set desc = 'Wowstash; a web wallet for the Wownero cryptocurrency.' %}
{% set img = 'https://wowstash.app/static/img/wow-treasure-chest.png' %}
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="{{ desc }}">
<meta name="author" content="@lza_menace">
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="theme-color" content="#ffffff">
<meta name="apple-mobile-web-app-title" content="Wowstash">
<meta name="application-name" content="Wowstash">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="keywords" content="wownero, cryptocurrency, wallet">
<meta name="twitter:title" content="Wowstash">
<meta name="twitter:description" content="{{ desc }}">
<meta name="twitter:image" content="{{ img }}">
<meta name="twitter:card" content="summary_large_image">
<meta property="og:url" content="https://wowstash.app/">
<meta property="og:image" content="{{ img }}">
<meta property="og:description" content="{{ desc }}">
<meta property="og:title" content="Wowstash">
<link rel="shortcut icon" href="/static/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="/static/favicon.ico" />
<link rel="stylesheet" href="/static/vendor/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/vendor/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="/static/css/main.css">

@ -1,30 +0,0 @@
<!DOCTYPE html>
<html lang="en">
{% include 'head.html' %}
<body id="page-top">
{% include 'navbar.html' %}
<header class="masthead">
<div class="container h-100">
<div class="row h-100">
<div class="col-lg-12 my-auto">
<div class="header-content-sm mx-auto">
<h2 class="mb-4">Error</h2>
<p>There was an error - an administrator has been notified.</p>
<p>Error: <code style="background-color: white;">{{ error.original_exception }}</code></p>
</div>
</div>
</div>
</div>
</header>
{% include 'footer.html' %}
{% include 'scripts.html' %}
</body>
</html>

@ -1,33 +0,0 @@
<!DOCTYPE html>
<html lang="en">
{% include 'head.html' %}
<body id="page-top">
{% include 'navbar.html' %}
<header class="masthead">
<div class="container h-100">
<div class="row h-100">
<div class="col-lg-12 my-auto">
<div class="header-content mx-auto">
<h1 class="mb-4">Donate</h1>
<p>Hey, this service is provided to you for free, please consider donating some WOW since I both donate my time and money keeping the service alive and paying for hosting.</p>
<p>lza_menace: <code style="background-color: white;">Wo59kvcHiDd48sstysDqGgBAN1fECLKALKw2bPUJhS4UjX9wj2SK4e4GH6HvrBmot6cBrWNE1T65UR6a5SLbzh882c1SXEhiK</code></p>
<a href="{{ url_for('wallet.dashboard') }}?to_addr=Wo59kvcHiDd48sstysDqGgBAN1fECLKALKw2bPUJhS4UjX9wj2SK4e4GH6HvrBmot6cBrWNE1T65UR6a5SLbzh882c1SXEhiK#send" class="btn btn-outline btn-xl js-scroll-trigger">Ok, take me to my wallet</a>
<br/><br/>
<a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ" target=_blank class="btn btn-outline btn-xl js-scroll-trigger">Nah, fuck you menace.</a>
</div>
</div>
</div>
</div>
</header>
{% include 'footer.html' %}
{% include 'scripts.html' %}
</body>
</html>

@ -17,10 +17,7 @@
<img src="data:image/png;base64,{{ qrcode }}" width=200 class="center">
<hr><br>
<h4>Balance</h4>
<p class="inline">{{ balances[1] | from_atomic }} WOW ({{ (balances[0] - balances[1]) | from_atomic }} locked)</p><br />
<p class="inline">Wallet height: {{ wallet_height['height'] }}</p><br />
<p class="inline">Node height: {{ node_height['height'] }}</p><br />
<p class="inline">Node address: {{ node_addr }}</p>
<p class="inline">{{ balances[1] | from_atomic }} WOW ({{ (balances[0] - balances[1]) | from_atomic }} locked)</p>
<span class="dashboard-buttons">
<div class="col-sm-6 dashboard-button">
<a class="btn btn-lg btn-link btn-outline btn-xl js-scroll-trigger" href="#transfers">See Txes</a>
@ -117,7 +114,7 @@
{{ send_form.csrf_token }}
<div class="form-group">
{{ send_form.address.label }}
<input class="form-control" id="address" name="address" placeholder="Wownero address" required="" type="text" value="{{ request.args.to_addr }}">
{{ send_form.address }}
</div>
<div class="form-group">
{{ send_form.amount.label }}
@ -130,7 +127,6 @@
</ul>
<input type="submit" value="Send" class="btn btn-link btn-outline btn-xl">
</form>
<a href="{{ url_for('meta.donate') }}" style="padding-top: 1em; display: block;">Donation Info</a>
</div>
</div>
</section>

@ -5,7 +5,7 @@
<body id="page-top">
<section class="section1" style="padding: 2em 0 !important;">
<section class="section1">
<div class="container">
<div class="section-heading text-center">
<h2>Your wallet is connecting</h2>
@ -31,6 +31,8 @@
</div>
</section>
{% include 'footer.html' %}
{% include 'scripts.html' %}
</body>

Loading…
Cancel
Save