X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=lib%2Fbitcoin_rpc.py;h=cfae41f2e7534cb090f38573bc625c017b72daa2;hb=HEAD;hp=731e13ab2b51b9f54275c9b7ce9ffee0339f1132;hpb=281c44e3192096227170b78684034db019e98ad5;p=stratum-mining.git diff --git a/lib/bitcoin_rpc.py b/lib/bitcoin_rpc.py index 731e13a..cfae41f 100644 --- a/lib/bitcoin_rpc.py +++ b/lib/bitcoin_rpc.py @@ -1,5 +1,5 @@ ''' - Implements simple interface to bitcoind's RPC. + Implements simple interface to novacoind's RPC. ''' import simplejson as json @@ -11,7 +11,7 @@ import stratum.logger log = stratum.logger.get_logger('bitcoin_rpc') class BitcoinRPC(object): - + def __init__(self, host, port, username, password): self.bitcoin_url = 'http://%s:%d' % (host, port) self.credentials = base64.b64encode("%s:%s" % (username, password)) @@ -19,7 +19,7 @@ class BitcoinRPC(object): 'Content-Type': 'text/json', 'Authorization': 'Basic %s' % self.credentials, } - + def _call_raw(self, data): return client.getPage( url=self.bitcoin_url, @@ -27,7 +27,7 @@ class BitcoinRPC(object): headers=self.headers, postdata=data, ) - + def _call(self, method, params): return self._call_raw(json.dumps({ 'jsonrpc': '2.0', @@ -48,12 +48,12 @@ class BitcoinRPC(object): def getinfo(self): resp = (yield self._call('getinfo', [])) defer.returnValue(json.loads(resp)['result']) - + @defer.inlineCallbacks def getblocktemplate(self): - resp = (yield self._call('getblocktemplate', [])) + resp = (yield self._call('getblocktemplate', [{}])) defer.returnValue(json.loads(resp)['result']) - + @defer.inlineCallbacks def prevhash(self): resp = (yield self._call('getwork', [])) @@ -62,8 +62,8 @@ class BitcoinRPC(object): except Exception as e: log.exception("Cannot decode prevhash %s" % str(e)) raise - + @defer.inlineCallbacks def validateaddress(self, address): resp = (yield self._call('validateaddress', [address,])) - defer.returnValue(json.loads(resp)['result']) \ No newline at end of file + defer.returnValue(json.loads(resp)['result'])