X-Git-Url: https://git.novaco.in/?p=p2pool.git;a=blobdiff_plain;f=p2pool%2Fbitcoin%2Fnetworks.py;h=c604696989fff9c38729cc15902c9725536291a7;hp=6e074f37dfb8d145bf89405dfeacd6d03eb43808;hb=f727ee10bf40c7b050b6fcc54ac491a21199b6ec;hpb=0ca9aa7494df862a242b479d50d48e84fafb0de7 diff --git a/p2pool/bitcoin/networks.py b/p2pool/bitcoin/networks.py index 6e074f3..c604696 100644 --- a/p2pool/bitcoin/networks.py +++ b/p2pool/bitcoin/networks.py @@ -4,7 +4,16 @@ import platform from twisted.internet import defer from . import data -from p2pool.util import math, pack +from p2pool.util import math, pack, jsonrpc + +@defer.inlineCallbacks +def check_genesis_block(bitcoind, genesis_block_hash): + try: + yield bitcoind.rpc_getblock(genesis_block_hash) + except jsonrpc.Error_for_code(-5): + defer.returnValue(False) + else: + defer.returnValue(True) nets = dict( bitcoin=math.Object( @@ -13,7 +22,7 @@ nets = dict( ADDRESS_VERSION=0, RPC_PORT=8332, RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue( - 'bitcoinaddress' in (yield bitcoind.rpc_help()) and + (yield check_genesis_block(bitcoind, '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f')) and not (yield bitcoind.rpc_getinfo())['testnet'] )), SUBSIDY_FUNC=lambda height: 50*100000000 >> (height + 1)//210000, @@ -21,9 +30,12 @@ nets = dict( BLOCK_PERIOD=600, # s SYMBOL='BTC', 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'), - BLOCK_EXPLORER_URL_PREFIX='http://blockexplorer.com/block/', - ADDRESS_EXPLORER_URL_PREFIX='http://blockexplorer.com/address/', - SANE_TARGET_RANGE=(2**256//2**32 - 1, 2**256//2**32 - 1), + BLOCK_EXPLORER_URL_PREFIX='https://blockchain.info/block/', + ADDRESS_EXPLORER_URL_PREFIX='https://blockchain.info/address/', + TX_EXPLORER_URL_PREFIX='https://blockchain.info/tx/', + SANE_TARGET_RANGE=(2**256//2**32//1000 - 1, 2**256//2**32 - 1), + DUMB_SCRYPT_DIFF=1, + DUST_THRESHOLD=0.001e8, ), bitcoin_testnet=math.Object( P2P_PREFIX='0b110907'.decode('hex'), @@ -41,7 +53,10 @@ nets = dict( 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'), BLOCK_EXPLORER_URL_PREFIX='http://blockexplorer.com/testnet/block/', ADDRESS_EXPLORER_URL_PREFIX='http://blockexplorer.com/testnet/address/', - SANE_TARGET_RANGE=(2**256//2**32 - 1, 2**256//2**32 - 1), + TX_EXPLORER_URL_PREFIX='http://blockexplorer.com/testnet/tx/', + SANE_TARGET_RANGE=(2**256//2**32//1000 - 1, 2**256//2**32 - 1), + DUMB_SCRYPT_DIFF=1, + DUST_THRESHOLD=1e8, ), namecoin=math.Object( @@ -60,7 +75,10 @@ nets = dict( 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'), BLOCK_EXPLORER_URL_PREFIX='http://explorer.dot-bit.org/b/', ADDRESS_EXPLORER_URL_PREFIX='http://explorer.dot-bit.org/a/', + TX_EXPLORER_URL_PREFIX='http://explorer.dot-bit.org/tx/', SANE_TARGET_RANGE=(2**256//2**32 - 1, 2**256//2**32 - 1), + DUMB_SCRYPT_DIFF=1, + DUST_THRESHOLD=0.2e8, ), namecoin_testnet=math.Object( P2P_PREFIX='fabfb5fe'.decode('hex'), @@ -78,7 +96,10 @@ nets = dict( 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'), BLOCK_EXPLORER_URL_PREFIX='http://testnet.explorer.dot-bit.org/b/', ADDRESS_EXPLORER_URL_PREFIX='http://testnet.explorer.dot-bit.org/a/', + TX_EXPLORER_URL_PREFIX='http://testnet.explorer.dot-bit.org/tx/', SANE_TARGET_RANGE=(2**256//2**32 - 1, 2**256//2**32 - 1), + DUMB_SCRYPT_DIFF=1, + DUST_THRESHOLD=1e8, ), litecoin=math.Object( @@ -97,7 +118,10 @@ nets = dict( 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'), BLOCK_EXPLORER_URL_PREFIX='http://explorer.litecoin.net/block/', ADDRESS_EXPLORER_URL_PREFIX='http://explorer.litecoin.net/address/', + TX_EXPLORER_URL_PREFIX='http://explorer.litecoin.net/tx/', SANE_TARGET_RANGE=(2**256//1000000000 - 1, 2**256//1000 - 1), + DUMB_SCRYPT_DIFF=2**16, + DUST_THRESHOLD=0.03e8, ), litecoin_testnet=math.Object( P2P_PREFIX='fcc1b7dc'.decode('hex'), @@ -115,8 +139,55 @@ nets = dict( 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'), BLOCK_EXPLORER_URL_PREFIX='http://nonexistent-litecoin-testnet-explorer/block/', ADDRESS_EXPLORER_URL_PREFIX='http://nonexistent-litecoin-testnet-explorer/address/', - SANE_TARGET_RANGE=(2**256//1000000000 - 1, 2**256//1000 - 1), + TX_EXPLORER_URL_PREFIX='http://nonexistent-litecoin-testnet-explorer/tx/', + SANE_TARGET_RANGE=(2**256//1000000000 - 1, 2**256 - 1), + DUMB_SCRYPT_DIFF=2**16, + DUST_THRESHOLD=1e8, ), + + terracoin=math.Object( + P2P_PREFIX='42babe56'.decode('hex'), + P2P_PORT=13333, + ADDRESS_VERSION=0, + RPC_PORT=13332, + RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue( + 'terracoinaddress' in (yield bitcoind.rpc_help()) and + not (yield bitcoind.rpc_getinfo())['testnet'] + )), + SUBSIDY_FUNC=lambda height: 20*100000000 >> (height + 1)//1050000, + POW_FUNC=data.hash256, + BLOCK_PERIOD=120, # s + SYMBOL='TRC', + CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Terracoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Terracoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.terracoin'), 'terracoin.conf'), + BLOCK_EXPLORER_URL_PREFIX='http://trc.cryptocoinexplorer.com/block/', + ADDRESS_EXPLORER_URL_PREFIX='http://trc.cryptocoinexplorer.com/address/', + TX_EXPLORER_URL_PREFIX='http://trc.cryptocoinexplorer.com/tx/', + SANE_TARGET_RANGE=(2**256//2**32//1000 - 1, 2**256//2**32 - 1), + DUMB_SCRYPT_DIFF=1, + DUST_THRESHOLD=1e8, + ), + terracoin_testnet=math.Object( + P2P_PREFIX='41babe56'.decode('hex'), + P2P_PORT=23333, + ADDRESS_VERSION=111, + RPC_PORT=23332, + RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue( + 'terracoinaddress' in (yield bitcoind.rpc_help()) and + (yield bitcoind.rpc_getinfo())['testnet'] + )), + SUBSIDY_FUNC=lambda height: 20*100000000 >> (height + 1)//1050000, + POW_FUNC=data.hash256, + BLOCK_PERIOD=120, # s + SYMBOL='tTRC', + CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Terracoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Terracoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.terracoin'), 'terracoin.conf'), + BLOCK_EXPLORER_URL_PREFIX='http://trc.cryptocoinexplorer.com/testnet/block/', + ADDRESS_EXPLORER_URL_PREFIX='http://trc.cryptocoinexplorer.com/testnet/address/', + TX_EXPLORER_URL_PREFIX='http://trc.cryptocoinexplorer.com/testnet/tx/', + SANE_TARGET_RANGE=(2**256//2**32//1000 - 1, 2**256//2**32 - 1), + DUMB_SCRYPT_DIFF=1, + DUST_THRESHOLD=1e8, + ), + ) for net_name, net in nets.iteritems(): net.NAME = net_name