added block explorer urls to block hash displays and changed names of irc bots to...
[p2pool.git] / p2pool / bitcoin / networks.py
1 import os
2 import platform
3
4 from twisted.internet import defer
5
6 from . import data
7 from p2pool.util import math, pack
8
9 nets = dict(
10     bitcoin=math.Object(
11         P2P_PREFIX='f9beb4d9'.decode('hex'),
12         P2P_PORT=8333,
13         ADDRESS_VERSION=0,
14         RPC_PORT=8332,
15         RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
16             'bitcoinaddress' in (yield bitcoind.rpc_help()) and
17             not (yield bitcoind.rpc_getinfo())['testnet']
18         )),
19         POW_FUNC=data.hash256,
20         BLOCK_PERIOD=600, # s
21         SYMBOL='BTC',
22         CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Bitcoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Bitcoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.bitcoin'), 'bitcoin.conf'),
23         BLOCK_EXPLORER_URL_PREFIX='http://blockexplorer.com/block/',
24     ),
25     bitcoin_testnet=math.Object(
26         P2P_PREFIX='fabfb5da'.decode('hex'),
27         P2P_PORT=18333,
28         ADDRESS_VERSION=111,
29         RPC_PORT=8332,
30         RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
31             'bitcoinaddress' in (yield bitcoind.rpc_help()) and
32             (yield bitcoind.rpc_getinfo())['testnet']
33         )),
34         POW_FUNC=data.hash256,
35         BLOCK_PERIOD=600, # s
36         SYMBOL='tBTC',
37         CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Bitcoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Bitcoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.bitcoin'), 'bitcoin.conf'),
38         BLOCK_EXPLORER_URL_PREFIX='http://blockexplorer.com/testnet/block/',
39     ),
40     
41     nameecoin=math.Object(
42         P2P_PREFIX='f9beb4fe'.decode('hex'),
43         P2P_PORT=8334,
44         ADDRESS_VERSION=52,
45         RPC_PORT=8332,
46         RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
47             'namecoinaddress' in (yield bitcoind.rpc_help()) and
48             not (yield bitcoind.rpc_getinfo())['testnet']
49         )),
50         POW_FUNC=data.hash256,
51         BLOCK_PERIOD=600, # s
52         SYMBOL='NMC',
53         CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Namecoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Namecoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.namecoin'), 'bitcoin.conf'),
54         BLOCK_EXPLORER_URL_PREFIX='http://explorer.dot-bit.org/b/',
55     ),
56     namecoin_testnet=math.Object(
57         P2P_PREFIX='fabfb5fe'.decode('hex'),
58         P2P_PORT=18334,
59         ADDRESS_VERSION=111,
60         RPC_PORT=8332,
61         RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
62             'namecoinaddress' in (yield bitcoind.rpc_help()) and
63             (yield bitcoind.rpc_getinfo())['testnet']
64         )),
65         POW_FUNC=data.hash256,
66         BLOCK_PERIOD=600, # s
67         SYMBOL='tNMC',
68         CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Namecoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Namecoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.namecoin'), 'bitcoin.conf'),
69         BLOCK_EXPLORER_URL_PREFIX='http://testnet.explorer.dot-bit.org/b/',
70     ),
71     
72     litecoin=math.Object(
73         P2P_PREFIX='fbc0b6db'.decode('hex'),
74         P2P_PORT=9333,
75         ADDRESS_VERSION=48,
76         RPC_PORT=9332,
77         RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
78             'litecoinaddress' in (yield bitcoind.rpc_help()) and
79             not (yield bitcoind.rpc_getinfo())['testnet']
80         )),
81         POW_FUNC=lambda data: pack.IntType(256).unpack(__import__('ltc_scrypt').getPoWHash(data)),
82         BLOCK_PERIOD=150, # s
83         SYMBOL='LTC',
84         CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Litecoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Litecoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.litecoin'), 'litecoin.conf'),
85         BLOCK_EXPLORER_URL_PREFIX='http://litecoin.kicks-ass.org/block/',
86     ),
87     litecoin_testnet=math.Object(
88         P2P_PREFIX='fcc1b7dc'.decode('hex'),
89         P2P_PORT=19333,
90         ADDRESS_VERSION=111,
91         RPC_PORT=19332,
92         RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
93             'litecoinaddress' in (yield bitcoind.rpc_help()) and
94             (yield bitcoind.rpc_getinfo())['testnet']
95         )),
96         POW_FUNC=lambda data: pack.IntType(256).unpack(__import__('ltc_scrypt').getPoWHash(data)),
97         BLOCK_PERIOD=150, # s
98         SYMBOL='tLTC',
99         CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Litecoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Litecoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.litecoin'), 'litecoin.conf'),
100         BLOCK_EXPLORER_URL_PREFIX='http://nonexistent-litecoin-testnet-explorer/block/',
101     ),
102 )
103 for net_name, net in nets.iteritems():
104     net.NAME = net_name