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