From b302355339a573688a78afb05316af5121842cb3 Mon Sep 17 00:00:00 2001 From: Michael Garcia <thecrazygm@gmail.com> Date: Fri, 20 Mar 2020 17:35:17 -0500 Subject: [PATCH] stn --- beem/account.py | 38 +- beem/blockchain.py | 4 +- beem/cli.py | 1356 ++++++++--------- beem/comment.py | 4 +- beem/hive.py | 2 +- beem/hiveconnect.py | 6 +- beem/imageuploader.py | 4 +- beem/instance.py | 4 +- beem/transactionbuilder.py | 4 +- beem/vote.py | 4 +- benchmarks/benchmarks/bench_transaction.py | 4 +- docs/apidefinitions.rst | 36 +- docs/index.rst | 12 +- docs/quickstart.rst | 8 +- docs/tutorials.rst | 30 +- examples/accout_reputation_by_SP.py | 8 +- examples/benchmark_beem.py | 10 +- examples/benchmark_nodes.py | 10 +- examples/benchmark_nodes2.py | 30 +- examples/cache_performance.py | 10 +- .../compare_transactions_speed_with_hive.py | 2 +- examples/compare_with_hive_python_account.py | 8 +- examples/hf20_testnet.py | 10 +- examples/memory_profiler1.py | 6 +- examples/memory_profiler2.py | 16 +- examples/next_witness_block_coundown.py | 12 +- examples/op_on_testnet.py | 32 +- examples/print_appbase_calls.py | 16 +- examples/stream_threading_performance.py | 18 +- examples/using_custom_chain.py | 6 +- examples/using_steem_offline.py | 8 +- tests/beem/test_account.py | 28 +- tests/beem/test_amount.py | 26 +- tests/beem/test_asset.py | 24 +- tests/beem/test_cli.py | 8 +- tests/beem/test_connection.py | 2 +- tests/beem/test_constants.py | 4 +- tests/beem/test_conveyor.py | 4 +- tests/beem/test_instance.py | 72 +- tests/beem/test_steem.py | 24 +- tests/beem/test_storage.py | 24 +- tests/beem/test_testnet.py | 112 +- tests/beem/test_txbuffers.py | 18 +- tests/beem/test_wallet.py | 50 +- tests/beemapi/test_websocket.py | 4 +- tests/beembase/test_transactions.py | 6 +- 46 files changed, 1062 insertions(+), 1062 deletions(-) diff --git a/beem/account.py b/beem/account.py index 8faf1b52..b2d9a3df 100644 --- a/beem/account.py +++ b/beem/account.py @@ -48,8 +48,8 @@ class Account(BlockchainObject): >>> from beem.account import Account >>> from beem import Hive - >>> stm = Hive() - >>> account = Account("gtg", hive_instance=stm) + >>> hv = Hive() + >>> account = Account("gtg", hive_instance=hv) >>> print(account) <Account gtg> >>> print(account.balances) # doctest: +SKIP @@ -244,7 +244,7 @@ class Account(BlockchainObject): current_pct = current_mana / max_mana * 100 else: current_pct = 0 - max_rc_creation_adjustment = Amount(rc_param["max_rc_creation_adjustment"], hive_instance=self.hive) + max_rc_creation_adjuhvent = Amount(rc_param["max_rc_creation_adjustment"], hive_instance=self.hive) return {"last_mana": last_mana, "last_update_time": last_update_time, "current_mana": current_mana, "max_mana": max_mana, "current_pct": current_pct, "max_rc_creation_adjustment": max_rc_creation_adjustment} @@ -660,8 +660,8 @@ class Account(BlockchainObject): >>> from beem.account import Account >>> from beem import Hive - >>> stm = Hive() - >>> account = Account("hiveit", hive_instance=stm) + >>> hv = Hive() + >>> account = Account("hiveit", hive_instance=hv) >>> account.get_feed(0, 1, raw_data=True) [] @@ -722,8 +722,8 @@ class Account(BlockchainObject): >>> from beem.account import Account >>> from beem import Hive - >>> stm = Hive() - >>> account = Account("hiveit", hive_instance=stm) + >>> hv = Hive() + >>> account = Account("hiveit", hive_instance=hv) >>> account.get_feed_entries(0, 1) [] @@ -745,8 +745,8 @@ class Account(BlockchainObject): >>> from beem.account import Account >>> from beem import Hive - >>> stm = Hive() - >>> account = Account("hiveit", hive_instance=stm) + >>> hv = Hive() + >>> account = Account("hiveit", hive_instance=hv) >>> entry = account.get_blog_entries(0, 1, raw_data=True)[0] >>> print("%s - %s - %s - %s" % (entry["author"], entry["permlink"], entry["blog"], entry["reblog_on"])) hiveit - firstpost - hiveit - 1970-01-01T00:00:00 @@ -769,8 +769,8 @@ class Account(BlockchainObject): >>> from beem.account import Account >>> from beem import Hive - >>> stm = Hive() - >>> account = Account("hiveit", hive_instance=stm) + >>> hv = Hive() + >>> account = Account("hiveit", hive_instance=hv) >>> account.get_blog(0, 1) [<Comment @hiveit/firstpost>] @@ -838,8 +838,8 @@ class Account(BlockchainObject): >>> from beem.account import Account >>> from beem import Hive - >>> stm = Hive() - >>> account = Account("hiveit", hive_instance=stm) + >>> hv = Hive() + >>> account = Account("hiveit", hive_instance=hv) >>> account.get_blog_authors() [] @@ -1426,8 +1426,8 @@ class Account(BlockchainObject): >>> from beem.account import Account >>> from beem import Hive - >>> stm = Hive() - >>> account = Account("beem.app", hive_instance=stm) + >>> hv = Hive() + >>> account = Account("beem.app", hive_instance=hv) >>> account.get_tags_used_by_author() [] @@ -1484,8 +1484,8 @@ class Account(BlockchainObject): >>> from beem.account import Account >>> from beem import Hive - >>> stm = Hive() - >>> account = Account("beem.app", hive_instance=stm) + >>> hv = Hive() + >>> account = Account("beem.app", hive_instance=hv) >>> account.get_account_votes() [] @@ -2462,8 +2462,8 @@ class Account(BlockchainObject): from beem.account import Account from beem import Hive active_wif = "5xxxx" - stm = Hive(keys=[active_wif]) - acc = Account("test", hive_instance=stm) + hv = Hive(keys=[active_wif]) + acc = Account("test", hive_instance=hv) acc.transfer("test1", 1, "HIVE", "test") """ diff --git a/beem/blockchain.py b/beem/blockchain.py index 9c9f2d7a..c0af6bcc 100644 --- a/beem/blockchain.py +++ b/beem/blockchain.py @@ -25,7 +25,7 @@ from beemapi.exceptions import NumRetriesReached from beemgraphenebase.py23 import py23_bytes from beem.instance import shared_hive_instance from .amount import Amount -import beem as stm +import beem as hv log = logging.getLogger(__name__) if sys.version_info < (3, 0): from Queue import Queue @@ -418,7 +418,7 @@ class Blockchain(object): hive_instance = [self.hive] nodelist = self.hive.rpc.nodes.export_working_nodes() for i in range(thread_num - 1): - hive_instance.append(stm.Hive(node=nodelist, + hive_instance.append(hv.Hive(node=nodelist, num_retries=self.hive.rpc.num_retries, num_retries_call=self.hive.rpc.num_retries_call, timeout=self.hive.rpc.timeout)) diff --git a/beem/cli.py b/beem/cli.py index 55c2ae05..cc9da990 100644 --- a/beem/cli.py +++ b/beem/cli.py @@ -98,35 +98,35 @@ def prompt_flag_callback(ctx, param, value): ctx.abort() -def unlock_wallet(stm, password=None): - if stm.unsigned and stm.nobroadcast: +def unlock_wallet(hv, password=None): + if hv.unsigned and hv.nobroadcast: return True - password_storage = stm.config["password_storage"] + password_storage = hv.config["password_storage"] if not password and KEYRING_AVAILABLE and password_storage == "keyring": password = keyring.get_password("beem", "wallet") if not password and password_storage == "environment" and "UNLOCK" in os.environ: password = os.environ.get("UNLOCK") if bool(password): - stm.wallet.unlock(password) + hv.wallet.unlock(password) else: password = click.prompt("Password to unlock wallet or posting/active wif", confirmation_prompt=False, hide_input=True) try: - stm.wallet.unlock(password) + hv.wallet.unlock(password) except: try: - stm.wallet.setKeys([password]) + hv.wallet.setKeys([password]) print("Wif accepted!") return True except: raise exceptions.WrongMasterPasswordException("entered password is not a valid password/wif") - if stm.wallet.locked(): + if hv.wallet.locked(): if password_storage == "keyring" or password_storage == "environment": print("Wallet could not be unlocked with %s!" % password_storage) password = click.prompt("Password to unlock wallet", confirmation_prompt=False, hide_input=True) if bool(password): - unlock_wallet(stm, password=password) - if not stm.wallet.locked(): + unlock_wallet(hv, password=password) + if not hv.wallet.locked(): return True else: print("Wallet could not be unlocked!") @@ -138,9 +138,9 @@ def unlock_wallet(stm, password=None): def node_answer_time(node): try: - stm_local = Hive(node=node, num_retries=2, num_retries_call=2, timeout=10) + hv_local = Hive(node=node, num_retries=2, num_retries_call=2, timeout=10) start = timer() - stm_local.get_config(use_stored_data=False) + hv_local.get_config(use_stored_data=False) stop = timer() rpc_answer_time = stop - start except KeyboardInterrupt: @@ -192,7 +192,7 @@ def cli(node, offline, no_broadcast, no_wallet, unsigned, create_link, hiveconne else: sc2 = None debug = verbose > 0 - stm = Hive( + hv = Hive( node=node, nobroadcast=no_broadcast, offline=offline, @@ -207,7 +207,7 @@ def cli(node, offline, no_broadcast, no_wallet, unsigned, create_link, hiveconne timeout=15, autoconnect=False ) - set_shared_hive_instance(stm) + set_shared_hive_instance(hv) pass @@ -225,20 +225,20 @@ def set(key, value): Set the default vote weight to 50 %: set default_vote_weight 50 """ - stm = shared_hive_instance() + hv = shared_hive_instance() if key == "default_account": - if stm.rpc is not None: - stm.rpc.rpcconnect() - stm.set_default_account(value) + if hv.rpc is not None: + hv.rpc.rpcconnect() + hv.set_default_account(value) elif key == "default_vote_weight": - stm.set_default_vote_weight(value) + hv.set_default_vote_weight(value) elif key == "nodes" or key == "node": if bool(value) or value != "default": - stm.set_default_nodes(value) + hv.set_default_nodes(value) else: - stm.set_default_nodes("") + hv.set_default_nodes("") elif key == "password_storage": - stm.config["password_storage"] = value + hv.config["password_storage"] = value if KEYRING_AVAILABLE and value == "keyring": password = click.prompt("Password to unlock wallet (Will be stored in keyring)", confirmation_prompt=False, hide_input=True) password = keyring.set_password("beem", "wallet", password) @@ -250,13 +250,13 @@ def set(key, value): if value == "environment": print("The wallet password can be stored in the UNLOCK environment variable to skip password prompt!") elif key == "client_id": - stm.config["client_id"] = value + hv.config["client_id"] = value elif key == "hot_sign_redirect_uri": - stm.config["hot_sign_redirect_uri"] = value + hv.config["hot_sign_redirect_uri"] = value elif key == "sc2_api_url": - stm.config["sc2_api_url"] = value + hv.config["sc2_api_url"] = value elif key == "oauth_base_url": - stm.config["oauth_base_url"] = value + hv.config["oauth_base_url"] = value else: print("wrong key") @@ -266,33 +266,33 @@ def set(key, value): def nextnode(results): """ Uses the next node in list """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() - stm.move_current_node_to_front() - node = stm.get_default_nodes() - offline = stm.offline + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() + hv.move_current_node_to_front() + node = hv.get_default_nodes() + offline = hv.offline if len(node) < 2: print("At least two nodes are needed!") return node = node[1:] + [node[0]] if not offline: - stm.rpc.next() - stm.get_blockchain_version() - while not offline and node[0] != stm.rpc.url and len(node) > 1: + hv.rpc.next() + hv.get_blockchain_version() + while not offline and node[0] != hv.rpc.url and len(node) > 1: node = node[1:] + [node[0]] - stm.set_default_nodes(node) + hv.set_default_nodes(node) if not results: return t = PrettyTable(["Key", "Value"]) t.align = "l" if not offline: - t.add_row(["Node-Url", stm.rpc.url]) + t.add_row(["Node-Url", hv.rpc.url]) else: t.add_row(["Node-Url", node[0]]) if not offline: - t.add_row(["Version", stm.get_blockchain_version()]) + t.add_row(["Version", hv.get_blockchain_version()]) else: t.add_row(["Version", "hivepy is in offline mode..."]) print(t) @@ -314,10 +314,10 @@ def nextnode(results): def pingnode(raw, sort, remove, threading): """ Returns the answer time in milliseconds """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() - nodes = stm.get_default_nodes() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() + nodes = hv.get_default_nodes() if not raw: t = PrettyTable(["Node", "Answer time [ms]"]) t.align = "l" @@ -346,7 +346,7 @@ def pingnode(raw, sort, remove, threading): for i in sorted_arg: if not remove or ping_times[i] != float("inf"): sorted_nodes.append(nodes[i]) - stm.set_default_nodes(sorted_nodes) + hv.set_default_nodes(sorted_nodes) if not raw: for i in sorted_arg: t.add_row([nodes[i], "%.2f" % (ping_times[i] * 1000)]) @@ -354,7 +354,7 @@ def pingnode(raw, sort, remove, threading): else: print(ping_times[sorted_arg]) else: - node = stm.rpc.url + node = hv.rpc.url rpc_answer_time = node_answer_time(node) rpc_time_str = "%.2f" % (rpc_answer_time * 1000) if raw: @@ -374,29 +374,29 @@ def pingnode(raw, sort, remove, threading): def currentnode(version, url): """ Sets the currently working node at the first place in the list """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() - offline = stm.offline - stm.move_current_node_to_front() - node = stm.get_default_nodes() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() + offline = hv.offline + hv.move_current_node_to_front() + node = hv.get_default_nodes() if version and not offline: - print(stm.get_blockchain_version()) + print(hv.get_blockchain_version()) return elif version and offline: print("Node is offline") return if url and not offline: - print(stm.rpc.url) + print(hv.rpc.url) return t = PrettyTable(["Key", "Value"]) t.align = "l" if not offline: - t.add_row(["Node-Url", stm.rpc.url]) + t.add_row(["Node-Url", hv.rpc.url]) else: t.add_row(["Node-Url", node[0]]) if not offline: - t.add_row(["Version", stm.get_blockchain_version()]) + t.add_row(["Version", hv.get_blockchain_version()]) else: t.add_row(["Version", "hivepy is in offline mode..."]) print(t) @@ -424,13 +424,13 @@ def currentnode(version, url): def updatenodes(show, test, only_https, only_wss, only_appbase, only_non_appbase): """ Update the nodelist from @fullnodeupdate """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() t = PrettyTable(["node", "Version", "score"]) t.align = "l" nodelist = NodeList() - nodelist.update_nodes(hive_instance=stm) + nodelist.update_nodes(hive_instance=hv) nodes = nodelist.get_nodes(exclude_limited=False, normal=not only_appbase, appbase=not only_non_appbase, wss=not only_https, https=not only_wss) if show or test: sorted_nodes = sorted(nodelist, key=lambda node: node["score"], reverse=True) @@ -440,26 +440,26 @@ def updatenodes(show, test, only_https, only_wss, only_appbase, only_non_appbase t.add_row([node["url"], node["version"], score]) print(t) if not test: - stm.set_default_nodes(nodes) + hv.set_default_nodes(nodes) @cli.command() def config(): """ Shows local configuration """ - stm = shared_hive_instance() + hv = shared_hive_instance() t = PrettyTable(["Key", "Value"]) t.align = "l" - for key in stm.config: + for key in hv.config: # hide internal config data if key in availableConfigurationKeys and key != "nodes" and key != "node": - t.add_row([key, stm.config[key]]) - node = stm.get_default_nodes() + t.add_row([key, hv.config[key]]) + node = hv.get_default_nodes() nodes = json.dumps(node, indent=4) t.add_row(["nodes", nodes]) if "password_storage" not in availableConfigurationKeys: - t.add_row(["password_storage", stm.config["password_storage"]]) - t.add_row(["data_dir", stm.config.data_dir]) + t.add_row(["password_storage", hv.config["password_storage"]]) + t.add_row(["data_dir", hv.config.data_dir]) print(t) @@ -469,30 +469,30 @@ def config(): def createwallet(wipe): """ Create new wallet with a new password """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() - if stm.wallet.created() and not wipe: + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() + if hv.wallet.created() and not wipe: wipe_answer = click.prompt("'Do you want to wipe your wallet? Are your sure? This is IRREVERSIBLE! If you dont have a backup you may lose access to your account! [y/n]", default="n") if wipe_answer in ["y", "ye", "yes"]: - stm.wallet.wipe(True) + hv.wallet.wipe(True) else: return elif wipe: - stm.wallet.wipe(True) + hv.wallet.wipe(True) password = None password = click.prompt("New wallet password", confirmation_prompt=True, hide_input=True) if not bool(password): print("Password cannot be empty! Quitting...") return - password_storage = stm.config["password_storage"] + password_storage = hv.config["password_storage"] if KEYRING_AVAILABLE and password_storage == "keyring": password = keyring.set_password("beem", "wallet", password) elif password_storage == "environment": print("The new wallet password can be stored in the UNLOCK environment variable to skip password prompt!") - stm.wallet.create(password) - set_shared_hive_instance(stm) + hv.wallet.create(password) + set_shared_hive_instance(hv) @cli.command() @@ -500,16 +500,16 @@ def createwallet(wipe): def walletinfo(test_unlock): """ Show info about wallet """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() t = PrettyTable(["Key", "Value"]) t.align = "l" - t.add_row(["created", stm.wallet.created()]) - t.add_row(["locked", stm.wallet.locked()]) - t.add_row(["Number of stored keys", len(stm.wallet.getPublicKeys())]) - t.add_row(["sql-file", stm.wallet.keyStorage.sqlDataBaseFile]) - password_storage = stm.config["password_storage"] + t.add_row(["created", hv.wallet.created()]) + t.add_row(["locked", hv.wallet.locked()]) + t.add_row(["Number of stored keys", len(hv.wallet.getPublicKeys())]) + t.add_row(["sql-file", hv.wallet.keyStorage.sqlDataBaseFile]) + password_storage = hv.config["password_storage"] t.add_row(["password_storage", password_storage]) password = os.environ.get("UNLOCK") if password is not None: @@ -521,11 +521,11 @@ def walletinfo(test_unlock): else: t.add_row(["keyring installed", "no"]) if test_unlock: - if unlock_wallet(stm): + if unlock_wallet(hv): t.add_row(["Wallet unlock", "successful"]) else: t.add_row(["Wallet unlock", "not working"]) - # t.add_row(["getPublicKeys", str(stm.wallet.getPublicKeys())]) + # t.add_row(["getPublicKeys", str(hv.wallet.getPublicKeys())]) print(t) @@ -535,17 +535,17 @@ def walletinfo(test_unlock): def parsewif(unsafe_import_key): """ Parse a WIF private key without importing """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if unsafe_import_key: for key in unsafe_import_key: try: - pubkey = PrivateKey(key, prefix=stm.prefix).pubkey + pubkey = PrivateKey(key, prefix=hv.prefix).pubkey print(pubkey) - account = stm.wallet.getAccountFromPublicKey(str(pubkey)) - account = Account(account, hive_instance=stm) - key_type = stm.wallet.getKeyType(account, str(pubkey)) + account = hv.wallet.getAccountFromPublicKey(str(pubkey)) + account = Account(account, hive_instance=hv) + key_type = hv.wallet.getKeyType(account, str(pubkey)) print("Account: %s - %s" % (account["name"], key_type)) except Exception as e: print(str(e)) @@ -555,11 +555,11 @@ def parsewif(unsafe_import_key): if not wifkey or wifkey == "quit" or wifkey == "exit": break try: - pubkey = PrivateKey(wifkey, prefix=stm.prefix).pubkey + pubkey = PrivateKey(wifkey, prefix=hv.prefix).pubkey print(pubkey) - account = stm.wallet.getAccountFromPublicKey(str(pubkey)) - account = Account(account, hive_instance=stm) - key_type = stm.wallet.getKeyType(account, str(pubkey)) + account = hv.wallet.getAccountFromPublicKey(str(pubkey)) + account = Account(account, hive_instance=hv) + key_type = hv.wallet.getKeyType(account, str(pubkey)) print("Account: %s - %s" % (account["name"], key_type)) except Exception as e: print(str(e)) @@ -575,15 +575,15 @@ def addkey(unsafe_import_key): When no [OPTION] is given, a password prompt for unlocking the wallet and a prompt for entering the private key are shown. """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() - if not unlock_wallet(stm): + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() + if not unlock_wallet(hv): return if not unsafe_import_key: unsafe_import_key = click.prompt("Enter private key", confirmation_prompt=False, hide_input=True) - stm.wallet.addPrivateKey(unsafe_import_key) - set_shared_hive_instance(stm) + hv.wallet.addPrivateKey(unsafe_import_key) + set_shared_hive_instance(hv) @cli.command() @@ -598,13 +598,13 @@ def delkey(confirm, pub): PUB is the public key from the private key which will be deleted from the wallet """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() - if not unlock_wallet(stm): + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() + if not unlock_wallet(hv): return - stm.wallet.removePrivateKeyFromPublicKey(pub) - set_shared_hive_instance(stm) + hv.wallet.removePrivateKeyFromPublicKey(pub) + set_shared_hive_instance(hv) @cli.command() @@ -637,15 +637,15 @@ def addtoken(name, unsafe_import_token): When no [OPTION] is given, a password prompt for unlocking the wallet and a prompt for entering the private key are shown. """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() - if not unlock_wallet(stm): + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() + if not unlock_wallet(hv): return if not unsafe_import_token: unsafe_import_token = click.prompt("Enter private token", confirmation_prompt=False, hide_input=True) - stm.wallet.addToken(name, unsafe_import_token) - set_shared_hive_instance(stm) + hv.wallet.addToken(name, unsafe_import_token) + set_shared_hive_instance(hv) @cli.command() @@ -660,25 +660,25 @@ def deltoken(confirm, name): name is the public name from the private token which will be deleted from the wallet """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() - if not unlock_wallet(stm): + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() + if not unlock_wallet(hv): return - stm.wallet.removeTokenFromPublicName(name) - set_shared_hive_instance(stm) + hv.wallet.removeTokenFromPublicName(name) + set_shared_hive_instance(hv) @cli.command() def listkeys(): """ Show stored keys """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() t = PrettyTable(["Available Key"]) t.align = "l" - for key in stm.wallet.getPublicKeys(): + for key in hv.wallet.getPublicKeys(): t.add_row([key]) print(t) @@ -687,13 +687,13 @@ def listkeys(): def listtoken(): """ Show stored token """ - stm = shared_hive_instance() + hv = shared_hive_instance() t = PrettyTable(["name", "scope", "status"]) t.align = "l" - if not unlock_wallet(stm): + if not unlock_wallet(hv): return - sc2 = HiveConnect(hive_instance=stm) - for name in stm.wallet.getPublicNames(): + sc2 = HiveConnect(hive_instance=hv) + for name in hv.wallet.getPublicNames(): ret = sc2.me(username=name) if "error" in ret: t.add_row([name, "-", ret["error"]]) @@ -705,12 +705,12 @@ def listtoken(): @cli.command() def listaccounts(): """Show stored accounts""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() t = PrettyTable(["Name", "Type", "Available Key"]) t.align = "l" - for account in stm.wallet.getAccounts(): + for account in hv.wallet.getAccounts(): t.add_row([ account["name"] or "n/a", account["type"] or "n/a", account["pubkey"] @@ -727,11 +727,11 @@ def upvote(post, account, weight): POST is @author/permlink """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not weight: - weight = stm.config["default_vote_weight"] + weight = hv.config["default_vote_weight"] else: weight = float(weight) if weight > 100: @@ -740,14 +740,14 @@ def upvote(post, account, weight): raise ValueError("Minimum vote weight is 0!") if not account: - account = stm.config["default_account"] - if not unlock_wallet(stm): + account = hv.config["default_account"] + if not unlock_wallet(hv): return try: - post = Comment(post, hive_instance=stm) + post = Comment(post, hive_instance=hv) tx = post.upvote(weight, voter=account) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) except exceptions.VotingInvalidOnArchivedPost: print("Post/Comment is older than 7 days! Did not upvote.") tx = {} @@ -762,19 +762,19 @@ def delete(post, account): POST is @author/permlink """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - account = stm.config["default_account"] - if not unlock_wallet(stm): + account = hv.config["default_account"] + if not unlock_wallet(hv): return try: - post = Comment(post, hive_instance=stm) + post = Comment(post, hive_instance=hv) tx = post.delete(account=account) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) except exceptions.VotingInvalidOnArchivedPost: print("Could not delete post.") tx = {} @@ -791,9 +791,9 @@ def downvote(post, account, weight): POST is @author/permlink """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() weight = float(weight) if weight > 100: @@ -802,14 +802,14 @@ def downvote(post, account, weight): raise ValueError("Minimum downvote weight is 0!") if not account: - account = stm.config["default_account"] - if not unlock_wallet(stm): + account = hv.config["default_account"] + if not unlock_wallet(hv): return try: - post = Comment(post, hive_instance=stm) + post = Comment(post, hive_instance=hv) tx = post.downvote(weight, voter=account) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) except exceptions.VotingInvalidOnArchivedPost: print("Post/Comment is older than 7 days! Did not downvote.") tx = {} @@ -825,19 +825,19 @@ def downvote(post, account, weight): @click.option('--account', '-a', help='Transfer from this account') def transfer(to, amount, asset, memo, account): """Transfer HBD/HIVE""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - account = stm.config["default_account"] + account = hv.config["default_account"] if not bool(memo): memo = '' - if not unlock_wallet(stm): + if not unlock_wallet(hv): return - acc = Account(account, hive_instance=stm) + acc = Account(account, hive_instance=hv) tx = acc.transfer(to, amount, asset, memo) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -848,21 +848,21 @@ def transfer(to, amount, asset, memo, account): @click.option('--to', help='Powerup this account', default=None) def powerup(amount, account, to): """Power up (vest HIVE as HIVE POWER)""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - account = stm.config["default_account"] - if not unlock_wallet(stm): + account = hv.config["default_account"] + if not unlock_wallet(hv): return - acc = Account(account, hive_instance=stm) + acc = Account(account, hive_instance=hv) try: amount = float(amount) except: amount = str(amount) tx = acc.transfer_to_vesting(amount, to=to) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -875,21 +875,21 @@ def powerdown(amount, account): amount is in VESTS """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - account = stm.config["default_account"] - if not unlock_wallet(stm): + account = hv.config["default_account"] + if not unlock_wallet(hv): return - acc = Account(account, hive_instance=stm) + acc = Account(account, hive_instance=hv) try: amount = float(amount) except: amount = str(amount) tx = acc.withdraw_vesting(amount) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -903,24 +903,24 @@ def delegate(amount, to_account, account): amount is in VESTS / Hive """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - account = stm.config["default_account"] - if not unlock_wallet(stm): + account = hv.config["default_account"] + if not unlock_wallet(hv): return - acc = Account(account, hive_instance=stm) + acc = Account(account, hive_instance=hv) try: amount = float(amount) except: - amount = Amount(str(amount), hive_instance=stm) - if amount.symbol == stm.hive_symbol: - amount = stm.hp_to_vests(float(amount)) + amount = Amount(str(amount), hive_instance=hv) + if amount.symbol == hv.hive_symbol: + amount = hv.hp_to_vests(float(amount)) tx = acc.delegate_vesting_shares(to_account, amount) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -933,17 +933,17 @@ def delegate(amount, to_account, account): 'VESTS, or false if it should receive them as HIVE.', is_flag=True) def powerdownroute(to, percentage, account, auto_vest): """Setup a powerdown route""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - account = stm.config["default_account"] - if not unlock_wallet(stm): + account = hv.config["default_account"] + if not unlock_wallet(hv): return - acc = Account(account, hive_instance=stm) + acc = Account(account, hive_instance=hv) tx = acc.set_withdraw_vesting_route(to, percentage, auto_vest=auto_vest) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -953,21 +953,21 @@ def powerdownroute(to, percentage, account, auto_vest): @click.option('--account', '-a', help='Powerup from this account') def convert(amount, account): """Convert HIVEDollars to Hive (takes a week to settle)""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - account = stm.config["default_account"] - if not unlock_wallet(stm): + account = hv.config["default_account"] + if not unlock_wallet(hv): return - acc = Account(account, hive_instance=stm) + acc = Account(account, hive_instance=hv) try: amount = float(amount) except: amount = str(amount) tx = acc.convert(amount) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -976,22 +976,22 @@ def convert(amount, account): def changewalletpassphrase(): """ Change wallet password """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() - if not unlock_wallet(stm): + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() + if not unlock_wallet(hv): return newpassword = None newpassword = click.prompt("New wallet password", confirmation_prompt=True, hide_input=True) if not bool(newpassword): print("Password cannot be empty! Quitting...") return - password_storage = stm.config["password_storage"] + password_storage = hv.config["password_storage"] if KEYRING_AVAILABLE and password_storage == "keyring": keyring.set_password("beem", "wallet", newpassword) elif password_storage == "environment": print("The new wallet password can be stored in the UNLOCK invironment variable to skip password prompt!") - stm.wallet.changePassphrase(newpassword) + hv.wallet.changePassphrase(newpassword) @cli.command() @@ -999,14 +999,14 @@ def changewalletpassphrase(): def power(account): """ Shows vote power and bandwidth """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if len(account) == 0: - if "default_account" in stm.config: - account = [stm.config["default_account"]] + if "default_account" in hv.config: + account = [hv.config["default_account"]] for name in account: - a = Account(name, hive_instance=stm) + a = Account(name, hive_instance=hv) print("\n@%s" % a.name) a.print_info(use_table=True) @@ -1016,14 +1016,14 @@ def power(account): def balance(account): """ Shows balance """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if len(account) == 0: - if "default_account" in stm.config: - account = [stm.config["default_account"]] + if "default_account" in hv.config: + account = [hv.config["default_account"]] for name in account: - a = Account(name, hive_instance=stm) + a = Account(name, hive_instance=hv) print("\n@%s" % a.name) t = PrettyTable(["Account", "HIVE", "HBD", "VESTS"]) t.align = "r" @@ -1059,12 +1059,12 @@ def balance(account): def interest(account): """ Get information about interest payment """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - if "default_account" in stm.config: - account = [stm.config["default_account"]] + if "default_account" in hv.config: + account = [hv.config["default_account"]] t = PrettyTable([ "Account", "Last Interest Payment", "Next Payment", @@ -1072,7 +1072,7 @@ def interest(account): ]) t.align = "r" for a in account: - a = Account(a, hive_instance=stm) + a = Account(a, hive_instance=hv) i = a.interest() t.add_row([ a["name"], @@ -1089,14 +1089,14 @@ def interest(account): def follower(account): """ Get information about followers """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - if "default_account" in stm.config: - account = [stm.config["default_account"]] + if "default_account" in hv.config: + account = [hv.config["default_account"]] for a in account: - a = Account(a, hive_instance=stm) + a = Account(a, hive_instance=hv) print("\nFollowers statistics for @%s (please wait...)" % a.name) followers = a.get_followers(False) followers.print_summarize_table(tag_type="Followers") @@ -1107,14 +1107,14 @@ def follower(account): def following(account): """ Get information about following """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - if "default_account" in stm.config: - account = [stm.config["default_account"]] + if "default_account" in hv.config: + account = [hv.config["default_account"]] for a in account: - a = Account(a, hive_instance=stm) + a = Account(a, hive_instance=hv) print("\nFollowing statistics for @%s (please wait...)" % a.name) following = a.get_following(False) following.print_summarize_table(tag_type="Following") @@ -1125,14 +1125,14 @@ def following(account): def muter(account): """ Get information about muter """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - if "default_account" in stm.config: - account = [stm.config["default_account"]] + if "default_account" in hv.config: + account = [hv.config["default_account"]] for a in account: - a = Account(a, hive_instance=stm) + a = Account(a, hive_instance=hv) print("\nMuters statistics for @%s (please wait...)" % a.name) muters = a.get_muters(False) muters.print_summarize_table(tag_type="Muters") @@ -1143,14 +1143,14 @@ def muter(account): def muting(account): """ Get information about muting """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - if "default_account" in stm.config: - account = [stm.config["default_account"]] + if "default_account" in hv.config: + account = [hv.config["default_account"]] for a in account: - a = Account(a, hive_instance=stm) + a = Account(a, hive_instance=hv) print("\nMuting statistics for @%s (please wait...)" % a.name) muting = a.get_mutings(False) muting.print_summarize_table(tag_type="Muting") @@ -1161,13 +1161,13 @@ def muting(account): def permissions(account): """ Show permissions of an account """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - if "default_account" in stm.config: - account = stm.config["default_account"] - account = Account(account, hive_instance=stm) + if "default_account" in hv.config: + account = hv.config["default_account"] + account = Account(account, hive_instance=hv) t = PrettyTable(["Permission", "Threshold", "Key/Account"], hrules=0) t.align = "r" for permission in ["owner", "active", "posting"]: @@ -1199,26 +1199,26 @@ def allow(foreign_account, permission, account, weight, threshold): When not given, password will be asked, from which a public key is derived. This derived key will then interact with your account. """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - account = stm.config["default_account"] - if not unlock_wallet(stm): + account = hv.config["default_account"] + if not unlock_wallet(hv): return if permission not in ["posting", "active", "owner"]: print("Wrong permission, please use: posting, active or owner!") return - acc = Account(account, hive_instance=stm) + acc = Account(account, hive_instance=hv) if not foreign_account: from beemgraphenebase.account import PasswordKey pwd = click.prompt("Password for Key Derivation", confirmation_prompt=True, hide_input=True) - foreign_account = format(PasswordKey(account, pwd, permission).get_public(), stm.prefix) + foreign_account = format(PasswordKey(account, pwd, permission).get_public(), hv.prefix) if threshold is not None: threshold = int(threshold) tx = acc.allow(foreign_account, weight=weight, permission=permission, threshold=threshold) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -1231,26 +1231,26 @@ def allow(foreign_account, permission, account, weight, threshold): 'by signatures to be able to interact') def disallow(foreign_account, permission, account, threshold): """Remove allowance an account/key to interact with your account""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - account = stm.config["default_account"] - if not unlock_wallet(stm): + account = hv.config["default_account"] + if not unlock_wallet(hv): return if permission not in ["posting", "active", "owner"]: print("Wrong permission, please use: posting, active or owner!") return if threshold is not None: threshold = int(threshold) - acc = Account(account, hive_instance=stm) + acc = Account(account, hive_instance=hv) if not foreign_account: from beemgraphenebase.account import PasswordKey pwd = click.prompt("Password for Key Derivation", confirmation_prompt=True) - foreign_account = [format(PasswordKey(account, pwd, permission).get_public(), stm.prefix)] + foreign_account = [format(PasswordKey(account, pwd, permission).get_public(), hv.prefix)] tx = acc.disallow(foreign_account, permission=permission, threshold=threshold) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -1261,21 +1261,21 @@ def disallow(foreign_account, permission, account, threshold): @click.option('--number', '-n', help='Number of subsidized accounts to be claimed (default = 1), when fee = 0 HIVE', default=1) def claimaccount(creator, fee, number): """Claim account for claimed account creation.""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not creator: - creator = stm.config["default_account"] - if not unlock_wallet(stm): + creator = hv.config["default_account"] + if not unlock_wallet(hv): return - creator = Account(creator, hive_instance=stm) - fee = Amount("%.3f %s" % (float(fee), stm.hive_symbol), hive_instance=stm) + creator = Account(creator, hive_instance=hv) + fee = Amount("%.3f %s" % (float(fee), hv.hive_symbol), hive_instance=hv) tx = None - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.claim_account(creator, fee=fee) - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.claim_account(creator, fee=fee) + tx = hv.hiveconnect.url_from_tx(tx) elif float(fee) == 0: - rc = RC(hive_instance=stm) + rc = RC(hive_instance=hv) current_costs = rc.claim_account(tx_size=200) current_mana = creator.get_rc_manabar()["current_mana"] last_mana = current_mana @@ -1288,7 +1288,7 @@ def claimaccount(creator, fee, number): tx = json.dumps(tx, indent=4) print(tx) cnt += 1 - tx = stm.claim_account(creator, fee=fee) + tx = hv.claim_account(creator, fee=fee) time.sleep(10) creator.refresh() current_mana = creator.get_rc_manabar()["current_mana"] @@ -1297,7 +1297,7 @@ def claimaccount(creator, fee, number): if cnt == 0: print("Not enough RC for a claim!") else: - tx = stm.claim_account(creator, fee=fee) + tx = hv.claim_account(creator, fee=fee) if tx is not None: tx = json.dumps(tx, indent=4) print(tx) @@ -1313,30 +1313,30 @@ def claimaccount(creator, fee, number): @click.option('--create-claimed-account', '-c', help='Instead of paying the account creation fee a subsidized account is created.', is_flag=True, default=False) def newaccount(accountname, account, owner, active, memo, posting, create_claimed_account): """Create a new account""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - account = stm.config["default_account"] - if not unlock_wallet(stm): + account = hv.config["default_account"] + if not unlock_wallet(hv): return - acc = Account(account, hive_instance=stm) + acc = Account(account, hive_instance=hv) if owner is None or active is None or memo is None or posting is None: password = click.prompt("Keys were not given - Passphrase is used to create keys\n New Account Passphrase", confirmation_prompt=True, hide_input=True) if not password: print("You cannot chose an empty password") return if create_claimed_account: - tx = stm.create_claimed_account(accountname, creator=acc, password=password) + tx = hv.create_claimed_account(accountname, creator=acc, password=password) else: - tx = stm.create_account(accountname, creator=acc, password=password) + tx = hv.create_account(accountname, creator=acc, password=password) else: if create_claimed_account: - tx = stm.create_claimed_account(accountname, creator=acc, owner_key=owner, active_key=active, memo_key=memo, posting_key=posting) + tx = hv.create_claimed_account(accountname, creator=acc, owner_key=owner, active_key=active, memo_key=memo, posting_key=posting) else: - tx = stm.create_account(accountname, creator=acc, owner_key=owner, active_key=active, memo_key=memo, posting_key=posting) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + tx = hv.create_account(accountname, creator=acc, owner_key=owner, active_key=active, memo_key=memo, posting_key=posting) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -1348,9 +1348,9 @@ def newaccount(accountname, account, owner, active, memo, posting, create_claime @click.option('--pair', '-p', help='"Key=Value" pairs', multiple=True) def setprofile(variable, value, account, pair): """Set a variable in an account\'s profile""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() keys = [] values = [] if pair: @@ -1365,16 +1365,16 @@ def setprofile(variable, value, account, pair): profile = Profile(keys, values) if not account: - account = stm.config["default_account"] - if not unlock_wallet(stm): + account = hv.config["default_account"] + if not unlock_wallet(hv): return - acc = Account(account, hive_instance=stm) + acc = Account(account, hive_instance=hv) json_metadata = Profile(acc["json_metadata"] if acc["json_metadata"] else {}) json_metadata.update(profile) tx = acc.update_account_profile(json_metadata) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -1384,23 +1384,23 @@ def setprofile(variable, value, account, pair): @click.option('--account', '-a', help='delprofile as this user') def delprofile(variable, account): """Delete a variable in an account\'s profile""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - account = stm.config["default_account"] - if not unlock_wallet(stm): + account = hv.config["default_account"] + if not unlock_wallet(hv): return - acc = Account(account, hive_instance=stm) + acc = Account(account, hive_instance=hv) json_metadata = Profile(acc["json_metadata"]) for var in variable: json_metadata.remove(var) tx = acc.update_account_profile(json_metadata) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -1411,12 +1411,12 @@ def delprofile(variable, account): def importaccount(account, roles): """Import an account using a passphrase""" from beemgraphenebase.account import PasswordKey - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() - if not unlock_wallet(stm): + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() + if not unlock_wallet(hv): return - account = Account(account, hive_instance=stm) + account = Account(account, hive_instance=hv) imported = False password = click.prompt("Account Passphrase", confirmation_prompt=False, hide_input=True) if not password: @@ -1424,40 +1424,40 @@ def importaccount(account, roles): return if "owner" in roles: owner_key = PasswordKey(account["name"], password, role="owner") - owner_pubkey = format(owner_key.get_public_key(), stm.prefix) + owner_pubkey = format(owner_key.get_public_key(), hv.prefix) if owner_pubkey in [x[0] for x in account["owner"]["key_auths"]]: print("Importing owner key!") owner_privkey = owner_key.get_private_key() - stm.wallet.addPrivateKey(owner_privkey) + hv.wallet.addPrivateKey(owner_privkey) imported = True if "active" in roles: active_key = PasswordKey(account["name"], password, role="active") - active_pubkey = format(active_key.get_public_key(), stm.prefix) + active_pubkey = format(active_key.get_public_key(), hv.prefix) if active_pubkey in [x[0] for x in account["active"]["key_auths"]]: print("Importing active key!") active_privkey = active_key.get_private_key() - stm.wallet.addPrivateKey(active_privkey) + hv.wallet.addPrivateKey(active_privkey) imported = True if "posting" in roles: posting_key = PasswordKey(account["name"], password, role="posting") - posting_pubkey = format(posting_key.get_public_key(), stm.prefix) + posting_pubkey = format(posting_key.get_public_key(), hv.prefix) if posting_pubkey in [ x[0] for x in account["posting"]["key_auths"] ]: print("Importing posting key!") posting_privkey = posting_key.get_private_key() - stm.wallet.addPrivateKey(posting_privkey) + hv.wallet.addPrivateKey(posting_privkey) imported = True if "memo" in roles: memo_key = PasswordKey(account["name"], password, role="memo") - memo_pubkey = format(memo_key.get_public_key(), stm.prefix) + memo_pubkey = format(memo_key.get_public_key(), hv.prefix) if memo_pubkey == account["memo_key"]: print("Importing memo key!") memo_privkey = memo_key.get_private_key() - stm.wallet.addPrivateKey(memo_privkey) + hv.wallet.addPrivateKey(memo_privkey) imported = True if not imported: @@ -1469,25 +1469,25 @@ def importaccount(account, roles): @click.option('--key', help='The new memo key') def updatememokey(account, key): """Update an account\'s memo key""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - account = stm.config["default_account"] - if not unlock_wallet(stm): + account = hv.config["default_account"] + if not unlock_wallet(hv): return - acc = Account(account, hive_instance=stm) + acc = Account(account, hive_instance=hv) if not key: from beemgraphenebase.account import PasswordKey pwd = click.prompt("Password for Memo Key Derivation", confirmation_prompt=True, hide_input=True) memo_key = PasswordKey(account, pwd, "memo") - key = format(memo_key.get_public_key(), stm.prefix) + key = format(memo_key.get_public_key(), hv.prefix) memo_privkey = memo_key.get_private_key() - if not stm.nobroadcast: - stm.wallet.addPrivateKey(memo_privkey) + if not hv.nobroadcast: + hv.wallet.addPrivateKey(memo_privkey) tx = acc.update_memo_key(key) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -1497,15 +1497,15 @@ def updatememokey(account, key): @click.argument('beneficiaries', nargs=-1) def beneficiaries(authorperm, beneficiaries): """Set beneficaries""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() - c = Comment(authorperm, hive_instance=stm) + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() + c = Comment(authorperm, hive_instance=hv) account = c["author"] if not account: - account = stm.config["default_account"] - if not unlock_wallet(stm): + account = hv.config["default_account"] + if not unlock_wallet(hv): return options = {"author": c["author"], @@ -1519,10 +1519,10 @@ def beneficiaries(authorperm, beneficiaries): beneficiaries = beneficiaries[0].split(",") beneficiaries_list_sorted = derive_beneficiaries(beneficiaries) for b in beneficiaries_list_sorted: - Account(b["account"], hive_instance=stm) - tx = stm.comment_options(options, authorperm, beneficiaries_list_sorted, account=account) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + Account(b["account"], hive_instance=hv) + tx = hv.comment_options(options, authorperm, beneficiaries_list_sorted, account=account) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -1532,14 +1532,14 @@ def beneficiaries(authorperm, beneficiaries): @click.option('--account', '-a', help='Account name') @click.option('--image-name', '-n', help='Image name') def uploadimage(image, account, image_name): - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - account = stm.config["default_account"] - if not unlock_wallet(stm): + account = hv.config["default_account"] + if not unlock_wallet(hv): return - iu = ImageUploader(hive_instance=stm) + iu = ImageUploader(hive_instance=hv) tx = iu.upload(image, account, image_name) if image_name is None: print("" % tx["url"]) @@ -1561,14 +1561,14 @@ def uploadimage(image, account, image_name): @click.option('--no-parse-body', help='Disable parsing of links, tags and images', is_flag=True, default=False) def post(body, account, title, permlink, tags, reply_identifier, community, beneficiaries, percent_hive_dollars, max_accepted_payout, no_parse_body): """broadcasts a post/comment""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - account = stm.config["default_account"] + account = hv.config["default_account"] author = account - if not unlock_wallet(stm): + if not unlock_wallet(hv): return with open(body) as f: content = f.read() @@ -1624,8 +1624,8 @@ def post(body, account, title, permlink, tags, reply_identifier, community, bene if max_accepted_payout is not None or percent_hive_dollars is not None: comment_options = {} if max_accepted_payout is not None: - if stm.hbd_symbol not in max_accepted_payout: - max_accepted_payout = str(Amount(float(max_accepted_payout), stm.hbd_symbol, hive_instance=stm)) + if hv.hbd_symbol not in max_accepted_payout: + max_accepted_payout = str(Amount(float(max_accepted_payout), hv.hbd_symbol, hive_instance=hv)) comment_options["max_accepted_payout"] = max_accepted_payout if percent_hive_dollars is not None: comment_options["percent_hive_dollars"] = percent_hive_dollars @@ -1633,11 +1633,11 @@ def post(body, account, title, permlink, tags, reply_identifier, community, bene if "beneficiaries" in parameter: beneficiaries = derive_beneficiaries(parameter["beneficiaries"]) for b in beneficiaries: - Account(b["account"], hive_instance=stm) - tx = stm.post(title, body, author=author, permlink=permlink, reply_identifier=reply_identifier, community=community, + Account(b["account"], hive_instance=hv) + tx = hv.post(title, body, author=author, permlink=permlink, reply_identifier=reply_identifier, community=community, tags=tags, comment_options=comment_options, beneficiaries=beneficiaries, parse_body=parse_body) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -1649,20 +1649,20 @@ def post(body, account, title, permlink, tags, reply_identifier, community, bene @click.option('--title', '-t', help='Title of the post') def reply(authorperm, body, account, title): """replies to a comment""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - account = stm.config["default_account"] - if not unlock_wallet(stm): + account = hv.config["default_account"] + if not unlock_wallet(hv): return if title is None: title = "" - tx = stm.post(title, body, json_metadata=None, author=account, reply_identifier=authorperm) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + tx = hv.post(title, body, json_metadata=None, author=account, reply_identifier=authorperm) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -1672,17 +1672,17 @@ def reply(authorperm, body, account, title): @click.option('--account', '-a', help='Your account') def approvewitness(witness, account): """Approve a witnesses""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - account = stm.config["default_account"] - if not unlock_wallet(stm): + account = hv.config["default_account"] + if not unlock_wallet(hv): return - acc = Account(account, hive_instance=stm) + acc = Account(account, hive_instance=hv) tx = acc.approvewitness(witness, approve=True) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -1692,17 +1692,17 @@ def approvewitness(witness, account): @click.option('--account', '-a', help='Your account') def disapprovewitness(witness, account): """Disapprove a witnesses""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - account = stm.config["default_account"] - if not unlock_wallet(stm): + account = hv.config["default_account"] + if not unlock_wallet(hv): return - acc = Account(account, hive_instance=stm) + acc = Account(account, hive_instance=hv) tx = acc.disapprovewitness(witness) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -1712,10 +1712,10 @@ def disapprovewitness(witness, account): @click.option('--outfile', '-o', help='Load transaction from file. If "-", read from stdin (defaults to "-")') def sign(file, outfile): """Sign a provided transaction with available and required keys""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() - if not unlock_wallet(stm): + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() + if not unlock_wallet(hv): return if file and file != "-": if not os.path.isfile(file): @@ -1728,7 +1728,7 @@ def sign(file, outfile): else: tx = click.get_text_stream('stdin') tx = ast.literal_eval(tx) - tx = stm.sign(tx, reconstruct_tx=False) + tx = hv.sign(tx, reconstruct_tx=False) tx = json.dumps(tx, indent=4) if outfile and outfile != "-": with open(outfile, 'w') as fp: @@ -1741,9 +1741,9 @@ def sign(file, outfile): @click.option('--file', help='Load transaction from file. If "-", read from stdin (defaults to "-")') def broadcast(file): """broadcast a signed transaction""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if file and file != "-": if not os.path.isfile(file): raise Exception("File %s does not exist!" % file) @@ -1755,7 +1755,7 @@ def broadcast(file): else: tx = click.get_text_stream('stdin') tx = ast.literal_eval(tx) - tx = stm.broadcast(tx) + tx = hv.broadcast(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -1765,12 +1765,12 @@ def broadcast(file): def ticker(hbd_to_hive): """ Show ticker """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() t = PrettyTable(["Key", "Value"]) t.align = "l" - market = Market(hive_instance=stm) + market = Market(hive_instance=hv) ticker = market.ticker() for key in ticker: if key in ["highest_bid", "latest", "lowest_ask"] and hbd_to_hive: @@ -1791,17 +1791,17 @@ def ticker(hbd_to_hive): def pricehistory(width, height, ascii): """ Show price history """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() - feed_history = stm.get_feed_history() - current_base = Amount(feed_history['current_median_history']["base"], hive_instance=stm) - current_quote = Amount(feed_history['current_median_history']["quote"], hive_instance=stm) + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() + feed_history = hv.get_feed_history() + current_base = Amount(feed_history['current_median_history']["base"], hive_instance=hv) + current_quote = Amount(feed_history['current_median_history']["quote"], hive_instance=hv) price_history = feed_history["price_history"] price = [] for h in price_history: - base = Amount(h["base"], hive_instance=stm) - quote = Amount(h["quote"], hive_instance=stm) + base = Amount(h["base"], hive_instance=hv) + quote = Amount(h["quote"], hive_instance=hv) price.append(float(base.amount / quote.amount)) if ascii: charset = u'ascii' @@ -1829,10 +1829,10 @@ def pricehistory(width, height, ascii): def tradehistory(days, hours, hbd_to_hive, limit, width, height, ascii): """ Show price history """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() - m = Market(hive_instance=stm) + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() + m = Market(hive_instance=hv) utc = pytz.timezone('UTC') stop = utc.localize(datetime.utcnow()) start = stop - timedelta(days=days) @@ -1840,9 +1840,9 @@ def tradehistory(days, hours, hbd_to_hive, limit, width, height, ascii): trades = m.trade_history(start=start, stop=stop, limit=limit, intervall=intervall) price = [] if hbd_to_hive: - base_str = stm.hive_symbol + base_str = hv.hive_symbol else: - base_str = stm.hbd_symbol + base_str = hv.hbd_symbol for trade in trades: base = 0 quote = 0 @@ -1875,10 +1875,10 @@ def tradehistory(days, hours, hbd_to_hive, limit, width, height, ascii): @click.option('--ascii', help='Use only ascii symbols', is_flag=True, default=False) def orderbook(chart, limit, show_date, width, height, ascii): """Obtain orderbook of the internal market""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() - market = Market(hive_instance=stm) + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() + market = Market(hive_instance=hv) orderbook = market.orderbook(limit=limit, raw_data=False) if not show_date: header = ["Asks Sum HBD", "Sell Orders", "Bids Sum HBD", "Buy Orders"] @@ -1973,36 +1973,36 @@ def buy(amount, asset, price, account, orderid): Limit buy price denoted in (HBD per HIVE) """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if account is None: - account = stm.config["default_account"] - if asset == stm.hbd_symbol: - market = Market(base=Asset(stm.hive_symbol), quote=Asset(stm.hbd_symbol), hive_instance=stm) + account = hv.config["default_account"] + if asset == hv.hbd_symbol: + market = Market(base=Asset(hv.hive_symbol), quote=Asset(hv.hbd_symbol), hive_instance=hv) else: - market = Market(base=Asset(stm.hbd_symbol), quote=Asset(stm.hive_symbol), hive_instance=stm) + market = Market(base=Asset(hv.hbd_symbol), quote=Asset(hv.hive_symbol), hive_instance=hv) if price is None: orderbook = market.orderbook(limit=1, raw_data=False) - if asset == stm.hive_symbol and len(orderbook["bids"]) > 0: - p = Price(orderbook["bids"][0]["base"], orderbook["bids"][0]["quote"], hive_instance=stm).invert() + if asset == hv.hive_symbol and len(orderbook["bids"]) > 0: + p = Price(orderbook["bids"][0]["base"], orderbook["bids"][0]["quote"], hive_instance=hv).invert() p_show = p elif len(orderbook["asks"]) > 0: - p = Price(orderbook["asks"][0]["base"], orderbook["asks"][0]["quote"], hive_instance=stm).invert() + p = Price(orderbook["asks"][0]["base"], orderbook["asks"][0]["quote"], hive_instance=hv).invert() p_show = p price_ok = click.prompt("Is the following Price ok: %s [y/n]" % (str(p_show))) if price_ok not in ["y", "ye", "yes"]: return else: - p = Price(float(price), u"%s:%s" % (stm.hbd_symbol, stm.hive_symbol), hive_instance=stm) - if not unlock_wallet(stm): + p = Price(float(price), u"%s:%s" % (hv.hbd_symbol, hv.hive_symbol), hive_instance=hv) + if not unlock_wallet(hv): return - a = Amount(float(amount), asset, hive_instance=stm) - acc = Account(account, hive_instance=stm) + a = Amount(float(amount), asset, hive_instance=hv) + acc = Account(account, hive_instance=hv) tx = market.buy(p, a, account=acc, orderid=orderid) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -2018,35 +2018,35 @@ def sell(amount, asset, price, account, orderid): Limit sell price denoted in (HBD per HIVE) """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() - if asset == stm.hbd_symbol: - market = Market(base=Asset(stm.hive_symbol), quote=Asset(stm.hbd_symbol), hive_instance=stm) + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() + if asset == hv.hbd_symbol: + market = Market(base=Asset(hv.hive_symbol), quote=Asset(hv.hbd_symbol), hive_instance=hv) else: - market = Market(base=Asset(stm.hbd_symbol), quote=Asset(stm.hive_symbol), hive_instance=stm) + market = Market(base=Asset(hv.hbd_symbol), quote=Asset(hv.hive_symbol), hive_instance=hv) if not account: - account = stm.config["default_account"] + account = hv.config["default_account"] if not price: orderbook = market.orderbook(limit=1, raw_data=False) - if asset == stm.hbd_symbol and len(orderbook["bids"]) > 0: - p = Price(orderbook["bids"][0]["base"], orderbook["bids"][0]["quote"], hive_instance=stm).invert() + if asset == hv.hbd_symbol and len(orderbook["bids"]) > 0: + p = Price(orderbook["bids"][0]["base"], orderbook["bids"][0]["quote"], hive_instance=hv).invert() p_show = p else: - p = Price(orderbook["asks"][0]["base"], orderbook["asks"][0]["quote"], hive_instance=stm).invert() + p = Price(orderbook["asks"][0]["base"], orderbook["asks"][0]["quote"], hive_instance=hv).invert() p_show = p price_ok = click.prompt("Is the following Price ok: %s [y/n]" % (str(p_show))) if price_ok not in ["y", "ye", "yes"]: return else: - p = Price(float(price), u"%s:%s" % (stm.hbd_symbol, stm.hive_symbol), hive_instance=stm) - if not unlock_wallet(stm): + p = Price(float(price), u"%s:%s" % (hv.hbd_symbol, hv.hive_symbol), hive_instance=hv) + if not unlock_wallet(hv): return - a = Amount(float(amount), asset, hive_instance=stm) - acc = Account(account, hive_instance=stm) + a = Amount(float(amount), asset, hive_instance=hv) + acc = Account(account, hive_instance=hv) tx = market.sell(p, a, account=acc, orderid=orderid) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -2056,18 +2056,18 @@ def sell(amount, asset, price, account, orderid): @click.option('--account', '-a', help='Sell with this account (defaults to "default_account")') def cancel(orderid, account): """Cancel order in the internal market""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() - market = Market(hive_instance=stm) + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() + market = Market(hive_instance=hv) if not account: - account = stm.config["default_account"] - if not unlock_wallet(stm): + account = hv.config["default_account"] + if not unlock_wallet(hv): return - acc = Account(account, hive_instance=stm) + acc = Account(account, hive_instance=hv) tx = market.cancel(orderid, account=acc) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -2076,13 +2076,13 @@ def cancel(orderid, account): @click.argument('account', nargs=1, required=False) def openorders(account): """Show open orders""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() - market = Market(hive_instance=stm) + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() + market = Market(hive_instance=hv) if not account: - account = stm.config["default_account"] - acc = Account(account, hive_instance=stm) + account = hv.config["default_account"] + acc = Account(account, hive_instance=hv) openorders = market.accountopenorders(account=acc) t = PrettyTable(["Orderid", "Created", "Order", "Account"], hrules=0) t.align = "r" @@ -2099,18 +2099,18 @@ def openorders(account): @click.option('--account', '-a', help='Rehive as this user') def rehive(identifier, account): """Rehive an existing post""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - account = stm.config["default_account"] - if not unlock_wallet(stm): + account = hv.config["default_account"] + if not unlock_wallet(hv): return - acc = Account(account, hive_instance=stm) - post = Comment(identifier, hive_instance=stm) + acc = Account(account, hive_instance=hv) + post = Comment(identifier, hive_instance=hv) tx = post.rehive(account=acc) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -2121,19 +2121,19 @@ def rehive(identifier, account): @click.option('--what', help='Follow these objects (defaults to ["blog"])', default=["blog"]) def follow(follow, account, what): """Follow another account""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - account = stm.config["default_account"] + account = hv.config["default_account"] if isinstance(what, str): what = [what] - if not unlock_wallet(stm): + if not unlock_wallet(hv): return - acc = Account(account, hive_instance=stm) + acc = Account(account, hive_instance=hv) tx = acc.follow(follow, what=what) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -2144,19 +2144,19 @@ def follow(follow, account, what): @click.option('--what', help='Mute these objects (defaults to ["ignore"])', default=["ignore"]) def mute(mute, account, what): """Mute another account""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - account = stm.config["default_account"] + account = hv.config["default_account"] if isinstance(what, str): what = [what] - if not unlock_wallet(stm): + if not unlock_wallet(hv): return - acc = Account(account, hive_instance=stm) + acc = Account(account, hive_instance=hv) tx = acc.follow(mute, what=what) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -2166,17 +2166,17 @@ def mute(mute, account, what): @click.option('--account', '-a', help='UnFollow/UnMute from this account') def unfollow(unfollow, account): """Unfollow/Unmute another account""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - account = stm.config["default_account"] - if not unlock_wallet(stm): + account = hv.config["default_account"] + if not unlock_wallet(hv): return - acc = Account(account, hive_instance=stm) + acc = Account(account, hive_instance=hv) tx = acc.unfollow(unfollow) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -2190,25 +2190,25 @@ def unfollow(unfollow, account): @click.option('--signing_key', help='Signing Key') def witnessupdate(witness, maximum_block_size, account_creation_fee, hbd_interest_rate, url, signing_key): """Change witness properties""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not witness: - witness = stm.config["default_account"] - if not unlock_wallet(stm): + witness = hv.config["default_account"] + if not unlock_wallet(hv): return - witness = Witness(witness, hive_instance=stm) + witness = Witness(witness, hive_instance=hv) props = witness["props"] if account_creation_fee is not None: props["account_creation_fee"] = str( - Amount("%.3f %s" % (float(account_creation_fee), stm.hive_symbol), hive_instance=stm)) + Amount("%.3f %s" % (float(account_creation_fee), hv.hive_symbol), hive_instance=hv)) if maximum_block_size is not None: props["maximum_block_size"] = int(maximum_block_size) if hbd_interest_rate is not None: props["hbd_interest_rate"] = int(float(hbd_interest_rate) * 100) tx = witness.update(signing_key or witness["signing_key"], url or witness["url"], props) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -2217,21 +2217,21 @@ def witnessupdate(witness, maximum_block_size, account_creation_fee, hbd_interes @click.argument('witness', nargs=1) def witnessdisable(witness): """Disable a witness""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not witness: - witness = stm.config["default_account"] - if not unlock_wallet(stm): + witness = hv.config["default_account"] + if not unlock_wallet(hv): return - witness = Witness(witness, hive_instance=stm) + witness = Witness(witness, hive_instance=hv) if not witness.is_active: print("Cannot disable a disabled witness!") return props = witness["props"] tx = witness.update('STM1111111111111111111111111111111114T1Anm', witness["url"], props) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -2241,18 +2241,18 @@ def witnessdisable(witness): @click.argument('signing_key', nargs=1) def witnessenable(witness, signing_key): """Enable a witness""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not witness: - witness = stm.config["default_account"] - if not unlock_wallet(stm): + witness = hv.config["default_account"] + if not unlock_wallet(hv): return - witness = Witness(witness, hive_instance=stm) + witness = Witness(witness, hive_instance=hv) props = witness["props"] tx = witness.update(signing_key, witness["url"], props) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -2266,23 +2266,23 @@ def witnessenable(witness, signing_key): @click.option('--url', help='Witness URL', default="") def witnesscreate(witness, pub_signing_key, maximum_block_size, account_creation_fee, hbd_interest_rate, url): """Create a witness""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() - if not unlock_wallet(stm): + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() + if not unlock_wallet(hv): return props = { "account_creation_fee": - Amount("%.3f %s" % (float(account_creation_fee), stm.hive_symbol), hive_instance=stm), + Amount("%.3f %s" % (float(account_creation_fee), hv.hive_symbol), hive_instance=hv), "maximum_block_size": int(maximum_block_size), "hbd_interest_rate": int(hbd_interest_rate * 100) } - tx = stm.witness_update(pub_signing_key, url, props, account=witness) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + tx = hv.witness_update(pub_signing_key, url, props, account=witness) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -2299,14 +2299,14 @@ def witnesscreate(witness, pub_signing_key, maximum_block_size, account_creation @click.option('--url', help='Witness URL') def witnessproperties(witness, wif, account_creation_fee, account_subsidy_budget, account_subsidy_decay, maximum_block_size, hbd_interest_rate, new_signing_key, url): """Update witness properties of witness WITNESS with the witness signing key WIF""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() - # if not unlock_wallet(stm): + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() + # if not unlock_wallet(hv): # return props = {} if account_creation_fee is not None: - props["account_creation_fee"] = Amount("%.3f %s" % (float(account_creation_fee), stm.hive_symbol), hive_instance=stm) + props["account_creation_fee"] = Amount("%.3f %s" % (float(account_creation_fee), hv.hive_symbol), hive_instance=hv) if account_subsidy_budget is not None: props["account_subsidy_budget"] = int(account_subsidy_budget) if account_subsidy_decay is not None: @@ -2320,9 +2320,9 @@ def witnessproperties(witness, wif, account_creation_fee, account_subsidy_budget if url is not None: props["url"] = url - tx = stm.witness_set_properties(wif, witness, props) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + tx = hv.witness_set_properties(wif, witness, props) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -2335,50 +2335,50 @@ def witnessproperties(witness, wif, account_creation_fee, account_subsidy_budget @click.option('--support-peg', help='Supports peg adjusting the quote, is overwritten by --set-quote!', is_flag=True, default=False) def witnessfeed(witness, wif, base, quote, support_peg): """Publish price feed for a witness""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if wif is None: - if not unlock_wallet(stm): + if not unlock_wallet(hv): return - witness = Witness(witness, hive_instance=stm) - market = Market(hive_instance=stm) + witness = Witness(witness, hive_instance=hv) + market = Market(hive_instance=hv) old_base = witness["hbd_exchange_rate"]["base"] old_quote = witness["hbd_exchange_rate"]["quote"] - last_published_price = Price(witness["hbd_exchange_rate"], hive_instance=stm) + last_published_price = Price(witness["hbd_exchange_rate"], hive_instance=hv) hive_usd = None print("Old price %.3f (base: %s, quote %s)" % (float(last_published_price), old_base, old_quote)) if quote is None and not support_peg: - quote = Amount("1.000 %s" % stm.hive_symbol, hive_instance=stm) + quote = Amount("1.000 %s" % hv.hive_symbol, hive_instance=hv) elif quote is None: latest_price = market.ticker()['latest'] if hive_usd is None: hive_usd = market.hive_usd_implied() - hbd_usd = float(latest_price.as_base(stm.hbd_symbol)) * hive_usd - quote = Amount(1. / hbd_usd, stm.hive_symbol, hive_instance=stm) + hbd_usd = float(latest_price.as_base(hv.hbd_symbol)) * hive_usd + quote = Amount(1. / hbd_usd, hv.hive_symbol, hive_instance=hv) else: - if str(quote[-5:]).upper() == stm.hive_symbol: - quote = Amount(quote, hive_instance=stm) + if str(quote[-5:]).upper() == hv.hive_symbol: + quote = Amount(quote, hive_instance=hv) else: - quote = Amount(quote, stm.hive_symbol, hive_instance=stm) + quote = Amount(quote, hv.hive_symbol, hive_instance=hv) if base is None: if hive_usd is None: hive_usd = market.hive_usd_implied() - base = Amount(hive_usd, stm.hbd_symbol, hive_instance=stm) + base = Amount(hive_usd, hv.hbd_symbol, hive_instance=hv) else: - if str(quote[-3:]).upper() == stm.hbd_symbol: - base = Amount(base, hive_instance=stm) + if str(quote[-3:]).upper() == hv.hbd_symbol: + base = Amount(base, hive_instance=hv) else: - base = Amount(base, stm.hbd_symbol, hive_instance=stm) - new_price = Price(base=base, quote=quote, hive_instance=stm) + base = Amount(base, hv.hbd_symbol, hive_instance=hv) + new_price = Price(base=base, quote=quote, hive_instance=hv) print("New price %.3f (base: %s, quote %s)" % (float(new_price), base, quote)) if wif is not None: props = {"hbd_exchange_rate": new_price} - tx = stm.witness_set_properties(wif, witness["owner"], props) + tx = hv.witness_set_properties(wif, witness["owner"], props) else: tx = witness.feed_publish(base, quote=quote) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -2388,13 +2388,13 @@ def witnessfeed(witness, wif, base, quote, support_peg): def witness(witness): """ List witness information """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() - witness = Witness(witness, hive_instance=stm) + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() + witness = Witness(witness, hive_instance=hv) witness_json = witness.json() - witness_schedule = stm.get_witness_schedule() - config = stm.get_config() + witness_schedule = hv.get_witness_schedule() + config = hv.get_config() if "VIRTUAL_SCHEDULE_LAP_LENGTH2" in config: lap_length = int(config["VIRTUAL_SCHEDULE_LAP_LENGTH2"]) else: @@ -2402,7 +2402,7 @@ def witness(witness): rank = 0 active_rank = 0 found = False - witnesses = WitnessesRankedByVote(limit=250, hive_instance=stm) + witnesses = WitnessesRankedByVote(limit=250, hive_instance=hv) vote_sum = witnesses.get_votes_sum() for w in witnesses: rank += 1 @@ -2450,21 +2450,21 @@ def witness(witness): def witnesses(account, limit): """ List witnesses """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if account: - account = Account(account, hive_instance=stm) + account = Account(account, hive_instance=hv) account_name = account["name"] if account["proxy"] != "": account_name = account["proxy"] account_type = "Proxy" else: account_type = "Account" - witnesses = WitnessesVotedByAccount(account_name, hive_instance=stm) + witnesses = WitnessesVotedByAccount(account_name, hive_instance=hv) print("%s: @%s (%d of 30)" % (account_type, account_name, len(witnesses))) else: - witnesses = WitnessesRankedByVote(limit=limit, hive_instance=stm) + witnesses = WitnessesRankedByVote(limit=limit, hive_instance=hv) witnesses.printAsTable() @@ -2478,11 +2478,11 @@ def witnesses(account, limit): def votes(account, direction, outgoing, incoming, days, export): """ List outgoing/incoming account votes """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - account = stm.config["default_account"] + account = hv.config["default_account"] if direction is None and not incoming and not outgoing: direction = "in" utc = pytz.timezone('UTC') @@ -2490,14 +2490,14 @@ def votes(account, direction, outgoing, incoming, days, export): out_votes_str = "" in_votes_str = "" if direction == "out" or outgoing: - votes = AccountVotes(account, start=limit_time, hive_instance=stm) + votes = AccountVotes(account, start=limit_time, hive_instance=hv) out_votes_str = votes.printAsTable(start=limit_time, return_str=True) if direction == "in" or incoming: - account = Account(account, hive_instance=stm) + account = Account(account, hive_instance=hv) votes_list = [] for v in account.history(start=limit_time, only_ops=["vote"]): votes_list.append(v) - votes = ActiveVotes(votes_list, hive_instance=stm) + votes = ActiveVotes(votes_list, hive_instance=hv) in_votes_str = votes.printAsTable(votee=account["name"], return_str=True) if export: with open(export, 'w') as w: @@ -2534,9 +2534,9 @@ def curation(authorperm, account, limit, min_vote, max_vote, min_performance, ma the fifth account vote in the given time duration (default is 7 days) """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if authorperm is None: authorperm = 'all' if account is None and authorperm != 'all': @@ -2545,11 +2545,11 @@ def curation(authorperm, account, limit, min_vote, max_vote, min_performance, ma show_all_voter = False if authorperm == 'all' or authorperm.isdigit(): if not account: - account = stm.config["default_account"] + account = hv.config["default_account"] utc = pytz.timezone('UTC') limit_time = utc.localize(datetime.utcnow()) - timedelta(days=days) - votes = AccountVotes(account, start=limit_time, hive_instance=stm) - authorperm_list = [Comment(vote.authorperm, hive_instance=stm) for vote in votes] + votes = AccountVotes(account, start=limit_time, hive_instance=hv) + authorperm_list = [Comment(vote.authorperm, hive_instance=hv) for vote in votes] if authorperm.isdigit(): if len(authorperm_list) < int(authorperm): raise ValueError("Authorperm id must be lower than %d" % (len(authorperm_list) + 1)) @@ -2584,7 +2584,7 @@ def curation(authorperm, account, limit, min_vote, max_vote, min_performance, ma index = 0 for authorperm in authorperm_list: index += 1 - comment = Comment(authorperm, hive_instance=stm) + comment = Comment(authorperm, hive_instance=hv) if payout is not None and comment.is_pending(): payout = float(payout) elif payout is not None: @@ -2596,7 +2596,7 @@ def curation(authorperm, account, limit, min_vote, max_vote, min_performance, ma max_curation = [0, 0, 0, 0, 0, 0] highest_vote = [0, 0, 0, 0, 0, 0] for vote in comment["active_votes"]: - vote_HBD = stm.rshares_to_hbd(int(vote["rshares"])) + vote_HBD = hv.rshares_to_hbd(int(vote["rshares"])) curation_HBD = curation_rewards_HBD["active_votes"][vote["voter"]] curation_HP = curation_rewards_HP["active_votes"][vote["voter"]] if vote_HBD > 0: @@ -2723,11 +2723,11 @@ def curation(authorperm, account, limit, min_vote, max_vote, min_performance, ma def rewards(accounts, only_sum, post, comment, curation, length, author, permlink, title, days): """ Lists received rewards """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not accounts: - accounts = [stm.config["default_account"]] + accounts = [hv.config["default_account"]] if not comment and not curation and not post: post = True permlink = True @@ -2739,9 +2739,9 @@ def rewards(accounts, only_sum, post, comment, curation, length, author, permlin limit_time = now - timedelta(days=days) for account in accounts: sum_reward = [0, 0, 0, 0, 0] - account = Account(account, hive_instance=stm) - median_price = Price(stm.get_current_median_history(), hive_instance=stm) - m = Market(hive_instance=stm) + account = Account(account, hive_instance=hv) + median_price = Price(hv.get_current_median_history(), hive_instance=hv) + m = Market(hive_instance=hv) latest = m.ticker()["latest"] if author and permlink: t = PrettyTable(["Author", "Permlink", "Payout", "HBD", "HP + HIVE", "Liquid USD", "Invested USD"]) @@ -2769,7 +2769,7 @@ def rewards(accounts, only_sum, post, comment, curation, length, author, permlin if not post and not comment and v["type"] == "author_reward": continue if v["type"] == "author_reward": - c = Comment(v, hive_instance=stm) + c = Comment(v, hive_instance=hv) try: c.refresh() except exceptions.ContentDoesNotExistsException: @@ -2778,11 +2778,11 @@ def rewards(accounts, only_sum, post, comment, curation, length, author, permlin continue if not comment and c.is_comment(): continue - payout_HBD = Amount(v["hbd_payout"], hive_instance=stm) - payout_HIVE = Amount(v["hive_payout"], hive_instance=stm) + payout_HBD = Amount(v["hbd_payout"], hive_instance=hv) + payout_HIVE = Amount(v["hive_payout"], hive_instance=hv) sum_reward[0] += float(payout_HBD) sum_reward[1] += float(payout_HIVE) - payout_HP = stm.vests_to_sp(Amount(v["vesting_payout"], hive_instance=stm)) + payout_HP = hv.vests_to_sp(Amount(v["vesting_payout"], hive_instance=hv)) sum_reward[2] += float(payout_HP) liquid_USD = float(payout_HBD) / float(latest) * float(median_price) + float(payout_HIVE) * float(median_price) sum_reward[3] += liquid_USD @@ -2804,14 +2804,14 @@ def rewards(accounts, only_sum, post, comment, curation, length, author, permlin (liquid_USD), (invested_USD)]) elif v["type"] == "curation_reward": - reward = Amount(v["reward"], hive_instance=stm) - payout_HP = stm.vests_to_sp(reward) + reward = Amount(v["reward"], hive_instance=hv) + payout_HP = hv.vests_to_sp(reward) liquid_USD = 0 invested_USD = float(payout_HP) * float(median_price) sum_reward[2] += float(payout_HP) sum_reward[4] += invested_USD if title: - c = Comment(construct_authorperm(v["comment_author"], v["comment_permlink"]), hive_instance=stm) + c = Comment(construct_authorperm(v["comment_author"], v["comment_permlink"]), hive_instance=hv) permlink_row = c.title else: permlink_row = v["comment_permlink"] @@ -2919,11 +2919,11 @@ def rewards(accounts, only_sum, post, comment, curation, length, author, permlin def pending(accounts, only_sum, post, comment, curation, length, author, permlink, title, days): """ Lists pending rewards """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not accounts: - accounts = [stm.config["default_account"]] + accounts = [hv.config["default_account"]] if not comment and not curation and not post: post = True permlink = True @@ -2936,9 +2936,9 @@ def pending(accounts, only_sum, post, comment, curation, length, author, permlin limit_time = utc.localize(datetime.utcnow()) - timedelta(days=days) for account in accounts: sum_reward = [0, 0, 0, 0] - account = Account(account, hive_instance=stm) - median_price = Price(stm.get_current_median_history(), hive_instance=stm) - m = Market(hive_instance=stm) + account = Account(account, hive_instance=hv) + median_price = Price(hv.get_current_median_history(), hive_instance=hv) + m = Market(hive_instance=hv) latest = m.ticker()["latest"] if author and permlink: t = PrettyTable(["Author", "Permlink", "Cashout", "HBD", "HP", "Liquid USD", "Invested USD"]) @@ -3002,9 +3002,9 @@ def pending(accounts, only_sum, post, comment, curation, length, author, permlin (liquid_USD), (invested_USD)]) if curation: - votes = AccountVotes(account, start=limit_time, hive_instance=stm) + votes = AccountVotes(account, start=limit_time, hive_instance=hv) for vote in votes: - c = Comment(vote["authorperm"], hive_instance=stm) + c = Comment(vote["authorperm"], hive_instance=hv) rewards = c.get_curation_rewards() if not rewards["pending_rewards"]: continue @@ -3122,12 +3122,12 @@ def claimreward(account, reward_hive, reward_hbd, reward_vests, claim_all_hive, By default, this will claim ``all`` outstanding balances. """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - account = stm.config["default_account"] - acc = Account(account, hive_instance=stm) + account = hv.config["default_account"] + acc = Account(account, hive_instance=hv) r = acc.balances["rewards"] if len(r) == 3 and r[0].amount + r[1].amount + r[2].amount == 0: print("Nothing to claim.") @@ -3135,7 +3135,7 @@ def claimreward(account, reward_hive, reward_hbd, reward_vests, claim_all_hive, elif len(r) == 2 and r[0].amount + r[1].amount: print("Nothing to claim.") return - if not unlock_wallet(stm): + if not unlock_wallet(hv): return if claim_all_hive: reward_hive = r[0] @@ -3145,8 +3145,8 @@ def claimreward(account, reward_hive, reward_hbd, reward_vests, claim_all_hive, reward_vests = r[2] tx = acc.claim_reward_balance(reward_hive, reward_hbd, reward_vests) - if stm.unsigned and stm.nobroadcast and stm.hiveconnect is not None: - tx = stm.hiveconnect.url_from_tx(tx) + if hv.unsigned and hv.nobroadcast and hv.hiveconnect is not None: + tx = hv.hiveconnect.url_from_tx(tx) tx = json.dumps(tx, indent=4) print(tx) @@ -3195,18 +3195,18 @@ def customjson(jsonid, json_data, account, active): value = float(value) field[key] = value data[d] = field - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not account: - account = stm.config["default_account"] - if not unlock_wallet(stm): + account = hv.config["default_account"] + if not unlock_wallet(hv): return - acc = Account(account, hive_instance=stm) + acc = Account(account, hive_instance=hv) if active: - tx = stm.custom_json(jsonid, data, required_auths=[account]) + tx = hv.custom_json(jsonid, data, required_auths=[account]) else: - tx = stm.custom_json(jsonid, data, required_posting_auths=[account]) + tx = hv.custom_json(jsonid, data, required_posting_auths=[account]) tx = json.dumps(tx, indent=4) print(tx) @@ -3217,16 +3217,16 @@ def customjson(jsonid, json_data, account, active): @click.option('--use-api', '-u', help='Uses the get_potential_signatures api call', is_flag=True, default=False) def verify(blocknumber, trx, use_api): """Returns the public signing keys for a block""" - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() - b = Blockchain(hive_instance=stm) + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() + b = Blockchain(hive_instance=hv) i = 0 if not blocknumber: blocknumber = b.get_current_block_num() try: int(blocknumber) - block = Block(blocknumber, hive_instance=stm) + block = Block(blocknumber, hive_instance=hv) if trx is not None: i = int(trx) trxs = [block.json_transactions[int(trx)]] @@ -3235,7 +3235,7 @@ def verify(blocknumber, trx, use_api): except Exception: trxs = [b.get_transaction(blocknumber)] blocknumber = trxs[0]["block_num"] - wallet = Wallet(hive_instance=stm) + wallet = Wallet(hive_instance=hv) t = PrettyTable(["trx", "Signer key", "Account"]) t.align = "l" if not use_api: @@ -3250,10 +3250,10 @@ def verify(blocknumber, trx, use_api): tx = b.get_transaction(trx["transaction_id"]) signed_tx = Signed_Transaction(tx) public_keys = [] - for key in signed_tx.verify(chain=stm.chain_params, recover_parameter=True): - public_keys.append(format(Base58(key, prefix=stm.prefix), stm.prefix)) + for key in signed_tx.verify(chain=hv.chain_params, recover_parameter=True): + public_keys.append(format(Base58(key, prefix=hv.prefix), hv.prefix)) else: - tx = TransactionBuilder(tx=trx, hive_instance=stm) + tx = TransactionBuilder(tx=trx, hive_instance=hv) public_keys = tx.get_potential_signatures() accounts = [] empty_public_keys = [] @@ -3288,17 +3288,17 @@ def info(objects): General information about the blockchain, a block, an account, a post/comment and a public key """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() if not objects: t = PrettyTable(["Key", "Value"]) t.align = "l" - info = stm.get_dynamic_global_properties() - median_price = stm.get_current_median_history() - hive_per_mvest = stm.get_hive_per_mvest() - chain_props = stm.get_chain_properties() - price = (Amount(median_price["base"], hive_instance=stm).amount / Amount(median_price["quote"], hive_instance=stm).amount) + info = hv.get_dynamic_global_properties() + median_price = hv.get_current_median_history() + hive_per_mvest = hv.get_hive_per_mvest() + chain_props = hv.get_chain_properties() + price = (Amount(median_price["base"], hive_instance=hv).amount / Amount(median_price["quote"], hive_instance=hv).amount) for key in info: t.add_row([key, info[key]]) t.add_row(["hive per mvest", hive_per_mvest]) @@ -3312,11 +3312,11 @@ def info(objects): if re.match("^[0-9-]*:[0-9-]", obj): obj, tran_nr = obj.split(":") if int(obj) < 1: - b = Blockchain(hive_instance=stm) + b = Blockchain(hive_instance=hv) block_number = b.get_current_block_num() + int(obj) - 1 else: block_number = obj - block = Block(block_number, hive_instance=stm) + block = Block(block_number, hive_instance=hv) if block: t = PrettyTable(["Key", "Value"]) t.align = "l" @@ -3348,7 +3348,7 @@ def info(objects): else: print("Block number %s unknown" % obj) elif re.match("^[a-zA-Z0-9\-\._]{2,16}$", obj): - account = Account(obj, hive_instance=stm) + account = Account(obj, hive_instance=hv) t = PrettyTable(["Key", "Value"]) t.align = "l" account_json = account.json() @@ -3369,7 +3369,7 @@ def info(objects): # witness available? try: - witness = Witness(obj, hive_instance=stm) + witness = Witness(obj, hive_instance=hv) witness_json = witness.json() t = PrettyTable(["Key", "Value"]) t.align = "l" @@ -3382,11 +3382,11 @@ def info(objects): except exceptions.WitnessDoesNotExistsException as e: print(str(e)) # Public Key - elif re.match("^" + stm.prefix + ".{48,55}$", obj): - account = stm.wallet.getAccountFromPublicKey(obj) + elif re.match("^" + hv.prefix + ".{48,55}$", obj): + account = hv.wallet.getAccountFromPublicKey(obj) if account: - account = Account(account, hive_instance=stm) - key_type = stm.wallet.getKeyType(account, obj) + account = Account(account, hive_instance=hv) + key_type = hv.wallet.getKeyType(account, obj) t = PrettyTable(["Account", "Key_type"]) t.align = "l" t.add_row([account["name"], key_type]) @@ -3395,7 +3395,7 @@ def info(objects): print("Public Key %s not known" % obj) # Post identifier elif re.match(".*@.{3,16}/.*$", obj): - post = Comment(obj, hive_instance=stm) + post = Comment(obj, hive_instance=hv) post_json = post.json() if post_json: t = PrettyTable(["Key", "Value"]) @@ -3426,18 +3426,18 @@ def userdata(account, signing_account): The request has to be signed by the requested account or an admin account. """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() - if not unlock_wallet(stm): + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() + if not unlock_wallet(hv): return if not account: - if "default_account" in stm.config: - account = stm.config["default_account"] - account = Account(account, hive_instance=stm) + if "default_account" in hv.config: + account = hv.config["default_account"] + account = Account(account, hive_instance=hv) if signing_account is not None: - signing_account = Account(signing_account, hive_instance=stm) - c = Conveyor(hive_instance=stm) + signing_account = Account(signing_account, hive_instance=hv) + c = Conveyor(hive_instance=hv) user_data = c.get_user_data(account, signing_account=signing_account) t = PrettyTable(["Key", "Value"]) t.align = "l" @@ -3455,18 +3455,18 @@ def featureflags(account, signing_account): The request has to be signed by the requested account or an admin account. """ - stm = shared_hive_instance() - if stm.rpc is not None: - stm.rpc.rpcconnect() - if not unlock_wallet(stm): + hv = shared_hive_instance() + if hv.rpc is not None: + hv.rpc.rpcconnect() + if not unlock_wallet(hv): return if not account: - if "default_account" in stm.config: - account = stm.config["default_account"] - account = Account(account, hive_instance=stm) + if "default_account" in hv.config: + account = hv.config["default_account"] + account = Account(account, hive_instance=hv) if signing_account is not None: - signing_account = Account(signing_account, hive_instance=stm) - c = Conveyor(hive_instance=stm) + signing_account = Account(signing_account, hive_instance=hv) + c = Conveyor(hive_instance=hv) user_data = c.get_feature_flags(account, signing_account=signing_account) t = PrettyTable(["Key", "Value"]) t.align = "l" diff --git a/beem/comment.py b/beem/comment.py index 32d5e27d..bbc6f3bc 100644 --- a/beem/comment.py +++ b/beem/comment.py @@ -37,8 +37,8 @@ class Comment(BlockchainObject): >>> from beem.comment import Comment >>> from beem.account import Account >>> from beem import Hive - >>> stm = Hive() - >>> acc = Account("gtg", hive_instance=stm) + >>> hv = Hive() + >>> acc = Account("gtg", hive_instance=hv) >>> authorperm = acc.get_blog(limit=1)[0]["authorperm"] >>> c = Comment(authorperm) >>> postdate = c["created"] diff --git a/beem/hive.py b/beem/hive.py index 996c0a14..1f682500 100644 --- a/beem/hive.py +++ b/beem/hive.py @@ -118,7 +118,7 @@ class Hive(object): .. code-block:: python from beem import Hive - stm = Hive(node=["https://mytstnet.com"], custom_chains={"MYTESTNET": + hv = Hive(node=["https://mytstnet.com"], custom_chains={"MYTESTNET": {'chain_assets': [{'asset': 'HBD', 'id': 0, 'precision': 3, 'symbol': 'HBD'}, {'asset': 'HIVE', 'id': 1, 'precision': 3, 'symbol': 'HIVE'}, {'asset': 'VESTS', 'id': 2, 'precision': 6, 'symbol': 'VESTS'}], diff --git a/beem/hiveconnect.py b/beem/hiveconnect.py index 9113ab63..580a2042 100644 --- a/beem/hiveconnect.py +++ b/beem/hiveconnect.py @@ -60,9 +60,9 @@ class HiveConnect(object): from beembase import operations from beem.hiveconnect import HiveConnect from pprint import pprint - stm = Hive(nobroadcast=True, unsigned=True) - sc2 = HiveConnect(hive_instance=stm) - tx = TransactionBuilder(hive_instance=stm) + hv = Hive(nobroadcast=True, unsigned=True) + sc2 = HiveConnect(hive_instance=hv) + tx = TransactionBuilder(hive_instance=hv) op = operations.Transfer(**{"from": 'test', "to": 'test1', "amount": '1.000 HIVE', diff --git a/beem/imageuploader.py b/beem/imageuploader.py index de7ea083..bd67878a 100644 --- a/beem/imageuploader.py +++ b/beem/imageuploader.py @@ -40,8 +40,8 @@ class ImageUploader(object): from beem import Hive from beem.imageuploader import ImageUploader - stm = Hive(keys=["5xxx"]) # private posting key - iu = ImageUploader(hive_instance=stm) + hv = Hive(keys=["5xxx"]) # private posting key + iu = ImageUploader(hive_instance=hv) iu.upload("path/to/image.png", "account_name") # "private posting key belongs to account_name """ diff --git a/beem/instance.py b/beem/instance.py index c473fc20..3e13eddd 100644 --- a/beem/instance.py +++ b/beem/instance.py @@ -4,7 +4,7 @@ from __future__ import division from __future__ import print_function from __future__ import unicode_literals from builtins import object -import beem as stm +import beem as hv class SharedInstance(object): @@ -30,7 +30,7 @@ def shared_hive_instance(): """ if not SharedInstance.instance: clear_cache() - SharedInstance.instance = stm.Hive(**SharedInstance.config) + SharedInstance.instance = hv.Hive(**SharedInstance.config) return SharedInstance.instance diff --git a/beem/transactionbuilder.py b/beem/transactionbuilder.py index ae1849b5..162899a4 100644 --- a/beem/transactionbuilder.py +++ b/beem/transactionbuilder.py @@ -42,8 +42,8 @@ class TransactionBuilder(dict): from beembase.operations import Transfer from beem import Hive wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" - stm = Hive(nobroadcast=True, keys={'active': wif}) - tx = TransactionBuilder(hive_instance=stm) + hv = Hive(nobroadcast=True, keys={'active': wif}) + tx = TransactionBuilder(hive_instance=hv) transfer = {"from": "test", "to": "test1", "amount": "1 HIVE", "memo": ""} tx.appendOps(Transfer(transfer)) tx.appendSigner("test", "active") # or tx.appendWif(wif) diff --git a/beem/vote.py b/beem/vote.py index 02a3508d..6c3fe611 100644 --- a/beem/vote.py +++ b/beem/vote.py @@ -32,8 +32,8 @@ class Vote(BlockchainObject): >>> from beem.vote import Vote >>> from beem import Hive - >>> stm = Hive() - >>> v = Vote("@gtg/hive-pressure-4-need-for-speed|gandalf", hive_instance=stm) + >>> hv = Hive() + >>> v = Vote("@gtg/hive-pressure-4-need-for-speed|gandalf", hive_instance=hv) """ type_id = 11 diff --git a/benchmarks/benchmarks/bench_transaction.py b/benchmarks/benchmarks/bench_transaction.py index 0a56877e..de921d9a 100644 --- a/benchmarks/benchmarks/bench_transaction.py +++ b/benchmarks/benchmarks/bench_transaction.py @@ -39,7 +39,7 @@ class Transaction(Benchmark): self.ref_block_num = 34294 self.ref_block_prefix = 3707022213 self.expiration = "2016-04-06T08:29:27" - self.stm = Hive( + self.hv = Hive( offline=True ) @@ -61,7 +61,7 @@ class Transaction(Benchmark): self.op = operations.Transfer(**{ "from": "foo", "to": "baar", - "amount": Amount("111.110 HIVE", hive_instance=self.stm), + "amount": Amount("111.110 HIVE", hive_instance=self.hv), "memo": "Fooo", "prefix": self.default_prefix }) diff --git a/docs/apidefinitions.rst b/docs/apidefinitions.rst index a024655a..89a5ac9c 100644 --- a/docs/apidefinitions.rst +++ b/docs/apidefinitions.rst @@ -146,8 +146,8 @@ get_chain_properties .. code-block:: python from beem import Hive - stm = Hive() - print(stm.get_chain_properties()) + hv = Hive() + print(hv.get_chain_properties()) get_comment_discussions_by_payout ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -165,8 +165,8 @@ get_config .. code-block:: python from beem import Hive - stm = Hive() - print(stm.get_config()) + hv = Hive() + print(hv.get_config()) get_content ~~~~~~~~~~~ @@ -208,8 +208,8 @@ get_current_median_history_price .. code-block:: python from beem import Hive - stm = Hive() - print(stm.get_current_median_history()) + hv = Hive() + print(hv.get_current_median_history()) get_discussions_by_active @@ -337,8 +337,8 @@ get_dynamic_global_properties .. code-block:: python from beem import Hive - stm = Hive() - print(stm.get_dynamic_global_properties()) + hv = Hive() + print(hv.get_dynamic_global_properties()) get_escrow ~~~~~~~~~~ @@ -384,8 +384,8 @@ get_feed_history .. code-block:: python from beem import Hive - stm = Hive() - print(stm.get_feed_history()) + hv = Hive() + print(hv.get_feed_history()) get_follow_count ~~~~~~~~~~~~~~~~ @@ -422,8 +422,8 @@ get_hardfork_version .. code-block:: python from beem import Hive - stm = Hive() - print(stm.get_hardfork_properties()["hf_version"]) + hv = Hive() + print(hv.get_hardfork_properties()["hf_version"]) get_key_references ~~~~~~~~~~~~~~~~~~ @@ -462,8 +462,8 @@ get_next_scheduled_hardfork .. code-block:: python from beem import Hive - stm = Hive() - print(stm.get_hardfork_properties()) + hv = Hive() + print(hv.get_hardfork_properties()) get_open_orders ~~~~~~~~~~~~~~~ @@ -586,8 +586,8 @@ get_reward_fund .. code-block:: python from beem import Hive - stm = Hive() - print(stm.get_reward_funds()) + hv = Hive() + print(hv.get_reward_funds()) get_savings_withdraw_from ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -730,8 +730,8 @@ get_witness_schedule .. code-block:: python from beem import Hive - stm = Hive() - print(stm.get_witness_schedule()) + hv = Hive() + print(hv.get_witness_schedule()) get_witnesses ~~~~~~~~~~~~~ diff --git a/docs/index.rst b/docs/index.rst index f468a5d8..b677f38f 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -92,12 +92,12 @@ Quickstart .. code-block:: python from beem.hive import Hive - stm = Hive() - stm.wallet.wipe(True) - stm.wallet.create("wallet-passphrase") - stm.wallet.unlock("wallet-passphrase") - stm.wallet.addPrivateKey("512345678") - stm.wallet.lock() + hv = Hive() + hv.wallet.wipe(True) + hv.wallet.create("wallet-passphrase") + hv.wallet.unlock("wallet-passphrase") + hv.wallet.addPrivateKey("512345678") + hv.wallet.lock() .. code-block:: python diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 361459f0..e371507c 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -20,16 +20,16 @@ By creating this object different options can be set. from beem import Hive from beem.account import Account - stm = Hive() - account = Account("test", hive_instance=stm) + hv = Hive() + account = Account("test", hive_instance=hv) .. code-block:: python from beem import Hive from beem.account import Account from beem.instance import set_shared_hive_instance - stm = Hive() - set_shared_hive_instance(stm) + hv = Hive() + set_shared_hive_instance(hv) account = Account("test") Wallet and Keys diff --git a/docs/tutorials.rst b/docs/tutorials.rst index d880302b..e4bbe55c 100644 --- a/docs/tutorials.rst +++ b/docs/tutorials.rst @@ -25,15 +25,15 @@ one comment operation from each sender. # not a real working key wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" - stm = Hive( + hv = Hive( bundle=True, # Enable bundle broadcast # nobroadcast=True, # Enable this for testing keys=[wif], ) - # Set stm as shared instance - set_shared_hive_instance(stm) + # Set hv as shared instance + set_shared_hive_instance(hv) - # Account and Comment will use now stm + # Account and Comment will use now hv account = Account("test") # Post @@ -45,7 +45,7 @@ one comment operation from each sender. # Upvote post with 25% c.upvote(25, voter=account) - pprint(stm.broadcast()) + pprint(hv.broadcast()) Use nobroadcast for testing @@ -208,9 +208,9 @@ the complete queue is sended at once to the node. The result is a list with repl .. code-block:: python from beem import Hive - stm = Hive("https://api.hiveit.com") - stm.rpc.get_config(add_to_queue=True) - stm.rpc.rpc_queue + hv = Hive("https://api.hiveit.com") + hv.rpc.get_config(add_to_queue=True) + hv.rpc.rpc_queue .. code-block:: python @@ -218,7 +218,7 @@ the complete queue is sended at once to the node. The result is a list with repl .. code-block:: python - result = stm.rpc.get_block({"block_num":1}, api="block", add_to_queue=False) + result = hv.rpc.get_block({"block_num":1}, api="block", add_to_queue=False) len(result) .. code-block:: python @@ -274,10 +274,10 @@ Example with one operation with and without the wallet: from beem import Hive from beem.transactionbuilder import TransactionBuilder from beembase import operations - stm = Hive() + hv = Hive() # Uncomment the following when using a wallet: - # stm.wallet.unlock("secret_password") - tx = TransactionBuilder(hive_instance=stm) + # hv.wallet.unlock("secret_password") + tx = TransactionBuilder(hive_instance=hv) op = operations.Transfer(**{"from": 'user_a', "to": 'user_b', "amount": '1.000 HBD', @@ -296,10 +296,10 @@ Example with signing and broadcasting two operations: from beem import Hive from beem.transactionbuilder import TransactionBuilder from beembase import operations - stm = Hive() + hv = Hive() # Uncomment the following when using a wallet: - # stm.wallet.unlock("secret_password") - tx = TransactionBuilder(hive_instance=stm) + # hv.wallet.unlock("secret_password") + tx = TransactionBuilder(hive_instance=hv) ops = [] op = operations.Transfer(**{"from": 'user_a', "to": 'user_b', diff --git a/examples/accout_reputation_by_SP.py b/examples/accout_reputation_by_SP.py index 715befe2..0097ac29 100644 --- a/examples/accout_reputation_by_SP.py +++ b/examples/accout_reputation_by_SP.py @@ -10,13 +10,13 @@ import matplotlib.pyplot as plt if __name__ == "__main__": - stm = Hive() - price = Amount(stm.get_current_median_history()["base"]) + hv = Hive() + price = Amount(hv.get_current_median_history()["base"]) reps = [0] for i in range(26, 91): reps.append(int(10**((i - 25) / 9 + 9))) # reps = np.logspace(9, 16, 60) - used_power = stm._calc_resulting_vote() + used_power = hv._calc_resulting_vote() last_hp = 0 hp_list = [] rep_score_list = [] @@ -25,7 +25,7 @@ if __name__ == "__main__": rep_score_list.append(score) needed_rshares = int(goal_rep) << 6 needed_vests = needed_rshares / used_power / 100 - needed_hp = stm.vests_to_hp(needed_vests) + needed_hp = hv.vests_to_hp(needed_vests) hp_list.append(needed_hp / 1000) # print("| %.1f | %.2f | %.2f | " % (score, needed_hp / 1000, needed_hp / 1000 - last_hp / 1000)) last_hp = needed_hp diff --git a/examples/benchmark_beem.py b/examples/benchmark_beem.py index 3f5ebae9..542a043e 100644 --- a/examples/benchmark_beem.py +++ b/examples/benchmark_beem.py @@ -22,23 +22,23 @@ if __name__ == "__main__": how_many_hours = 1 nodes = NodeList() if node_setup == 0: - stm = Hive(node=nodes.get_nodes(normal=True, wss=True), num_retries=10) + hv = Hive(node=nodes.get_nodes(normal=True, wss=True), num_retries=10) max_batch_size = None threading = False thread_num = 8 elif node_setup == 1: - stm = Hive(node=nodes.get_nodes(normal=True, wss=True), num_retries=10) + hv = Hive(node=nodes.get_nodes(normal=True, wss=True), num_retries=10) max_batch_size = None threading = True thread_num = 16 elif node_setup == 2: - stm = Hive(node=nodes.get_nodes(appbase=False, https=False), num_retries=10) + hv = Hive(node=nodes.get_nodes(appbase=False, https=False), num_retries=10) max_batch_size = None threading = True thread_num = 16 - blockchain = Blockchain(hive_instance=stm) + blockchain = Blockchain(hive_instance=hv) last_block_id = 19273700 - last_block = Block(last_block_id, hive_instance=stm) + last_block = Block(last_block_id, hive_instance=hv) startTime = datetime.now() stopTime = last_block.time() + timedelta(seconds=how_many_hours * 60 * 60) diff --git a/examples/benchmark_nodes.py b/examples/benchmark_nodes.py index 34454482..6efe0300 100644 --- a/examples/benchmark_nodes.py +++ b/examples/benchmark_nodes.py @@ -32,14 +32,14 @@ if __name__ == "__main__": for node in nodes: print("Current node:", node) try: - stm = Hive(node=node, num_retries=3) - blockchain = Blockchain(hive_instance=stm) - account = Account("gtg", hive_instance=stm) + hv = Hive(node=node, num_retries=3) + blockchain = Blockchain(hive_instance=hv) + account = Account("gtg", hive_instance=hv) virtual_op_count = account.virtual_op_count() - blockchain_version = stm.get_blockchain_version() + blockchain_version = hv.get_blockchain_version() last_block_id = 19273700 - last_block = Block(last_block_id, hive_instance=stm) + last_block = Block(last_block_id, hive_instance=hv) startTime = datetime.now() stopTime = last_block.time() + timedelta(seconds=how_many_minutes * 60) diff --git a/examples/benchmark_nodes2.py b/examples/benchmark_nodes2.py index 8bdcec00..6b161096 100644 --- a/examples/benchmark_nodes2.py +++ b/examples/benchmark_nodes2.py @@ -48,11 +48,11 @@ def benchmark_node(node, how_many_minutes=10, how_many_seconds=30): authorperm = construct_authorperm(author, permlink) last_block_id = 19273700 try: - stm = Hive(node=node, num_retries=3, num_retries_call=3, timeout=30) - blockchain = Blockchain(hive_instance=stm) - blockchain_version = stm.get_blockchain_version() + hv = Hive(node=node, num_retries=3, num_retries_call=3, timeout=30) + blockchain = Blockchain(hive_instance=hv) + blockchain_version = hv.get_blockchain_version() - last_block = Block(last_block_id, hive_instance=stm) + last_block = Block(last_block_id, hive_instance=hv) stopTime = last_block.time() + timedelta(seconds=how_many_minutes * 60) total_transaction = 0 @@ -90,9 +90,9 @@ def benchmark_node(node, how_many_minutes=10, how_many_seconds=30): block_count = -1 try: - stm = Hive(node=node, num_retries=3, num_retries_call=3, timeout=30) - account = Account("gtg", hive_instance=stm) - blockchain_version = stm.get_blockchain_version() + hv = Hive(node=node, num_retries=3, num_retries_call=3, timeout=30) + account = Account("gtg", hive_instance=hv) + blockchain_version = hv.get_blockchain_version() start = timer() for acc_op in account.history_reverse(batch_size=100): @@ -114,20 +114,20 @@ def benchmark_node(node, how_many_minutes=10, how_many_seconds=30): successful = False try: - stm = Hive(node=node, num_retries=3, num_retries_call=3, timeout=30) - account = Account("gtg", hive_instance=stm) - blockchain_version = stm.get_blockchain_version() + hv = Hive(node=node, num_retries=3, num_retries_call=3, timeout=30) + account = Account("gtg", hive_instance=hv) + blockchain_version = hv.get_blockchain_version() start = timer() - Vote(authorpermvoter, hive_instance=stm) + Vote(authorpermvoter, hive_instance=hv) stop = timer() vote_time = stop - start start = timer() - Comment(authorperm, hive_instance=stm) + Comment(authorperm, hive_instance=hv) stop = timer() comment_time = stop - start start = timer() - Account(author, hive_instance=stm) + Account(author, hive_instance=hv) stop = timer() account_time = stop - start start = timer() @@ -200,7 +200,7 @@ if __name__ == "__main__": print("\n") print("Total benchmark time: %.2f s\n" % (timer() - benchmark_time)) if set_default_nodes: - stm = Hive(offline=True) - stm.set_default_nodes(working_nodes) + hv = Hive(offline=True) + hv.set_default_nodes(working_nodes) else: print("beempy set nodes " + str(working_nodes)) diff --git a/examples/cache_performance.py b/examples/cache_performance.py index f05f88f4..1d1997f6 100644 --- a/examples/cache_performance.py +++ b/examples/cache_performance.py @@ -17,8 +17,8 @@ log = logging.getLogger(__name__) logging.basicConfig(level=logging.INFO) -def stream_votes(stm, threading, thread_num): - b = Blockchain(hive_instance=stm) +def stream_votes(hv, threading, thread_num): + b = Blockchain(hive_instance=hv) opcount = 0 start_time = time.time() for op in b.stream(start=23483000, stop=23485000, threading=threading, thread_num=thread_num, @@ -43,11 +43,11 @@ if __name__ == "__main__": vote_result = [] duration = [] - stm = Hive(node=node_list, timeout=timeout) - b = Blockchain(hive_instance=stm) + hv = Hive(node=node_list, timeout=timeout) + b = Blockchain(hive_instance=hv) block = b.get_current_block() block.set_cache_auto_clean(False) - opcount, total_duration = stream_votes(stm, threading, thread_num) + opcount, total_duration = stream_votes(hv, threading, thread_num) print("Finished!") block.set_cache_auto_clean(True) cache_len = len(list(block._cache)) diff --git a/examples/compare_transactions_speed_with_hive.py b/examples/compare_transactions_speed_with_hive.py index 6a0bbc2b..2264b282 100644 --- a/examples/compare_transactions_speed_with_hive.py +++ b/examples/compare_transactions_speed_with_hive.py @@ -44,7 +44,7 @@ class BeemTest(object): self.ref_block_num = 34294 self.ref_block_prefix = 3707022213 self.expiration = "2016-04-06T08:29:27" - self.stm = Hive(offline=True) + self.hv = Hive(offline=True) def doit(self, printWire=False, ops=None): ops = [Operation(ops)] diff --git a/examples/compare_with_hive_python_account.py b/examples/compare_with_hive_python_account.py index 98baade5..206e1d5f 100644 --- a/examples/compare_with_hive_python_account.py +++ b/examples/compare_with_hive_python_account.py @@ -16,10 +16,10 @@ logging.basicConfig(level=logging.INFO) if __name__ == "__main__": - stm = Hive("https://api.hiveit.com") - beem_acc = Account("thecrazygm", hive_instance=stm) - stm2 = hiveHive(nodes=["https://api.hiveit.com"]) - hive_acc = hiveAccount("thecrazygm", hived_instance=stm2) + hv = Hive("https://api.hiveit.com") + beem_acc = Account("thecrazygm", hive_instance=hv) + hv2 = hiveHive(nodes=["https://api.hiveit.com"]) + hive_acc = hiveAccount("thecrazygm", hived_instance=hv2) # profile print("beem_acc.profile {}".format(beem_acc.profile)) diff --git a/examples/hf20_testnet.py b/examples/hf20_testnet.py index 55fa8a4b..7e8af750 100644 --- a/examples/hf20_testnet.py +++ b/examples/hf20_testnet.py @@ -22,12 +22,12 @@ logging.basicConfig(level=logging.INFO) if __name__ == "__main__": - # stm = Hive(node="https://testnet.timcliff.com/") - # stm = Hive(node="https://testnet.hiveitdev.com") - stm = Hive(node="https://api.hiveit.com") - stm.wallet.unlock(pwd="pwd123") + # hv = Hive(node="https://testnet.timcliff.com/") + # hv = Hive(node="https://testnet.hiveitdev.com") + hv = Hive(node="https://api.hiveit.com") + hv.wallet.unlock(pwd="pwd123") - account = Account("beembot", hive_instance=stm) + account = Account("beembot", hive_instance=hv) print(account.get_voting_power()) account.transfer("thecrazygm", 0.001, "HBD", "test") diff --git a/examples/memory_profiler1.py b/examples/memory_profiler1.py index 01d74f2e..b0baf7a8 100644 --- a/examples/memory_profiler1.py +++ b/examples/memory_profiler1.py @@ -17,9 +17,9 @@ logging.basicConfig(level=logging.INFO) @profile def profiling(name_list): - stm = Hive() - set_shared_hive_instance(stm) - del stm + hv = Hive() + set_shared_hive_instance(hv) + del hv print("start") for name in name_list: print("account: %s" % (name)) diff --git a/examples/memory_profiler2.py b/examples/memory_profiler2.py index 7b355c5a..8c1ed94f 100644 --- a/examples/memory_profiler2.py +++ b/examples/memory_profiler2.py @@ -17,13 +17,13 @@ def profiling(node, name_list, shared_instance=True, clear_acc_cache=False, clea print("shared_instance %d clear_acc_cache %d clear_all_cache %d" % (shared_instance, clear_acc_cache, clear_all_cache)) if not shared_instance: - stm = Hive(node=node) - print(str(stm)) + hv = Hive(node=node) + print(str(hv)) else: - stm = None + hv = None acc_dict = {} for name in name_list: - acc = Account(name, hive_instance=stm) + acc = Account(name, hive_instance=hv) acc_dict[name] = acc if clear_acc_cache: acc.clear_cache() @@ -31,13 +31,13 @@ def profiling(node, name_list, shared_instance=True, clear_acc_cache=False, clea if clear_all_cache: clear_cache() if not shared_instance: - del stm.rpc + del hv.rpc if __name__ == "__main__": - stm = Hive() - print("Shared instance: " + str(stm)) - set_shared_hive_instance(stm) + hv = Hive() + print("Shared instance: " + str(hv)) + set_shared_hive_instance(hv) b = Blockchain() account_list = [] for a in b.get_all_accounts(limit=500): diff --git a/examples/next_witness_block_coundown.py b/examples/next_witness_block_coundown.py index b917b0f5..0dc9ad7a 100644 --- a/examples/next_witness_block_coundown.py +++ b/examples/next_witness_block_coundown.py @@ -27,22 +27,22 @@ if __name__ == "__main__": witness = "thecrazygm" else: witness = sys.argv[1] - stm = Hive() - witness = Witness(witness, hive_instance=stm) + hv = Hive() + witness = Witness(witness, hive_instance=hv) - witness_schedule = stm.get_witness_schedule() - config = stm.get_config() + witness_schedule = hv.get_witness_schedule() + config = hv.get_config() if "VIRTUAL_SCHEDULE_LAP_LENGTH2" in config: lap_length = int(config["VIRTUAL_SCHEDULE_LAP_LENGTH2"]) else: lap_length = int(config["HIVE_VIRTUAL_SCHEDULE_LAP_LENGTH2"]) - witnesses = WitnessesRankedByVote(limit=250, hive_instance=stm) + witnesses = WitnessesRankedByVote(limit=250, hive_instance=hv) vote_sum = witnesses.get_votes_sum() virtual_time_to_block_num = int(witness_schedule["num_scheduled_witnesses"]) / (lap_length / (vote_sum + 1)) while True: witness.refresh() - witness_schedule = stm.get_witness_schedule(use_stored_data=False) + witness_schedule = hv.get_witness_schedule(use_stored_data=False) witness_json = witness.json() virtual_diff = int(witness_json["virtual_scheduled_time"]) - int(witness_schedule['current_virtual_time']) diff --git a/examples/op_on_testnet.py b/examples/op_on_testnet.py index 0f95b26e..b988c026 100644 --- a/examples/op_on_testnet.py +++ b/examples/op_on_testnet.py @@ -27,13 +27,13 @@ walletpassword = "123" if __name__ == "__main__": testnet_node = "https://testnet.hive.vc" - stm = Hive(node=testnet_node) - prefix = stm.prefix + hv = Hive(node=testnet_node) + prefix = hv.prefix # curl --data "username=username&password=secretPassword" https://testnet.hive.vc/create if useWallet: - stm.wallet.wipe(True) - stm.wallet.create(walletpassword) - stm.wallet.unlock(walletpassword) + hv.wallet.wipe(True) + hv.wallet.create(walletpassword) + hv.wallet.unlock(walletpassword) active_key = PasswordKey(username, password, role="active", prefix=prefix) owner_key = PasswordKey(username, password, role="owner", prefix=prefix) posting_key = PasswordKey(username, password, role="posting", prefix=prefix) @@ -47,16 +47,16 @@ if __name__ == "__main__": owner_privkey = owner_key.get_private_key() memo_privkey = memo_key.get_private_key() if useWallet: - stm.wallet.addPrivateKey(owner_privkey) - stm.wallet.addPrivateKey(active_privkey) - stm.wallet.addPrivateKey(memo_privkey) - stm.wallet.addPrivateKey(posting_privkey) + hv.wallet.addPrivateKey(owner_privkey) + hv.wallet.addPrivateKey(active_privkey) + hv.wallet.addPrivateKey(memo_privkey) + hv.wallet.addPrivateKey(posting_privkey) else: - stm = Hive(node=testnet_node, + hv = Hive(node=testnet_node, wif={'active': str(active_privkey), 'posting': str(posting_privkey), 'memo': str(memo_privkey)}) - account = Account(username, hive_instance=stm) + account = Account(username, hive_instance=hv) if account["name"] == "beem": account.disallow("beem1", permission='posting') account.allow('beem1', weight=1, permission='posting', account=None) @@ -64,13 +64,13 @@ if __name__ == "__main__": elif account["name"] == "beem5": account.allow('beem4', weight=2, permission='active', account=None) if useWallet: - stm.wallet.getAccountFromPrivateKey(str(active_privkey)) + hv.wallet.getAccountFromPrivateKey(str(active_privkey)) - # stm.create_account("beem1", creator=account, password=password1) + # hv.create_account("beem1", creator=account, password=password1) - account1 = Account("beem1", hive_instance=stm) - b = Blockchain(hive_instance=stm) + account1 = Account("beem1", hive_instance=hv) + b = Blockchain(hive_instance=hv) blocknum = b.get_current_block().identifier account.transfer("beem1", 1, "HBD", "test") - b1 = Block(blocknum, hive_instance=stm) + b1 = Block(blocknum, hive_instance=hv) diff --git a/examples/print_appbase_calls.py b/examples/print_appbase_calls.py index 31035825..6c26d0c2 100644 --- a/examples/print_appbase_calls.py +++ b/examples/print_appbase_calls.py @@ -15,26 +15,26 @@ logging.basicConfig(level=logging.INFO) if __name__ == "__main__": - stm = Hive(node="https://api.hiveit.com") - # stm = Hive(node="https://testnet.hiveitdev.com") - # stm = Hive(node="wss://appbasetest.timcliff.com") - # stm = Hive(node="https://api.hiveitstage.com") - # stm = Hive(node="https://api.hiveitdev.com") - all_calls = stm.rpc.get_methods(api="jsonrpc") + hv = Hive(node="https://api.hiveit.com") + # hv = Hive(node="https://testnet.hiveitdev.com") + # hv = Hive(node="wss://appbasetest.timcliff.com") + # hv = Hive(node="https://api.hiveitstage.com") + # hv = Hive(node="https://api.hiveitdev.com") + all_calls = hv.rpc.get_methods(api="jsonrpc") t = PrettyTable(["method", "args", "ret"]) t.align = "l" t_condenser = PrettyTable(["method", "args", "ret"]) t_condenser.align = "l" for call in all_calls: if "condenser" not in call: - ret = stm.rpc.get_signature({'method': call}, api="jsonrpc") + ret = hv.rpc.get_signature({'method': call}, api="jsonrpc") t.add_row([ call, ret['args'], ret['ret'] ]) else: - ret = stm.rpc.get_signature({'method': call}, api="jsonrpc") + ret = hv.rpc.get_signature({'method': call}, api="jsonrpc") t_condenser.add_row([ call, ret['args'], diff --git a/examples/stream_threading_performance.py b/examples/stream_threading_performance.py index a483cfb8..2cdd18ac 100644 --- a/examples/stream_threading_performance.py +++ b/examples/stream_threading_performance.py @@ -17,8 +17,8 @@ log = logging.getLogger(__name__) logging.basicConfig(level=logging.INFO) -def stream_votes(stm, threading, thread_num): - b = Blockchain(hive_instance=stm) +def stream_votes(hv, threading, thread_num): + b = Blockchain(hive_instance=hv) opcount = 0 start_time = time.time() for op in b.stream(start=23483000, stop=23483200, threading=threading, thread_num=thread_num, @@ -43,18 +43,18 @@ if __name__ == "__main__": vote_result = [] duration = [] - stm_wss = Hive(node=node_list_wss, timeout=timeout) - stm_https = Hive(node=node_list_https, timeout=timeout) + hv_wss = Hive(node=node_list_wss, timeout=timeout) + hv_https = Hive(node=node_list_https, timeout=timeout) print("Without threading wss") - opcount_wot_wss, total_duration_wot_wss = stream_votes(stm_wss, False, 8) + opcount_wot_wss, total_duration_wot_wss = stream_votes(hv_wss, False, 8) print("Without threading https") - opcount_wot_https, total_duration_wot_https = stream_votes(stm_https, False, 8) + opcount_wot_https, total_duration_wot_https = stream_votes(hv_https, False, 8) if threading: print("\n Threading with %d threads is activated now." % thread_num) - stm = Hive(node=node_list_wss, timeout=timeout) - opcount_wss, total_duration_wss = stream_votes(stm, threading, thread_num) - opcount_https, total_duration_https = stream_votes(stm, threading, thread_num) + hv = Hive(node=node_list_wss, timeout=timeout) + opcount_wss, total_duration_wss = stream_votes(hv, threading, thread_num) + opcount_https, total_duration_https = stream_votes(hv, threading, thread_num) print("Finished!") print("Results:") diff --git a/examples/using_custom_chain.py b/examples/using_custom_chain.py index 0a0ea703..73bd0780 100644 --- a/examples/using_custom_chain.py +++ b/examples/using_custom_chain.py @@ -22,7 +22,7 @@ logging.basicConfig(level=logging.INFO) if __name__ == "__main__": - stm = Hive(node=["https://testnet.hiveitdev.com"], + hv = Hive(node=["https://testnet.hiveitdev.com"], custom_chains={"TESTNETHF20": {'chain_assets': [ @@ -33,5 +33,5 @@ if __name__ == "__main__": 'chain_id': '46d82ab7d8db682eb1959aed0ada039a6d49afa1602491f93dde9cac3e8e6c32', 'min_version': '0.20.0', 'prefix': 'TST'}}) - print(stm.get_blockchain_version()) - print(stm.get_config()["HIVE_CHAIN_ID"]) + print(hv.get_blockchain_version()) + print(hv.get_config()["HIVE_CHAIN_ID"]) diff --git a/examples/using_steem_offline.py b/examples/using_steem_offline.py index e206a2ee..35e2788f 100644 --- a/examples/using_steem_offline.py +++ b/examples/using_steem_offline.py @@ -28,17 +28,17 @@ wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" if __name__ == "__main__": - stm_online = Hive() - ref_block_num, ref_block_prefix = getBlockParams(stm_online) + hv_online = Hive() + ref_block_num, ref_block_prefix = getBlockParams(hv_online) print("ref_block_num %d - ref_block_prefix %d" % (ref_block_num, ref_block_prefix)) - stm = Hive(offline=True) + hv = Hive(offline=True) op = operations.Transfer({'from': 'beembot', 'to': 'thecrazygm', 'amount': "0.001 HBD", 'memo': ""}) - tb = TransactionBuilder(hive_instance=stm) + tb = TransactionBuilder(hive_instance=hv) tb.appendOps([op]) tb.appendWif(wif) diff --git a/tests/beem/test_account.py b/tests/beem/test_account.py index de18e906..87668f94 100644 --- a/tests/beem/test_account.py +++ b/tests/beem/test_account.py @@ -43,13 +43,13 @@ class Testcases(unittest.TestCase): set_shared_hive_instance(cls.bts) def test_account(self): - stm = self.bts + hv = self.bts account = self.account - Account("beembot", hive_instance=stm) + Account("beembot", hive_instance=hv) with self.assertRaises( exceptions.AccountDoesNotExistsException ): - Account("DoesNotExistsXXX", hive_instance=stm) + Account("DoesNotExistsXXX", hive_instance=hv) # asset = Asset("1.3.0") # symbol = asset["symbol"] self.assertEqual(account.name, "beembot") @@ -173,8 +173,8 @@ class Testcases(unittest.TestCase): self.assertEqual(h_list[-1][1]['block'], h_all_raw[-2 + zero_element][1]['block']) def test_history2(self): - stm = self.bts - account = Account("beembot", hive_instance=stm) + hv = self.bts + account = Account("beembot", hive_instance=hv) h_list = [] max_index = account.virtual_op_count() for h in account.history(start=max_index - 4, stop=max_index, use_block_num=False, batch_size=2, raw_output=False): @@ -205,8 +205,8 @@ class Testcases(unittest.TestCase): self.assertEqual(h_list[i][0] - h_list[i - 1][0], 1) def test_history_reverse2(self): - stm = self.bts - account = Account("beembot", hive_instance=stm) + hv = self.bts + account = Account("beembot", hive_instance=hv) h_list = [] max_index = account.virtual_op_count() for h in account.history_reverse(start=max_index, stop=max_index - 4, use_block_num=False, batch_size=2, raw_output=False): @@ -237,9 +237,9 @@ class Testcases(unittest.TestCase): self.assertEqual(h_list[i][0] - h_list[i - 1][0], -1) def test_history_block_num(self): - stm = self.bts + hv = self.bts zero_element = 0 - account = Account("fullnodeupdate", hive_instance=stm) + account = Account("fullnodeupdate", hive_instance=hv) h_all_raw = [] for h in account.history_reverse(raw_output=True): h_all_raw.append(h) @@ -424,10 +424,10 @@ class Testcases(unittest.TestCase): self.assertEqual(content[k], json_content[k]) def test_estimate_virtual_op_num(self): - stm = self.bts - account = Account("gtg", hive_instance=stm) + hv = self.bts + account = Account("gtg", hive_instance=hv) block_num = 21248120 - block = Block(block_num, hive_instance=stm) + block = Block(block_num, hive_instance=hv) op_num1 = account.estimate_virtual_op_num(block.time(), stop_diff=1, max_count=100) op_num2 = account.estimate_virtual_op_num(block_num, stop_diff=1, max_count=100) op_num3 = account.estimate_virtual_op_num(block_num, stop_diff=100, max_count=100) @@ -462,8 +462,8 @@ class Testcases(unittest.TestCase): last_block = new_block def test_history_votes(self): - stm = self.bts - account = Account("gtg", hive_instance=stm) + hv = self.bts + account = Account("gtg", hive_instance=hv) utc = pytz.timezone('UTC') limit_time = utc.localize(datetime.utcnow()) - timedelta(days=2) votes_list = [] diff --git a/tests/beem/test_amount.py b/tests/beem/test_amount.py index 7a750112..a5b78b3d 100644 --- a/tests/beem/test_amount.py +++ b/tests/beem/test_amount.py @@ -42,56 +42,56 @@ class Testcases(unittest.TestCase): self.assertIsInstance(ret["amount"], Decimal) def test_init(self): - stm = self.bts + hv = self.bts # String init - asset = Asset("HBD", hive_instance=stm) + asset = Asset("HBD", hive_instance=hv) symbol = asset["symbol"] precision = asset["precision"] - amount = Amount("1 {}".format(symbol), hive_instance=stm) + amount = Amount("1 {}".format(symbol), hive_instance=hv) self.dotest(amount, 1, symbol) # Amount init - amount = Amount(amount, hive_instance=stm) + amount = Amount(amount, hive_instance=hv) self.dotest(amount, 1, symbol) # blockchain dict init amount = Amount({ "amount": 1 * 10 ** precision, "asset_id": asset["id"] - }, hive_instance=stm) + }, hive_instance=hv) self.dotest(amount, 1, symbol) # API dict init amount = Amount({ "amount": 1.3 * 10 ** precision, "asset": asset["id"] - }, hive_instance=stm) + }, hive_instance=hv) self.dotest(amount, 1.3, symbol) # Asset as symbol - amount = Amount(1.3, Asset("HBD"), hive_instance=stm) + amount = Amount(1.3, Asset("HBD"), hive_instance=hv) self.dotest(amount, 1.3, symbol) # Asset as symbol - amount = Amount(1.3, symbol, hive_instance=stm) + amount = Amount(1.3, symbol, hive_instance=hv) self.dotest(amount, 1.3, symbol) # keyword inits - amount = Amount(amount=1.3, asset=Asset("HBD", hive_instance=stm), hive_instance=stm) + amount = Amount(amount=1.3, asset=Asset("HBD", hive_instance=hv), hive_instance=hv) self.dotest(amount, 1.3, symbol) - amount = Amount(amount=1.3001, asset=Asset("HBD", hive_instance=stm), hive_instance=stm) + amount = Amount(amount=1.3001, asset=Asset("HBD", hive_instance=hv), hive_instance=hv) self.dotest(amount, 1.3001, symbol) - amount = Amount(amount=1.3001, asset=Asset("HBD", hive_instance=stm), fixed_point_arithmetic=True, hive_instance=stm) + amount = Amount(amount=1.3001, asset=Asset("HBD", hive_instance=hv), fixed_point_arithmetic=True, hive_instance=hv) self.dotest(amount, 1.3, symbol) # keyword inits - amount = Amount(amount=1.3, asset=dict(Asset("HBD", hive_instance=stm)), hive_instance=stm) + amount = Amount(amount=1.3, asset=dict(Asset("HBD", hive_instance=hv)), hive_instance=hv) self.dotest(amount, 1.3, symbol) # keyword inits - amount = Amount(amount=1.3, asset=symbol, hive_instance=stm) + amount = Amount(amount=1.3, asset=symbol, hive_instance=hv) self.dotest(amount, 1.3, symbol) def test_copy(self): diff --git a/tests/beem/test_asset.py b/tests/beem/test_asset.py index 60333e3c..d133e8c6 100644 --- a/tests/beem/test_asset.py +++ b/tests/beem/test_asset.py @@ -36,11 +36,11 @@ class Testcases(unittest.TestCase): ]) def test_assert(self, node_param): if node_param == "normal": - stm = self.bts + hv = self.bts else: - stm = self.hiveit + hv = self.hiveit with self.assertRaises(AssetDoesNotExistsException): - Asset("FOObarNonExisting", full=False, hive_instance=stm) + Asset("FOObarNonExisting", full=False, hive_instance=hv) @parameterized.expand([ ("normal", "HBD", "HBD", 3, "@@000000013"), @@ -52,10 +52,10 @@ class Testcases(unittest.TestCase): ]) def test_properties(self, node_param, data, symbol_str, precision, asset_str): if node_param == "normal": - stm = self.bts + hv = self.bts else: - stm = self.testnet - asset = Asset(data, full=False, hive_instance=stm) + hv = self.testnet + asset = Asset(data, full=False, hive_instance=hv) self.assertEqual(asset.symbol, symbol_str) self.assertEqual(asset.precision, precision) self.assertEqual(asset.asset, asset_str) @@ -66,22 +66,22 @@ class Testcases(unittest.TestCase): ]) def test_assert_equal(self, node_param): if node_param == "normal": - stm = self.bts + hv = self.bts else: - stm = self.hiveit - asset1 = Asset("HBD", full=False, hive_instance=stm) - asset2 = Asset("HBD", full=False, hive_instance=stm) + hv = self.hiveit + asset1 = Asset("HBD", full=False, hive_instance=hv) + asset2 = Asset("HBD", full=False, hive_instance=hv) self.assertTrue(asset1 == asset2) self.assertTrue(asset1 == "HBD") self.assertTrue(asset2 == "HBD") - asset3 = Asset("HIVE", full=False, hive_instance=stm) + asset3 = Asset("HIVE", full=False, hive_instance=hv) self.assertTrue(asset1 != asset3) self.assertTrue(asset3 != "HBD") self.assertTrue(asset1 != "HIVE") a = {'asset': '@@000000021', 'precision': 3, 'id': 'HIVE', 'symbol': 'HIVE'} b = {'asset': '@@000000021', 'precision': 3, 'id': '@@000000021', 'symbol': 'HIVE'} - self.assertTrue(Asset(a, hive_instance=stm) == Asset(b, hive_instance=stm)) + self.assertTrue(Asset(a, hive_instance=hv) == Asset(b, hive_instance=hv)) """ # Mocker comes from pytest-mock, providing an easy way to have patched objects diff --git a/tests/beem/test_cli.py b/tests/beem/test_cli.py index daed9e30..56611968 100644 --- a/tests/beem/test_cli.py +++ b/tests/beem/test_cli.py @@ -32,8 +32,8 @@ class Testcases(unittest.TestCase): nodelist.update_nodes(hive_instance=Steem(node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) cls.node_list = nodelist.get_nodes(exclude_limited=True) - # stm = shared_hive_instance() - # stm.config.refreshBackup() + # hv = shared_hive_instance() + # hv.config.refreshBackup() runner = CliRunner() result = runner.invoke(cli, ['-o', 'set', 'default_vote_weight', '100']) if result.exit_code != 0: @@ -59,8 +59,8 @@ class Testcases(unittest.TestCase): @classmethod def tearDownClass(cls): - stm = shared_hive_instance() - stm.config.recover_with_latest_backup() + hv = shared_hive_instance() + hv.config.recover_with_latest_backup() def test_balance(self): runner = CliRunner() diff --git a/tests/beem/test_connection.py b/tests/beem/test_connection.py index 1a18794a..b91d192e 100644 --- a/tests/beem/test_connection.py +++ b/tests/beem/test_connection.py @@ -11,7 +11,7 @@ log = logging.getLogger() class Testcases(unittest.TestCase): - def test_stm1stm2(self): + def test_hv1hv2(self): nodelist = NodeList() nodelist.update_nodes(hive_instance=Steem(node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) b1 = Steem( diff --git a/tests/beem/test_constants.py b/tests/beem/test_constants.py index 0b0debfd..c5467699 100644 --- a/tests/beem/test_constants.py +++ b/tests/beem/test_constants.py @@ -32,8 +32,8 @@ class Testcases(unittest.TestCase): ) def test_constants(self): - stm = self.appbase - hive_conf = stm.get_config() + hv = self.appbase + hive_conf = hv.get_config() if "HIVE_100_PERCENT" in hive_conf: HIVE_100_PERCENT = hive_conf['HIVE_100_PERCENT'] else: diff --git a/tests/beem/test_conveyor.py b/tests/beem/test_conveyor.py index 54102518..27ad8771 100644 --- a/tests/beem/test_conveyor.py +++ b/tests/beem/test_conveyor.py @@ -16,9 +16,9 @@ class Testcases(unittest.TestCase): @classmethod def setUpClass(cls): nodelist = NodeList() - stm = Steem(node=nodelist.get_nodes(), nobroadcast=True, + hv = Steem(node=nodelist.get_nodes(), nobroadcast=True, num_retries=10, expiration=120) - set_shared_hive_instance(stm) + set_shared_hive_instance(hv) def test_healthcheck(self): health = Conveyor().healthcheck() diff --git a/tests/beem/test_instance.py b/tests/beem/test_instance.py index 3ce51c49..473a05d6 100644 --- a/tests/beem/test_instance.py +++ b/tests/beem/test_instance.py @@ -40,10 +40,10 @@ class Testcases(unittest.TestCase): def setUpClass(cls): cls.nodelist = NodeList() cls.nodelist.update_nodes(hive_instance=Steem(node=cls.nodelist.get_nodes(exclude_limited=False), num_retries=10)) - stm = Steem(node=cls.nodelist.get_nodes()) - stm.config.refreshBackup() - stm.set_default_nodes(["xyz"]) - del stm + hv = Steem(node=cls.nodelist.get_nodes()) + hv.config.refreshBackup() + hv.set_default_nodes(["xyz"]) + del hv cls.urls = cls.nodelist.get_nodes(exclude_limited=True) cls.bts = Steem( @@ -61,8 +61,8 @@ class Testcases(unittest.TestCase): @classmethod def tearDownClass(cls): - stm = Steem(node=cls.nodelist.get_nodes()) - stm.config.recover_with_latest_backup() + hv = Steem(node=cls.nodelist.get_nodes()) + hv.config.recover_with_latest_backup() @parameterized.expand([ ("instance"), @@ -80,8 +80,8 @@ class Testcases(unittest.TestCase): Account("test", hive_instance=Steem(node="https://abc.d", autoconnect=False, num_retries=1)) else: set_shared_hive_instance(Steem(node="https://abc.d", autoconnect=False, num_retries=1)) - stm = self.bts - acc = Account("test", hive_instance=stm) + hv = self.bts + acc = Account("test", hive_instance=hv) self.assertIn(acc.hive.rpc.url, self.urls) self.assertIn(acc["balance"].hive.rpc.url, self.urls) with self.assertRaises( @@ -95,18 +95,18 @@ class Testcases(unittest.TestCase): ]) def test_amount(self, node_param): if node_param == "instance": - stm = Steem(node="https://abc.d", autoconnect=False, num_retries=1) + hv = Steem(node="https://abc.d", autoconnect=False, num_retries=1) set_shared_hive_instance(self.bts) o = Amount("1 HBD") self.assertIn(o.hive.rpc.url, self.urls) with self.assertRaises( RPCConnection ): - Amount("1 HBD", hive_instance=stm) + Amount("1 HBD", hive_instance=hv) else: set_shared_hive_instance(Steem(node="https://abc.d", autoconnect=False, num_retries=1)) - stm = self.bts - o = Amount("1 HBD", hive_instance=stm) + hv = self.bts + o = Amount("1 HBD", hive_instance=hv) self.assertIn(o.hive.rpc.url, self.urls) with self.assertRaises( RPCConnection @@ -128,8 +128,8 @@ class Testcases(unittest.TestCase): Block(1, hive_instance=Steem(node="https://abc.d", autoconnect=False, num_retries=1)) else: set_shared_hive_instance(Steem(node="https://abc.d", autoconnect=False, num_retries=1)) - stm = self.bts - o = Block(1, hive_instance=stm) + hv = self.bts + o = Block(1, hive_instance=hv) self.assertIn(o.hive.rpc.url, self.urls) with self.assertRaises( RPCConnection @@ -151,8 +151,8 @@ class Testcases(unittest.TestCase): Blockchain(hive_instance=Steem(node="https://abc.d", autoconnect=False, num_retries=1)) else: set_shared_hive_instance(Steem(node="https://abc.d", autoconnect=False, num_retries=1)) - stm = self.bts - o = Blockchain(hive_instance=stm) + hv = self.bts + o = Blockchain(hive_instance=hv) self.assertIn(o.hive.rpc.url, self.urls) with self.assertRaises( RPCConnection @@ -174,8 +174,8 @@ class Testcases(unittest.TestCase): Comment(self.authorperm, hive_instance=Steem(node="https://abc.d", autoconnect=False, num_retries=1)) else: set_shared_hive_instance(Steem(node="https://abc.d", autoconnect=False, num_retries=1)) - stm = self.bts - o = Comment(self.authorperm, hive_instance=stm) + hv = self.bts + o = Comment(self.authorperm, hive_instance=hv) self.assertIn(o.hive.rpc.url, self.urls) with self.assertRaises( RPCConnection @@ -197,8 +197,8 @@ class Testcases(unittest.TestCase): Market(hive_instance=Steem(node="https://abc.d", autoconnect=False, num_retries=1)) else: set_shared_hive_instance(Steem(node="https://abc.d", autoconnect=False, num_retries=1)) - stm = self.bts - o = Market(hive_instance=stm) + hv = self.bts + o = Market(hive_instance=hv) self.assertIn(o.hive.rpc.url, self.urls) with self.assertRaises( RPCConnection @@ -220,8 +220,8 @@ class Testcases(unittest.TestCase): Price(10.0, "HIVE/HBD", hive_instance=Steem(node="https://abc.d", autoconnect=False, num_retries=1)) else: set_shared_hive_instance(Steem(node="https://abc.d", autoconnect=False, num_retries=1)) - stm = self.bts - o = Price(10.0, "HIVE/HBD", hive_instance=stm) + hv = self.bts + o = Price(10.0, "HIVE/HBD", hive_instance=hv) self.assertIn(o.hive.rpc.url, self.urls) with self.assertRaises( RPCConnection @@ -243,8 +243,8 @@ class Testcases(unittest.TestCase): Vote(self.authorpermvoter, hive_instance=Steem(node="https://abc.d", autoconnect=False, num_retries=1)) else: set_shared_hive_instance(Steem(node="https://abc.d", autoconnect=False, num_retries=1)) - stm = self.bts - o = Vote(self.authorpermvoter, hive_instance=stm) + hv = self.bts + o = Vote(self.authorpermvoter, hive_instance=hv) self.assertIn(o.hive.rpc.url, self.urls) with self.assertRaises( RPCConnection @@ -267,8 +267,8 @@ class Testcases(unittest.TestCase): o.hive.get_config() else: set_shared_hive_instance(Steem(node="https://abc.d", autoconnect=False, num_retries=1)) - stm = self.bts - o = Wallet(hive_instance=stm) + hv = self.bts + o = Wallet(hive_instance=hv) self.assertIn(o.hive.rpc.url, self.urls) with self.assertRaises( RPCConnection @@ -291,8 +291,8 @@ class Testcases(unittest.TestCase): Witness("gtg", hive_instance=Steem(node="https://abc.d", autoconnect=False, num_retries=1)) else: set_shared_hive_instance(Steem(node="https://abc.d", autoconnect=False, num_retries=1)) - stm = self.bts - o = Witness("gtg", hive_instance=stm) + hv = self.bts + o = Witness("gtg", hive_instance=hv) self.assertIn(o.hive.rpc.url, self.urls) with self.assertRaises( RPCConnection @@ -315,8 +315,8 @@ class Testcases(unittest.TestCase): o.hive.get_config() else: set_shared_hive_instance(Steem(node="https://abc.d", autoconnect=False, num_retries=1)) - stm = self.bts - o = TransactionBuilder(hive_instance=stm) + hv = self.bts + o = TransactionBuilder(hive_instance=hv) self.assertIn(o.hive.rpc.url, self.urls) with self.assertRaises( RPCConnection @@ -337,19 +337,19 @@ class Testcases(unittest.TestCase): with self.assertRaises( RPCConnection ): - stm = Steem(node="https://abc.d", autoconnect=False, num_retries=1) - stm.get_config() + hv = Steem(node="https://abc.d", autoconnect=False, num_retries=1) + hv.get_config() else: set_shared_hive_instance(Steem(node="https://abc.d", autoconnect=False, num_retries=1)) - stm = self.bts - o = stm + hv = self.bts + o = hv o.get_config() self.assertIn(o.rpc.url, self.urls) with self.assertRaises( RPCConnection ): - stm = shared_hive_instance() - stm.get_config() + hv = shared_hive_instance() + hv.get_config() def test_config(self): set_shared_config({"node": self.urls}) diff --git a/tests/beem/test_steem.py b/tests/beem/test_steem.py index 779700ee..2362e707 100644 --- a/tests/beem/test_steem.py +++ b/tests/beem/test_steem.py @@ -401,39 +401,39 @@ class Testcases(unittest.TestCase): self.assertTrue(bts.get_blockchain_version() is not None) def test_hp_to_rshares(self): - stm = self.bts - rshares = stm.hp_to_rshares(stm.vests_to_hp(1e6)) + hv = self.bts + rshares = hv.hp_to_rshares(hv.vests_to_hp(1e6)) self.assertTrue(abs(rshares - 20000000000.0) < 2) def test_rshares_to_vests(self): - stm = self.bts - rshares = stm.hp_to_rshares(stm.vests_to_hp(1e6)) - rshares2 = stm.vests_to_rshares(1e6) + hv = self.bts + rshares = hv.hp_to_rshares(hv.vests_to_hp(1e6)) + rshares2 = hv.vests_to_rshares(1e6) self.assertTrue(abs(rshares - rshares2) < 2) def test_hp_to_hbd(self): - stm = self.bts + hv = self.bts hp = 500 - ret = stm.hp_to_hbd(hp) + ret = hv.hp_to_hbd(hp) self.assertTrue(ret is not None) def test_hbd_to_rshares(self): - stm = self.bts + hv = self.bts test_values = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7] for v in test_values: try: - hbd = round(stm.rshares_to_hbd(stm.hbd_to_rshares(v)), 5) + hbd = round(hv.rshares_to_hbd(hv.hbd_to_rshares(v)), 5) except ValueError: # Reward pool smaller than 1e7 HBD (e.g. caused by a very low hive price) continue self.assertEqual(hbd, v) def test_rshares_to_vote_pct(self): - stm = self.bts + hv = self.bts hp = 1000 voting_power = 9000 for vote_pct in range(500, 10000, 500): - rshares = stm.hp_to_rshares(hp, voting_power=voting_power, vote_pct=vote_pct) - vote_pct_ret = stm.rshares_to_vote_pct(rshares, hive_power=hp, voting_power=voting_power) + rshares = hv.hp_to_rshares(hp, voting_power=voting_power, vote_pct=vote_pct) + vote_pct_ret = hv.rshares_to_vote_pct(rshares, hive_power=hp, voting_power=voting_power) self.assertEqual(vote_pct_ret, vote_pct) def test_sign(self): diff --git a/tests/beem/test_storage.py b/tests/beem/test_storage.py index a06cae95..0ad0c175 100644 --- a/tests/beem/test_storage.py +++ b/tests/beem/test_storage.py @@ -30,12 +30,12 @@ wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" class Testcases(unittest.TestCase): @classmethod def setUpClass(cls): - stm = shared_hive_instance() - stm.config.refreshBackup() + hv = shared_hive_instance() + hv.config.refreshBackup() nodelist = NodeList() nodelist.update_nodes(hive_instance=Steem(node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) - cls.stm = Steem( + cls.hv = Steem( node=nodelist.get_nodes(exclude_limited=True), nobroadcast=True, # We want to bundle many operations into a single transaction @@ -44,11 +44,11 @@ class Testcases(unittest.TestCase): # Overwrite wallet to use this list of wifs only ) - cls.stm.set_default_account("test") - set_shared_hive_instance(cls.stm) - # self.stm.newWallet("TestingOneTwoThree") + cls.hv.set_default_account("test") + set_shared_hive_instance(cls.hv) + # self.hv.newWallet("TestingOneTwoThree") - cls.wallet = Wallet(hive_instance=cls.stm) + cls.wallet = Wallet(hive_instance=cls.hv) cls.wallet.wipe(True) cls.wallet.newWallet(pwd="TestingOneTwoThree") cls.wallet.unlock(pwd="TestingOneTwoThree") @@ -56,11 +56,11 @@ class Testcases(unittest.TestCase): @classmethod def tearDownClass(cls): - stm = shared_hive_instance() - stm.config.recover_with_latest_backup() + hv = shared_hive_instance() + hv.config.recover_with_latest_backup() def test_set_default_account(self): - stm = self.stm - stm.set_default_account("beembot") + hv = self.hv + hv.set_default_account("beembot") - self.assertEqual(stm.config["default_account"], "beembot") + self.assertEqual(hv.config["default_account"], "beembot") diff --git a/tests/beem/test_testnet.py b/tests/beem/test_testnet.py index e23a4143..18e15dc5 100644 --- a/tests/beem/test_testnet.py +++ b/tests/beem/test_testnet.py @@ -41,8 +41,8 @@ class Testcases(unittest.TestCase): @classmethod def setUpClass(cls): nodelist = NodeList() - # stm = shared_hive_instance() - # stm.config.refreshBackup() + # hv = shared_hive_instance() + # hv.config.refreshBackup() # nodes = nodelist.get_testnet() cls.nodes = nodelist.get_nodes() cls.bts = Steem( @@ -72,45 +72,45 @@ class Testcases(unittest.TestCase): super().__init__(*args, **kwargs) raise unittest.SkipTest() - stm = self.bts - stm.nobroadcast = True - stm.wallet.wipe(True) - stm.wallet.create("123") - stm.wallet.unlock("123") - - stm.wallet.addPrivateKey(self.active_key1) - stm.wallet.addPrivateKey(self.memo_key1) - stm.wallet.addPrivateKey(self.posting_key1) - - stm.wallet.addPrivateKey(self.active_key) - stm.wallet.addPrivateKey(self.memo_key) - stm.wallet.addPrivateKey(self.posting_key) - stm.wallet.addPrivateKey(self.active_private_key_of_beem4) - stm.wallet.addPrivateKey(self.active_private_key_of_beem5) + hv = self.bts + hv.nobroadcast = True + hv.wallet.wipe(True) + hv.wallet.create("123") + hv.wallet.unlock("123") + + hv.wallet.addPrivateKey(self.active_key1) + hv.wallet.addPrivateKey(self.memo_key1) + hv.wallet.addPrivateKey(self.posting_key1) + + hv.wallet.addPrivateKey(self.active_key) + hv.wallet.addPrivateKey(self.memo_key) + hv.wallet.addPrivateKey(self.posting_key) + hv.wallet.addPrivateKey(self.active_private_key_of_beem4) + hv.wallet.addPrivateKey(self.active_private_key_of_beem5) @classmethod def tearDownClass(cls): - stm = shared_hive_instance() - stm.config.recover_with_latest_backup() + hv = shared_hive_instance() + hv.config.recover_with_latest_backup() def test_wallet_keys(self): - stm = self.bts - stm.wallet.unlock("123") - priv_key = stm.wallet.getPrivateKeyForPublicKey(str(PrivateKey(self.posting_key, prefix=stm.prefix).pubkey)) + hv = self.bts + hv.wallet.unlock("123") + priv_key = hv.wallet.getPrivateKeyForPublicKey(str(PrivateKey(self.posting_key, prefix=hv.prefix).pubkey)) self.assertEqual(str(priv_key), self.posting_key) - priv_key = stm.wallet.getKeyForAccount("beem", "active") + priv_key = hv.wallet.getKeyForAccount("beem", "active") self.assertEqual(str(priv_key), self.active_key) - priv_key = stm.wallet.getKeyForAccount("beem1", "posting") + priv_key = hv.wallet.getKeyForAccount("beem1", "posting") self.assertEqual(str(priv_key), self.posting_key1) - priv_key = stm.wallet.getPrivateKeyForPublicKey(str(PrivateKey(self.active_private_key_of_beem4, prefix=stm.prefix).pubkey)) + priv_key = hv.wallet.getPrivateKeyForPublicKey(str(PrivateKey(self.active_private_key_of_beem4, prefix=hv.prefix).pubkey)) self.assertEqual(str(priv_key), self.active_private_key_of_beem4) - priv_key = stm.wallet.getKeyForAccount("beem4", "active") + priv_key = hv.wallet.getKeyForAccount("beem4", "active") self.assertEqual(str(priv_key), self.active_private_key_of_beem4) - priv_key = stm.wallet.getPrivateKeyForPublicKey(str(PrivateKey(self.active_private_key_of_beem5, prefix=stm.prefix).pubkey)) + priv_key = hv.wallet.getPrivateKeyForPublicKey(str(PrivateKey(self.active_private_key_of_beem5, prefix=hv.prefix).pubkey)) self.assertEqual(str(priv_key), self.active_private_key_of_beem5) - priv_key = stm.wallet.getKeyForAccount("beem5", "active") + priv_key = hv.wallet.getKeyForAccount("beem5", "active") self.assertEqual(str(priv_key), self.active_private_key_of_beem5) def test_transfer(self): @@ -324,14 +324,14 @@ class Testcases(unittest.TestCase): new_tx.broadcast() def test_verifyAuthority(self): - stm = self.bts - stm.wallet.unlock("123") - tx = TransactionBuilder(use_condenser_api=True, hive_instance=stm) + hv = self.bts + hv.wallet.unlock("123") + tx = TransactionBuilder(use_condenser_api=True, hive_instance=hv) tx.appendOps(Transfer(**{"from": "beem", "to": "beem1", - "amount": Amount("1.300 HBD", hive_instance=stm), + "amount": Amount("1.300 HBD", hive_instance=hv), "memo": "Foobar"})) - account = Account("beem", hive_instance=stm) + account = Account("beem", hive_instance=hv) tx.appendSigner(account, "active") self.assertTrue(len(tx.wifs) > 0) tx.sign() @@ -519,14 +519,14 @@ class Testcases(unittest.TestCase): def test_appendWif(self): nodelist = NodeList() - stm = Steem(node=self.nodes, + hv = Steem(node=self.nodes, nobroadcast=True, expiration=120, num_retries=10) - tx = TransactionBuilder(use_condenser_api=True, hive_instance=stm) + tx = TransactionBuilder(use_condenser_api=True, hive_instance=hv) tx.appendOps(Transfer(**{"from": "beem", "to": "beem1", - "amount": Amount("1 HIVE", hive_instance=stm), + "amount": Amount("1 HIVE", hive_instance=hv), "memo": ""})) with self.assertRaises( MissingKeyError @@ -542,17 +542,17 @@ class Testcases(unittest.TestCase): def test_appendSigner(self): nodelist = NodeList() - stm = Steem(node=self.nodes, + hv = Steem(node=self.nodes, keys=[self.active_key], nobroadcast=True, expiration=120, num_retries=10) - tx = TransactionBuilder(use_condenser_api=True, hive_instance=stm) + tx = TransactionBuilder(use_condenser_api=True, hive_instance=hv) tx.appendOps(Transfer(**{"from": "beem", "to": "beem1", - "amount": Amount("1 HIVE", hive_instance=stm), + "amount": Amount("1 HIVE", hive_instance=hv), "memo": ""})) - account = Account("beem", hive_instance=stm) + account = Account("beem", hive_instance=hv) with self.assertRaises( AssertionError ): @@ -564,17 +564,17 @@ class Testcases(unittest.TestCase): def test_verifyAuthorityException(self): nodelist = NodeList() - stm = Steem(node=self.nodes, + hv = Steem(node=self.nodes, keys=[self.posting_key], nobroadcast=True, expiration=120, num_retries=10) - tx = TransactionBuilder(use_condenser_api=True, hive_instance=stm) + tx = TransactionBuilder(use_condenser_api=True, hive_instance=hv) tx.appendOps(Transfer(**{"from": "beem", "to": "beem1", - "amount": Amount("1 HIVE", hive_instance=stm), + "amount": Amount("1 HIVE", hive_instance=hv), "memo": ""})) - account = Account("beem2", hive_instance=stm) + account = Account("beem2", hive_instance=hv) tx.appendSigner(account, "active") tx.appendWif(self.posting_key) self.assertTrue(len(tx.wifs) > 0) @@ -587,35 +587,35 @@ class Testcases(unittest.TestCase): def test_Transfer_broadcast(self): nodelist = NodeList() - stm = Steem(node=self.nodes, + hv = Steem(node=self.nodes, keys=[self.active_key], nobroadcast=True, expiration=120, num_retries=10) - tx = TransactionBuilder(use_condenser_api=True, expiration=10, hive_instance=stm) + tx = TransactionBuilder(use_condenser_api=True, expiration=10, hive_instance=hv) tx.appendOps(Transfer(**{"from": "beem", "to": "beem1", - "amount": Amount("1 HIVE", hive_instance=stm), + "amount": Amount("1 HIVE", hive_instance=hv), "memo": ""})) tx.appendSigner("beem", "active") tx.sign() tx.broadcast() def test_TransactionConstructor(self): - stm = self.bts + hv = self.bts opTransfer = Transfer(**{"from": "beem", "to": "beem1", - "amount": Amount("1 HIVE", hive_instance=stm), + "amount": Amount("1 HIVE", hive_instance=hv), "memo": ""}) - tx1 = TransactionBuilder(use_condenser_api=True, hive_instance=stm) + tx1 = TransactionBuilder(use_condenser_api=True, hive_instance=hv) tx1.appendOps(opTransfer) - tx = TransactionBuilder(tx1, hive_instance=stm) + tx = TransactionBuilder(tx1, hive_instance=hv) self.assertFalse(tx.is_empty()) self.assertTrue(len(tx.list_operations()) == 1) self.assertTrue(repr(tx) is not None) self.assertTrue(str(tx) is not None) - account = Account("beem", hive_instance=stm) + account = Account("beem", hive_instance=hv) tx.appendSigner(account, "active") self.assertTrue(len(tx.wifs) > 0) tx.sign() @@ -624,20 +624,20 @@ class Testcases(unittest.TestCase): def test_follow_active_key(self): nodelist = NodeList() - stm = Steem(node=self.nodes, + hv = Steem(node=self.nodes, keys=[self.active_key], nobroadcast=True, expiration=120, num_retries=10) - account = Account("beem", hive_instance=stm) + account = Account("beem", hive_instance=hv) account.follow("beem1") def test_follow_posting_key(self): nodelist = NodeList() - stm = Steem(node=self.nodes, + hv = Steem(node=self.nodes, keys=[self.posting_key], nobroadcast=True, expiration=120, num_retries=10) - account = Account("beem", hive_instance=stm) + account = Account("beem", hive_instance=hv) account.follow("beem1") diff --git a/tests/beem/test_txbuffers.py b/tests/beem/test_txbuffers.py index 0afb0612..ad6a7d10 100644 --- a/tests/beem/test_txbuffers.py +++ b/tests/beem/test_txbuffers.py @@ -34,7 +34,7 @@ class Testcases(unittest.TestCase): nodelist = NodeList() nodelist.update_nodes(hive_instance=Steem(node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) node_list = nodelist.get_nodes(exclude_limited=True) - cls.stm = Steem( + cls.hv = Steem( node=node_list, keys={"active": wif, "owner": wif, "memo": wif}, nobroadcast=True, @@ -46,20 +46,20 @@ class Testcases(unittest.TestCase): keys={"active": wif, "owner": wif, "memo": wif}, num_retries=10 ) - set_shared_hive_instance(cls.stm) - cls.stm.set_default_account("test") + set_shared_hive_instance(cls.hv) + cls.hv.set_default_account("test") def test_emptyTransaction(self): - stm = self.stm - tx = TransactionBuilder(hive_instance=stm) + hv = self.hv + tx = TransactionBuilder(hive_instance=hv) self.assertTrue(tx.is_empty()) self.assertTrue(tx["ref_block_num"] is not None) def test_verify_transaction(self): - stm = self.stm - block = Block(22005665, hive_instance=stm) + hv = self.hv + block = Block(22005665, hive_instance=hv) trx = block.transactions[28] signed_tx = Signed_Transaction(trx) - key = signed_tx.verify(chain=stm.chain_params, recover_parameter=False) - public_key = format(Base58(key[0]), stm.prefix) + key = signed_tx.verify(chain=hv.chain_params, recover_parameter=False) + public_key = format(Base58(key[0]), hv.prefix) self.assertEqual(public_key, "STM4tzr1wjmuov9ftXR6QNv7qDWsbShMBPQpuwatZsfSc5pKjRDfq") diff --git a/tests/beem/test_wallet.py b/tests/beem/test_wallet.py index e708c285..2c253b8d 100644 --- a/tests/beem/test_wallet.py +++ b/tests/beem/test_wallet.py @@ -21,12 +21,12 @@ wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" class Testcases(unittest.TestCase): @classmethod def setUpClass(cls): - stm = shared_hive_instance() - stm.config.refreshBackup() + hv = shared_hive_instance() + hv.config.refreshBackup() nodelist = NodeList() nodelist.update_nodes(hive_instance=Steem(node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) - cls.stm = Steem( + cls.hv = Steem( node=nodelist.get_nodes(exclude_limited=True), nobroadcast=True, # We want to bundle many operations into a single transaction @@ -34,11 +34,11 @@ class Testcases(unittest.TestCase): num_retries=10 # Overwrite wallet to use this list of wifs only ) - cls.stm.set_default_account("test") - set_shared_hive_instance(cls.stm) - # self.stm.newWallet("TestingOneTwoThree") + cls.hv.set_default_account("test") + set_shared_hive_instance(cls.hv) + # self.hv.newWallet("TestingOneTwoThree") - cls.wallet = Wallet(hive_instance=cls.stm) + cls.wallet = Wallet(hive_instance=cls.hv) cls.wallet.wipe(True) cls.wallet.newWallet(pwd="TestingOneTwoThree") cls.wallet.unlock(pwd="TestingOneTwoThree") @@ -46,12 +46,12 @@ class Testcases(unittest.TestCase): @classmethod def tearDownClass(cls): - stm = shared_hive_instance() - stm.config.recover_with_latest_backup() + hv = shared_hive_instance() + hv.config.recover_with_latest_backup() def test_wallet_lock(self): - stm = self.stm - self.wallet.hive = stm + hv = self.hv + self.wallet.hive = hv self.wallet.unlock(pwd="TestingOneTwoThree") self.assertTrue(self.wallet.unlocked()) self.assertFalse(self.wallet.locked()) @@ -59,8 +59,8 @@ class Testcases(unittest.TestCase): self.assertTrue(self.wallet.locked()) def test_change_masterpassword(self): - stm = self.stm - self.wallet.hive = stm + hv = self.hv + self.wallet.hive = hv self.wallet.unlock(pwd="TestingOneTwoThree") self.assertTrue(self.wallet.unlocked()) self.wallet.changePassphrase("newPass") @@ -72,8 +72,8 @@ class Testcases(unittest.TestCase): self.wallet.lock() def test_Keys(self): - stm = self.stm - self.wallet.hive = stm + hv = self.hv + self.wallet.hive = hv self.wallet.unlock(pwd="TestingOneTwoThree") keys = self.wallet.getPublicKeys() self.assertTrue(len(keys) > 0) @@ -82,8 +82,8 @@ class Testcases(unittest.TestCase): self.assertEqual(private, wif) def test_account_by_pub(self): - stm = self.stm - self.wallet.hive = stm + hv = self.hv + self.wallet.hive = hv self.wallet.unlock(pwd="TestingOneTwoThree") acc = Account("gtg") pub = acc["owner"]["key_auths"][0][0] @@ -102,8 +102,8 @@ class Testcases(unittest.TestCase): self.assertEqual(pub, acc_by_pub_list[0]["pubkey"]) def test_pub_lookup(self): - stm = self.stm - self.wallet.hive = stm + hv = self.hv + self.wallet.hive = hv self.wallet.unlock(pwd="TestingOneTwoThree") with self.assertRaises( exceptions.MissingKeyError @@ -123,8 +123,8 @@ class Testcases(unittest.TestCase): self.wallet.getPostingKeyForAccount("test") def test_pub_lookup_keys(self): - stm = self.stm - self.wallet.hive = stm + hv = self.hv + self.wallet.hive = hv self.wallet.unlock(pwd="TestingOneTwoThree") with self.assertRaises( exceptions.MissingKeyError @@ -140,8 +140,8 @@ class Testcases(unittest.TestCase): self.wallet.getPostingKeysForAccount("test") def test_encrypt(self): - stm = self.stm - self.wallet.hive = stm + hv = self.hv + self.wallet.hive = hv self.wallet.unlock(pwd="TestingOneTwoThree") self.wallet.masterpassword = "TestingOneTwoThree" self.assertEqual([self.wallet.encrypt_wif("5HqUkGuo62BfcJU5vNhTXKJRXuUi9QSE6jp8C3uBJ2BVHtB8WSd"), @@ -154,8 +154,8 @@ class Testcases(unittest.TestCase): self.wallet.masterpassword = "TestingOneTwoThree" def test_deencrypt(self): - stm = self.stm - self.wallet.hive = stm + hv = self.hv + self.wallet.hive = hv self.wallet.unlock(pwd="TestingOneTwoThree") self.wallet.masterpassword = "TestingOneTwoThree" self.assertEqual([self.wallet.decrypt_wif("6PRN5mjUTtud6fUXbJXezfn6oABoSr6GSLjMbrGXRZxSUcxThxsUW8epQi"), diff --git a/tests/beemapi/test_websocket.py b/tests/beemapi/test_websocket.py index 057b3221..3df13f28 100644 --- a/tests/beemapi/test_websocket.py +++ b/tests/beemapi/test_websocket.py @@ -27,10 +27,10 @@ class Testcases(unittest.TestCase): super().__init__(*args, **kwargs) nodelist = NodeList() nodelist.update_nodes(hive_instance=Steem(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10)) - stm = Steem(node=nodelist.get_nodes()) + hv = Steem(node=nodelist.get_nodes()) self.ws = SteemWebsocket( - urls=stm.rpc.nodes, + urls=hv.rpc.nodes, num_retries=10 ) diff --git a/tests/beembase/test_transactions.py b/tests/beembase/test_transactions.py index 931679c2..e4fadbf3 100644 --- a/tests/beembase/test_transactions.py +++ b/tests/beembase/test_transactions.py @@ -43,7 +43,7 @@ class Testcases(unittest.TestCase): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.stm = Steem( + self.hv = Steem( offline=True ) @@ -82,7 +82,7 @@ class Testcases(unittest.TestCase): self.op = operations.Transfer(**{ "from": "foo", "to": "baar", - "amount": Amount("111.110 HIVE", hive_instance=self.stm), + "amount": Amount("111.110 HIVE", hive_instance=self.hv), "memo": "Fooo", "prefix": default_prefix }) @@ -236,7 +236,7 @@ class Testcases(unittest.TestCase): "from": "testuser", "to": "testuser", "amount": "1.000 HIVE", - "memo": "testmemo", + "memo": "tehvemo", "prefix": default_prefix }) self.cm = ( -- GitLab