mmgen-tool 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. COMMANDS:{}
  37. Type '{} <command> --help for usage information on a particular command
  38. """.format(command_help,prog_name)
  39. }
  40. short_opts = "hqv"
  41. long_opts = "help","quiet","verbose"
  42. opts,cmd_args = process_opts(sys.argv,help_data,short_opts,long_opts)
  43. if 'quiet' in opts: g.quiet = True
  44. if 'verbose' in opts: g.verbose = True
  45. if len(cmd_args) < 1:
  46. usage(help_data)
  47. sys.exit(1)
  48. else: command = cmd_args.pop(0)
  49. if command not in commands.keys():
  50. msg("'%s': No such command" % command)
  51. sys.exit(1)
  52. if cmd_args and cmd_args[0] == '--help':
  53. tool_usage(prog_name, command)
  54. sys.exit(0)
  55. args = process_args(prog_name, command, cmd_args) if cmd_args else []
  56. #print command + "(" + ", ".join(args) + ")"
  57. eval(command + "(" + ", ".join(args) + ")")