Last active
February 12, 2018 17:38
-
-
Save l3acucm/9d4cb32bb1e8d51785ce0e0ae5e850f7 to your computer and use it in GitHub Desktop.
Interaction with bitcoind via pure python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from __future__ import print_function | |
| import requests, json | |
| # Default port for the bitcoin testnet is 18332 | |
| # The port number depends on the one writtein the bitcoin.conf file | |
| rpcPort = 18332 | |
| # The RPC username and RPC password MUST match the one in your bitcoin.conf file | |
| rpcUser = 'gurdurbur' | |
| rpcPassword = 'murmurmur' | |
| #Accessing the RPC local server | |
| serverURL = 'http://' + rpcUser + ':' + rpcPassword + '@localhost:' + str(rpcPort) | |
| headers = {'content-type': 'application/json'} | |
| payload = json.dumps({"method": 'getbestblockhash', "params": ['1KuWLoZuoJgz3N6sLoAwGth9XGm8YuFTGt'], "jsonrpc": "1.0"}) | |
| response = requests.post(serverURL, headers=headers, data=payload) | |
| print(response.text) | |
| # payload = json.dumps({"method": 'listaccounts', "params": [], "jsonrpc": "2.0"}) | |
| # response = requests.post(serverURL, headers=headers, data=payload) | |
| # print(response.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment