def get_seed_files(opt,args): # favor unencrypted seed sources first, as they don't require passwords u,e = SeedSourceUnenc,SeedSourceEnc ret = _pop_and_return(args,u.get_extensions()) from mmgen.filename import find_file_in_dir wf = find_file_in_dir(Wallet,g.data_dir) # Make this the first encrypted ss in the list if wf: ret.append(wf) ret += _pop_and_return(args,e.get_extensions()) if not (ret or opt.mmgen_keys_from_file or opt.keys_from_file): # or opt.use_wallet_dat die(1,'You must specify a seed or key source!') return ret
def get_seed_file(cmd_args, nargs, invoked_as=None): from mmgen.filename import find_file_in_dir from mmgen.seed import Wallet wf = find_file_in_dir(Wallet, g.data_dir) wd_from_opt = bool(opt.hidden_incog_input_params or opt.in_fmt) # have wallet data from opt? import mmgen.opts as opts if len(cmd_args) + (wd_from_opt or bool(wf)) < nargs: opts.usage() elif len(cmd_args) > nargs: opts.usage() elif len(cmd_args) == nargs and wf and invoked_as != 'gen': msg('Warning: overriding default wallet with user-supplied wallet') if cmd_args or wf: check_infile(cmd_args[0] if cmd_args else wf) return cmd_args[0] if cmd_args else (wf, None)[wd_from_opt]
def get_seed_file(cmd_args,nargs,invoked_as=None): from mmgen.filename import find_file_in_dir from mmgen.seed import Wallet wf = find_file_in_dir(Wallet,g.data_dir) wd_from_opt = bool(opt.hidden_incog_input_params or opt.in_fmt) # have wallet data from opt? import mmgen.opts as opts if len(cmd_args) + (wd_from_opt or bool(wf)) < nargs: if not wf: msg('No default wallet found, and no other seed source was specified') opts.usage() elif len(cmd_args) > nargs: opts.usage() elif len(cmd_args) == nargs and wf and invoked_as != 'gen': qmsg('Warning: overriding default wallet with user-supplied wallet') if cmd_args or wf: check_infile(cmd_args[0] if cmd_args else wf) return cmd_args[0] if cmd_args else (wf,None)[wd_from_opt]
confirm_or_exit(m1, m2, exit_msg='Password not changed') ss_out.write_to_file(desc='New wallet', outdir=g.data_dir) msg('Securely deleting old wallet') from subprocess import check_output, CalledProcessError sd_cmd = (['wipe', '-sf'], ['sdelete', '-p', '20'])[g.platform == 'win'] try: check_output(sd_cmd + [ss_in.infile.name]) except: ymsg("WARNING: '{}' command failed, using regular file delete instead". format(sd_cmd[0])) os.unlink(ss_in.infile.name) else: try: assert invoked_as == 'gen', 'dw' assert not opt.stdout, 'dw' assert not find_file_in_dir(Wallet, g.data_dir), 'dw' m = 'Make this wallet your default and move it to the data directory?' assert keypress_confirm(m, default_yes=True), 'dw' except Exception as e: if e[0] != 'dw': raise ss_out.write_to_file() else: ss_out.write_to_file(outdir=g.data_dir) if invoked_as == 'passchg': if ss_out.ssdata.passwd == ss_in.ssdata.passwd: msg('New and old passphrases are the same') else: msg('Wallet passphrase has changed') if ss_out.ssdata.hash_preset != ss_in.ssdata.hash_preset: msg("Hash preset has been changed to '{}'".format(
if invoked_as == 'passchg' and ss_in.infile.dirname == g.data_dir: confirm_or_exit(m1, m2, exit_msg='Password not changed') ss_out.write_to_file(desc='New wallet', outdir=g.data_dir) msg('Securely deleting old wallet') from subprocess import check_output, CalledProcessError sd_cmd = (['wipe', '-sf'], ['sdelete', '-p', '20'])[g.platform == 'win'] try: check_output(sd_cmd + [ss_in.infile.name]) except: msg( yellow( "WARNING: '%s' command failed, using regular file delete instead" % sd_cmd[0])) # msg('Command output: {}\nReturn value {}'.format(e.output,e.returncode)) os.unlink(ss_in.infile.name) elif invoked_as == 'gen' and not find_file_in_dir(Wallet,g.data_dir) \ and not opt.stdout and keypress_confirm(m3,default_yes=True): ss_out.write_to_file(outdir=g.data_dir) else: ss_out.write_to_file() if invoked_as == 'passchg': if ss_out.ssdata.passwd == ss_in.ssdata.passwd: msg('New and old passphrases are the same') else: msg('Wallet passphrase has changed') if ss_out.ssdata.hash_preset != ss_in.ssdata.hash_preset: msg("Hash preset has been changed to '{}'".format( ss_out.ssdata.hash_preset))
confirm_or_raise(m1,m2,exit_msg='Password not changed') ss_out.write_to_file(desc='New wallet',outdir=g.data_dir) msg('Securely deleting old wallet') from subprocess import check_output,CalledProcessError sd_cmd = (['wipe','-sf'],['sdelete','-p','20'])[g.platform=='win'] try: check_output(sd_cmd + [ss_in.infile.name]) except: ymsg("WARNING: '{}' command failed, using regular file delete instead".format(sd_cmd[0])) os.unlink(ss_in.infile.name) else: try: assert invoked_as == 'gen','dw' assert not opt.outdir,'dw' assert not opt.stdout,'dw' assert not find_file_in_dir(Wallet,g.data_dir),'dw' m = 'Make this wallet your default and move it to the data directory?' assert keypress_confirm(m,default_yes=True),'dw' except Exception as e: if e.args[0] != 'dw': raise ss_out.write_to_file() else: ss_out.write_to_file(outdir=g.data_dir) if invoked_as == 'passchg': if ss_out.ssdata.passwd == ss_in.ssdata.passwd: msg('New and old passphrases are the same') else: msg('Wallet passphrase has changed') if ss_out.ssdata.hash_preset != ss_in.ssdata.hash_preset: msg("Hash preset has been changed to '{}'".format(ss_out.ssdata.hash_preset))