Fix NovaCoin 0.4.4.7b5 getblocktemplate default behavior change, that was preventing...
[stratum-mining.git] / lib / bitcoin_rpc.py
index 3517b6d..cfae41f 100644 (file)
@@ -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',
@@ -45,10 +45,15 @@ class BitcoinRPC(object):
             defer.returnValue(False)
 
     @defer.inlineCallbacks
+    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', []))
@@ -57,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'])