def sweep_run(args): pw.setOnline() # check recipient is a valid address if not pw.validateAddress(args.recipient): print(f"ERROR: {args.recipient} is not a valid address") sys.exit(EXIT_INVALID_RECIPIENT) recipient = pw.Address(args.recipient) # sweep expired foils asset = pw.Asset(args.assetid) asset_fee = get_asset_fee(args.assetid) date = time.time() foils = Foil.get_batches_between(db_session, args.batch_start, args.batch_end) for foil in foils: if args.ignore_expiry or foil.expiry and date >= foil.expiry: addr = pw.Address(seed=foil.seed) balance = addr.balance(assetId=args.assetid) if balance == 0: print(f"Skipping {foil.batch} {addr.address}, balance is 0") continue result = addr.sendAsset(recipient, asset, balance - asset_fee, \ feeAsset=asset, txFee=asset_fee) print(result) print(f"Swept {foil.batch} {addr.address}, txid {result['id']}") else: print(f"Skipping {foil.batch} {addr.address}, not yet expired")
def __init__(self, address='', publicKey='', privateKey='', seed='', alias='', nonce=0): if nonce < 0 or nonce > 4294967295: raise ValueError('Nonce must be between 0 and 4294967295') if seed: self._generate(seed=seed, nonce=nonce) elif privateKey: self._generate(privateKey=privateKey) elif publicKey: self._generate(publicKey=publicKey) elif address: if not pywaves.validateAddress(address): raise ValueError("Invalid address") else: self.address = address self.publicKey = publicKey self.privateKey = privateKey self.seed = seed self.nonce = nonce elif alias and not pywaves.OFFLINE: self.address = pywaves.wrapper('/alias/by-alias/%s' % alias).get( "address", "") self.publicKey = '' self.privateKey = '' self.seed = '' self.nonce = 0 else: self._generate(nonce=nonce) if not pywaves.OFFLINE: self.aliases = self.aliases()
def sendWaves(): address = str(request.form['address']) realIp=request.headers.get('X-Forwarded-For') if address == None or address == "": return "Invalid address",400 if pw.validateAddress(address)==False: return "Invalid address",400 userDataForAddress = users.find_one({"address":str(address),"asset":"waves"}) userDataForIps = ips.find_one({"ip":str(realIp),"asset":"waves"}) if userDataForAddress == None and userDataForIps ==None: users.insert_one({ "address":str(address), "lasttime":int(time.time()), "asset":"waves" }) ips.insert_one({ "ip":realIp, "lasttime":int(time.time()), "asset":"waves" }) send_waves(address) return "Send "+str(FAUCET_VALUE)+" token to "+str(address),200 if userDataForAddress !=None and checklastTime(userDataForAddress) ==False: minutes=calculateLastTime(userDataForAddress) return "Failed, you must wait for "+str(minutes[0])+"Min "+str(minutes[1])+"Sec",400 if userDataForIps !=None and checklastTime(userDataForIps) ==False: minutes=calculateLastTime(userDataForIps) return "Failed, you must wait for "+str(minutes[0])+"Min "+str(minutes[1])+"Sec",400 if userDataForAddress==None: users.insert_one({ "address":str(address), "lasttime":int(time.time()), "asset":"waves" }) else: users.update_one({ "address": address,"asset":"waves"}, { "$set": { "lasttime": int(time.time()) }}) if userDataForIps==None: ips.insert_one({ "ip":realIp, "lasttime":int(time.time()), "asset":"waves" }) else: ips.update_one({ "ip": realIp,"asset":"waves" }, { "$set": { "lasttime": int(time.time()) }}) send_waves(address) return "Send "+str(FAUCET_VALUE)+" token to "+str(address),200
def send(update, context): user = update.message.from_user id = user.id mydb = connectMeToDB() mycursor = mydb.cursor() mycursor.execute("SELECT * FROM wallets where user="******"" if len(myresult) == 0: message = "\U0001F6D1 Use command /wallet to create new address" update.message.reply_text(message) return if len(context.args) != 2: message = "\U0001F6D1 For send WAVES use command \n/send <Address> <Amount>" update.message.reply_text(message) return address = context.args[0] amount = context.args[1] if not pw.validateAddress(address): message = "\U0001F6D1 Address is not valid. Please check!" update.message.reply_text(message) return amount_f = 0 try: amount_f = float(amount) except: message = "\U0001F6D1 Valid format for amount is 1 or 1.0" update.message.reply_text(message) return error_mess = "" real_amount = int(amount_f * (100000000)) #remove all past payments sql = "DELETE FROM payments WHERE user = "******"INSERT INTO payments(user, address, amount) VALUES(%s, %s, %s)" data = (str(id), address, real_amount) mycursor.execute(sql, data) mydb.commit() message = "\U0001F195 New transation\n\nRecepient\n\U0001F194 " + address + "\nAmount\n\U0001F4B8 " + str(amount_f) + " WAVES\n\nUse /confirm to send transaction to blockchain." update.message.reply_text(message) mycursor.close() mydb.close()
def _verify(self, address): validated = False try: validated = pw.validateAddress(address) except: pass if validated: self.address = address return validated
def get_account_address(prompt): while True: value = input(prompt) pw.setNode(node=NODE, chain=NETWORK) if not pw.validateAddress(value): print("Sorry, please provide correct address.") continue else: break return value
def check(addr=None): if not pw.validateAddress(addr): return abort(400, 'invalid address') amount = request.args.get('amount') try: amount = float(amount) except: abort(400, f'invalid amount "{amount}"') amount_int = int(round(amount * 10**asset.decimals)) invoice_id = request.args.get('invoice_id') qrcode_data = f'waves://{addr}?asset={ASSET_ID}&amount={amount_int}&attachment={{"invoice_id":"{invoice_id}"}}' return render_template('addr.html', addr=addr, invoice_id=invoice_id, qrcode_data=qrcode_data, asset_id=ASSET_ID, amount=amount_int, node=WAVES_NODE)
NODE = config.get('main', 'node') NETWORK = config.get('main', 'network') RFBGATEWAY = config.get('rfbnetwork', 'rfb_gateway') RFBGATEWAYPORT = config.getint('rfbnetwork', 'rfb_gateway_port') HOST_PORT = config.getint('rfbnetwork', 'rfb_node_port') ACCOUNT_ADDRESS = config.get('account', 'account_address') amountAssetID = config.get('market', 'amount_asset') priceAssetID = config.get('market', 'price_asset') LOGFILE = config.get('logging', 'logfile') pw.setNode(node=NODE, chain=NETWORK) wallet_file = Path("wallet.dat") if wallet_file.is_file(): f = open("wallet.dat", "r") if f.mode == 'r': contents = f.read() if pw.validateAddress(contents): ACCOUNT_ADDRESS = contents if ACCOUNT_ADDRESS == "XXX": print("Please configure your account address") ACCOUNT_ADDRESS = configureAccountAddress(NODE, NETWORK) log("-" * 80) # log(" Node : %s" % NODE) log(" Network : %s" % NETWORK) log(" RFBGateway : %s" % RFBGATEWAY) log(" RFBGatewayPort : %s" % RFBGATEWAYPORT) log(" HostPort : %s" % HOST_PORT) log(" AccountAddress : %s" % ACCOUNT_ADDRESS) # log(" Amount Asset ID : %s" % amountAssetID) # log(" Price Asset ID : %s" % priceAssetID)
def repeat(message): id = message.chat.id set_zero1 = True set_zero2 = True set_zero3 = True try: print(message.chat.username + ": " + message.text) except: print(str(id) + ": " + message.text) conn = sqlite3.connect("gold_users.db") db = conn.cursor() sql = "SELECT used_id FROM banned" db.execute(sql) b = db.fetchall() not_banned = True for i in range(len(b)): if id == b[i][0]: bot.send_message(id, "Sorry, but you was banned") not_banned = False break # try: if not_banned: # conn=sqlite3.connect("gold_users.db") # db=conn.cursor() try: text = message.text.lower() sql = "SELECT language FROM alco WHERE user_id=?" db.execute(sql, [id]) lang = int(db.fetchall()[0][0]) # bot.send_message(354502298, lang) print(text) if text == exp["balance"][lang]: bot.send_message(id, exp["your balance"][lang] + ":\n" + balance(db, id), reply_markup=bal_markup(lang)) elif text == exp["settings"][lang]: bot.send_message(id, exp["settings"][lang] + ":", reply_markup=markup5(lang)) elif text == exp["language"][lang]: bot.send_message(id, exp["choose your language:"][lang], reply_markup=markup2) elif text == exp["make bet"][lang]: bot.send_message(id, exp["enter amount"][lang], reply_markup=markup4(lang)) elif text == exp["cancel"][lang]: bot.send_message(id, exp["cancel"][lang], reply_markup=markup(lang)) elif text == exp["affiliate link"][lang]: bot.send_message(id, exp["ref reward"][lang], reply_markup=markup(lang)) bot.send_message(id, "t.me/goldmillion_dice_bot?start=" + str(id)) elif text == exp["faucet"][lang]: print(1) aff = date_check(id, db, conn) if aff < 3: rand_link = rand(0, len(link) - 1) sql = "UPDATE alco SET faucet=? WHERE user_id=?" db.execute(sql, [link[rand_link][1], id]) sql = "UPDATE alco SET date_check=? WHERE user_id=?" db.execute(sql, [aff + 1, id]) conn.commit() gif = open("animation.gif.mp4", "rb") bot.send_document(id, gif) bot.send_message(id, "[personal link](" + link[rand_link][0] + ")\n\n" + exp["your code:"][lang], parse_mode="Markdown", reply_markup=markup6(lang)) set_zero2 = False else: bot.send_message(id, exp["try tomorrow"][lang], reply_markup=markup(lang)) elif text == exp["withdraw"][lang]: sql = "UPDATE alco SET withdraw=? WHERE user_id=?" db.execute(sql, ["wait", id]) conn.commit() set_zero3 = False bot.send_message(id, exp["your wallet"][lang], reply_markup=markup4(lang)) elif text == exp["deposit"][lang]: bot.send_message(id, exp["deposit instruction"][lang], reply_markup=markup8(lang)) elif text == exp["my id"][lang]: bot.send_message(id, str(id)) elif text == exp["deposit wallet"][lang]: bot.send_message(id, "3PGQGQeq3gmFrKyUyyX38fyRmWYkvUcUD1C") elif text == exp["check transactions"][lang]: node_url = 'https://nodes.wavesnodes.com' address = '3PGQGQeq3gmFrKyUyyX38fyRmWYkvUcUD1C' limit = 1000 sql = "SELECT after FROM date" db.execute(sql) before = db.fetchall()[0][0] transactions = requests.get( f'{node_url}/transactions/address/{address}/limit/{limit}?before={before}').json() a = [] for i in range(len(transactions[0])): if transactions[0][i]["id"] != before: if transactions[0][i]["type"] == 4 and transactions[0][i]["recipient"] == address and len( transactions[0][i]["attachment"]) and transactions[0][i][ "assetId"] == "85Jc7CzxHBg9vNokztjyznpimvQv7AUJjxPDQ5Vywf2a": try: attachment = int(str(base58.b58decode(transactions[0][i]["attachment"]))[2:-1]) a += " " a[len(a) - 1] = [attachment, transactions[0][i]["amount"] / 100000000] except: pass else: break check_send = True if len(a): for i in range(len(a)): try: add_balance(a[i][0], a[i][1], db, conn) if a[i][0] == int(id): check_send = False bot.send_message(a[i][0], "income transfer:\n+" + str(a[i][1])) bot.send_message(a[i][0], exp["your balance"][lang] + ":\n" + balance(db, a[i][0]), reply_markup=bal_markup(lang)) except: pass if check_send: bot.send_message(id, exp["try later"][lang]) sql = "UPDATE date SET after=?" db.execute(sql, [transactions[0][0]["id"]]) conn.commit() elif text == exp["high"][lang] or text == exp["low"][lang]: try: # if True: bet = beet(id, db, conn) if bet > 0 and bet <= float(balance(db, id)): if bet <= 1000000: secret_number = secrets.randbelow(100) if text == exp["high"][lang]: if secret_number < 51: update_balance((-1) * bet, id, db, conn) bot.send_message(id, exp["lose"][lang] + "\n\n" + exp["your balance"][ lang] + ":\n" + balance(db, id), reply_markup=markup(lang)) elif secret_number > 50: update_balance(bet, id, db, conn) bot.send_message(id, exp["win"][lang] + "\n\n" + exp["your balance"][ lang] + ":\n" + balance(db, id), reply_markup=markup(lang)) elif text == exp["low"][lang]: if secret_number > 48: update_balance((-1) * bet, id, db, conn) bot.send_message(id, exp["lose"][lang] + "\n\n" + exp["your balance"][ lang] + ":\n" + balance(db, id), reply_markup=markup(lang)) elif secret_number < 49: update_balance(bet, id, db, conn) bot.send_message(id, exp["win"][lang] + "\n\n" + exp["your balance"][ lang] + ":\n" + balance(db, id), reply_markup=markup(lang)) try: add_balance(354502298, round(bet * 0.006, 8), db, conn) except: pass try: add_balance(972984750, round(bet * 0.006, 8), db, conn) except: pass try: add_balance(383025136, round(bet * 0.002, 8), db, conn) except: pass try: add_balance(849678522, round(bet * 0.002, 8), db, conn) except: pass sql = "SELECT ref FROM alco WHERE user_id=?" db.execute(sql, [id]) ref = db.fetchall()[0][0] print(ref) if ref != 0: add_balance(ref, round(bet * 0.004, 8), db, conn) else: bot.send_message(id, "max bet: 1'000'000") else: bot.send_message(id, exp["incorrect amount"][lang], reply_markup=markup(lang)) except: bot.send_message(id, exp["enter amount of coins"][lang], reply_markup=markup(lang)) elif text[:21] == 'admin_update_balance_' and (id == 354502298 or id == 972984750): add_balance(text[21:text.index("*")], text[text.index("*") + 1:], db, conn) bot.send_message(text[21:text.index("*")], "balance changed:\n" + text[text.index("*") + 1:]) elif text[:11] == "admin_send_" and (id == 354502298 or id == 972984750): try: conn = sqlite3.connect("gold_users.db") cursor = conn.cursor() sql = "SELECT user_id FROM alco" cursor.execute(sql) a = cursor.fetchall() for i in range(len(a)): try: sql = "SELECT language FROM alco WHERE user_id=?" db.execute(sql, [a[i][0]]) lang = int(db.fetchall()[0][0]) if lang == int(text[11]): bot.send_message(int(a[i][0]), text[12:]) except: print("нет(") except: pass elif text[:10] == "admin_ban_" and (id == 354502298 or id == 972984750): ban_user(int(text[10:])) bot.send_message(int(text[10:]), "you was banned") bot.send_message(354502298, "user " + text[10:] + " was banned") elif text[:10] == "admin_air_" and (id == 354502298 or id == 972984750): try: conn = sqlite3.connect("gold_users.db") cursor = conn.cursor() sql = "SELECT user_id FROM alco" cursor.execute(sql) a = cursor.fetchall() for i in range(len(a)): try: add_balance(int(a[i][0]), text[10:], db, conn) bot.send_message(int(a[i][0]), "balance changed:\n" + text[10:]) except: print("нет(") except: pass elif text[:7] == "admin5 " and id == 354502298: try: sql = "UPDATE alco SET ref=? WHERE user_id=?" db.execute(sql, [int(text[7:text.index("*")]), int(text[text.index("*") + 1:])]) conn.commit() bot.send_message(int(text[7:text.index("*")]), "referral was added") bot.send_message(354502298, "добавлено") except: pass elif db.execute("SELECT withdraw FROM alco WHERE user_id=?", [id]).fetchall()[0][0] == "wait": try: if pw.validateAddress(str(message.text)): sql = "UPDATE alco SET withdraw=? WHERE user_id=?" db.execute(sql, [str(message.text), id]) conn.commit() set_zero3 = False bot.send_message(id, exp["now enter amount:"][lang]) print(str(message.text)) else: bot.send_message(id, "incorrect address") except: bot.send_message(id, "incorrect address") else: try: sql = "SELECT faucet FROM alco WHERE user_id=?" db.execute(sql, [id]) if_num = db.fetchall()[0][0] w_amount = None if if_num == 0: sql = "SELECT withdraw FROM alco WHERE user_id=?" db.execute(sql, [id]) w_amount = db.fetchall()[0][0] if w_amount == "wait": w_amount = None print(if_num) print(w_amount) if if_num != 0: if str(if_num) == text: add_balance(id, +3000, db, conn) bot.send_message(354502298, "faucet") bot.send_message(id, "balance changed:\n" + "+3000", reply_markup=markup(lang)) sql = "SELECT ref FROM alco WHERE user_id=?" db.execute(sql, [id]) ref = db.fetchall()[0][0] if ref != 0: try: add_balance(ref, +1000, db, conn) bot.send_message(ref, "affiliate bonus:\n" + "+1000") except: pass else: bot.send_message(id, exp["invalid code"][lang]) elif isinstance(w_amount, str): if float(balance(db, id)) >= float(text) and float(text) > 5000: try: send_amount = int((float(text) - 5000) * 100000000) bot.send_message(id, "wait a second...", reply_markup=None) FDToken = pw.Asset("85Jc7CzxHBg9vNokztjyznpimvQv7AUJjxPDQ5Vywf2a") myAddress = pw.Address(privateKey='secret_key') recipient = pw.Address(str(w_amount)) myAddress.sendAsset(recipient, FDToken, send_amount, attachment="payout from t.me/goldmillion_dice_bot") add_balance(id, float(text) * (-1), db, conn) bot.send_message(id, "success!", reply_markup=markup(lang)) except: pass else: bot.send_message(id, "not enough coins") else: float(text) write_bet(id, text, db, conn) set_zero1 = False bot.send_message(id, exp["bet: "][lang] + text, reply_markup=markup3(lang)) except: bot.send_message(id, exp["try again"][lang], reply_markup=markup(lang)) if set_zero1: sql = "UPDATE alco SET current_number=? WHERE user_id=?" db.execute(sql, [None, id]) if set_zero2: sql = "UPDATE alco SET faucet=? WHERE user_id=?" db.execute(sql, [0, id]) if set_zero3: sql = "UPDATE alco SET withdraw=? WHERE user_id=?" db.execute(sql, [None, id]) if set_zero1 or set_zero2 or set_zero3: conn.commit() except: pass
def validateaddress(address): if pywaves.validateAddress(address): return {"address": address} err = OtherError("invalid address", 0) raise err
def is_address(s): try: return pywaves.validateAddress(s) except: return False
def is_address(val): try: return pywaves.validateAddress(val) except: # pylint: disable=bare-except return False
def req(addr=None): if not pw.validateAddress(addr): return abort(400, 'invalid address') return render_template('addr.html', addr=addr, qrcode_data=None)