X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=p2pool%2Fbitcoin%2Fnetworks.py;h=9db3252eb4b947b3dfc6b41cd162435493cb526c;hb=f732111a6e08d7d0649c330d1c703535a8ea80b5;hp=aa86224f6b81f5edbf7c6d530ea7ed51dda1692e;hpb=fb1e69bf13ff677bc9f79ebb49d8d0e838502375;p=p2pool.git diff --git a/p2pool/bitcoin/networks.py b/p2pool/bitcoin/networks.py index aa86224..9db3252 100644 --- a/p2pool/bitcoin/networks.py +++ b/p2pool/bitcoin/networks.py @@ -4,112 +4,63 @@ 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) + +@defer.inlineCallbacks +def get_subsidy(bitcoind, target): + res = yield bitcoind.rpc_getblock(target) + + defer.returnValue(res) nets = dict( - bitcoin=math.Object( - P2P_PREFIX='f9beb4d9'.decode('hex'), - P2P_PORT=8333, - ADDRESS_VERSION=0, - RPC_PORT=8332, + novacoin=math.Object( + P2P_PREFIX='e4e8e9e5'.decode('hex'), + P2P_PORT=7777, + ADDRESS_VERSION=8, + RPC_PORT=8344, RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue( - 'bitcoinaddress' in (yield bitcoind.rpc_help()) and + 0 == (yield bitcoind.rpc_getblock('00000a060336cbb72fe969666d337b87198b1add2abaa59cca226820b32933a4'))['height'] and not (yield bitcoind.rpc_getinfo())['testnet'] )), - POW_FUNC=data.hash256, + SUBSIDY_FUNC=lambda bitcoind, target: get_subsidy(bitcoind, target), 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_MAX_TARGET=2**256//2**32 - 1, + SYMBOL='NVC', + CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'NovaCoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/NovaCoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.novacoin'), 'novacoin.conf'), + BLOCK_EXPLORER_URL_PREFIX='http://explorer.novaco.in/block/', + ADDRESS_EXPLORER_URL_PREFIX='http://explorer.novaco.in/address/', + TX_EXPLORER_URL_PREFIX='http://explorer.novaco.in/tx/', + SANE_TARGET_RANGE=(2**256//1000000000 - 1, 2**256//1000 - 1), + DUMB_SCRYPT_DIFF=2**16, + DUST_THRESHOLD=0.01e6, ), - bitcoin_testnet=math.Object( - P2P_PREFIX='fabfb5da'.decode('hex'), - P2P_PORT=18333, + novacoin_testnet=math.Object( + P2P_PREFIX='cdf2c0ef'.decode('hex'), + P2P_PORT=17777, ADDRESS_VERSION=111, - RPC_PORT=8332, + RPC_PORT=18344, RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue( - 'bitcoinaddress' in (yield bitcoind.rpc_help()) and + 0 == (yield bitcoind.rpc_getblock('0000c763e402f2436da9ed36c7286f62c3f6e5dbafce9ff289bd43d7459327eb'))['height'] and (yield bitcoind.rpc_getinfo())['testnet'] )), - POW_FUNC=data.hash256, - BLOCK_PERIOD=600, # s - SYMBOL='tBTC', - 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_MAX_TARGET=2**256//2**32 - 1, - ), - - namecoin=math.Object( - P2P_PREFIX='f9beb4fe'.decode('hex'), - P2P_PORT=8334, - ADDRESS_VERSION=52, - RPC_PORT=8332, - RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue( - 'namecoinaddress' in (yield bitcoind.rpc_help()) and - not (yield bitcoind.rpc_getinfo())['testnet'] - )), - POW_FUNC=data.hash256, + SUBSIDY_FUNC=lambda bitcoind, target: get_subsidy(bitcoind, target), BLOCK_PERIOD=600, # s - SYMBOL='NMC', - 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/', - SANE_MAX_TARGET=2**256//2**32 - 1, - ), - namecoin_testnet=math.Object( - P2P_PREFIX='fabfb5fe'.decode('hex'), - P2P_PORT=18334, - ADDRESS_VERSION=111, - RPC_PORT=8332, - RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue( - 'namecoinaddress' in (yield bitcoind.rpc_help()) and - (yield bitcoind.rpc_getinfo())['testnet'] - )), - POW_FUNC=data.hash256, - BLOCK_PERIOD=600, # s - SYMBOL='tNMC', - 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/', - SANE_MAX_TARGET=2**256//2**32 - 1, - ), - - litecoin=math.Object( - P2P_PREFIX='fbc0b6db'.decode('hex'), - P2P_PORT=9333, - ADDRESS_VERSION=48, - RPC_PORT=9332, - RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue( - 'litecoinaddress' in (yield bitcoind.rpc_help()) and - not (yield bitcoind.rpc_getinfo())['testnet'] - )), - POW_FUNC=lambda data: pack.IntType(256).unpack(__import__('ltc_scrypt').getPoWHash(data)), - BLOCK_PERIOD=150, # s - SYMBOL='LTC', - 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://abe.liteco.in/block/', - ADDRESS_EXPLORER_URL_PREFIX='http://abe.liteco.in/address/', - SANE_MAX_TARGET=2**256//1000 - 1, - ), - litecoin_testnet=math.Object( - P2P_PREFIX='fcc1b7dc'.decode('hex'), - P2P_PORT=19333, - ADDRESS_VERSION=111, - RPC_PORT=19332, - RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue( - 'litecoinaddress' in (yield bitcoind.rpc_help()) and - (yield bitcoind.rpc_getinfo())['testnet'] - )), - POW_FUNC=lambda data: pack.IntType(256).unpack(__import__('ltc_scrypt').getPoWHash(data)), - BLOCK_PERIOD=150, # s - SYMBOL='tLTC', - 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_MAX_TARGET=2**256//1000 - 1, + SYMBOL='tNVC', + CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'NovaCoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/NovaCoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.novacoin'), 'novacoin.conf'), + BLOCK_EXPLORER_URL_PREFIX='http://novacoin.su/block/', + ADDRESS_EXPLORER_URL_PREFIX='http://novacoin.su/address/', + TX_EXPLORER_URL_PREFIX='http://novacoin.su/tx/', + SANE_TARGET_RANGE=(2**256//1000000000 - 1, 2**256//1000 - 1), + DUMB_SCRYPT_DIFF=2**16, + DUST_THRESHOLD=0.01e6, ), ) for net_name, net in nets.iteritems():