Add support for the Terracoin network.
[p2pool.git] / p2pool / bitcoin / networks.py
index ddb60af..ea53f05 100644 (file)
@@ -117,6 +117,44 @@ nets = dict(
         ADDRESS_EXPLORER_URL_PREFIX='http://nonexistent-litecoin-testnet-explorer/address/',
         SANE_TARGET_RANGE=(2**256//1000000000 - 1, 2**256 - 1),
     ),
+
+    terracoin=math.Object(
+        P2P_PREFIX='42babe56'.decode('hex'),
+        P2P_PORT=13333,
+        ADDRESS_VERSION=0,
+        RPC_PORT=13332,
+        RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
+            'terracoinaddress' in (yield bitcoind.rpc_help()) and
+            not (yield bitcoind.rpc_getinfo())['testnet']
+        )),
+        SUBSIDY_FUNC=lambda height: 20*100000000 >> (height + 1)//1050000,
+        POW_FUNC=data.hash256,
+        BLOCK_PERIOD=120, # s
+        SYMBOL='TRC',
+        CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Terracoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Terracoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.terracoin'), 'terracoin.conf'),
+        BLOCK_EXPLORER_URL_PREFIX='http://cryptocoinexplorer.com:3750/block/',
+        ADDRESS_EXPLORER_URL_PREFIX='http://cryptocoinexplorer.com:3750/address/',
+        SANE_TARGET_RANGE=(2**256//2**32//1000 - 1, 2**256//2**32 - 1),
+    ),
+    terracoin_testnet=math.Object(
+        P2P_PREFIX='41babe56'.decode('hex'),
+        P2P_PORT=23333,
+        ADDRESS_VERSION=111,
+        RPC_PORT=23332,
+        RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
+            'terracoinaddress' in (yield bitcoind.rpc_help()) and
+            (yield bitcoind.rpc_getinfo())['testnet']
+        )),
+        SUBSIDY_FUNC=lambda height: 20*100000000 >> (height + 1)//1050000,
+        POW_FUNC=data.hash256,
+        BLOCK_PERIOD=120, # s
+        SYMBOL='tTRC',
+        CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Terracoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Terracoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.terracoin'), 'terracoin.conf'),
+        BLOCK_EXPLORER_URL_PREFIX='http://cryptocoinexplorer.com:3750/testnet/block/',
+        ADDRESS_EXPLORER_URL_PREFIX='http://cryptocoinexplorer.com:3750/testnet/address/',
+        SANE_TARGET_RANGE=(2**256//2**32//1000 - 1, 2**256//2**32 - 1),
+    ),
+
 )
 for net_name, net in nets.iteritems():
     net.NAME = net_name