Beispiel #1
0
def get_seed():
    # type: () -> bytes
    """
    Prompts the user securely for their seed.
    """
    print(
        'Enter seed and press return (typing will not be shown).  '
        'If empty, a random seed will be generated and displayed on the screen.'
    )
    seed = secure_input('')  # type: Text
    return seed.encode('ascii')
Beispiel #2
0
    def prompt_for_seed() -> Seed:
        """
        Prompts the user to enter their seed via stdin.
        """
        seed = secure_input(
            'Enter seed and press return (typing will not be shown).\n'
            'If no seed is specified, a random one will be used instead.\n')

        if isinstance(seed, str):
            seed = seed.encode('ascii')

        return Seed(seed) if seed else Seed.random()
Beispiel #3
0
  def prompt_for_seed():
    # type: () -> Seed
    """
    Prompts the user to enter their seed via stdin.
    """
    seed = secure_input(
      'Enter seed and press return (typing will not be shown).\n'
      'If no seed is specified, a random one will be used instead.\n'
    )

    if isinstance(seed, text_type):
      seed = seed.encode('ascii')

    return Seed(seed) if seed else Seed.random()
Beispiel #4
0
def main(uri, testnet, pow_uri, debug_requests):
  # type: (Text, bool, Text, bool) -> None
  seed = secure_input(
    'Enter seed and press return (typing will not be shown).\n'
    'If no seed is specified, a random one will be used instead.\n'
  )

  if isinstance(seed, text_type):
    seed = seed.encode('ascii')

  adapter_ = resolve_adapter(uri)

  # If ``pow_uri`` is specified, route POW requests to a separate node.
  if pow_uri:
    pow_adapter = resolve_adapter(pow_uri)

    adapter_ =\
      RoutingWrapper(adapter_)\
        .add_route('attachToTangle', pow_adapter)\
        .add_route('interruptAttachingToTangle', pow_adapter)

  # If ``debug_requests`` is specified, log HTTP requests/responses.
  if debug_requests:
    basicConfig(level=DEBUG, stream=stderr)

    logger = getLogger(__name__)
    logger.setLevel(DEBUG)

    adapter_.set_logger(logger)

  cornode = cornode(adapter_, seed=seed, testnet=testnet)

  # To speed up certain operations, install an address cache.
  AddressGenerator.cache = MemoryAddressCache()

  _banner = (
    'cornode API client for {uri} ({testnet}) initialized as variable `cornode`.\n'
    'Type `help(cornode)` for help.'.format(
      testnet = 'testnet' if testnet else 'mainnet',
      uri     = uri,
    )
  )

  start_shell(cornode, _banner)
Beispiel #5
0
def main(uri, testnet, pow_uri, debug_requests):
    # type: (Text, bool, Text, bool) -> None
    seed = secure_input(
        'Enter seed and press return (typing will not be shown).\n'
        'If no seed is specified, a random one will be used instead.\n')

    if isinstance(seed, text_type):
        seed = seed.encode('ascii')

    adapter_ = resolve_adapter(uri)

    # If ``pow_uri`` is specified, route POW requests to a separate node.
    if pow_uri:
        pow_adapter = resolve_adapter(pow_uri)

        adapter_ =\
          RoutingWrapper(adapter_)\
            .add_route('attachToTangle', pow_adapter)\
            .add_route('interruptAttachingToTangle', pow_adapter)

    # If ``debug_requests`` is specified, log HTTP requests/responses.
    if debug_requests:
        logger = getLogger(__name__)
        logger.setLevel(DEBUG)
        adapter_.set_logger(logger)

    iota = Iota(adapter_, seed=seed, testnet=testnet)

    _banner = (
        'IOTA API client for {uri} ({testnet}) initialized as variable `iota`.\n'
        'Type `help(iota)` for help.'.format(
            testnet='testnet' if testnet else 'mainnet',
            uri=uri,
        ))

    start_shell(iota, _banner)