chainlib

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

commit d24fea2d4f5fa4c0a5ff4feb6fcac8df4015d71a
parent d3f6d1138d4f3c7114f055026a40677c1dbd0c85
Author: lash <dev@holbrook.no>
Date:   Sun, 20 Feb 2022 18:27:00 +0000

Passphrase file in wallet key file

Diffstat:
MCHANGELOG | 4++++
Mchainlib/cli/arg.py | 1+
Mchainlib/cli/config.py | 10+++++++++-
Msetup.cfg | 2+-
4 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG @@ -1,3 +1,7 @@ +- 0.0.19 + * Passphrase file option to unlock keyfile for CLI tooling +- 0.0.18 + * Upgrade hexathon skipping buggy compact hex method - 0.0.17 * Add loglevel environment variable - 0.0.16 diff --git a/chainlib/cli/arg.py b/chainlib/cli/arg.py @@ -166,6 +166,7 @@ class ArgumentParser(argparse.ArgumentParser): self.add_argument('--seq', action='store_true', help='Use sequential rpc ids') if arg_flags & Flag.KEY_FILE: self.add_argument('-y', '--key-file', dest='y', type=str, help='Keystore file to use for signing or address') + self.add_argument('--passphrase-file', dest='passphrase_file', type=str, help='File containing passphrase for keystore') if arg_flags & Flag.SEND: self.add_argument('-s', '--send', dest='s', action='store_true', help='Send to network') if arg_flags & Flag.RAW: diff --git a/chainlib/cli/config.py b/chainlib/cli/config.py @@ -3,6 +3,7 @@ import logging import os import sys import re +import stat # external imports import confini @@ -213,7 +214,14 @@ class Config(confini.Config): args_override['CHAIN_SPEC'] = getattr(args, 'i') if arg_flags & Flag.KEY_FILE: args_override['WALLET_KEY_FILE'] = getattr(args, 'y') - + fp = getattr(args, 'passphrase_file') + if fp != None: + st = os.stat(fp) + if stat.S_IMODE(st.st_mode) & (stat.S_IRWXO | stat.S_IRWXG) > 0: + logg.warning('others than owner have access on password file') + f = open(fp, 'r') + args_override['WALLET_PASSPHRASE'] = f.read() + f.close() config.dict_override(args_override, 'cli args') if arg_flags & Flag.PROVIDER: diff --git a/setup.cfg b/setup.cfg @@ -3,7 +3,7 @@ name=chainlib license=WTFPL2 author_email=dev@holbrook.no description=Generic blockchain access library and tooling -version=0.0.18 +version=0.0.19 url=https://gitlab.com/chaintools/chainlib author=Louis Holbrook