Browse Source

Add --wallet-password-stdin

Related: Issue #409
master
cindiv 6 years ago
parent
commit
b83e27c391
  1. 16
      jmclient/jmclient/wallet_utils.py
  2. 6
      jmclient/jmclient/yieldgenerator.py
  3. 5
      scripts/cli_options.py
  4. 7
      scripts/receive-payjoin.py
  5. 4
      scripts/sendpayment.py
  6. 2
      scripts/tumbler.py

16
jmclient/jmclient/wallet_utils.py

@ -101,6 +101,13 @@ def get_wallettool_parser():
"if your address starts with '3' use 'segwit-p2sh.\n" "if your address starts with '3' use 'segwit-p2sh.\n"
"Native segwit addresses (starting with 'bc') are" "Native segwit addresses (starting with 'bc') are"
"not yet supported.")) "not yet supported."))
parser.add_option('--wallet-password-stdin',
action='store_true',
default=False,
dest='wallet_password_stdin',
help='Read wallet password from stdin')
return parser return parser
@ -1072,7 +1079,7 @@ def create_wallet(path, password, max_mixdepth, wallet_cls=None, **kwargs):
def open_test_wallet_maybe(path, seed, max_mixdepth, def open_test_wallet_maybe(path, seed, max_mixdepth,
test_wallet_cls=SegwitLegacyWallet, **kwargs): test_wallet_cls=SegwitLegacyWallet, wallet_password_stdin=False, **kwargs):
""" """
Create a volatile test wallet if path is a hex-encoded string of length 64, Create a volatile test wallet if path is a hex-encoded string of length 64,
otherwise run open_wallet(). otherwise run open_wallet().
@ -1114,6 +1121,11 @@ def open_test_wallet_maybe(path, seed, max_mixdepth,
del kwargs['read_only'] del kwargs['read_only']
return test_wallet_cls(storage, **kwargs) return test_wallet_cls(storage, **kwargs)
if wallet_password_stdin is True:
stdin = sys.stdin.read()
password = stdin.encode('utf-8')
return open_wallet(path, ask_for_password=False, password=password, mixdepth=max_mixdepth, **kwargs)
return open_wallet(path, mixdepth=max_mixdepth, **kwargs) return open_wallet(path, mixdepth=max_mixdepth, **kwargs)
@ -1220,7 +1232,7 @@ def wallet_tool_main(wallet_root_path):
wallet = open_test_wallet_maybe( wallet = open_test_wallet_maybe(
wallet_path, seed, options.mixdepth, read_only=read_only, wallet_path, seed, options.mixdepth, read_only=read_only,
gap_limit=options.gaplimit) wallet_password_stdin=options.wallet_password_stdin, gap_limit=options.gaplimit)
# this object is only to respect the layering, # this object is only to respect the layering,
# the service will not be started since this is a synchronous script: # the service will not be started since this is a synchronous script:

6
jmclient/jmclient/yieldgenerator.py

@ -220,6 +220,11 @@ def ygmain(ygclass, txfee=1000, cjfee_a=200, cjfee_r=0.002, ordertype='swreloffe
parser.add_option('-m', '--mixdepth', action='store', type='int', parser.add_option('-m', '--mixdepth', action='store', type='int',
dest='mixdepth', default=None, dest='mixdepth', default=None,
help="highest mixdepth to use") help="highest mixdepth to use")
parser.add_option('--wallet-password-stdin',
action='store_true',
default=False,
dest='wallet_password_stdin',
help='Read wallet password from stdin')
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
if len(args) < 1: if len(args) < 1:
parser.error('Needs a wallet') parser.error('Needs a wallet')
@ -248,6 +253,7 @@ def ygmain(ygclass, txfee=1000, cjfee_a=200, cjfee_r=0.002, ordertype='swreloffe
wallet_path = get_wallet_path(wallet_name, 'wallets') wallet_path = get_wallet_path(wallet_name, 'wallets')
wallet = open_test_wallet_maybe( wallet = open_test_wallet_maybe(
wallet_path, wallet_name, options.mixdepth, wallet_path, wallet_name, options.mixdepth,
wallet_password_stdin=options.wallet_password_stdin,
gap_limit=options.gaplimit) gap_limit=options.gaplimit)
wallet_service = WalletService(wallet) wallet_service = WalletService(wallet)

5
scripts/cli_options.py

@ -72,6 +72,11 @@ def add_common_options(parser):
.format('random_under_max_order_choose', .format('random_under_max_order_choose',
', '.join(order_choose_algorithms.keys())), ', '.join(order_choose_algorithms.keys())),
dest='order_choose_fn') dest='order_choose_fn')
parser.add_option('--wallet-password-stdin',
action='store_true',
default=False,
dest='wallet_password_stdin',
help='Read wallet password from stdin')
add_order_choose_short_options(parser) add_order_choose_short_options(parser)

7
scripts/receive-payjoin.py

@ -36,6 +36,12 @@ def receive_payjoin_main(makerclass):
dest='amtmixdepths', dest='amtmixdepths',
help='number of mixdepths in wallet, default 5', help='number of mixdepths in wallet, default 5',
default=5) default=5)
parser.add_option('--wallet-password-stdin',
action='store_true',
default=False,
dest='wallet_password_stdin',
help='Read wallet password from stdin')
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
if len(args) < 2: if len(args) < 2:
parser.error('Needs a wallet, and a receiving amount in satoshis') parser.error('Needs a wallet, and a receiving amount in satoshis')
@ -62,6 +68,7 @@ def receive_payjoin_main(makerclass):
max_mix_depth = max([options.mixdepth, options.amtmixdepths - 1]) max_mix_depth = max([options.mixdepth, options.amtmixdepths - 1])
wallet = open_test_wallet_maybe( wallet = open_test_wallet_maybe(
wallet_path, wallet_name, max_mix_depth, wallet_path, wallet_name, max_mix_depth,
wallet_password_stdin=options.wallet_password_stdin,
gap_limit=options.gaplimit) gap_limit=options.gaplimit)
if jm_single().config.get("BLOCKCHAIN", "blockchain_source") == "electrum-server": if jm_single().config.get("BLOCKCHAIN", "blockchain_source") == "electrum-server":

