moved CONF_FILE_FUNCs from networks to bitcoin.networks, added the namecoin func...
[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 BitcoinMainnet = math.Object(
10     P2P_PREFIX='f9beb4d9'.decode('hex'),
11     P2P_PORT=8333,
12     ADDRESS_VERSION=0,
13     RPC_PORT=8332,
14     RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
15         'bitcoinaddress' in (yield bitcoind.rpc_help()) and
16         not (yield bitcoind.rpc_getinfo())['testnet']
17     )),
18     POW_FUNC=data.hash256,
19     SYMBOL='BTC',
20     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'),
21 )
22 BitcoinTestnet = math.Object(
23     P2P_PREFIX='fabfb5da'.decode('hex'),
24     P2P_PORT=18333,
25     ADDRESS_VERSION=111,
26     RPC_PORT=8332,
27     RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
28         'bitcoinaddress' in (yield bitcoind.rpc_help()) and
29         (yield bitcoind.rpc_getinfo())['testnet']
30     )),
31     POW_FUNC=data.hash256,
32     SYMBOL='tBTC',
33     CONF_FILE_FUNC=BitcoinMainnet.CONF_FILE_FUNC,
34 )
35
36 NamecoinMainnet = math.Object(
37     P2P_PREFIX='f9beb4fe'.decode('hex'),
38     P2P_PORT=8334,
39     ADDRESS_VERSION=52,
40     RPC_PORT=8332,
41     RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
42         'namecoinaddress' in (yield bitcoind.rpc_help()) and
43         not (yield bitcoind.rpc_getinfo())['testnet']
44     )),
45     POW_FUNC=data.hash256,
46     SYMBOL='NMC',
47     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'),
48 )
49 NamecoinTestnet = math.Object(
50     P2P_PREFIX='fabfb5fe'.decode('hex'),
51     P2P_PORT=18334,
52     ADDRESS_VERSION=111,
53     RPC_PORT=8332,
54     RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
55         'namecoinaddress' in (yield bitcoind.rpc_help()) and
56         (yield bitcoind.rpc_getinfo())['testnet']
57     )),
58     POW_FUNC=data.hash256,
59     SYMBOL='tNMC',
60     CONF_FILE_FUNC=NamecoinMainnet.CONF_FILE_FUNC,
61 )
62
63 LitecoinMainnet = math.Object(
64     P2P_PREFIX='fbc0b6db'.decode('hex'),
65     P2P_PORT=9333,
66     ADDRESS_VERSION=48,
67     RPC_PORT=9332,
68     RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
69         'litecoinaddress' in (yield bitcoind.rpc_help()) and
70         not (yield bitcoind.rpc_getinfo())['testnet']
71     )),
72     POW_FUNC=lambda data: pack.IntType(256).unpack(__import__('ltc_scrypt').getPoWHash(data)),
73     SYMBOL='LTC',
74     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'),
75 )
76 LitecoinTestnet = math.Object(
77     P2P_PREFIX='fcc1b7dc'.decode('hex'),
78     P2P_PORT=19333,
79     ADDRESS_VERSION=111,
80     RPC_PORT=19332,
81     RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
82         'litecoinaddress' in (yield bitcoind.rpc_help()) and
83         (yield bitcoind.rpc_getinfo())['testnet']
84     )),
85     POW_FUNC=lambda data: pack.IntType(256).unpack(__import__('ltc_scrypt').getPoWHash(data)),
86     SYMBOL='tLTC',
87     CONF_FILE_FUNC=LitecoinMainnet.CONF_FILE_FUNC,
88 )