Browse Source

[mswin]: Bitcoin .cookie filename fix
[opt/cfg]: Add --bitcoin-data-dir option

philemon 8 years ago
parent
commit
0b3a40bd29
5 changed files with 23 additions and 17 deletions
  1. 3 0
      data_files/mmgen.cfg
  2. 7 4
      mmgen/globalvars.py
  3. 11 10
      mmgen/opts.py
  4. 1 2
      mmgen/util.py
  5. 1 1
      scripts/deinstall.sh

+ 3 - 0
data_files/mmgen.cfg

@@ -29,6 +29,9 @@
 # Uncomment to override 'rpcpassword' in bitcoin.conf
 # rpc_password mypassword
 
+# Uncomment to set the Bitcoin datadir
+# bitcoin_data_dir /path/to/datadir
+
 # Set the default hash preset:
 # hash_preset 3
 

+ 7 - 4
mmgen/globalvars.py

@@ -90,8 +90,10 @@ class g(object):
 						else os.path.join(home_dir,'.bitcoin')
 
 	# User opt sets global var:
-	common_opts = ('color','no_license','rpc_host','rpc_port','testnet','rpc_user','rpc_password')
-
+	common_opts = (
+		'color','no_license','rpc_host','rpc_port','testnet','rpc_user','rpc_password',
+		'bitcoin_data_dir'
+	)
 	required_opts = (
 		'quiet','verbose','debug','outdir','echo_passphrase','passwd_file','stdout',
 		'show_hash_presets','label','keep_passphrase','keep_hash_preset',
@@ -102,11 +104,12 @@ class g(object):
 		('label','keep_label'),
 		('tx_id','info'),
 		('tx_id','terse_info'),
-		('batch','rescan'),
+		('batch','rescan')
 	)
 	cfg_file_opts = (
 		'color','debug','hash_preset','http_timeout','no_license','rpc_host','rpc_port',
-		'quiet','tx_fee','tx_fee_adj','usr_randchars','testnet','rpc_user','rpc_password'
+		'quiet','tx_fee','tx_fee_adj','usr_randchars','testnet','rpc_user','rpc_password',
+		'bitcoin_data_dir'
 	)
 	env_opts = (
 		'MMGEN_BOGUS_WALLET_DATA',

+ 11 - 10
mmgen/opts.py

@@ -67,16 +67,17 @@ def _show_hash_presets():
 
 # most, but not all, of these set the corresponding global var
 common_opts_data = """
---, --color=c        Set to '0' to disable color output, '1' to enable
---, --data-dir=d     Specify the location of {pnm}'s data directory
---, --no-license     Suppress the GPL license prompt
---, --rpc-host=h     Communicate with bitcoind running on host 'h'
---, --rpc-port=p     Communicate with bitcoind listening on port 'p'
---, --rpc-user=u     Override 'rpcuser' in bitcoin.conf
---, --rpc-password=p Override 'rpcpassword' in bitcoin.conf
---, --testnet=1      Set to '1' enable testnet, '0' to disable
---, --skip-cfg-file  Skip reading the configuration file
---, --version        Print version information and exit
+--, --color=0|1           Disable or enable color output
+--, --bitcoin-data-dir=d  Specify Bitcoin data directory location 'd'
+--, --data-dir=d          Specify {pnm} data directory location 'd'
+--, --no-license          Suppress the GPL license prompt
+--, --rpc-host=h          Communicate with bitcoind running on host 'h'
+--, --rpc-port=p          Communicate with bitcoind listening on port 'p'
+--, --rpc-user=user       Override 'rpcuser' in bitcoin.conf
+--, --rpc-password=pass   Override 'rpcpassword' in bitcoin.conf
+--, --testnet=0|1         Disable or enable testnet
+--, --skip-cfg-file       Skip reading the configuration file
+--, --version             Print version information and exit
 """.format(pnm=g.proj_name)
 
 def opt_preproc_debug(short_opts,long_opts,skipped_opts,uopts,args):

+ 1 - 2
mmgen/util.py

@@ -704,8 +704,7 @@ def get_bitcoind_cfg_options(cfg_keys):
 
 def get_bitcoind_auth_cookie():
 
-	f = os.path.join(g.bitcoin_data_dir,('',g.testnet_name)[g.testnet],
-						('.','_')[g.platform=='win']+'cookie')
+	f = os.path.join(g.bitcoin_data_dir,('',g.testnet_name)[g.testnet],'.cookie')
 
 	if file_is_readable(f):
 		return get_lines_from_file(f,'')[0]

+ 1 - 1
scripts/deinstall.sh

@@ -2,7 +2,7 @@
 
 CMD='rm -rf /usr/local/share/mmgen /usr/local/bin/mmgen-* /usr/local/lib/python2.7/dist-packages/mmgen*'
 
-if [ "$EUID" = 0 ]; then
+if [ "$EUID" = 0 -o "$HOMEPATH" ]; then
 	set -x; $CMD
 else
 	set -x; sudo $CMD