Replace getwork call with getblocktemplate

This commit is contained in:
Sai Raj 2021-06-06 03:04:46 +05:30 committed by GitHub
parent a19ae3444a
commit 76077630aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -141,10 +141,14 @@ class BitcoinRPC(object):
@defer.inlineCallbacks
def prevhash(self):
resp = (yield self._call('getwork', []))
try:
defer.returnValue(json.loads(resp)['result']['data'][8:72])
resp = (yield self._call('getblocktemplate', [{}]))
defer.returnValue(json.loads(resp)['result']['previousblockhash'])
except Exception as e:
if (str(e) == "500 Internal Server Error"):
resp = (yield self._call('getblocktemplate', []))
defer.returnValue(json.loads(resp)['result']['previousblockhash'])
else:
log.exception("Cannot decode prevhash %s" % str(e))
raise