Install Python libraries Install the Python library python-bitcoinrpc. Bitcoin does not require an extra auth header blockdaemon:blockdaemon Can still use extra auth user in header existing curl example can use basic auth can use X-Auth-Token in header without auth user can use bearer token in header without auth user can pass auth as url param Further Reading Bitcoin RPC Protocol Python-bitcoinrpc.
Comments 1 comment. Sort by Date Votes. Bhaskar Das January 04, Comment actions Permalink.
Sign up using Email and Password. Post as a guest Name.
Returns a list of most recent transaction. Only works if there is an unspent output for this transaction, or if the blockhash is specified. Keep in mind however that Steven Roose's suggestion won't work if there's an " " in the password. Combines multiple PBSTs into one transaction. Returns object mempool data for the specified transaction id if in mempool.
Email Required, but never shown. The Overflow Blog.
You can also make a request by explicitly mentioning the username and password in the URI: http://bitcoinrpc:ahything@/. Making your request to. › wiki › API_reference_(JSON-RPC).
Mint: A new language designed for building single page applications. Featured on Meta. Stack Overflow for Teams is now free for up to 50 users, forever. Related Hot Network Questions. Question feed. Stack Overflow works best with JavaScript enabled. However, you need to know how to fill in your username and your URL address in order to make it work in the first place!
Whenever you're unsure about how to curl an RPC command, just look at the bitcoin-cli help and go from there. In order to speak with the bitcoind port, you need a user name and password. Our user name is StandUp and our password is 8eafeaf45c33cbcf2dd1. As of Bitcoin Core 0. The downside of this is that it makes use of RPC commands by other applications, such as the ones detailed in this chapter, more difficult. So, we're going to stick with the plain rpcuser and rpcpassword information for now, but for production software, consider moving to cookies.
Take a look in your bitcoin. This is even less recommended than putting it in a file, except for testing on testnet.
If you want to do it anywhere else, make sure you know what you're doing! With all of that in hand, you're ready to send off standard RPC commands with curl The first is method , which is the RPC method being used. This should generally match the command names you've been feeding into bitcoin-cli for ages. The second is params , which is a JSON array of parameters.
These are the same as the arguments or named arguments that you've been using. They're also the most confusing part of curl , in large part because they're a structured array rather than a simple list. You can now send your first curl command by accessing the getmininginfo RPC:.
If things still don't work, be sure that you're allowing access to port or from localhost. The result is another JSON array, which is unfortunately ugly to read if you're using curl by hand. Fortunately, you can clean it up simply by piping it through jq :. You'll see a bit of connectivity reporting as the data is downloaded, then when that data hits jq , everything will be output in a correctly indented form.
We'll be omitting the download information in future examples. Though you're accessing bitcoind directly, you'll still get access to wallet functionality, because that's largely stored in bitcoind itself. This is our first example of a real parameter, "". This is the required label parameter for getaddressesbylabel , but all of our addresses are under the default label, so nothing special was required here. The result is a list of all the addresses that have been used by this wallet This is almost exactly the same output that you receive when you type bitcoin-cli listunspent , showing how closely tied the two interfaces are.
If no cleanup or extra help is needed, then bitcoin-cli just outputs the RPC.