def do_batch(dat): """ Make a batch of transfers :param dat: :return: """ import config snap_info = pickle.loads(Redisdb.get("snapshot_info")) # TODO: obtener la cuenta a partir de la clave pública # TODO: obtener balance de la moneda a repartir y de la moneda del fee # try: Bitshares = config.BitShares(node=config.WSS_NODE, wif=dat['key']) except Exception as err: print(err.__repr__()) Redisdb.rpush("messages", "*|launch_error|key not found") print(0) return False for job in dat['job']: try: test = Bitshares.transfer(job[0].decode('utf8'), float(job[1]), dat['asset'], "", "1.2.4411") except Exception as err: print(err.__repr__()) print(0) Redisdb.decr("batch_jobs", int(1)) Redisdb.rpush( "messages", datetime.datetime.now().isoformat() + " Jobs queue: {}".format(int(Redisdb.get("batch_jobs"))))
def do_batch(dat): """ Make a batch of transfers :param dat: :return: """ import config snap_info = pickle.loads(Redisdb.get("snapshot_info")) try: Bitshares = config.BitShares(node=config.WSS_NODE, wif=dat['form']['key']) oaccount = Bitshares.wallet.getAccounts()[0] except Exception as err: print(err.__repr__()) Redisdb.rpush("messages", "*|launch_error|key not found") print(0) return False for job in dat['job']: try: wif = dat['key'] pub = format(account.PrivateKey(wif).pubkey, config.PREFIX) to_account_id = job[0].decode('utf8') amount = 10 asset_id = dat['asset']['id'] message = "abcdefgABCDEFG0123456789" nonce = "5862723643998573708" fee = objects.Asset(amount=0, asset_id="1.3.0") amount = objects.Asset(amount=int(amount), asset_id=asset_id) encrypted_memo = memo.encode_memo( account.PrivateKey(wif), account.PublicKey(pub, prefix=config.PREFIX), nonce, message) memoStruct = { "from": pub, "to": pub, "nonce": nonce, "message": encrypted_memo, } memoObj = objects.Memo(**memoStruct) tmp = operations.Transfer( **{ "fee": fee, "from": dat['from'], "to": to_account_id, "amount": amount, "memo": memoObj, "prefix": config.PREFIX }) print() #test = Bitshares.transfer(job[0].decode('utf8'), float(job[1]), dat['asset'], "", dat['from']) except Exception as err: print(err.__repr__()) print(0) Redisdb.decr("batch_jobs", int(1)) Redisdb.rpush( "messages", datetime.datetime.now().isoformat() + " Jobs queue: {}".format(int(Redisdb.get("batch_jobs"))))