globalvars.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. #!/usr/bin/env python
  2. #
  3. # mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
  4. # Copyright (C)2013-2016 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. globalvars.py: Constants and configuration options for the MMGen suite
  20. """
  21. import sys,os
  22. from mmgen.obj import BTCAmt
  23. # Global vars are set to dfl values in class g.
  24. # They're overridden in this order:
  25. # 1 - config file
  26. # 2 - environmental vars
  27. # 3 - command line
  28. class g(object):
  29. def die(ev=0,s=''):
  30. if s: sys.stderr.write(s+'\n')
  31. sys.exit(ev)
  32. # Variables - these might be altered at runtime:
  33. version = '0.8.8'
  34. release_date = 'November 2016'
  35. proj_name = 'MMGen'
  36. prog_name = os.path.basename(sys.argv[0])
  37. author = 'Philemon'
  38. email = '<mmgen-py@yandex.com>'
  39. Cdates = '2013-2016'
  40. user_entropy = ''
  41. hash_preset = '3'
  42. usr_randchars = 30
  43. tx_fee = BTCAmt('0.0003')
  44. tx_fee_adj = 1.0
  45. tx_confs = 3
  46. seed_len = 256
  47. http_timeout = 60
  48. # Constants - some of these might be overriden, but they don't change thereafter
  49. debug = False
  50. quiet = False
  51. no_license = False
  52. hold_protect = True
  53. color = (False,True)[sys.stdout.isatty()]
  54. testnet = False
  55. rpc_host = ''
  56. rpc_port = 0
  57. rpc_user = ''
  58. rpc_password = ''
  59. testnet_name = 'testnet3'
  60. bogus_wallet_data = '' # for debugging, used by test suite
  61. for k in ('win','linux'):
  62. if sys.platform[:len(k)] == k:
  63. platform = k; break
  64. else:
  65. die(1,"'%s': platform not supported by %s\n" % (sys.platform,proj_name))
  66. if os.getenv('HOME'): # Linux or MSYS
  67. home_dir = os.getenv('HOME')
  68. elif platform == 'win': # Windows native:
  69. die(1,'$HOME not set! {} for Windows must be run in MSYS environment'.format(proj_name))
  70. else:
  71. die(2,'$HOME is not set! Unable to determine home directory')
  72. data_dir_root,data_dir,cfg_file = None,None,None
  73. bitcoin_data_dir = os.path.join(os.getenv('APPDATA'),'Bitcoin') if platform == 'win' \
  74. else os.path.join(home_dir,'.bitcoin')
  75. # User opt sets global var:
  76. common_opts = (
  77. 'color','no_license','rpc_host','rpc_port','testnet','rpc_user','rpc_password',
  78. 'bitcoin_data_dir'
  79. )
  80. required_opts = (
  81. 'quiet','verbose','debug','outdir','echo_passphrase','passwd_file','stdout',
  82. 'show_hash_presets','label','keep_passphrase','keep_hash_preset',
  83. 'brain_params','b16','usr_randchars'
  84. )
  85. incompatible_opts = (
  86. ('quiet','verbose'),
  87. ('label','keep_label'),
  88. ('tx_id','info'),
  89. ('tx_id','terse_info'),
  90. ('batch','rescan')
  91. )
  92. cfg_file_opts = (
  93. 'color','debug','hash_preset','http_timeout','no_license','rpc_host','rpc_port',
  94. 'quiet','tx_fee','tx_fee_adj','usr_randchars','testnet','rpc_user','rpc_password',
  95. 'bitcoin_data_dir'
  96. )
  97. env_opts = (
  98. 'MMGEN_BOGUS_WALLET_DATA',
  99. 'MMGEN_DEBUG',
  100. 'MMGEN_QUIET',
  101. 'MMGEN_DISABLE_COLOR',
  102. 'MMGEN_DISABLE_HOLD_PROTECT',
  103. 'MMGEN_MIN_URANDCHARS',
  104. 'MMGEN_NO_LICENSE',
  105. 'MMGEN_RPC_HOST',
  106. 'MMGEN_TESTNET'
  107. )
  108. min_screen_width = 80
  109. minconf = 1
  110. # Global var sets user opt:
  111. global_sets_opt = ['minconf','seed_len','hash_preset','usr_randchars','debug',
  112. 'quiet','tx_confs','tx_fee_adj','tx_fee','key_generator']
  113. keyconv_exec = 'keyconv'
  114. mins_per_block = 9
  115. passwd_max_tries = 5
  116. max_urandchars = 80
  117. min_urandchars = 10
  118. seed_lens = 128,192,256
  119. mn_lens = [i / 32 * 3 for i in seed_lens]
  120. mmenc_ext = 'mmenc'
  121. salt_len = 16
  122. aesctr_iv_len = 16
  123. hincog_chk_len = 8
  124. key_generators = 'python-ecdsa','keyconv','secp256k1' # 1,2,3
  125. key_generator = 3 # secp256k1 is default
  126. hash_presets = {
  127. # Scrypt params:
  128. # ID N p r
  129. # N is a power of two
  130. '1': [12, 8, 1],
  131. '2': [13, 8, 4],
  132. '3': [14, 8, 8],
  133. '4': [15, 8, 12],
  134. '5': [16, 8, 16],
  135. '6': [17, 8, 20],
  136. '7': [18, 8, 24],
  137. }