50 lines
3.3 KiB
HTML
50 lines
3.3 KiB
HTML
|
<!DOCTYPE html>
|
|||
|
<html lang="en">
|
|||
|
<head>
|
|||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|||
|
<style>
|
|||
|
body {
|
|||
|
max-width: 30em;
|
|||
|
margin-left: 2em;
|
|||
|
}
|
|||
|
p.center {text-align:center;}
|
|||
|
</style>
|
|||
|
<link rel="shortcut icon" href="../rho.ico">
|
|||
|
<title>RPC to the blockchain</title>
|
|||
|
</head>
|
|||
|
<body><p><a href="./index.html"> To Home page</a></p>
|
|||
|
<h1>RPC to the blockchain</h1><p>
|
|||
|
|
|||
|
Bitcoind is an rpc server, and bitcoin-qt can be started to also operate as a server. It operates JSON-RPC interface over HTTP over sockets. (But you have to talk JSON HTTP if engaging it directly. There is a <a href="http://wxcode.sourceforge.net/docs/wxjson/">wxJSON source only library</a> for wxWidgets, but it is not part of wxWidgets itself. There are a <a href="http://www.json.org/">huge number of JSON libraries</a>, and we don’t have any real need to represent JSON data in wxWidgets objects.</p><p>
|
|||
|
|
|||
|
One data structure we need, and bitcoin does not have is the partial Merkle-patricia trie. As these can potentially get quite large, we likely want a format more efficient than JSON. And for generally short messages, tcp is overhead.</p><p>
|
|||
|
|
|||
|
If we want anyone to be able to talk the chain, if we want anyone to be able to write programs that interact with the chain, we need to talk JSON in http on tcp. But if we just want our custom client to talk to our custom server, we should talk binary, since they are largely using the same internal format anyway – modulo the usual byte order problems.</p><p>
|
|||
|
|
|||
|
This means that one can programatically do all the things the bitcoin-qt gui does, such as generate an address for payment, and check if that payment has been made.</p><p>
|
|||
|
|
|||
|
bitcoin-cli is an rpc client, that provides a command line interface to the server, so that a human can do the same things as a program. </p><p>
|
|||
|
|
|||
|
Eloipool is an example of program that calls the server</p><p>
|
|||
|
|
|||
|
RPC calls are fully documented <a href="https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs">here</a>, giving an example of how to call bitcoind directly from curl.
|
|||
|
|
|||
|
Bitcoin-qt provides a console that allows the same command line controls as bitcoin-cli. One can issue command lines in bitcoin-qt as if using the bitcoin-cli client:<br/>
|
|||
|
Click "Help > Debug window". You should see the "Debug window".<br/>
|
|||
|
Click "Console" tab. You should see the console screen where you can enter bitcoin-cli commands.</p><p>
|
|||
|
|
|||
|
To run bitcoin-qt as a server add to bitcoin.conf<br/><code>
|
|||
|
server=1<br/>
|
|||
|
rpcuser=myname <br/>
|
|||
|
rpcpassword=password</code></p><p>
|
|||
|
|
|||
|
The bitcoin server binds to local host, so the password is not that critical. It should not be possible to speak to the server from outside the machine. We, of course, being oriented towards everyone running a client and only a few people running a server, will offer a safe subset of calls that are globally accessible from the entire internet – which will require a process that resists DNS attacks.</p><p>
|
|||
|
|
|||
|
Bitcoin_QT offers <a href="https://gist.github.com/donpdonp/4997294">a lot of command line options</a>, and these command line options parallel the ones in the conf file.</p>
|
|||
|
|
|||
|
<p style="background-color: #ccffcc; font-size: 80%;">These documents are
|
|||
|
licensed under the <a href="http://creativecommons.org/licenses/by-sa/3.0/" rel="license">Creative
|
|||
|
Commons Attribution-Share Alike 3.0 License</a></p>
|
|||
|
</body>
|
|||
|
</html>
|