fixed address link going to block explorer page
[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         ADDRESS_EXPLORER_URL_PREFIX='http://blockexplorer.com/address/',
25         SANE_MAX_TARGET=2**256//2**32 - 1,
26     ),
27     bitcoin_testnet=math.Object(
28         P2P_PREFIX='fabfb5da'.decode('hex'),
29         P2P_PORT=18333,
30         ADDRESS_VERSION=111,
31         RPC_PORT=8332,
32         RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
33             'bitcoinaddress' in (yield bitcoind.rpc_help()) and
34             (yield bitcoind.rpc_getinfo())['testnet']
35         )),
36         POW_FUNC=data.hash256,
37         BLOCK_PERIOD=600, # s
38         SYMBOL='tBTC',
39         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'),
40         BLOCK_EXPLORER_URL_PREFIX='http://blockexplorer.com/testnet/block/',
41         ADDRESS_EXPLORER_URL_PREFIX='http://blockexplorer.com/testnet/address/',
42         SANE_MAX_TARGET=2**256//2**32 - 1,
43     ),
44     
45     namecoin=math.Object(
46         P2P_PREFIX='f9beb4fe'.decode('hex'),
47         P2P_PORT=8334,
48         ADDRESS_VERSION=52,
49         RPC_PORT=8332,
50         RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
51             'namecoinaddress' in (yield bitcoind.rpc_help()) and
52             not (yield bitcoind.rpc_getinfo())['testnet']
53         )),
54         POW_FUNC=data.hash256,
55         BLOCK_PERIOD=600, # s
56         SYMBOL='NMC',
57         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'),
58         BLOCK_EXPLORER_URL_PREFIX='http://explorer.dot-bit.org/b/',
59         ADDRESS_EXPLORER_URL_PREFIX='http://explorer.dot-bit.org/a/',
60         SANE_MAX_TARGET=2**256//2**32 - 1,
61     ),
62     namecoin_testnet=math.Object(
63         P2P_PREFIX='fabfb5fe'.decode('hex'),
64         P2P_PORT=18334,
65         ADDRESS_VERSION=111,
66         RPC_PORT=8332,
67         RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
68             'namecoinaddress' in (yield bitcoind.rpc_help()) and
69             (yield bitcoind.rpc_getinfo())['testnet']
70         )),
71         POW_FUNC=data.hash256,
72         BLOCK_PERIOD=600, # s
73         SYMBOL='tNMC',
74         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'),
75         BLOCK_EXPLORER_URL_PREFIX='http://testnet.explorer.dot-bit.org/b/',
76         ADDRESS_EXPLORER_URL_PREFIX='http://testnet.explorer.dot-bit.org/a/',
77         SANE_MAX_TARGET=2**256//2**32 - 1,
78     ),
79     
80     litecoin=math.Object(
81         P2P_PREFIX='fbc0b6db'.decode('hex'),
82         P2P_PORT=9333,
83         ADDRESS_VERSION=48,
84         RPC_PORT=9332,
85         RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
86             'litecoinaddress' in (yield bitcoind.rpc_help()) and
87             not (yield bitcoind.rpc_getinfo())['testnet']
88         )),
89         POW_FUNC=lambda data: pack.IntType(256).unpack(__import__('ltc_scrypt').getPoWHash(data)),
90         BLOCK_PERIOD=150, # s
91         SYMBOL='LTC',
92         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'),
93         BLOCK_EXPLORER_URL_PREFIX='http://abe.liteco.in/block/',
94         ADDRESS_EXPLORER_URL_PREFIX='http://abe.liteco.in/address/',
95         SANE_MAX_TARGET=2**256//1000 - 1,
96     ),
97     litecoin_testnet=math.Object(
98         P2P_PREFIX='fcc1b7dc'.decode('hex'),
99         P2P_PORT=19333,
100         ADDRESS_VERSION=111,
101         RPC_PORT=19332,
102         RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
103             'litecoinaddress' in (yield bitcoind.rpc_help()) and
104             (yield bitcoind.rpc_getinfo())['testnet']
105         )),
106         POW_FUNC=lambda data: pack.IntType(256).unpack(__import__('ltc_scrypt').getPoWHash(data)),
107         BLOCK_PERIOD=150, # s
108         SYMBOL='tLTC',
109         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'),
110         BLOCK_EXPLORER_URL_PREFIX='http://nonexistent-litecoin-testnet-explorer/block/',
111         ADDRESS_EXPLORER_URL_PREFIX='http://nonexistent-litecoin-testnet-explorer/address/',
112         SANE_MAX_TARGET=2**256//1000 - 1,
113     ),
114 )
115 for net_name, net in nets.iteritems():
116     net.NAME = net_name