Ejemplo n.º 1
0
def get_bitcoind( new_bitcoind_opts=None, reset=False, new=False ):
   """
   Get or instantiate our bitcoind client.
   Optionally re-set the bitcoind options.
   """
   global bitcoind 
   global bitcoin_opts 
   
   if reset:
       bitcoind = None
   
   elif not new and bitcoind is not None:
      return bitcoind 
   
   if new or bitcoind is None:
      if new_bitcoind_opts is not None:
         bitcoin_opts = new_bitcoind_opts
      
      new_bitcoind = None
      try:
         new_bitcoind = virtualchain.connect_bitcoind( bitcoin_opts )
         
         if new:
             return new_bitcoind
         
         else:
             # save for subsequent reuse 
             bitcoind = new_bitcoind
             return bitcoind 
      
      except Exception, e:
         log.exception( e )
         return None 
Ejemplo n.º 2
0
def get_bitcoind_client(config_path=CONFIG_PATH):
    """
    Connect to bitcoind
    """
    bitcoind_opts = virtualchain.get_bitcoind_config(config_file=config_path)
    log.debug("Connect to bitcoind at %s:%s (%s)" % (bitcoind_opts['bitcoind_server'], bitcoind_opts['bitcoind_port'], config_path))
    client = virtualchain.connect_bitcoind( bitcoind_opts )

    return client
Ejemplo n.º 3
0
def get_bitcoind_client(config_path=CONFIG_PATH):
    """
    Connect to bitcoind
    """
    bitcoind_opts = virtualchain.get_bitcoind_config(config_file=config_path)
    if bitcoind_opts['bitcoind_mock']:
        # testing 
        log.debug("Connect to mock bitcoind (%s)" % config_path)
       
        # mock bitcoind requires mock utxo options as well
        utxo_opts = blockstack_utxo.default_mock_utxo_opts(config_path)
        bitcoind_opts.update(utxo_opts)

        from blockstack_integration_tests import connect_mock_bitcoind
        client = connect_mock_bitcoind( bitcoind_opts, reset=True )
    else:
        # production
        log.debug("Connect to production bitcoind (%s)" % config_path)
        client = virtualchain.connect_bitcoind( bitcoind_opts )

    return client