try local rpc then look for remote file config ~/.bitcoin/bitcoin.conf

Added some logic to try to connect to a local bitcoind instance. if that fails look for a config file ~/.bitcoin/bitcoin.conf  and use the details in there to connect.  This file can also be used to connect to a remove node as long as the remote server variables are defined. 
"rpcuser"   -  username
"rpcpassword"  -  password
"rpcconnect" -  defaults to localhost but works for remote server as long as whitelist is setup (rpcallowip)
"rpcport"  -  defaults to 8332