def setup(): remove_wallet_dir() gen_key(no_unmount=True) from mmgen.seed import SeedSource opt.hidden_incog_input_params = None opt.quiet = True opt.in_fmt = 'words' ss_in = SeedSource() opt.out_fmt = 'mmdat' opt.usr_randchars = 0 opt.hash_preset = '1' opt.set_by_user = ['hash_preset'] opt.passwd_file = os.path.join(tx_dir, key_fn) from mmgen.obj import MMGenWalletLabel opt.label = MMGenWalletLabel('Autosign Wallet') ss_out = SeedSource(ss=ss_in) ss_out.write_to_file(desc='autosign wallet', outdir=wallet_dir)
def setup(): remove_wallet_dir() gen_key(no_unmount=True) from mmgen.seed import SeedSource opt.hidden_incog_input_params = None opt.quiet = True opt.in_fmt = 'words' ss_in = SeedSource() opt.out_fmt = 'mmdat' opt.usr_randchars = 0 opt.hash_preset = '1' opt.set_by_user = ['hash_preset'] opt.passwd_file = os.path.join(tx_dir,key_fn) from mmgen.obj import MMGenWalletLabel opt.label = MMGenWalletLabel('Autosign Wallet') ss_out = SeedSource(ss=ss_in) ss_out.write_to_file(desc='autosign wallet',outdir=wallet_dir)
qmsg("This wallet's Seed ID: {}".format(ss_out.seed.sid.hl())) if invoked_as == 'passchg': if not (opt.force_update or [ k for k in ('passwd', 'hash_preset', 'label') if getattr(ss_out.ssdata, k) != getattr(ss_in.ssdata, k) ]): die( 1, 'Password, hash preset and label are unchanged. Taking no action') if invoked_as == 'passchg' and ss_in.infile.dirname == g.data_dir: m1 = yellow('Confirmation of default wallet update') m2 = 'update the default wallet' 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?'
else: ss_out = SeedSource(ss=ss_in,passchg=invoked_as=='passchg') if invoked_as == 'gen': qmsg("This wallet's Seed ID: {}".format(ss_out.seed.sid.hl())) if invoked_as == 'passchg': if not (opt.force_update or [k for k in ('passwd','hash_preset','label') if getattr(ss_out.ssdata,k) != getattr(ss_in.ssdata,k)]): die(1,'Password, hash preset and label are unchanged. Taking no action') if invoked_as == 'passchg' and ss_in.infile.dirname == g.data_dir: m1 = yellow('Confirmation of default wallet update') m2 = 'update the default wallet' 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?'
) } cmd_args = opt.opts.init(opts_data,opt_filter=opt_filter) if len(cmd_args) < nargs \ and not opt.hidden_incog_input_params and not opt.in_fmt: die(1,"An input file or input format must be specified") elif len(cmd_args) > nargs \ or (len(cmd_args) == nargs and opt.hidden_incog_input_params): msg("No input files may be specified" if invoked_as == "gen" else "Too many input files specified") opt.opts.usage() if cmd_args: check_infile(cmd_args[0]) if not invoked_as == "chk": do_license_msg() if invoked_as in ("conv","passchg"): msg(green("Processing input wallet")) ss_in = None if invoked_as == "gen" \ else SeedSource(*cmd_args,passchg=invoked_as=="passchg") if invoked_as == "chk": sys.exit() if invoked_as in ("conv","passchg"): msg(green("Processing output wallet")) ss_out = SeedSource(ss=ss_in,passchg=invoked_as=="passchg") ss_out.write_to_file()