import itertools
import struct
+from twisted.internet import defer
+
from . import base58, skiplists
from p2pool.util import bases, math, variable
import p2pool
BITCOIN_P2P_PREFIX = 'f9beb4d9'.decode('hex')
BITCOIN_P2P_PORT = 8333
BITCOIN_ADDRESS_VERSION = 0
+ BITCOIN_RPC_CHECK = staticmethod(defer.inlineCallbacks(lambda bitcoind: defer.returnValue('name_firstupdate' not in (yield bitcoind.rpc_help()) and not (yield bitcoind.rpc_getinfo())['testnet'])))
class Testnet(object):
BITCOIN_P2P_PREFIX = 'fabfb5da'.decode('hex')
BITCOIN_P2P_PORT = 18333
BITCOIN_ADDRESS_VERSION = 111
+ BITCOIN_RPC_CHECK = staticmethod(defer.inlineCallbacks(lambda bitcoind: defer.returnValue('name_firstupdate' not in (yield bitcoind.rpc_help()) and (yield bitcoind.rpc_getinfo())['testnet'])))
url = 'http://%s:%i/' % (args.bitcoind_address, args.bitcoind_rpc_port)
print '''Testing bitcoind RPC connection to '%s' with username '%s'...''' % (url, args.bitcoind_rpc_username)
bitcoind = jsonrpc.Proxy(url, (args.bitcoind_rpc_username, args.bitcoind_rpc_password))
+ good = yield args.net.BITCOIN_RPC_CHECK(bitcoind)
+ if not good:
+ print " Check failed! Make sure that you're connected to the right bitcoind with --bitcoind-rpc-port!"
+ return
temp_work, temp_height = yield getwork(bitcoind)
print ' ...success!'
print ' Current block hash: %x height: %i' % (temp_work.previous_block, temp_height)
log.err()
except:
log.err(None, 'Fatal error:')
+ finally:
reactor.stop()
def run():
BITCOIN_P2P_PREFIX = 'f9beb4fe'.decode('hex')
BITCOIN_P2P_PORT = 8334
BITCOIN_ADDRESS_VERSION = 52
+ BITCOIN_RPC_CHECK = staticmethod(defer.inlineCallbacks(lambda bitcoind: defer.returnValue('name_firstupdate' in (yield bitcoind.rpc_help()) and not (yield bitcoind.rpc_getinfo())['testnet'])))
class NamecoinTestnet(object):
BITCOIN_P2P_PREFIX = 'fabfb5fe'.decode('hex')
BITCOIN_P2P_PORT = 18334
BITCOIN_ADDRESS_VERSION = 111
+ BITCOIN_RPC_CHECK = staticmethod(defer.inlineCallbacks(lambda bitcoind: defer.returnValue('name_firstupdate' in (yield bitcoind.rpc_help()) and (yield bitcoind.rpc_getinfo())['testnet'])))