Пример #1
0
def save_keys(exchange, public_key, private_key):
    password = request.cookies.get('password')
    encrypted_public_key = encrypt_key((public_key), password).decode('utf-8')
    encrypted_private_key = encrypt_key((private_key),
                                        password).decode('utf-8')

    args = (exchange, encrypted_public_key, encrypted_private_key)
    database.new_argument_query(
        "INSERT INTO exchanges_api_keys (`exchange`,`public_key`,`private_key`) VALUES (?, ?, ?) ;",
        args)

    return True
Пример #2
0
def update_coin_prices_settings(coin, new_exchange):
    if_exist = database.new_query(
        "SELECT count(1) FROM `coins_prices` WHERE `name`='" + coin +
        "'")[0][0]
    if if_exist:
        response = database.new_argument_query(
            "UPDATE `coins_prices` SET `exchange`=? WHERE `name`=?",
            (new_exchange, coin))
    else:
        response = database.new_argument_query(
            "INSERT INTO `coins_prices` (`exchange`, `name`) VALUES (?, ?)",
            (new_exchange, coin))
    return response
Пример #3
0
def update_all_keys(old_pass, new_pass):
    old_pass = hashlib.sha256(old_pass.encode('utf-8')).hexdigest()
    new_pass = hashlib.sha256(new_pass.encode('utf-8')).hexdigest()

    for key_pair in get_all_keys():
        pair_id = key_pair[0]

        public_key = (decrypt_key(key_pair[1], old_pass)['data']).decode()
        private_key = (decrypt_key(key_pair[2], old_pass)['data']).decode()

        encrypted_public_key = encrypt_key((public_key),
                                           new_pass).decode('utf-8')
        encrypted_private_key = encrypt_key((private_key),
                                            new_pass).decode('utf-8')

        args = (encrypted_public_key, encrypted_private_key, pair_id)
        database.new_argument_query(
            "UPDATE exchanges_api_keys SET `public_key`=?, `private_key`=? WHERE `id`=? ;",
            args)
    return True
Пример #4
0
def groups_edit(group_id):
    all_wallets = []
    if request.referrer is not None and '/groups' in request.referrer:
        messages = []
        if 'save' in request.form:
            group_name = request.form['name']
            args = (group_id, )
            database.new_argument_query(
                "DELETE FROM wallet_group WHERE group_id=?", args)
            for key, val in request.form.items():
                if key != 'name' and key != 'save':
                    args = (key, group_id)
                    database.new_argument_query(
                        "INSERT INTO wallet_group (`wallet_id`,`group_id`) VALUES (?, ?) ;",
                        args)
            database.new_argument_query(
                "UPDATE groups SET `name`=? WHERE `id`=?;",
                (group_name, group_id))
            messages.append("Saved!")

        elif 'cancel' in request.form:
            return make_response(redirect("/groups"))

        group_details = groups.get_group_details(group_id)
        group_name = group_details[0]
        group_currency = group_details[1]
        group_wallets = wallets.get_address_by_group(group_id)

        for wallet in currency.get_all_wallets(group_currency):
            tmp_wallet = []

            tmp_wallet.append(wallet[0])
            tmp_wallet.append(wallet[2])
            tmp_wallet.append(wallet[3])

            if wallet[3] in group_wallets:
                tmp_wallet.append(True)
            else:
                tmp_wallet.append(False)

            all_wallets.append(tmp_wallet)
        # [id, name, address, state (in group or not)]
        return render_template('groups_edit.html',
                               group_id=group_id,
                               all_wallets=all_wallets,
                               group_name=group_name,
                               messages=messages)
    else:
        return make_response(redirect("/groups"))
Пример #5
0
def remove_wallet(id):
    args = (id, )
    response = database.new_argument_query(
        "DELETE FROM wallets WHERE `id`=? ;", args)
    return response
Пример #6
0
def save_wallet(currency, address, name):
    args = (currency, address, name)
    database.new_argument_query(
        "INSERT INTO wallets (`currency`,`address`,`name`) VALUES (?, ?, ?) ;",
        args)
    return
Пример #7
0
def save_new_time(time):
    return database.new_argument_query(
        "UPDATE settings SET `value`=? WHERE `name`='dash_interval' ;",
        (time, ))
Пример #8
0
def update_column(name, new_value):
    args = (str(new_value), name)
    return database.new_argument_query(
        "UPDATE settings SET `value`=? WHERE `name`=? ;", args)
Пример #9
0
def remove_key(id):
    args = (id, )
    response = database.new_argument_query(
        "DELETE FROM exchanges_api_keys WHERE `id`=? ;", args)
    return response
Пример #10
0
def remove_group(id):
    args = (id, )
    database.new_argument_query("DELETE FROM groups WHERE `id`=? ;", args)
    database.new_argument_query(
        "DELETE FROM wallet_group WHERE `group_id`=? ;", args)
    return True
Пример #11
0
def create_new_group(name, currency):
    args = (name, currency)
    return database.new_argument_query(
        "INSERT INTO groups (`name`,`currency`) VALUES (?, ?) ;", args)