Ejemplo n.º 1
0
    def _execute(self, request):
        inclusion_states = request['inclusionStates']  # type: bool
        seed = request['seed']  # type: Seed
        start = request['start']  # type: int
        stop = request['stop']  # type: Optional[int]

        # Determine the addresses we will be scanning, and pull their
        # transaction hashes.
        if stop is None:
            my_hashes = list(
                chain(*(hashes for _, hashes in iter_used_addresses(
                    self.adapter, seed, start))))
        else:
            ft_response = \
                FindTransactionsCommand(self.adapter)(
                    addresses=
                    AddressGenerator(seed).get_addresses(start, stop - start),
                )

            my_hashes = ft_response['hashes']

        return {
            'bundles':
            get_bundles_from_transaction_hashes(
                adapter=self.adapter,
                transaction_hashes=my_hashes,
                inclusion_states=inclusion_states,
            ),
        }
Ejemplo n.º 2
0
  def _execute(self, request):
    inclusion_states  = request['inclusionStates'] # type: bool
    seed              = request['seed'] # type: Seed
    start             = request['start'] # type: int
    stop              = request['stop'] # type: Optional[int]

    # Determine the addresses we will be scanning, and pull their
    # transaction hashes.
    if stop is None:
      my_hashes = list(chain(*(
        hashes
          for _, hashes in iter_used_addresses(self.adapter, seed, start)
      )))
    else:
      ft_response =\
        FindTransactionsCommand(self.adapter)(
          addresses =
            AddressGenerator(seed).get_addresses(start, stop - start),
        )

      my_hashes = ft_response['hashes']

    return {
      'bundles':
        get_bundles_from_transaction_hashes(
          adapter             = self.adapter,
          transaction_hashes  = my_hashes,
          inclusion_states    = inclusion_states,
        ),
    }
Ejemplo n.º 3
0
    def _execute(self, request):
        inclusion_states = request['inclusionStates']  # type: bool
        seed = request['seed']  # type: Seed
        start = request['start']  # type: int
        stop = request['stop']  # type: Optional[int]
        security_level = request['security_level']  # type: Optional[int]

        if stop is None:
            my_addresses = []  # type: List[Address]
            my_hashes = []  # type: List[TransactionHash]

            for addy, hashes in iter_used_addresses(self.adapter, seed, start, security_level):
                my_addresses.append(addy)
                my_hashes.extend(hashes)
        else:
            ft_command = FindTransactionsCommand(self.adapter)

            my_addresses = (
                AddressGenerator(seed, security_level).get_addresses(start, stop - start)
            )
            my_hashes = ft_command(addresses=my_addresses).get('hashes') or []

        account_balance = 0
        if my_hashes:
            # Load balances for the addresses that we generated.
            gb_response = (
                GetBalancesCommand(self.adapter)(addresses=my_addresses)
            )

            for i, balance in enumerate(gb_response['balances']):
                my_addresses[i].balance = balance
                account_balance += balance

        return {
            'addresses':
                list(sorted(my_addresses, key=attrgetter('key_index'))),

            'balance': account_balance,

            'bundles':
                get_bundles_from_transaction_hashes(
                    adapter=self.adapter,
                    transaction_hashes=my_hashes,
                    inclusion_states=inclusion_states,
                ),
        }
Ejemplo n.º 4
0
  def _execute(self, request):
    inclusion_states  = request['inclusionStates'] # type: bool
    seed              = request['seed'] # type: Seed
    start             = request['start'] # type: int
    stop              = request['stop'] # type: Optional[int]

    if stop is None:
      my_addresses  = [] # type: List[Address]
      my_hashes     = [] # type: List[TransactionHash]

      for addy, hashes in iter_used_addresses(self.adapter, seed, start):
        my_addresses.append(addy)
        my_hashes.extend(hashes)
    else:
      ft_command = FindTransactionsCommand(self.adapter)

      my_addresses  = AddressGenerator(seed).get_addresses(start, stop - start)
      my_hashes     = ft_command(addresses=my_addresses).get('hashes') or []

    account_balance = 0
    if my_hashes:
      # Load balances for the addresses that we generated.
      gb_response = GetBalancesCommand(self.adapter)(addresses=my_addresses)

      for i, balance in enumerate(gb_response['balances']):
        my_addresses[i].balance = balance
        account_balance += balance

    return {
      'addresses':  list(sorted(my_addresses, key=attrgetter('key_index'))),
      'balance':    account_balance,

      'bundles':
        get_bundles_from_transaction_hashes(
          adapter             = self.adapter,
          transaction_hashes  = my_hashes,
          inclusion_states    = inclusion_states,
        ),
    }
Ejemplo n.º 5
0
    def _execute(self, request):
        inclusion_states = request['inclusionStates']  # type: bool
        address = request['address']  # type: Address

        # Determine the addresses we will be scanning, and pull their
        # transaction hashes.

        ft_response =\
            FindTransactionsCommand(self.adapter)(
                addresses =
                    address
            )

        my_hashes = ft_response['hashes']

        return {
            'bundles':
            get_bundles_from_transaction_hashes(
                adapter=self.adapter,
                transaction_hashes=my_hashes,
                inclusion_states=inclusion_states,
            ),
        }