2

Anyone knows how to connect to (or even possible) a remote "-regtest" server? I have managed to setup the -regtest daemon, but still trying to figure out how to connect to it using BitCoinJ client.

===== Update ======

Just in-case someone here has the same query, I've managed to connect to the remote -regtest, I can now download the blockchain and perform RPC using BitCoinJ

  1. Just follow the bitcoin example to setup the bitcoind. (I ran using bitcoind -regtest -daemon)

  2. In the BitcoinJ code, use the REG_TEST_NET, and add your remote -regtest server's IP to BitCoinJ's PeerGroup object using

peerGroup.addAddress(InetAddress.getByName(your-remote-ip));

  1. in the bitcoin.conf, I set the additional following attributes server=1 rpcport=18444
  • Just in-case someone here has the same query, I've managed to connect to the remote -regtest. – cozytrony Jul 15 '15 at 6:04
1

If anyone is looking to connect to a RegTestnet using bitcoinJ here are the step on mac:

I used a docker image to setup the bitcoin network.

https://github.com/freewil/bitcoin-testnet-box

run this docker image using this command:

docker run -t -i -p 19001:19001 -p 19011:19011 -p 19000:19000 freewil/bitcoin-testnet-box

When you run this docker image it will start 2 bitcoin nodes.

Node 1 will listen to bitcoin node connections on port 19000 and for rpc connections on port 19001.

Node 2 is not listening to bitcoin node connections. Node 2 is connected to node 1.

Now using the port forwarding settings in Virtual Box forward the container port 19000 to your host machine port 19000.

Now you can connect to Node 1 from any machine in your local network (wifi network) using the address your-machine-local-ip:19000

Here your local machine ip is the ip address of your laptop in your local network. In mac you can find it out from network preferences.

To connect to Node 1 from bitcoinj use this:

mParams = RegTestParams.get();
.
.
// define how to connect based on network params
if (mParams == RegTestParams.get()) {
    try {
        PeerAddress pa = new PeerAddress(mParams, InetAddress.getByName("<your-machine-local-ip>"), 19000);
        mKit.setPeerNodes(pa);
    } catch (UnknownHostException e) {
        e.printStackTrace();
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.