mmgen-tool 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/usr/bin/env python
  2. #
  3. # mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
  4. # Copyright (C) 2013 by philemon <mmgen-py@yandex.com>
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. """
  19. mmgen-tool: Perform various Bitcoin-related operations - part of the MMGen suite
  20. """
  21. import sys, os
  22. from hashlib import sha256
  23. import mmgen.config as g
  24. import mmgen.tool as tool
  25. from mmgen.Opts import *
  26. from mmgen.util import pretty_hexdump
  27. help_data = {
  28. 'prog_name': g.prog_name,
  29. 'desc': "Perform various BTC-related operations",
  30. 'usage': "[opts] <command> <args>",
  31. 'options': """
  32. -d, --outdir= d Specify an alternate directory 'd' for output
  33. -h, --help Print this help message
  34. -q, --quiet Produce quieter output
  35. -r, --usr-randchars=n Get 'n' characters of additional randomness from
  36. user (min={g.min_urandchars}, max={g.max_urandchars})
  37. -v, --verbose Produce more verbose output
  38. """.format(g=g),
  39. 'notes': """
  40. COMMANDS:{}
  41. Type '{} <command> --help for usage information on a particular
  42. command
  43. """.format(tool.command_help,g.prog_name)
  44. }
  45. opts,cmd_args = parse_opts(sys.argv,help_data)
  46. if 'quiet' in opts: g.quiet = True
  47. if 'verbose' in opts: g.verbose = True
  48. if len(cmd_args) < 1:
  49. usage(help_data)
  50. sys.exit(1)
  51. command = cmd_args.pop(0)
  52. if command not in tool.commands.keys():
  53. msg("'%s': No such command" % command)
  54. sys.exit(1)
  55. if cmd_args and cmd_args[0] == '--help':
  56. tool.tool_usage(g.prog_name, command)
  57. sys.exit(0)
  58. args = tool.process_args(g.prog_name, command, cmd_args)
  59. tool.opts = opts
  60. #print command + "(" + ", ".join(args) + ")"
  61. eval("tool." + command + "(" + ", ".join(args) + ")")