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 remote node as long as the remote server variables are defined. 
"rpcuser"   -  username
"rpcpassword"  -  password
"rpcconnect" -  defaults to localhost but works for remote server ip.
      Note: Remote server needs to have whitelist setup (rpcallowip=) for the incoming connection.
"rpcport"  -  defaults to 8332