80 lines
2.7 KiB
Python
Executable file
80 lines
2.7 KiB
Python
Executable file
#!/usr/bin/env python
|
|
#
|
|
# mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
|
|
# Copyright (C) 2013 by philemon <mmgen-py@yandex.com>
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
"""
|
|
mmgen-walletchk: Check integrity of a mmgen deterministic wallet, display
|
|
information about it and export seed and mnemonic data
|
|
"""
|
|
|
|
import sys
|
|
from mmgen.Opts import *
|
|
|
|
from mmgen.util import *
|
|
|
|
help_data = {
|
|
'prog_name': sys.argv[0].split("/")[-1],
|
|
'desc': """Check integrity of a %s deterministic wallet, display
|
|
its information and export seed and mnemonic data."""\
|
|
% g.proj_name,
|
|
'usage': "[opts] [filename]",
|
|
'options': """
|
|
-h, --help Print this help message
|
|
-d, --outdir d Specify an alternate directory 'd' for output
|
|
-e, --echo-passphrase Print passphrase to screen when typing it
|
|
-m, --export-mnemonic Export the wallet's mnemonic to file
|
|
-P, --passwd-file f Get passphrase from file 'f'
|
|
-q, --quiet Suppress warnings; overwrite files without prompting
|
|
-s, --export-seed Export the wallet's seed to file
|
|
-S, --stdout Print seed or mnemonic data to standard output
|
|
-v, --verbose Produce more verbose output
|
|
"""
|
|
}
|
|
|
|
short_opts = "hd:emP:qsSv"
|
|
long_opts = "help","outdir=","echo_passphrase","export_mnemonic",\
|
|
"passwd_file=","quiet","export_seed","stdout","verbose"
|
|
|
|
opts,cmd_args = process_opts(sys.argv,help_data,short_opts,long_opts)
|
|
if 'quiet' in opts: g.quiet = True
|
|
if 'verbose' in opts: g.verbose = True
|
|
|
|
# Argument sanity checks and processing:
|
|
check_opts(opts,long_opts)
|
|
|
|
if len(cmd_args) != 1: usage(help_data)
|
|
|
|
check_infile(cmd_args[0])
|
|
|
|
if 'export_mnemonic' in opts:
|
|
qmsg("Exporting mnemonic data to file by user request")
|
|
if 'export_seed' in opts:
|
|
qmsg("Exporting seed data to file by user request")
|
|
|
|
seed = get_seed_from_wallet(cmd_args[0], opts)
|
|
if seed: qmsg("Wallet is OK")
|
|
|
|
if 'export_mnemonic' in opts:
|
|
wl = get_default_wordlist()
|
|
|
|
from mmgen.mnemonic import get_mnemonic_from_seed
|
|
p = True if g.debug else False
|
|
mn = get_mnemonic_from_seed(seed, wl, g.default_wl, print_info=p)
|
|
|
|
write_mnemonic(mn, seed, opts)
|
|
|
|
if 'export_seed' in opts:
|
|
write_seed(seed, opts)
|