mmgen-tool 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. from mmgen.Opts import *
  24. import mmgen.config as g
  25. from mmgen.util import pretty_hexdump
  26. from mmgen.tool import *
  27. prog_name = sys.argv[0].split("/")[-1]
  28. help_data = {
  29. 'prog_name': prog_name,
  30. 'desc': "Perform various BTC-related operations",
  31. 'usage': "[opts] <command> <args>",
  32. 'options': """
  33. -h, --help Print this help message
  34. -q, --quiet Produce quieter output
  35. -v, --verbose Produce more verbose output
  36. """,
  37. 'notes': """
  38. COMMANDS:{}
  39. Type '{} <command> --help for usage information on a particular
  40. command
  41. """.format(command_help,prog_name)
  42. }
  43. opts,cmd_args = parse_opts(sys.argv,help_data)
  44. if 'quiet' in opts: g.quiet = True
  45. if 'verbose' in opts: g.verbose = True
  46. if len(cmd_args) < 1:
  47. usage(help_data)
  48. sys.exit(1)
  49. else: command = cmd_args.pop(0)
  50. if command not in commands.keys():
  51. msg("'%s': No such command" % command)
  52. sys.exit(1)
  53. if cmd_args and cmd_args[0] == '--help':
  54. tool_usage(prog_name, command)
  55. sys.exit(0)
  56. args = process_args(prog_name, command, cmd_args)
  57. #print command + "(" + ", ".join(args) + ")"
  58. eval(command + "(" + ", ".join(args) + ")")