Skip to content
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.

Commit

Permalink
always print full version info when starting
Browse files Browse the repository at this point in the history
  • Loading branch information
gurnec committed Oct 12, 2017
1 parent 2ef1458 commit 1b03755
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 6 deletions.
1 change: 1 addition & 0 deletions btcrecover.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

if __name__ == "__main__":

print("Starting", btcrpass.full_version())
btcrpass.parse_arguments(sys.argv[1:])
(password_found, not_found_msg) = btcrpass.main()

Expand Down
16 changes: 15 additions & 1 deletion btcrecover/btcrpass.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@
# Armory, btcrecover will just load the version that ships with Armory.


def full_version():
from struct import calcsize
return "btcrecover {} on Python {} {}-bit, {}-bit unicodes, {}-bit ints".format(
__version__,
".".join(str(i) for i in sys.version_info[:3]),
calcsize("P") * 8,
sys.maxunicode.bit_length(),
sys.maxint.bit_length() + 1
)


# One of these two is typically called relatively early by parse_arguments()
def enable_unicode_mode():
global io, tstr, tstr_from_stdin, tchr
Expand Down Expand Up @@ -2883,7 +2894,7 @@ def init_parser_common():
parser_common.add_argument("--listpass", action="store_true", help="just list all password combinations to test and exit")
parser_common.add_argument("--performance", action="store_true", help="run a continuous performance test (Ctrl-C to exit)")
parser_common.add_argument("--pause", action="store_true", help="pause before exiting")
parser_common.add_argument("--version","-v",action="version", version="%(prog)s " + __version__)
parser_common.add_argument("--version","-v",action="store_true", help="show full version information and exit")
bip39_group = parser_common.add_argument_group("BIP-39 passwords")
bip39_group.add_argument("--bip39", action="store_true", help="search for a BIP-39 password instead of from a wallet")
bip39_group.add_argument("--mpk", metavar="XPUB", help="the master public key")
Expand Down Expand Up @@ -3006,6 +3017,9 @@ def parse_arguments(effective_argv, wallet = None, base_iterator = None,
parser.print_help()
sys.exit(0)

# Version information is always printed by btcrecover.py, so just exit
if args.version: sys.exit(0)


if args.performance and (base_iterator or args.passwordlist or args.tokenlist):
error_exit("--performance cannot be used with --tokenlist or --passwordlist")
Expand Down
13 changes: 11 additions & 2 deletions btcrecover/btcrseed.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@

ADDRESSDB_DEF_FILENAME = "addresses.db"

def full_version():
return "seedrecover {}, {}".format(
__version__,
btcrpass.full_version()
)


################################### Utility Functions ###################################

Expand Down Expand Up @@ -1549,7 +1555,7 @@ def main(argv):
parser.add_argument("--no-pause", action="store_true", help="never pause before exiting (default: auto)")
parser.add_argument("--performance", action="store_true", help="run a continuous performance test (Ctrl-C to exit)")
parser.add_argument("--btcr-args", action="store_true", help=argparse.SUPPRESS)
parser.add_argument("--version","-v", action="version", version="%(prog)s {} (btcrecover.py {})".format(__version__, btcrpass.__version__))
parser.add_argument("--version","-v",action="store_true", help="show full version information and exit")

# Optional bash tab completion support
try:
Expand All @@ -1559,12 +1565,15 @@ def main(argv):
pass
assert argv

# Parse the args; unknown args will be passed to btcrpass.parse_arguments() iff --btcrpass-args is specified
# Parse the args; unknown args will be passed to btcrpass.parse_arguments() iff --btcr-args is specified
args, extra_args = parser.parse_known_args(argv)
if extra_args and not args.btcr_args:
parser.parse_args(argv) # re-parse them just to generate an error for the unknown args
assert False

# Version information is always printed by seedrecover.py, so just exit
if args.version: sys.exit(0)

if args.wallet:
loaded_wallet = btcrpass.load_wallet(args.wallet)

Expand Down
2 changes: 0 additions & 2 deletions btcrecover/test/test_passwords.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def close(self): pass
class StringIONonClosing(BytesIO, NonClosingBase):
def close(self): pass
btcrpass.enable_ascii_mode()
tstr = str
tchr = chr
utf8_opt = ""
print("** Testing in ASCII character mode **")
Expand All @@ -81,7 +80,6 @@ def close(self): pass
class StringIONonClosing(StringIO, NonClosingBase):
def close(self): pass
btcrpass.enable_unicode_mode()
tstr = unicode
tchr = unichr
utf8_opt = " --utf8"
print("** Testing in Unicode character mode **")
Expand Down
7 changes: 6 additions & 1 deletion run-all-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ def main(test_module, exit = None, buffer = None):

is_coincurve_loadable = test_passwords.can_load_coincurve()
if is_coincurve_loadable:
from btcrecover.test import test_seeds
from btcrecover.test import test_seeds
from btcrecover.btcrseed import full_version
else:
from btcrecover.btcrpass import full_version

# Add two new arguments to those already provided by main()
parser = argparse.ArgumentParser(add_help=False)
Expand All @@ -72,6 +75,8 @@ def main(test_module, exit = None, buffer = None):
if not args.no_pause:
atexit.register(lambda: raw_input("\nPress Enter to exit ..."))

print("Testing", full_version() + "\n")

# Additional setup normally done by green.cmdline.main()
if has_green:
green_args = green.config.parseArguments()
Expand Down
1 change: 1 addition & 0 deletions seedrecover.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

if __name__ == "__main__":

print("Starting", btcrseed.full_version())
btcrseed.register_autodetecting_wallets()
mnemonic_sentence = btcrseed.main(sys.argv[1:])

Expand Down

0 comments on commit 1b03755

Please sign in to comment.