1

I'm pursuing an idea for a web app I had and I've hit a road block. I've worked with many other JSON APIs using php but I've never been introduced to this RPC side of things. I've done reading but still stuck.

I've set up a local bitcoin server using the bitcoin-qt.exe -server command in windows and I've used the resulting console to receive api responses. I'm now confused about how I go about connecting my web app to that server so I can make those calls from my php file and this let users interact with the bitcoin network from the webpage.

1

The Bitcoin wiki is going to a great source for developing your web app. This page describes the process and makes everthing generally less confusing when using PHP.

PHP Developer Intro

You're going to need this library. To start you first connect to your node like so, the following should also print out some basic info about your node.

require_once 'jsonRPCClient.php';

$bitcoin = new jsonRPCClient('http://user:password@127.0.0.1:8332/');

echo "<div>\n";

print_r($bitcoin->getinfo());
echo "</div>";

And to do stuff like get a new address:

$sendaddress = $bitcoin->getnewaddress();

For other commands check out the API reference.

  • But if I'm just directing newjsonRPCClient() to 127.0.0.1 then how will I put that on an online file? It'll try to execute that on the server? – not anyone Feb 9 '14 at 1:32
  • PHP is server side, and otherwise interfacing with Bitcoin-qt on the client side would be dangerous. What's stopping me from modifying your website code to empty out the wallet client side would connect to? – John T Feb 9 '14 at 2:21
0

To connect remotely from Bitcoin you should allow the ip of remote host and then you can easily send commands and receive response from your web server for this you need a static IP address. Add the following in your bitcoin configuration file

rpcallowip=ipofremotehost

if you have bitcoin on windows you should have conf file under %appdata% > roaming > bitcoin

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.