diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5eb345617c58fdc9214ca7e2755981b5d8d3f2d8..6dd40c71ba68c9ce1d9781ee000ac0b194d61f9c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,9 +1,13 @@ Changelog ========= +0.23.6 +------ +* beempy --key key_list.json command can be used to set keys in beempy without using the wallet. + 0.23.5 ------ * Add missing diff_match_patch to requirements -* beempy download with providing a permlink will download all posts +* beempy download without providing a permlink will download all posts * Improve Yaml parsing 0.23.4 diff --git a/beem/cli.py b/beem/cli.py index 317e39701cd96c105e49785af77c675567454a08..073d5bf5b0efba0dc4d06b365ed66f2f88a3a039 100644 --- a/beem/cli.py +++ b/beem/cli.py @@ -109,6 +109,8 @@ def unlock_wallet(stm, password=None, allow_wif=True): return True if not stm.wallet.locked(): return True + if len(stm.wallet.keys) > 0: + return True password_storage = stm.config["password_storage"] if not password and KEYRING_AVAILABLE and password_storage == "keyring": password = keyring.get_password("beem", "wallet") @@ -182,6 +184,8 @@ def node_answer_time(node): '--steem', '-s', is_flag=True, default=False, help="Connect to the Steem blockchain") @click.option( '--hive', '-h', is_flag=True, default=False, help="Connect to the Hive blockchain") +@click.option( + '--keys', '-k', help="JSON file that contains account keys, when set, the wallet cannot be used.") @click.option( '--token', '-t', is_flag=True, default=False, help="Uses a hivesigner/steemconnect token to broadcast (only broadcast operation with posting permission)") @click.option( @@ -190,7 +194,7 @@ def node_answer_time(node): @click.option( '--verbose', '-v', default=3, help='Verbosity') @click.version_option(version=__version__) -def cli(node, offline, no_broadcast, no_wallet, unsigned, create_link, steem, hive, token, expires, verbose): +def cli(node, offline, no_broadcast, no_wallet, unsigned, create_link, steem, hive, keys, token, expires, verbose): # Logging log = logging.getLogger(__name__) @@ -203,7 +207,24 @@ def cli(node, offline, no_broadcast, no_wallet, unsigned, create_link, steem, hi ch.setLevel(getattr(logging, verbosity.upper())) ch.setFormatter(formatter) log.addHandler(ch) - + + keys_list = [] + autoconnect = False + if keys and keys != "": + if not os.path.isfile(keys): + raise Exception("File %s does not exist!" % keys) + with open(keys) as fp: + keyfile = fp.read() + if keyfile.find('\0') > 0: + with open(keys, encoding='utf-16') as fp: + keyfile = fp.read() + keyfile = ast.literal_eval(keyfile) + for account in keyfile: + for role in ["owner", "active", "posting", "memo"]: + if role in keyfile[account]: + keys_list.append(keyfile[account][role]) + if len(keys_list) > 0: + autoconnect = True if create_link: no_broadcast = True unsigned = True @@ -218,6 +239,7 @@ def cli(node, offline, no_broadcast, no_wallet, unsigned, create_link, steem, hi stm = Hive( node=node, nobroadcast=no_broadcast, + keys=keys_list, offline=offline, nowallet=no_wallet, unsigned=unsigned, @@ -228,13 +250,14 @@ def cli(node, offline, no_broadcast, no_wallet, unsigned, create_link, steem, hi num_retries=10, num_retries_call=3, timeout=15, - autoconnect=False + autoconnect=autoconnect ) else: stm = Steem( node=node, nobroadcast=no_broadcast, offline=offline, + keys=keys_list, nowallet=no_wallet, unsigned=unsigned, use_sc2=token, @@ -244,7 +267,7 @@ def cli(node, offline, no_broadcast, no_wallet, unsigned, create_link, steem, hi num_retries=10, num_retries_call=3, timeout=15, - autoconnect=False + autoconnect=autoconnect ) set_shared_blockchain_instance(stm) diff --git a/beem/version.py b/beem/version.py index aeb337e6b03e8f94fc986ff6cedb5604934cafc3..0ffc41134b688754a333b27cfcb9286f8d757dcc 100644 --- a/beem/version.py +++ b/beem/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.23.5' +version = '0.23.6' diff --git a/beem/wallet.py b/beem/wallet.py index f82a9d8b1da7850e46e291c1c7422d30b1e9e312..2fa65481c70d68b7e9e6a01c0b49e164211d214c 100644 --- a/beem/wallet.py +++ b/beem/wallet.py @@ -124,7 +124,7 @@ class Wallet(object): if "wif" in kwargs and "keys" not in kwargs: kwargs["keys"] = kwargs["wif"] master_password_set = False - if "keys" in kwargs: + if "keys" in kwargs and len(kwargs["keys"]) > 0: self.setKeys(kwargs["keys"]) else: """ If no keys are provided manually we load the SQLite diff --git a/beemapi/version.py b/beemapi/version.py index aeb337e6b03e8f94fc986ff6cedb5604934cafc3..0ffc41134b688754a333b27cfcb9286f8d757dcc 100644 --- a/beemapi/version.py +++ b/beemapi/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.23.5' +version = '0.23.6' diff --git a/beembase/version.py b/beembase/version.py index aeb337e6b03e8f94fc986ff6cedb5604934cafc3..0ffc41134b688754a333b27cfcb9286f8d757dcc 100644 --- a/beembase/version.py +++ b/beembase/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.23.5' +version = '0.23.6' diff --git a/beemgraphenebase/version.py b/beemgraphenebase/version.py index aeb337e6b03e8f94fc986ff6cedb5604934cafc3..0ffc41134b688754a333b27cfcb9286f8d757dcc 100644 --- a/beemgraphenebase/version.py +++ b/beemgraphenebase/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.23.5' +version = '0.23.6' diff --git a/docs/cli.rst b/docs/cli.rst index a1dc6ad542c8f423294b1e21e094bbdfa7c6dec6..58f54639453f052af0fd5248d674c90bc248bc68 100644 --- a/docs/cli.rst +++ b/docs/cli.rst @@ -26,6 +26,25 @@ To bypass password entry, you can set an environment variable ``UNLOCK``. UNLOCK=mysecretpassword beempy transfer <recipient_name> 100 STEEM +Using a key json file +--------------------- + +A key_file.json can be used to provide private keys to beempy: +:: + + { + "account_a": {"posting": "5xx", "active": "5xx"}, + "account_b": {"posting": "5xx"], + } + +with + +:: + + beempy --key key_file.json command + +When set, the wallet cannot be used. + Common Commands --------------- First, you may like to import your Steem account: diff --git a/setup.py b/setup.py index 6585cfe362ffaa9a6c50e7bb38fa22ef82bd50df..a80cdcf2683cafa5823c9bc191e3aa965e254d5f 100755 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ except LookupError: ascii = codecs.lookup('ascii') codecs.register(lambda name, enc=ascii: {True: enc}.get(name == 'mbcs')) -VERSION = '0.23.5' +VERSION = '0.23.6' tests_require = ['mock >= 2.0.0', 'pytest', 'pytest-mock', 'parameterized']