Example #1
0
def register():
    if request.method == 'POST':
        if "" in request.form.values():
            return render_template("register.html")
        if request.form['username'] in list(User.query.values(User.name)):
            return render_template("register.html",error="Please enter a password.")
        if request.form['email'] in list(User.query.values(User.email)):
            return render_template("register.html",error="Please enter a valid email.")
        if request.form['password'] != request.form['passwordconfirm']:
            return render_template("register.html",error="Passwords do not match.")
        #TODO: error for when they try to register when logged in already
        u = User(request.form['username'], request.form['email'],generate_password_hash(request.form['password'].strip()))
        db_session.add(u)
        db_session.commit()

        for currency in config.get_currencies():
            addr = generate_deposit_address(currency)
            a = Address(currency,addr,u.id)
            db_session.add(a)
        db_session.commit()
        if not send_confirm_email(u.id):
            return home_page("ltc_btc", danger='An error occured during registration. Please contact the administrator.')
        return home_page("ltc_btc", dismissable='Successfully registered. Please check your email and confirm your account before logging in.')

    if request.method == 'GET':
        return render_template("register.html")
Example #2
0
def account_page(**kwargs):
    return render_template(
        'account.html',
        currencies=config.get_currencies(),
        openorders=openorders(
            session['userid']),
        **kwargs)
Example #3
0
def register():
    if request.method == 'POST':
        if "" in request.form.values():
            return render_template("register.html")
        if request.form['username'] in list(User.query.values(User.name)):
            return render_template("register.html",error="password")
        if request.form['email'] in list(User.query.values(User.email)):
            return render_template("register.html",error="email")
        if request.form['password'] != request.form['passwordconfirm']:
            return render_template("register.html",error="matching")
        #TODO: error for when they try to register when logged in already
        u = User(request.form['username'], request.form['email'],generate_password_hash(request.form['password'].strip()))
        db_session.add(u)
        db_session.commit()

        for currency in config.get_currencies():
            addr = generate_deposit_address(currency)
            a = Address(currency,addr,u.id)
            db_session.add(a)
        db_session.commit()
        return home_page("ltc_btc", dismissable='Successfully registered. Please log in.')

    if request.method == 'GET':
        return render_template("register.html")
Example #4
0
def account_page(**kwargs):
    return render_template('account.html',
                           currencies=config.get_currencies(),
                           openorders=openorders(session['userid']),
                           **kwargs)
Example #5
0
from jsonrpc import ServiceProxy
import cPickle
from database import init_db, db_session, redis
from models import *
from app import adjustbalance
from config import config
import logging
import daemon

logging.basicConfig(filename=config.get_tx_log_file(), level=logging.DEBUG)
currencies = config.get_currencies()
init_db()


def handle_transactions():
    for currency in currencies:
        logging.info("Processing {} deposits".format(currency))
        oldtransactions = CompletedOrder.query.filter().all()
        oldids = [x.transaction_id for x in oldtransactions]

        rpc = ServiceProxy(currencies[currency]["daemon"])
        transactions = [tx for tx in rpc.listtransactions() if tx["category"] == "receive"]
        newtransactions = []

        for tx in transactions:
            if tx["txid"] not in oldids:
                newtransactions.append(tx)
        for tx in newtransactions:
            addr = Address.query.filter(Address.address == str(tx["address"])).first()
            if addr:
                logging.info("New Deposit! TXID: {} Amount: {} UserID: {}".format(tx["txid"], tx["amount"], addr.user))