:mod:`viz.account` ================== .. py:module:: viz.account Module Contents --------------- .. data:: HistoryGenerator .. py:class:: Account(account_name: str, blockchain_instance: Optional['Client'] = None) Bases: :class:`dict` .. autoapi-inheritance-diagram:: viz.account.Account :parts: 1 :private-bases: This class allows to easily access Account data. :param str account_name: Name of the account :param viz.viz.Client blockchain_instance: Client instance .. method:: balances(self) :property: Shortcut to :py:func:`get_balances` .. method:: energy(self) :property: Account energy at the moment of last use (stale) .. method:: refresh(self) Loads account object from blockchain. .. method:: get_balances(self) Obtain account balances. :return: dict with balances like ``{'VIZ': 49400000.0, 'SHARES': 0.0}`` .. method:: current_energy(self) Returns current account energy (actual data, counts regenerated energy) .. method:: virtual_op_count(self) Returns number of virtual ops performed by this account. .. method:: get_withdraw_routes(self, type_: str = 'all') Get vesting withdraw routes. :param type_: route type, one of `all`, `incoming`, `outgoing` :return: list with routes Example return: .. code-block:: python [ { 'from_account': 'alice', 'to_account': 'bob', 'percent': 10000, 'auto_vest': False } ] .. method:: get_account_history(self, index: int, limit: int, start: Optional[int] = None, stop: Optional[int] = None, order: int = -1, filter_by: Optional[Union[str, List[str]]] = None, raw_output: bool = False) A generator over get_account_history RPC. It offers serialization, filtering and fine grained iteration control. .. note:: This method is mostly for internal use, probably you need :py:func:`history`. :param int index: start index for get_account_history :param int limit: How many items in account history will be scanned (any ops, not only filtered) :param int start: (Optional) skip items until this index :param int stop: (Optional) stop iteration early at this index :param order: (1, -1): 1 for chronological, -1 for reverse order :param str,list filter_by: filter out all but these operations :param bool raw_output: (Defaults to False). If True, return history in steemd format (unchanged). .. method:: history(self, filter_by: Optional[Union[str, List[str]]] = None, start: int = 0, batch_size: int = 1000, raw_output: bool = False, limit: int = -1) Stream account history in chronological order. This generator yields history items which may be in list or dict form depending on ``raw_output``. :param str,list filter_by: filter out all but these operations :param int start: (Optional) skip items until this index :param int batch_size: (Optional) request as many items from API in each chunk :param bool raw_output: (Defaults to False). If True, return history in steemd format (unchanged). :param int limit: (Optional) limit number of filtered items to this amount (-1 means unlimited). This is a rough limit, actual results could be a bit longer :return: number of ops Non-raw output example of yielded item: .. code-block:: python { 'from': 'viz', 'to': 'null', 'amount': '1.000 VIZ', 'memo': 'test', 'trx_id': '592010ade718c91a81cba3b8378c35ed81d23f23', 'block': 5, 'trx_in_block': 0, 'op_in_trx': 0, 'virtual_op': 0, 'timestamp': '2020-05-19T08:10:47', 'account': 'viz', 'type': 'transfer', '_id': 'd1ed77ae861bb1ecc26a82dd275cc80e5ac124a6', 'index': 0, } Raw output example of single item: .. code-block:: python [ 0, { 'trx_id': '592010ade718c91a81cba3b8378c35ed81d23f23', 'block': 5, 'trx_in_block': 0, 'op_in_trx': 0, 'virtual_op': 0, 'timestamp': '2020-05-19T08:10:47', 'op': ['transfer', {'from': 'viz', 'to': 'null', 'amount': '1.000 VIZ', 'memo': 'test'}], }, ] .. method:: history_reverse(self, filter_by: Optional[Union[str, List[str]]] = None, batch_size: int = 1000, raw_output: bool = False, limit: int = -1) Stream account history in reverse chronological order. This generator yields history items which may be in list or dict form depending on ``raw_output``. Output is similar to :py:func:`history`. :param str,list filter_by: filter out all but these operations :param int batch_size: (Optional) request as many items from API in each chunk :param bool raw_output: (Defaults to False). If True, return history in steemd format (unchanged). :param int limit: (Optional) limit number of filtered items to this amount (-1 means unlimited). This is a rough limit, actual results could be a bit longer :return: number of ops .. method:: __contains__() True if the dictionary has the specified key, else False. .. method:: __delattr__() Implement delattr(self, name). .. method:: __delitem__() Delete self[key]. .. method:: __dir__() Default dir() implementation. .. method:: __eq__() Return self==value. .. method:: __format__() Default object formatter. .. method:: __ge__() Return self>=value. .. method:: __getattribute__() Return getattr(self, name). .. method:: __getitem__() x.__getitem__(y) <==> x[y] .. method:: __gt__() Return self>value. .. method:: __iter__() Implement iter(self). .. method:: __le__() Return self<=value. .. method:: __len__() Return len(self). .. method:: __lt__() Return self size of D in memory, in bytes .. method:: __str__() Return str(self). .. method:: __subclasshook__() Abstract classes can override this to customize issubclass(). This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached). .. method:: clear() D.clear() -> None. Remove all items from D. .. method:: copy() D.copy() -> a shallow copy of D .. method:: get() Return the value for key if key is in the dictionary, else default. .. method:: items() D.items() -> a set-like object providing a view on D's items .. method:: keys() D.keys() -> a set-like object providing a view on D's keys .. method:: pop() D.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised .. method:: popitem() D.popitem() -> (k, v), remove and return some (key, value) pair as a 2-tuple; but raise KeyError if D is empty. .. method:: setdefault() Insert key with a value of default if key is not in the dictionary. Return the value for key if key is in the dictionary, else default. .. method:: update() D.update([E, ]**F) -> None. Update D from dict/iterable E and F. If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k] .. method:: values() D.values() -> an object providing a view on D's values