Пример #1
0
def make_transaction_to_address(user, amount, address):

    rpc_connection = connect()

    txid = rpc_connection.sendtoaddress(address, round(amount, 6),
                                        "tippbot withdraw")

    logger.info(
        'creating withdraw transaction (user: %s, amount: %.3f, address: %s, txid: %s)',
        user.user_id, amount, address, txid)
    if db.create_withdraw_transaction(txid, amount, user):
        logger.info('withdraw successful.')
        return txid
    else:
        raise util.TipBotException("error")
Пример #2
0
def make_transaction_to_address(user, amount, address):
    txfee = 0.01
    commands = [["settxfee", txfee]]
    rpc_connection = connect()
    result = rpc_connection.batch_(commands)
    if result[0]:
        commands = [[
            "sendtoaddress", address, amount - txfee, "ztipbot withdraw"
        ]]
        result = rpc_connection.batch_(commands)
        txid = result[0]
        logger.info(
            'creating withdraw transaction (user: %s, amount: %.3f, address: %s)',
            user.user_id, amount, address)
        if db.create_withdraw_transaction(txid, amount, user):
            logger.info('withdraw successful.')
            return
        else:
            raise util.TipBotException("error")