4
scripts/sendpayment.py

@ -131,7 +131,9 @@ def main():
wallet_path = get_wallet_path(wallet_name, None) wallet_path = get_wallet_path(wallet_name, None)
wallet = open_test_wallet_maybe( wallet = open_test_wallet_maybe(
wallet_path, wallet_name, max_mix_depth, gap_limit=options.gaplimit) wallet_path, wallet_name, max_mix_depth,
wallet_password_stdin=options.wallet_password_stdin,
gap_limit=options.gaplimit)
wallet_service = WalletService(wallet) wallet_service = WalletService(wallet)
# in this script, we need the wallet synced before # in this script, we need the wallet synced before
# logic processing for some paths, so do it now: # logic processing for some paths, so do it now:

2
scripts/tumbler.py

@ -41,7 +41,7 @@ def main():
if options['amtmixdepths'] > max_mix_depth: if options['amtmixdepths'] > max_mix_depth:
max_mix_depth = options['amtmixdepths'] max_mix_depth = options['amtmixdepths']
wallet_path = get_wallet_path(wallet_name, None) wallet_path = get_wallet_path(wallet_name, None)
wallet = open_test_wallet_maybe(wallet_path, wallet_name, max_mix_depth) wallet = open_test_wallet_maybe(wallet_path, wallet_name, max_mix_depth, wallet_password_stdin=options_org.wallet_password_stdin)
wallet_service = WalletService(wallet) wallet_service = WalletService(wallet)
# in this script, we need the wallet synced before # in this script, we need the wallet synced before
# logic processing for some paths, so do it now: # logic processing for some paths, so do it now:

Loading…
Cancel
Save