Merge pull request #56 from Keep-it-Monero/master

redo lastblock with jsonrpc post method
This commit is contained in:
jw 2021-03-30 13:43:24 -04:00 committed by GitHub
commit 4d4272971d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -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")