globalvars.py 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. #!/usr/bin/env python
  2. #
  3. # mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
  4. # Copyright (C)2013-2018 The MMGen Project <mmgen@tuta.io>
  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. # Global vars are set to dfl values in class g.
  23. # They're overridden in this order:
  24. # 1 - config file
  25. # 2 - environmental vars
  26. # 3 - command line
  27. class g(object):
  28. skip_segwit_active_check = bool(os.getenv('MMGEN_TEST_SUITE'))
  29. def die(ev=0,s=''):
  30. if s: sys.stderr.write(s+'\n')
  31. sys.exit(ev)
  32. # Constants:
  33. version = '0.9.8'
  34. release_date = 'May 2018'
  35. proj_name = 'MMGen'
  36. proj_url = 'https://github.com/mmgen/mmgen'
  37. prog_name = os.path.basename(sys.argv[0])
  38. author = 'The MMGen Project'
  39. email = '<mmgen@tuta.io>'
  40. Cdates = '2013-2018'
  41. keywords = 'Bitcoin, BTC, cryptocurrency, wallet, cold storage, offline, online, spending, open-source, command-line, Python, Linux, Bitcoin Core, bitcoind, hd, deterministic, hierarchical, secure, anonymous, Electrum, seed, mnemonic, brainwallet, Scrypt, utility, script, scriptable, blockchain, raw, transaction, permissionless, console, terminal, curses, ansi, color, tmux, remote, client, daemon, RPC, json, entropy, xterm, rxvt, PowerShell, MSYS, MinGW, mswin, Armbian, Raspbian, Raspberry Pi, Orange Pi, BCash, BCH, Litecoin, LTC, altcoin, ZEC, Zcash, DASH, Dashpay, ETH, Ethereum, Classic, SHA256Compress, XMR, Monero, EMC, Emercoin'
  42. max_int = 0xffffffff
  43. stdin_tty = bool(sys.stdin.isatty() or os.getenv('MMGEN_TEST_SUITE'))
  44. http_timeout = 60
  45. # Variables - these might be altered at runtime:
  46. user_entropy = ''
  47. hash_preset = '3'
  48. usr_randchars = 30
  49. tx_fee_adj = 1.0
  50. tx_confs = 3
  51. seed_len = 256
  52. # Constant vars - some of these might be overriden in opts.py, but they don't change thereafter
  53. coin = 'BTC'
  54. debug = False
  55. debug_opts = False
  56. debug_rpc = False
  57. debug_addrlist = False
  58. quiet = False
  59. no_license = False
  60. color = (False,True)[sys.stdout.isatty()]
  61. force_256_color = False
  62. testnet = False
  63. regtest = False
  64. accept_defaults = False
  65. chain = None # set by first call to rpc_init()
  66. chains = 'mainnet','testnet','regtest'
  67. daemon_version = None # set by first call to rpc_init()
  68. rpc_host = ''
  69. rpc_port = 0
  70. rpc_user = ''
  71. rpc_password = ''
  72. rpch = None # global RPC handle
  73. bob = False
  74. alice = False
  75. # test suite:
  76. bogus_wallet_data = u''
  77. traceback_cmd = 'scripts/traceback.py'
  78. debug_utf8 = False
  79. for k in ('win','linux'):
  80. if sys.platform[:len(k)] == k:
  81. platform = k; break
  82. else:
  83. die(1,"'{}': platform not supported by {}\n".format(sys.platform,proj_name))
  84. if os.getenv('HOME'): # Linux or MSYS
  85. home_dir = os.getenv('HOME').decode('utf8')
  86. elif platform == 'win': # Windows native:
  87. die(1,'$HOME not set! {} for Windows must be run in MSYS environment'.format(proj_name))
  88. else:
  89. die(2,'$HOME is not set! Unable to determine home directory')
  90. data_dir_root,data_dir,cfg_file = None,None,None
  91. daemon_data_dir = u'' # set by user or protocol
  92. # User opt sets global var:
  93. common_opts = (
  94. 'color','no_license','rpc_host','rpc_port','testnet','rpc_user','rpc_password',
  95. 'daemon_data_dir','force_256_color','regtest','coin','bob','alice',
  96. 'accept_defaults'
  97. )
  98. required_opts = (
  99. 'quiet','verbose','debug','outdir','echo_passphrase','passwd_file','stdout',
  100. 'show_hash_presets','label','keep_passphrase','keep_hash_preset','yes',
  101. 'brain_params','b16','usr_randchars','coin','bob','alice','key_generator'
  102. )
  103. incompatible_opts = (
  104. ('base32','hex'), # mmgen-passgen
  105. ('bob','alice'),
  106. ('quiet','verbose'),
  107. ('label','keep_label'),
  108. ('tx_id','info'),
  109. ('tx_id','terse_info'),
  110. ('batch','rescan') # still incompatible as of Core 0.15.0
  111. )
  112. cfg_file_opts = (
  113. 'color','debug','hash_preset','http_timeout','no_license','rpc_host','rpc_port',
  114. 'quiet','tx_fee_adj','usr_randchars','testnet','rpc_user','rpc_password',
  115. 'daemon_data_dir','force_256_color','regtest',
  116. 'btc_max_tx_fee','ltc_max_tx_fee','bch_max_tx_fee',
  117. 'max_tx_file_size'
  118. )
  119. env_opts = (
  120. 'MMGEN_BOGUS_WALLET_DATA',
  121. 'MMGEN_DEBUG_ALL',
  122. 'MMGEN_DEBUG',
  123. 'MMGEN_DEBUG_OPTS',
  124. 'MMGEN_DEBUG_RPC',
  125. 'MMGEN_DEBUG_ADDRLIST',
  126. 'MMGEN_DEBUG_UTF8',
  127. 'MMGEN_QUIET',
  128. 'MMGEN_DISABLE_COLOR',
  129. 'MMGEN_FORCE_256_COLOR',
  130. 'MMGEN_MIN_URANDCHARS',
  131. 'MMGEN_NO_LICENSE',
  132. 'MMGEN_RPC_HOST',
  133. 'MMGEN_TESTNET',
  134. 'MMGEN_REGTEST'
  135. )
  136. min_screen_width = 80
  137. minconf = 1
  138. max_tx_file_size = 100000
  139. # Global var sets user opt:
  140. global_sets_opt = ['minconf','seed_len','hash_preset','usr_randchars','debug',
  141. 'quiet','tx_confs','tx_fee_adj','key_generator']
  142. passwd_max_tries = 5
  143. max_urandchars = 80
  144. min_urandchars = 10
  145. seed_lens = 128,192,256
  146. mmenc_ext = 'mmenc'
  147. salt_len = 16
  148. aesctr_iv_len = 16
  149. hincog_chk_len = 8
  150. key_generators = 'python-ecdsa','secp256k1' # '1','2'
  151. key_generator = 2 # secp256k1 is default
  152. hash_presets = {
  153. # Scrypt params:
  154. # ID N p r (N is an exponent of two)
  155. '1': [12, 8, 1],
  156. '2': [13, 8, 4],
  157. '3': [14, 8, 8],
  158. '4': [15, 8, 12],
  159. '5': [16, 8, 16],
  160. '6': [17, 8, 20],
  161. '7': [18, 8, 24],
  162. }