def test_create_account_password(self): bts = Steem(node=get_steem_nodes(), nobroadcast=True, unsigned=True, data_refresh_time_seconds=900, keys={"active": wif, "owner": wif2, "memo": wif3}, num_retries=10) core_unit = "STM" name = ''.join(random.choice(string.ascii_lowercase) for _ in range(12)) key5 = PrivateKey() bts.txbuffer.clear() tx = bts.create_account( name, creator="test", # 1.2.7 password="******", additional_owner_keys=[format(key5.pubkey, core_unit)], additional_active_keys=[format(key5.pubkey, core_unit)], additional_posting_keys=[format(key5.pubkey, core_unit)], additional_owner_accounts=["test1"], # 1.2.0 additional_active_accounts=["test1"], storekeys=False, ) if isinstance(tx["operations"][0], list): self.assertEqual( tx["operations"][0][0], "account_create" ) op = tx["operations"][0][1] else: self.assertEqual( tx["operations"][0]["type"], "account_create_operation" ) op = tx["operations"][0]["value"] role = "active" self.assertIn( format(key5.pubkey, core_unit), [x[0] for x in op[role]["key_auths"]]) self.assertIn( format(key5.pubkey, core_unit), [x[0] for x in op[role]["key_auths"]]) self.assertIn( "test1", [x[0] for x in op[role]["account_auths"]]) role = "owner" self.assertIn( format(key5.pubkey, core_unit), [x[0] for x in op[role]["key_auths"]]) self.assertIn( format(key5.pubkey, core_unit), [x[0] for x in op[role]["key_auths"]]) self.assertIn( "test1", [x[0] for x in op[role]["account_auths"]]) self.assertEqual( op["creator"], "test")
def main(): parser = argparse.ArgumentParser() parser.add_argument("config", help="Config file in JSON format") parser.add_argument("--logconfig", help="Logger Config file in JSON format", default='logger.json') parser.add_argument("--datadir", help="Data storage dir", default='.') args = parser.parse_args() setup_logging(default_path=args.logconfig) logger.info("Loading config: %s" % str(args.config)) config = json.loads(open(args.config).read()) datadir = args.datadir nodelist = NodeList() nodelist.update_nodes() stm = Steem(node=nodelist.get_nodes(), num_retries=5, call_num_retries=3, timeout=15) scot = Scot_by_comment( config, stm ) data_file = os.path.join(datadir, 'data.db') data_db = shelve.open(data_file) if "last_block_num" in data_db: last_block_num = data_db["last_block_num"] else: last_block_num = 0 if "comment_queue" in data_db: comment_queue = data_db["comment_queue"] else: comment_queue = {} if "last_block_num" in data_db: start_block = data_db["last_block_num"] + 1 else: start_block = None data_db.close() logger.info("starting token distributor..") block_counter = None while True: last_block_num = scot.run(start_block) # Update nodes once a day if block_counter is None: block_counter = last_block_num elif last_block_num - block_counter > 20 * 60 * 24: nodelist.update_nodes() stm = Steem(node=nodelist.get_nodes(), num_retries=5, call_num_retries=3, timeout=15) scot.stm = stm start_block = last_block_num + 1 data_db = shelve.open(data_file) data_db["last_block_num"] = last_block_num data_db.close() time.sleep(3)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes( normal=True, appbase=True), num_retries=10)) stm = Steem(node=nodelist.get_nodes()) self.ws = SteemWebsocket(urls=stm.rpc.nodes, num_retries=10)
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem( node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) cls.bts = Steem(node=nodelist.get_nodes(exclude_limited=True), nobroadcast=True, keys=[wif], num_retries=10) set_shared_steem_instance(cls.bts)
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes( normal=True, appbase=True), num_retries=10)) cls.bts = Steem(node=nodelist.get_nodes(), nobroadcast=True, num_retries=10) set_shared_steem_instance(cls.bts)
def test_create_account(self): bts = Steem(node=self.nodelist.get_steem_nodes(), nobroadcast=True, unsigned=True, data_refresh_time_seconds=900, keys={ "active": wif, "owner": wif, "memo": wif }, num_retries=10) core_unit = "STM" name = ''.join( random.choice(string.ascii_lowercase) for _ in range(12)) key1 = PrivateKey() key2 = PrivateKey() key3 = PrivateKey() key4 = PrivateKey() key5 = PrivateKey() bts.txbuffer.clear() tx = bts.create_account( name, creator="test", # 1.2.7 owner_key=format(key1.pubkey, core_unit), active_key=format(key2.pubkey, core_unit), posting_key=format(key3.pubkey, core_unit), memo_key=format(key4.pubkey, core_unit), additional_owner_keys=[format(key5.pubkey, core_unit)], additional_active_keys=[format(key5.pubkey, core_unit)], additional_posting_keys=[format(key5.pubkey, core_unit)], additional_owner_accounts=["test1"], # 1.2.0 additional_active_accounts=["test2"], additional_posting_accounts=["test3"], storekeys=False, ) self.assertEqual(tx["operations"][0][0], "account_create") op = tx["operations"][0][1] role = "active" self.assertIn(format(key5.pubkey, core_unit), [x[0] for x in op[role]["key_auths"]]) self.assertIn(format(key5.pubkey, core_unit), [x[0] for x in op[role]["key_auths"]]) self.assertIn("test2", [x[0] for x in op[role]["account_auths"]]) role = "posting" self.assertIn(format(key5.pubkey, core_unit), [x[0] for x in op[role]["key_auths"]]) self.assertIn(format(key5.pubkey, core_unit), [x[0] for x in op[role]["key_auths"]]) self.assertIn("test3", [x[0] for x in op[role]["account_auths"]]) role = "owner" self.assertIn(format(key5.pubkey, core_unit), [x[0] for x in op[role]["key_auths"]]) self.assertIn(format(key5.pubkey, core_unit), [x[0] for x in op[role]["key_auths"]]) self.assertIn("test1", [x[0] for x in op[role]["account_auths"]]) self.assertEqual(op["creator"], "test")
def setUpClass(cls): nodelist = NodeList() stm = Steem(node=nodelist.get_nodes()) stm.config.refreshBackup() stm.set_default_nodes(["xyz"]) del stm cls.urls = nodelist.get_nodes() cls.bts = Steem(node=cls.urls, nobroadcast=True, num_retries=10) set_shared_steem_instance(cls.bts)
async def claim(): stm = Steem(node="https://api.steemit.com", keys=[SR]) rc = RC(steem_instance=stm) acc = Account('sourovafrin') current_mana = acc.get_rc_manabar()["current_mana"] mana_cost= stm.get_rc_cost(rc.get_resource_count(tx_size=250, execution_time_count=0, state_bytes_count=0, new_account_op_count=1)) mana_cost+=2500000000 if current_mana>mana_cost: stm.claim_account('sourovafrin','0 STEEM') await client.send_message(client.get_channel('544916428881657856'), "<@397972596207124480> I have claimed a steem discounted account just now and that's only for you")
def setUpClass(cls): cls.nodelist = NodeList() cls.nodelist.update_nodes(steem_instance=Steem(node=cls.nodelist.get_steem_nodes(), num_retries=10)) cls.bts = Steem( node=cls.nodelist.get_steem_nodes(), nobroadcast=True, unsigned=True, data_refresh_time_seconds=900, keys={"active": wif, "owner": wif2, "memo": wif3}, num_retries=10) cls.account = Account("test", full=True, steem_instance=cls.bts)
def test_create_account_password(self, node_param): if node_param == "non_appbase": bts = Steem(node=self.nodelist.get_nodes(appbase=False), nobroadcast=True, unsigned=True, data_refresh_time_seconds=900, keys={ "active": wif, "owner": wif, "memo": wif }, num_retries=10) elif node_param == "appbase": bts = Steem(node=self.nodelist.get_nodes(normal=False, appbase=True), nobroadcast=True, unsigned=True, data_refresh_time_seconds=900, keys={ "active": wif, "owner": wif, "memo": wif }, num_retries=10) name = ''.join( random.choice(string.ascii_lowercase) for _ in range(12)) key5 = PrivateKey() bts.txbuffer.clear() tx = bts.create_account( name, creator="test", # 1.2.7 password="******", additional_owner_keys=[format(key5.pubkey, core_unit)], additional_active_keys=[format(key5.pubkey, core_unit)], additional_posting_keys=[format(key5.pubkey, core_unit)], additional_owner_accounts=["test1"], # 1.2.0 additional_active_accounts=["test1"], storekeys=False, delegation_fee_steem="0 STEEM") self.assertEqual(tx["operations"][0][0], "account_create") op = tx["operations"][0][1] role = "active" self.assertIn(format(key5.pubkey, core_unit), [x[0] for x in op[role]["key_auths"]]) self.assertIn(format(key5.pubkey, core_unit), [x[0] for x in op[role]["key_auths"]]) self.assertIn("test1", [x[0] for x in op[role]["account_auths"]]) role = "owner" self.assertIn(format(key5.pubkey, core_unit), [x[0] for x in op[role]["key_auths"]]) self.assertIn(format(key5.pubkey, core_unit), [x[0] for x in op[role]["key_auths"]]) self.assertIn("test1", [x[0] for x in op[role]["account_auths"]]) self.assertEqual(op["creator"], "test")
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem( node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) cls.bts = Steem(node=nodelist.get_nodes(exclude_limited=True), nobroadcast=True, num_retries=10) cls.steemit = Steem(node="https://api.steemit.com", nobroadcast=True, num_retries=10) set_shared_steem_instance(cls.bts)
def perform_follow_unfollow(account_details): print("Follow unfollow function called") print(account_details) for key in account_details: print(key) try: if 'key' in account_details[key]: if key == 'steem': s = Steem(keys=[account_details[key]['key']], nodes=[ "http://seed1.blockbrothers.io:2001", "http://seed.liondani.com:2016", "https://api.steemit.com", "https://rpc.buildteam.io" ]) elif key == 'smoke': s = Steem( keys=[account_details[key]['key']], node=['https://rpc.smoke.io/'], custom_chains={ "SMOKE": { "chain_id": "1ce08345e61cd3bf91673a47fc507e7ed01550dab841fd9cdb0ab66ef576aaf0", "min_version": "0.0.0", "prefix": "SMK", "chain_assets": [{ "asset": "STEEM", "symbol": "SMOKE", "precision": 3, "id": 1 }, { "asset": "VESTS", "symbol": "VESTS", "precision": 6, "id": 2 }] } }) else: s = Steem(keys=[account_details[key]['key']], node=[ "https://wls.kennybll.com", "https://rpc.whaleshares.io", "ws://188.166.99.136:8090" ]) print(account_details[key]) a = Account(account=account_details[key]['username'], steem_instance=s) a.follow(account_details[key]['author']) except Exception as e: print("Error while follow/unfollow: {}".format(str(e)))
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) cls.appbase = Steem( node=nodelist.get_nodes(exclude_limited=True), nobroadcast=True, bundle=False, # Overwrite wallet to use this list of wifs only keys={"active": wif}, num_retries=10 )
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem( node=nodelist.get_nodes(hive=True), num_retries=10)) cls.bts = Steem(node=nodelist.get_nodes(hive=True), nobroadcast=True, unsigned=True, data_refresh_time_seconds=900, num_retries=10) cls.account = Account("test", full=True, steem_instance=cls.bts)
def test_stm1stm2(self): nodelist = NodeList() b1 = Steem(node=nodelist.get_testnet(), nobroadcast=True, num_retries=10) b2 = Steem(node=nodelist.get_nodes(appbase=False), nobroadcast=True, num_retries=10) self.assertNotEqual(b1.rpc.url, b2.rpc.url)
def test_default_connection(self): nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10)) b2 = Steem( node=nodelist.get_nodes(), nobroadcast=True, ) set_shared_steem_instance(b2) bts = Account("beem") self.assertEqual(bts.steem.prefix, "STM")
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem( node=nodelist.get_steem_nodes(), num_retries=10)) cls.bts = Steem(node=nodelist.get_steem_nodes(), nobroadcast=True, num_retries=10) set_shared_steem_instance(cls.bts) cls.asset = Asset("SBD") cls.symbol = cls.asset["symbol"] cls.precision = cls.asset["precision"] cls.asset2 = Asset("STEEM")
def test_stm1stm2(self): nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes( normal=True, appbase=True), num_retries=10)) b1 = Steem(node=nodelist.get_testnet(testnet=True, testnetdev=False), nobroadcast=True, num_retries=10) b2 = Steem(node=nodelist.get_nodes(), nobroadcast=True, num_retries=10) self.assertNotEqual(b1.rpc.url, b2.rpc.url)
def main(): s = Steem( keys=["<active_wif>"], ) acc = Account('emrebeyler', steem_instance=s) resp = acc.delegate_vesting_shares( "holger80", s.sp_to_vests(1), account="emrebeyler" ) print(resp)
def setUpClass(cls): cls.bts = Steem(node=get_node_list(appbase=False), nobroadcast=True, num_retries=10) cls.appbase = Steem(node=get_node_list(appbase=True), nobroadcast=True, num_retries=10) set_shared_steem_instance(cls.bts) cls.asset = Asset("SBD") cls.symbol = cls.asset["symbol"] cls.precision = cls.asset["precision"] cls.asset2 = Asset("STEEM")
def setUpClass(cls): cls.bts = Steem( node=get_hive_nodes(), nobroadcast=True, num_retries=10 ) cls.steemit = Steem( node="https://api.steemit.com", nobroadcast=True, num_retries=10 ) set_shared_steem_instance(cls.bts)
def test_default_connection(self): nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem( node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) b2 = Steem( node=nodelist.get_nodes(exclude_limited=True), nobroadcast=True, ) set_shared_steem_instance(b2) bts = Account("beem") self.assertEqual(bts.blockchain.prefix, "STM")
def test_stm1stm2(self): nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem( node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) b1 = Steem(node="https://api.steemit.com", nobroadcast=True, num_retries=10) node_list = nodelist.get_nodes(exclude_limited=True) b2 = Steem(node=node_list, nobroadcast=True, num_retries=10) self.assertNotEqual(b1.rpc.url, b2.rpc.url)
def __init__(self, con: Configuration, log: Logger, nobroadcast=True, active=''): self.conf = con self.stm = Steem(node="https://appbasetest.timcliff.com", nobroadcast=nobroadcast, unsigned=nobroadcast) self.stm.set_default_nodes(NODE_LIST) self.log = log set_shared_steem_instance(self.stm)
def clean_steem(self): steem = self.cleaned_data['steem'] try: s = Steem( keys=[steem], nodes=["https://api.steemit.com", "https://rpc.buildteam.io"]) if s.is_connected(): return steem else: raise forms.ValidationError('This is an invalid key') except: raise forms.ValidationError('This is an invalid key')
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem( node=nodelist.get_steem_nodes(), num_retries=10)) cls.bts = Steem(node=nodelist.get_steem_nodes(), nobroadcast=True, unsigned=True, keys={"active": wif}, num_retries=10) # from getpass import getpass # self.bts.wallet.unlock(getpass()) set_shared_steem_instance(cls.bts) cls.bts.set_default_account("test")
def test_stm1stm2(self): b1 = Steem( node=["wss://testnet.steem.vc"], nobroadcast=True, num_retries=10 ) b2 = Steem( node=get_node_list(appbase=False), nobroadcast=True, num_retries=10 ) self.assertNotEqual(b1.rpc.url, b2.rpc.url)
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) cls.bts = Steem( node=nodelist.get_nodes(exclude_limited=True), nobroadcast=True, keys={"active": wif}, num_retries=10 ) cls.test_block_id = 19273700 # from getpass import getpass # self.bts.wallet.unlock(getpass()) set_shared_steem_instance(cls.bts) cls.bts.set_default_account("test")
def claim_tokens(): username = ["ufm.reserve", "taskmanager", "tmholdings", "upfundme", "tmps"] for username in username: url = "http://scot-api.steem-engine.com/@" + username r = requests.get(url) result = r.json() json_data = [] for token in result: scot = result[token] if int(scot["pending_token"]) > 0: json_data.append({"symbol": token}) print(username + " can claim %s" % (token)) if len(json_data) > 0: nodes = NodeList() nodes.update_nodes() stm = Steem(nodes.get_nodes()) try: stm.unlock(pwd=beem_pass) except: stm = Steem(node=nodes.get_nodes(), keys=[pwd]) stm.custom_json("scot_claim_token", json_data, required_posting_auths=[username]) else: print(username + " Has nothing to claim")
def __init__(self): """Initialisation.""" self.load_settings() self.nodes = [ 'https://api.steemit.com', 'https://rpc.buildteam.io', 'https://api.steem.house', 'https://steemd.steemitdev.com', 'https://steemd.steemitstage.com', 'https://steemd.steemgigs.org' ] self.s = Steem(keys=self.posting_key) self.s.set_default_nodes(self.nodes) self.b = Blockchain(self.s) set_shared_steem_instance(self.s) self.p = Pool(4)