redo lastblock with jsonrpc post method
This commit is contained in:
parent
7ae267ace2
commit
8457c35304
11
network.py
11
network.py
|
@ -7,7 +7,12 @@ import re
|
||||||
# networkurl = "http://opennode.minemonero.pro:18081/getinfo"
|
# networkurl = "http://opennode.minemonero.pro:18081/getinfo"
|
||||||
# networkurl = "http://node.xmr.pt:18081/getinfo"
|
# networkurl = "http://node.xmr.pt:18081/getinfo"
|
||||||
networkurl = "http://node.supportxmr.com:18081/getinfo"
|
networkurl = "http://node.supportxmr.com:18081/getinfo"
|
||||||
lastblock = "http://node.supportxmr.com:18081/get_last_block_header"
|
|
||||||
|
jsonurl = "http://node.supportxmr.com:18081/json_rpc"
|
||||||
|
headers = {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
}
|
||||||
|
requestdata = '{"jsonrpc":"2.0","id":"0","method":"get_last_block_header"}'
|
||||||
|
|
||||||
@sopel.module.commands('fork', 'forkening')
|
@sopel.module.commands('fork', 'forkening')
|
||||||
def fork(bot, trigger):
|
def fork(bot, trigger):
|
||||||
|
@ -63,8 +68,10 @@ def mempool(bot, trigger):
|
||||||
def lastblock(bot, trigger):
|
def lastblock(bot, trigger):
|
||||||
try:
|
try:
|
||||||
r=requests.get(lastblock)
|
r=requests.get(lastblock)
|
||||||
|
r=requests.post(jsonurl, headers=headers, data=requestdata)
|
||||||
j=r.json()
|
j=r.json()
|
||||||
bot.say("The current number of txs in Monero's Last Block is {0}".format(j['block_header']['num_txes']))
|
block=j['result']['block_header']
|
||||||
|
bot.say("Last block height is {0} with {1} transactions".format(block['height'],block['num_txes']))
|
||||||
except:
|
except:
|
||||||
bot.say("Something borked o_O")
|
bot.say("Something borked o_O")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue