4 from twisted.internet import defer
7 from p2pool.util import math, pack, jsonrpc
10 def check_genesis_block(bitcoind, genesis_block_hash):
12 yield bitcoind.rpc_getblock(genesis_block_hash)
13 except jsonrpc.Error_for_code(-5):
14 defer.returnValue(False)
16 defer.returnValue(True)
20 P2P_PREFIX='f9beb4d9'.decode('hex'),
24 RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
25 (yield check_genesis_block(bitcoind, '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f')) and
26 not (yield bitcoind.rpc_getinfo())['testnet']
28 SUBSIDY_FUNC=lambda height: 50*100000000 >> (height + 1)//210000,
29 POW_FUNC=data.hash256,
32 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'),
33 BLOCK_EXPLORER_URL_PREFIX='https://blockchain.info/block/',
34 ADDRESS_EXPLORER_URL_PREFIX='https://blockchain.info/address/',
35 TX_EXPLORER_URL_PREFIX='https://blockchain.info/tx/',
36 SANE_TARGET_RANGE=(2**256//2**32//1000 - 1, 2**256//2**32 - 1),
38 DUST_THRESHOLD=0.001e8,
40 bitcoin_testnet=math.Object(
41 P2P_PREFIX='0b110907'.decode('hex'),
45 RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
46 'bitcoinaddress' in (yield bitcoind.rpc_help()) and
47 (yield bitcoind.rpc_getinfo())['testnet']
49 SUBSIDY_FUNC=lambda height: 50*100000000 >> (height + 1)//210000,
50 POW_FUNC=data.hash256,
53 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'),
54 BLOCK_EXPLORER_URL_PREFIX='http://blockexplorer.com/testnet/block/',
55 ADDRESS_EXPLORER_URL_PREFIX='http://blockexplorer.com/testnet/address/',
56 TX_EXPLORER_URL_PREFIX='http://blockexplorer.com/testnet/tx/',
57 SANE_TARGET_RANGE=(2**256//2**32//1000 - 1, 2**256//2**32 - 1),
63 P2P_PREFIX='f9beb4fe'.decode('hex'),
67 RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
68 'namecoinaddress' in (yield bitcoind.rpc_help()) and
69 not (yield bitcoind.rpc_getinfo())['testnet']
71 SUBSIDY_FUNC=lambda height: 50*100000000 >> (height + 1)//210000,
72 POW_FUNC=data.hash256,
75 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'),
76 BLOCK_EXPLORER_URL_PREFIX='http://explorer.dot-bit.org/b/',
77 ADDRESS_EXPLORER_URL_PREFIX='http://explorer.dot-bit.org/a/',
78 TX_EXPLORER_URL_PREFIX='http://explorer.dot-bit.org/tx/',
79 SANE_TARGET_RANGE=(2**256//2**32 - 1, 2**256//2**32 - 1),
83 namecoin_testnet=math.Object(
84 P2P_PREFIX='fabfb5fe'.decode('hex'),
88 RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
89 'namecoinaddress' in (yield bitcoind.rpc_help()) and
90 (yield bitcoind.rpc_getinfo())['testnet']
92 SUBSIDY_FUNC=lambda height: 50*100000000 >> (height + 1)//210000,
93 POW_FUNC=data.hash256,
96 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'),
97 BLOCK_EXPLORER_URL_PREFIX='http://testnet.explorer.dot-bit.org/b/',
98 ADDRESS_EXPLORER_URL_PREFIX='http://testnet.explorer.dot-bit.org/a/',
99 TX_EXPLORER_URL_PREFIX='http://testnet.explorer.dot-bit.org/tx/',
100 SANE_TARGET_RANGE=(2**256//2**32 - 1, 2**256//2**32 - 1),
105 litecoin=math.Object(
106 P2P_PREFIX='fbc0b6db'.decode('hex'),
110 RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
111 'litecoinaddress' in (yield bitcoind.rpc_help()) and
112 not (yield bitcoind.rpc_getinfo())['testnet']
114 SUBSIDY_FUNC=lambda height: 50*100000000 >> (height + 1)//840000,
115 POW_FUNC=lambda data: pack.IntType(256).unpack(__import__('ltc_scrypt').getPoWHash(data)),
116 BLOCK_PERIOD=150, # s
118 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'),
119 BLOCK_EXPLORER_URL_PREFIX='http://explorer.litecoin.net/block/',
120 ADDRESS_EXPLORER_URL_PREFIX='http://explorer.litecoin.net/address/',
121 TX_EXPLORER_URL_PREFIX='http://explorer.litecoin.net/tx/',
122 SANE_TARGET_RANGE=(2**256//1000000000 - 1, 2**256//1000 - 1),
123 DUMB_SCRYPT_DIFF=2**16,
124 DUST_THRESHOLD=0.03e8,
126 litecoin_testnet=math.Object(
127 P2P_PREFIX='fcc1b7dc'.decode('hex'),
131 RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
132 'litecoinaddress' in (yield bitcoind.rpc_help()) and
133 (yield bitcoind.rpc_getinfo())['testnet']
135 SUBSIDY_FUNC=lambda height: 50*100000000 >> (height + 1)//840000,
136 POW_FUNC=lambda data: pack.IntType(256).unpack(__import__('ltc_scrypt').getPoWHash(data)),
137 BLOCK_PERIOD=150, # s
139 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'),
140 BLOCK_EXPLORER_URL_PREFIX='http://nonexistent-litecoin-testnet-explorer/block/',
141 ADDRESS_EXPLORER_URL_PREFIX='http://nonexistent-litecoin-testnet-explorer/address/',
142 TX_EXPLORER_URL_PREFIX='http://nonexistent-litecoin-testnet-explorer/tx/',
143 SANE_TARGET_RANGE=(2**256//1000000000 - 1, 2**256 - 1),
144 DUMB_SCRYPT_DIFF=2**16,
148 terracoin=math.Object(
149 P2P_PREFIX='42babe56'.decode('hex'),
153 RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
154 'terracoinaddress' in (yield bitcoind.rpc_help()) and
155 not (yield bitcoind.rpc_getinfo())['testnet']
157 SUBSIDY_FUNC=lambda height: 20*100000000 >> (height + 1)//1050000,
158 POW_FUNC=data.hash256,
159 BLOCK_PERIOD=120, # s
161 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'),
162 BLOCK_EXPLORER_URL_PREFIX='http://trc.cryptocoinexplorer.com/block/',
163 ADDRESS_EXPLORER_URL_PREFIX='http://trc.cryptocoinexplorer.com/address/',
164 TX_EXPLORER_URL_PREFIX='http://trc.cryptocoinexplorer.com/tx/',
165 SANE_TARGET_RANGE=(2**256//2**32//1000 - 1, 2**256//2**32 - 1),
169 terracoin_testnet=math.Object(
170 P2P_PREFIX='41babe56'.decode('hex'),
174 RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
175 'terracoinaddress' in (yield bitcoind.rpc_help()) and
176 (yield bitcoind.rpc_getinfo())['testnet']
178 SUBSIDY_FUNC=lambda height: 20*100000000 >> (height + 1)//1050000,
179 POW_FUNC=data.hash256,
180 BLOCK_PERIOD=120, # s
182 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'),
183 BLOCK_EXPLORER_URL_PREFIX='http://trc.cryptocoinexplorer.com/testnet/block/',
184 ADDRESS_EXPLORER_URL_PREFIX='http://trc.cryptocoinexplorer.com/testnet/address/',
185 TX_EXPLORER_URL_PREFIX='http://trc.cryptocoinexplorer.com/testnet/tx/',
186 SANE_TARGET_RANGE=(2**256//2**32//1000 - 1, 2**256//2**32 - 1),
192 for net_name, net in nets.iteritems():