@@ -64,7 +64,7 @@ def main():
64
64
data = json.dumps(rpc_input),
65
65
headers = headers)
66
66
67
- # preaty print json outout
67
+ # pretty print json output
68
68
print (json.dumps(response.json(), indent = 4 ))
69
69
70
70
if __name__ == " __main__" :
@@ -99,18 +99,19 @@ The baisc bitmonerod rpc calls are as follows:
99
99
- get_info
100
100
- get_connections
101
101
102
+
103
+ ** Prerequsits**
104
+
105
+ Before executing this code make sure that bitmonerod is running.
106
+
102
107
** Basic example showing how to get a block header**
103
108
``` python
104
109
import requests
105
110
import json
106
111
107
- ** Prerequsits**
108
-
109
- Before executing this code make sure that bitmonerod is running.
110
-
111
112
def main ():
112
113
113
- # simple wallet is running on the localhost and port of 18082
114
+ # bitmonerod is running on the localhost and port of 18081
114
115
url = " http://localhost:18081/json_rpc"
115
116
116
117
# standard json header
@@ -134,12 +135,72 @@ def main():
134
135
data = json.dumps(rpc_input),
135
136
headers = headers)
136
137
137
- # preaty print json outout
138
+ # pretty print json output
139
+ print (json.dumps(response.json(), indent = 4 ))
140
+
141
+ if __name__ == " __main__" :
142
+ main()
143
+ ```
144
+
145
+ Generated output:
146
+ ``` python
147
+ {
148
+ " result" : {
149
+ " status" : " OK" ,
150
+ " block_header" : {
151
+ " difficulty" : 756932534 ,
152
+ " height" : 796743 ,
153
+ " nonce" : 8389 ,
154
+ " depth" : 46 ,
155
+ " orphan_status" : false,
156
+ " hash" : " d78e2d024532d8d8f9c777e2572623fd0f229d72d9c9c9da3e7cb841a3cb73c6" ,
157
+ " timestamp" : 1445741816 ,
158
+ " major_version" : 1 ,
159
+ " minor_version" : 0 ,
160
+ " prev_hash" : " dff9c6299c84f945fabde9e96afa5d44f3c8fa88835fb87a965259c46694a2cd" ,
161
+ " reward" : 8349972377827
162
+ }
163
+ },
164
+ " jsonrpc" : " 2.0" ,
165
+ " id" : " 0"
166
+ }
167
+ ```
168
+
169
+ ** Basic example showing how to get a mining status**
170
+ ``` python
171
+ import requests
172
+ import json
173
+
174
+ def main ():
175
+
176
+ # bitmonerod' is running on the localhost and port of 18081
177
+ url = " http://localhost:18081/mining_status"
178
+
179
+ # standard json header
180
+ headers = {' content-type' : ' application/json' }
181
+
182
+ # execute the rpc request
183
+ response = requests.post(
184
+ url,
185
+ headers = headers)
186
+
187
+ # pretty print json output
138
188
print (json.dumps(response.json(), indent = 4 ))
139
189
140
190
if __name__ == " __main__" :
141
191
main()
142
192
```
193
+ Generated output:
194
+
195
+ ``` python
196
+ {
197
+ " status" : " OK" ,
198
+ " threads_count" : 2 ,
199
+ " speed" : 117 ,
200
+ " active" : true,
201
+ " address" : " 48daf1rG3hE1Txapcsxh6WXNe9MLNKtu7W7tKTivtSoVLHErYzvdcpea2nSTgGkz66RFP4GKVAsTV14v6G3oddBTHfxP6tU"
202
+ }
203
+ ```
143
204
144
205
More examples are comming soon.
145
206
0 commit comments