#NEWLINE# def extract_bitcoincore_config( ) : #NEWLINE# #INDENT# bitcoincore_config = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if ( platform . system ( ) == 'Darwin' ) : #NEWLINE# #INDENT# btc_conf_file = os . path . expanduser ( '~/Library/Application Support/Bitcoin/' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( platform . system ( ) == 'Windows' ) : #NEWLINE# #INDENT# btc_conf_file = os . path . join ( os . environ [ 'APPDATA' ] , 'Bitcoin' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# btc_conf_file = os . path . expanduser ( '~/.bitcoin' ) #NEWLINE# #UNINDENT# #UNINDENT# btc_conf_file = os . path . join ( btc_conf_file , 'bitcoin.conf' ) #NEWLINE# if os . path . exists ( btc_conf_file ) : #NEWLINE# #INDENT# conf = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# with open ( btc_conf_file , 'r' ) as fd : #NEWLINE# #INDENT# for line in fd . readlines ( ) : #NEWLINE# #INDENT# if ( ( '#' in line ) or ( '=' not in line ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# ( k , v ) = line . split ( '=' , 1 ) #NEWLINE# conf [ k . strip ( ) ] = v . strip ( ) #NEWLINE# #UNINDENT# config_keys = { #NEWLINE# #INDENT# 'rpcport' : 'backend-port' , #NEWLINE# 'rpcuser' : 'backend-user' , #NEWLINE# 'rpcpassword' : 'backend-password' , #NEWLINE# 'rpcssl' : 'backend-ssl' , #NEWLINE# #UNINDENT# } #NEWLINE# for bitcoind_key in config_keys : #NEWLINE# #INDENT# if ( bitcoind_key in conf ) : #NEWLINE# #INDENT# counterparty_key = config_keys [ bitcoind_key ] #NEWLINE# bitcoincore_config [ counterparty_key ] = conf [ bitcoind_key ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return bitcoincore_config