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