How do we talk to bitcoind in a PHP plugin?

2

2

I'm trying to write a PHP plugin that will talk to bitcoind to generate a random address to send a bitcoin transaction to.

I'm really confused: how am I supposed to setup bitcoind so that we can query it to generate a random address?

Thanks!

Vinamrata

Posted 2013-10-18T00:54:50.087

Reputation: 43

Answers

2

First, run bitcoind on your server. Set up bitcoin.conf to have the correct RPC port and a password and etc.

Then, include the jsonRPCClient.php file:

include('jsonRPCClient.php');

Then, instantiate an object like so:

$bitcoind = new jsonRPCClient("http://$YOUR_RPC_USER:$YOUR_RPC_PASS@$YOUR_RPC_HOST:$YOUR_RPC_PORT/");

You can now run commands from the RPC using this object.

$bitcoind->getnetworkhashps();
$bitcoind->getrawtransaction($txid);

So if you want a new address:

$newaddr = $bitcoind->getnewaddress();

bvpx

Posted 2013-10-18T00:54:50.087

Reputation: 1 052

0

bitcoind - d for daemon. It has a native JSON-RPC API built in to it, indeed that's what it provides. You simply use JSON-RPC calls to get information out of bitcoind, or indeed to send information to bitcoind.

extcoin

Posted 2013-10-18T00:54:50.087

Reputation: 219