Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: Nshan0102 on August 16, 2019, 10:33:02 AM



Title: Help! to connect Bitcoin Core
Post by: Nshan0102 on August 16, 2019, 10:33:02 AM
Hi there!
I'm searching in the google for more than one week and no result.

I have a Bitcoin Core Wallet in some Hosting ( for example it is:  123.321.256.632 )
There is an laravel programmed project in other hosting ( for example it is:  127.0.0.12 ) which is going to make payment processes.
I have installed Fully unit-tested Bitcoin JSON-RPC client based on GuzzleHttp. ( here is the link to github: https://github.com/denpamusic/php-bitcoinrpc);

In the Bitcoin server I have
1. started bitcoin-qt,
2. set config file ( rpc ) in both places (C:\Users\MyUserName\AppData\Roaming\Bitcoin\bitcoin.conf) and (D:\BlockChain\bitcoin.conf)
    # Generated by https://jlopp.github.io/bitcoin-core-config-generator/

   # This config should be placed in following path:
   # %UserProfile%\AppData\Roaming\Bitcoin\bitcoin.conf

   # [network]
   # Listen for incoming connections on non-default port.
   port=8333

   # [rpc]
   # Listen for JSON-RPC connections on this port
   rpcport=8332

   # [Sections]
   # Most options automatically apply to mainnet, testnet, and regtest networks.
   # If you want to confine an option to just one network, you should add it in the relevant section.  
   # EXCEPTIONS: The options addnode, connect, port, bind, rpcport, rpcbind and wallet
   # only apply to mainnet unless they appear in the appropriate section below.

   # Options only for mainnet
   [main]

   # Options only for testnet
   [test]

   # Options only for regtest
   [regtest]


   server=1

   rpcuser=Admin
   rpcpassword=passWordAdmin
   rpcallowip=123.321.256.632
   rpcconnect=127.0.0.1

Then I want to connect to my Bitcoin Core from my laravel project and it says cURL error 52: Empty reply from server (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
Here is my code to connect with Bitcoin Core

public function btcReplenish(Request $request){

        $bitCoinD = new BitcoinClient([
            'host'          => self::RDC_HOST,
            'port'          => 8333,
            'user'          => self::RDC_USER,
            'password'      => self::RDC_PASS,
        ]);

        $balance = $bitCoinD->wallet('wallet.dat')->getbalance();
        echo $balance->get();        
        die;
    }

Please help me if there is someone who knows how to do that!


Title: Re: Help! to connect Bitcoin Core
Post by: o_solo_miner on August 16, 2019, 02:08:46 PM
If you where using core 0.18.1 you should add also this in your bitcoin.conf:

rpcallowip=xxx.xxx.xxx.0/24 (your local Network)
rpcbind=IP of the PC wich is running core /bitcoin-qt

with that it should work.

Consider using rpcauth in the future.


Title: Re: Help! to connect Bitcoin Core
Post by: Nshan0102 on August 16, 2019, 02:38:34 PM
rpcallowip=xxx.xxx.xxx.0/24 (your local Network)
rpcbind=IP of the PC wich is running core /bitcoin-qt

isn't the rpcallowip the same as rpcbind?


Title: Re: Help! to connect Bitcoin Core
Post by: o_solo_miner on August 16, 2019, 02:43:39 PM
no, with core 18.0.0 it changes, so you must use rpcbind.
You can read the core change log for rpcbind.

The same applied to 'Solo Miner', as the miner can't get work from bitcoind if the rpcbind is not set.


Title: Re: Help! to connect Bitcoin Core
Post by: Nshan0102 on August 16, 2019, 02:52:18 PM
no, with core 18.0.0 it changes, so you must use rpcbind.
You can read the core change log for rpcbind.

The same applied to 'Solo Miner', as the miner can't get work from bitcoind if the rpcbind is not set.

Is it neccessary to run bitcoind deamon, or it is ok if the bitcoin-qt is running?


Title: Re: Help! to connect Bitcoin Core
Post by: o_solo_miner on August 16, 2019, 03:00:09 PM
bitcoin-qt is fine, the same conf used for qt.
Bitcoin-qt is basicly the gui for bitcoind, so thats why it is the same.


Title: Re: Help! to connect Bitcoin Core
Post by: Nshan0102 on August 16, 2019, 03:42:18 PM
bitcoin-qt is fine, the same conf used for qt.
Bitcoin-qt is basicly the gui for bitcoind, so thats why it is the same.
Thank you very much I will try and let you know if it's the solution!


Title: Re: Help! to connect Bitcoin Core
Post by: Nshan0102 on August 16, 2019, 04:51:29 PM
I have inserted that sattings to my bitcoin.conf, but still can't connect to it  :-\ :-\ :-\


Title: Re: Help! to connect Bitcoin Core
Post by: o_solo_miner on August 16, 2019, 04:56:58 PM
first problem is solved, bitcoin-qt, leave it as it is now.

for your second problem:

bitcoin.conf
Code:
 # [rpc]
   # Listen for JSON-RPC connections on this port
   rpcport=8332


your app credentials
Code:
public function btcReplenish(Request $request){
        $bitCoinD = new BitcoinClient([
            'host'          => self::RDC_HOST,
           [i] 'port'          => 8333,[/i]
            'user'          => self::RDC_USER,
            'password'      => self::RDC_PASS,
        ]);

did you try to use the bitcoin-qt rpc-port:
       'port'          => 8332,


Title: Re: Help! to connect Bitcoin Core
Post by: Nshan0102 on August 17, 2019, 06:27:41 AM
did you try to use the bitcoin-qt rpc-port:
       'port'          => 8332,
Yep! I have tried but the 8332 port is closed and the response is

cURL error 7: Failed to connect to 123.321.256.632 port 8332: Timed out (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)


Title: Re: Help! to connect Bitcoin Core
Post by: Nshan0102 on August 17, 2019, 02:41:43 PM
today I have searched very long to discover if my bitcoin.conf settings are wrong, and I found some mistakes there.
After some fixes I could run commands from my Bitcoin server's command line and it works.

Now the problem is that I still can't use my rpc.

I'm sorry for this, but I just want to know if it's required to install some server like ( Apache, nginx... ) in the Bitcoin server side?
Because I'm new in this kind of stuff and have to learn many things.


Title: Re: Help! to connect Bitcoin Core
Post by: o_solo_miner on August 18, 2019, 09:02:48 AM
for bitcoin core: simple answer is no, you don't need it.
But you need the rpc port to be exposed to the outside world to be able to comunicate with it over the internet.
If there is a wallet on the bincoin-qt/bitcoind this is a very bad idea!
Instead, if you want to connect two servers in a different location over the internet, then you have to use a vpn as best. You can use openvpn on both sides of the servers.

for your JSON-RPC client based on GuzzleHttp you need PHP.
But I would not recoment to use that, did you read that:
https://github.com/denpamusic/php-bitcoinrpc/issues/44

Please provide the bitcoin.conf so that others can also learn from what you found.

Did you try to test the rpc over shh localy (on the server itself)  to ensure this works?

It is essential that you have read and understand this:
https://en.bitcoin.it/wiki/API_reference_(JSON-RPC)


Title: Re: Help! to connect Bitcoin Core
Post by: Nshan0102 on August 19, 2019, 10:17:16 AM
Please provide the bitcoin.conf so that others can also learn from what you found.

Now my bitcoin.conf looks likes this.
Code:
# Generated by https://jlopp.github.io/bitcoin-core-config-generator/

# This config should be placed in following path:
# %UserProfile%\AppData\Roaming\Bitcoin\bitcoin.conf

server=1

# [network]
# Listen for incoming connections on non-default port.
port=8333

# [rpc]
# Listen for JSON-RPC connections on this port
rpcuser=Administrator
rpcpassword=somepassword
rpcallowip=111.222.0.0/16
rpcport=8332

Did you try to test the rpc over shh localy (on the server itself)  to ensure this works?
Yes and it works.
But I can't access it from other server.