Update networks.py
[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         SUBSIDY_FUNC=lambda height: 50*100000000 >> (height + 1)//210000,
20         POW_FUNC=data.hash256,
21         BLOCK_PERIOD=600, # s
22         SYMBOL='BTC',
23         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'),
24         BLOCK_EXPLORER_URL_PREFIX='https://blockchain.info/block/',
25         ADDRESS_EXPLORER_URL_PREFIX='https://blockchain.info/address/',
26         SANE_TARGET_RANGE=(2**256//2**32//1000 - 1, 2**256//2**32 - 1),
27         DUMB_SCRYPT_DIFF=1,
28         DUST_THRESHOLD=0.001e8,
29     ),
30     bitcoin_testnet=math.Object(
31         P2P_PREFIX='0b110907'.decode('hex'),
32         P2P_PORT=18333,
33         ADDRESS_VERSION=111,
34         RPC_PORT=18332,
35         RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
36             'bitcoinaddress' in (yield bitcoind.rpc_help()) and
37             (yield bitcoind.rpc_getinfo())['testnet']
38         )),
39         SUBSIDY_FUNC=lambda height: 50*100000000 >> (height + 1)//210000,
40         POW_FUNC=data.hash256,
41         BLOCK_PERIOD=600, # s
42         SYMBOL='tBTC',
43         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'),
44         BLOCK_EXPLORER_URL_PREFIX='http://blockexplorer.com/testnet/block/',
45         ADDRESS_EXPLORER_URL_PREFIX='http://blockexplorer.com/testnet/address/',
46         SANE_TARGET_RANGE=(2**256//2**32//1000 - 1, 2**256//2**32 - 1),
47         DUMB_SCRYPT_DIFF=1,
48         DUST_THRESHOLD=1e8,
49     ),
50     
51     namecoin=math.Object(
52         P2P_PREFIX='f9beb4fe'.decode('hex'),
53         P2P_PORT=8334,
54         ADDRESS_VERSION=52,
55         RPC_PORT=8332,
56         RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
57             'namecoinaddress' in (yield bitcoind.rpc_help()) and
58             not (yield bitcoind.rpc_getinfo())['testnet']
59         )),
60         SUBSIDY_FUNC=lambda height: 50*100000000 >> (height + 1)//210000,
61         POW_FUNC=data.hash256,
62         BLOCK_PERIOD=600, # s
63         SYMBOL='NMC',
64         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'),
65         BLOCK_EXPLORER_URL_PREFIX='http://explorer.dot-bit.org/b/',
66         ADDRESS_EXPLORER_URL_PREFIX='http://explorer.dot-bit.org/a/',
67         SANE_TARGET_RANGE=(2**256//2**32 - 1, 2**256//2**32 - 1),
68         DUMB_SCRYPT_DIFF=1,
69         DUST_THRESHOLD=0.2e8,
70     ),
71     namecoin_testnet=math.Object(
72         P2P_PREFIX='fabfb5fe'.decode('hex'),
73         P2P_PORT=18334,
74         ADDRESS_VERSION=111,
75         RPC_PORT=8332,
76         RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
77             'namecoinaddress' in (yield bitcoind.rpc_help()) and
78             (yield bitcoind.rpc_getinfo())['testnet']
79         )),
80         SUBSIDY_FUNC=lambda height: 50*100000000 >> (height + 1)//210000,
81         POW_FUNC=data.hash256,
82         BLOCK_PERIOD=600, # s
83         SYMBOL='tNMC',
84         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'),
85         BLOCK_EXPLORER_URL_PREFIX='http://testnet.explorer.dot-bit.org/b/',
86         ADDRESS_EXPLORER_URL_PREFIX='http://testnet.explorer.dot-bit.org/a/',
87         SANE_TARGET_RANGE=(2**256//2**32 - 1, 2**256//2**32 - 1),
88         DUMB_SCRYPT_DIFF=1,
89         DUST_THRESHOLD=1e8,
90     ),
91     
92     litecoin=math.Object(
93         P2P_PREFIX='fbc0b6db'.decode('hex'),
94         P2P_PORT=9333,
95         ADDRESS_VERSION=48,
96         RPC_PORT=9332,
97         RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
98             'litecoinaddress' in (yield bitcoind.rpc_help()) and
99             not (yield bitcoind.rpc_getinfo())['testnet']
100         )),
101         SUBSIDY_FUNC=lambda height: 50*100000000 >> (height + 1)//840000,
102         POW_FUNC=lambda data: pack.IntType(256).unpack(__import__('ltc_scrypt').getPoWHash(data)),
103         BLOCK_PERIOD=150, # s
104         SYMBOL='LTC',
105         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'),
106         BLOCK_EXPLORER_URL_PREFIX='http://explorer.litecoin.net/block/',
107         ADDRESS_EXPLORER_URL_PREFIX='http://explorer.litecoin.net/address/',
108         SANE_TARGET_RANGE=(2**256//1000000000 - 1, 2**256//1000 - 1),
109         DUMB_SCRYPT_DIFF=2**16,
110         DUST_THRESHOLD=0.03e8,
111     ),
112     litecoin_testnet=math.Object(
113         P2P_PREFIX='fcc1b7dc'.decode('hex'),
114         P2P_PORT=19333,
115         ADDRESS_VERSION=111,
116         RPC_PORT=19332,
117         RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
118             'litecoinaddress' in (yield bitcoind.rpc_help()) and
119             (yield bitcoind.rpc_getinfo())['testnet']
120         )),
121         SUBSIDY_FUNC=lambda height: 50*100000000 >> (height + 1)//840000,
122         POW_FUNC=lambda data: pack.IntType(256).unpack(__import__('ltc_scrypt').getPoWHash(data)),
123         BLOCK_PERIOD=150, # s
124         SYMBOL='tLTC',
125         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'),
126         BLOCK_EXPLORER_URL_PREFIX='http://nonexistent-litecoin-testnet-explorer/block/',
127         ADDRESS_EXPLORER_URL_PREFIX='http://nonexistent-litecoin-testnet-explorer/address/',
128         SANE_TARGET_RANGE=(2**256//1000000000 - 1, 2**256 - 1),
129         DUMB_SCRYPT_DIFF=2**16,
130         DUST_THRESHOLD=1e8,
131     ),
132
133     terracoin=math.Object(
134         P2P_PREFIX='42babe56'.decode('hex'),
135         P2P_PORT=13333,
136         ADDRESS_VERSION=0,
137         RPC_PORT=13332,
138         RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
139             'terracoinaddress' in (yield bitcoind.rpc_help()) and
140             not (yield bitcoind.rpc_getinfo())['testnet']
141         )),
142         SUBSIDY_FUNC=lambda height: 20*100000000 >> (height + 1)//1050000,
143         POW_FUNC=data.hash256,
144         BLOCK_PERIOD=120, # s
145         SYMBOL='TRC',
146         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'),
147         BLOCK_EXPLORER_URL_PREFIX='http://cryptocoinexplorer.com:3750/block/',
148         ADDRESS_EXPLORER_URL_PREFIX='http://cryptocoinexplorer.com:3750/address/',
149         SANE_TARGET_RANGE=(2**256//2**32//1000 - 1, 2**256//2**32 - 1),
150         DUMB_SCRYPT_DIFF=1,
151         DUST_THRESHOLD=1e8,
152     ),
153     terracoin_testnet=math.Object(
154         P2P_PREFIX='41babe56'.decode('hex'),
155         P2P_PORT=23333,
156         ADDRESS_VERSION=111,
157         RPC_PORT=23332,
158         RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
159             'terracoinaddress' in (yield bitcoind.rpc_help()) and
160             (yield bitcoind.rpc_getinfo())['testnet']
161         )),
162         SUBSIDY_FUNC=lambda height: 20*100000000 >> (height + 1)//1050000,
163         POW_FUNC=data.hash256,
164         BLOCK_PERIOD=120, # s
165         SYMBOL='tTRC',
166         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'),
167         BLOCK_EXPLORER_URL_PREFIX='http://cryptocoinexplorer.com:3750/testnet/block/',
168         ADDRESS_EXPLORER_URL_PREFIX='http://cryptocoinexplorer.com:3750/testnet/address/',
169         SANE_TARGET_RANGE=(2**256//2**32//1000 - 1, 2**256//2**32 - 1),
170         DUMB_SCRYPT_DIFF=1,
171         DUST_THRESHOLD=1e8,
172     ),
173
174 )
175 for net_name, net in nets.iteritems():
176     net.NAME = net_name