async def wallet_watcher(): await client.wait_until_ready() start = int(rpc.getStatus()['blockCount']) - 100000 while not client.is_closed: height = int(rpc.getStatus()['blockCount']) print("HEIGHT IS: " + str(height)) for tx in get_deposits(start, session): session.add(tx) try: session.commit() except: session.rollback() balance = session.query(TipJar).filter( TipJar.paymentid == tx.paymentid).first() if not balance: # don't do for withdrawal return good_embed = discord.Embed(title="Deposit Recieved!", colour=discord.Colour(0xD4AF37)) good_embed.description = "Your deposit of {} {} has now been credited.".format( tx.amount / config['units'], config['symbol']) print("TRANSACTION PID IS: " + tx.paymentid) good_embed.add_field(name="New Balance", value="{0:,.2f}".format(balance.amount / config['units'])) user = await client.get_user_info(str(balance.userid)) await client.send_message(user, embed=good_embed) if start < height: start += 1000 if start >= height: start = height - 1 await asyncio.sleep(0.5) # just less than the block time
async def wallet_watcher(): await client.wait_until_ready() while not client.is_closed: for tx in get_deposits(session): session.add(tx) try: session.commit() except: session.rollback() balance = session.query(TipJar).filter( TipJar.paymentid == tx.paymentid).first() if not balance: # don't do for withdrawals from jar (basically tips) return good_embed = discord.Embed(title="Deposit Recieved!", colour=discord.Colour(0xD4AF37)) good_embed.description = "Your deposit of {} {} has now been credited.".format( tx.amount / config['units'], config['symbol']) print("TRANSACTION PID IS: " + tx.paymentid) good_embed.add_field(name="New Balance", value="{0:,.2f}".format(balance.amount / config['units'])) user = await client.get_user_info(str(balance.userid)) try: await client.send_message(user, embed=good_embed) except: continue await asyncio.sleep(119) # just less than the block time
def ahorros_para_lograr_meta(): data = parse_data(request.get_json()) ini_dep = data.get('ini_dep') fin_bal = data.get('fin_bal') freq = data.get('freq') num_of_years = data.get('num_of_years') rate = data.get('rate') dep_when = data.get('dep_when') time_scale, rows_per_page = data.get('time_scale') periods, periods_m, periods_a = get_periods(freq, num_of_years) fv = fut_val(rate / (100 * freq), freq * num_of_years, ini_dep) reg_dep = -1 * payment(rate / (100 * freq), freq * num_of_years, 0, fin_bal + fv, dep_when) deposits, reg_deps, extra_deps = get_deposits(ini_dep, reg_dep, 0, 0, 0, periods) interests, agg_interests, agg_deposits, balances = get_balances( periods, deposits, ini_dep, rate, freq, dep_when) return jsonify({ 'reg_dep': reg_dep, 'time_scale': time_scale, 'total_dep': sum(deposits), 'total_int': sum(interests), 'fin_bal': balances[-1], 'periods': periods, 'agg_deposits': agg_deposits, 'agg_interests': agg_interests, 'balances': balances, 'table': get_table(periods, deposits, interests, balances), 'table_m': get_table_m(periods_m, deposits, interests, balances, freq), 'table_a': get_table_a(periods_a, deposits, interests, balances, freq) }), 200, HEADERS
async def wallet_watcher(): await client.wait_until_ready() start = 194320 while not client.is_closed: height = int(rpc.getStatus()['blockCount']) for tx in get_deposits(start, session): session.add(tx) try: session.commit() except: session.rollback() if start < height: start += 1000 if start >= height: start = height - 1 await asyncio.sleep(10)
def calculadora_de_ahorros(): data = parse_data(request.get_json()) ini_dep = data.get('ini_dep') reg_dep = data.get('reg_dep') freq = data.get('freq') num_of_years = data.get('num_of_years') rate = data.get('rate') extra_dep = data.get('extra_dep') extra_dep_start = data.get('extra_dep_start') extra_dep_f = data.get('extra_dep_f') dep_when = data.get('dep_when') time_scale, rows_per_page = data.get('time_scale') periods, periods_m, periods_a = get_periods(freq, num_of_years) deposits, reg_deps, extra_deps = get_deposits(ini_dep, reg_dep, extra_dep, extra_dep_start, extra_dep_f, periods) interests, agg_interests, agg_deposits, balances = get_balances( periods, deposits, ini_dep, rate, freq, dep_when) return jsonify({ 'time_scale': time_scale, 'total_dep': sum(deposits), 'total_int': sum(interests), 'fin_bal': balances[-1], 'periods': periods, 'agg_deposits': agg_deposits, 'agg_interests': agg_interests, 'balances': balances, 'table': get_table(periods, deposits, interests, balances), 'table_m': get_table_m(periods_m, deposits, interests, balances, freq), 'table_a': get_table_a(periods_a, deposits, interests, balances, freq) }), 200, HEADERS