chainlib

Generic blockchain access library and tooling
Log | Files | Refs | README | LICENSE

commit b1096ba20a46fadee35e63682ead3ab0603df39f
parent 3b1388f28e2f43a1c1969521f3435cebadfd9839
Author: lash <dev@holbrook.no>
Date:   Sat,  5 Aug 2023 17:21:21 +0100

Add interactive passphrase input for keyfile

Diffstat:
MCHANGELOG | 3+++
Mchainlib/cli/arg.py | 1+
Mchainlib/cli/config.py | 3+++
Msetup.cfg | 2+-
Mtests/test_cli.py | 1+
5 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG b/CHANGELOG @@ -1,3 +1,6 @@ +- 0.4.18 + * Add interactive passphrase input when missing for keyfile dependent actions + * Add -z flag to indicate empty passphrase - 0.4.17 * Replace pysha3 with safe-pysha3 - 0.4.16 diff --git a/chainlib/cli/arg.py b/chainlib/cli/arg.py @@ -134,6 +134,7 @@ class Arg(BaseArg): self.add('y', 'key_file', help='Keystore file to use for signing or address') self.set_long('y', 'key_file') + self.add('z', 'key_file', typ=bool, help='No password to unlock keystore file') self.add_long('passphrase-file', 'key_file', help='Keystore file to use for signing or address') self.add('s', 'send', typ=bool, help='Send to network') diff --git a/chainlib/cli/config.py b/chainlib/cli/config.py @@ -81,6 +81,9 @@ def process_config(config, arg, args, flags, positional_name=None): f = open(fp, 'r') args_override['WALLET_PASSPHRASE'] = f.read() f.close() + elif not args.z: + import getpass + args_override['WALLET_PASSPHRASE'] = getpass.getpass('wallet passphrase: ') config.censor('PASSPHRASE', 'WALLET') if arg.match('backend', flags): diff --git a/setup.cfg b/setup.cfg @@ -3,7 +3,7 @@ name=chainlib license=AGPLv3+ author_email=dev@holbrook.no description=Generic blockchain access library and tooling -version=0.4.17 +version=0.4.18 url=https://git.defalsify.org/chainlib author=Louis Holbrook diff --git a/tests/test_cli.py b/tests/test_cli.py @@ -118,6 +118,7 @@ class TestCli(unittest.TestCase): args = ap.parse_args([ '-y', 'foo', '-i', 'foo:bar:42:baz', + '-z', ]) config = Config()