66e50dacd73bb5fbf6ae8db0bf6ad4390dce35d7
[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         SYMBOL='BTC',
21         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'),
22     ),
23     bitcoin_testnet=math.Object(
24         P2P_PREFIX='fabfb5da'.decode('hex'),
25         P2P_PORT=18333,
26         ADDRESS_VERSION=111,
27         RPC_PORT=8332,
28         RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
29             'bitcoinaddress' in (yield bitcoind.rpc_help()) and
30             (yield bitcoind.rpc_getinfo())['testnet']
31         )),
32         POW_FUNC=data.hash256,
33         SYMBOL='tBTC',
34         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'),
35     ),
36     
37     nameecoin=math.Object(
38         P2P_PREFIX='f9beb4fe'.decode('hex'),
39         P2P_PORT=8334,
40         ADDRESS_VERSION=52,
41         RPC_PORT=8332,
42         RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
43             'namecoinaddress' in (yield bitcoind.rpc_help()) and
44             not (yield bitcoind.rpc_getinfo())['testnet']
45         )),
46         POW_FUNC=data.hash256,
47         SYMBOL='NMC',
48         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'),
49     ),
50     namecoin_testnet=math.Object(
51         P2P_PREFIX='fabfb5fe'.decode('hex'),
52         P2P_PORT=18334,
53         ADDRESS_VERSION=111,
54         RPC_PORT=8332,
55         RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
56             'namecoinaddress' in (yield bitcoind.rpc_help()) and
57             (yield bitcoind.rpc_getinfo())['testnet']
58         )),
59         POW_FUNC=data.hash256,
60         SYMBOL='tNMC',
61         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'),
62     ),
63     
64     litecoin=math.Object(
65         P2P_PREFIX='fbc0b6db'.decode('hex'),
66         P2P_PORT=9333,
67         ADDRESS_VERSION=48,
68         RPC_PORT=9332,
69         RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
70             'litecoinaddress' in (yield bitcoind.rpc_help()) and
71             not (yield bitcoind.rpc_getinfo())['testnet']
72         )),
73         POW_FUNC=lambda data: pack.IntType(256).unpack(__import__('ltc_scrypt').getPoWHash(data)),
74         SYMBOL='LTC',
75         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'),
76     ),
77     litecoin_testnet=math.Object(
78         P2P_PREFIX='fcc1b7dc'.decode('hex'),
79         P2P_PORT=19333,
80         ADDRESS_VERSION=111,
81         RPC_PORT=19332,
82         RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
83             'litecoinaddress' in (yield bitcoind.rpc_help()) and
84             (yield bitcoind.rpc_getinfo())['testnet']
85         )),
86         POW_FUNC=lambda data: pack.IntType(256).unpack(__import__('ltc_scrypt').getPoWHash(data)),
87         SYMBOL='tLTC',
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     ),
90 )