Source code for pyrogram.raw.types.wallet_state

#  Pyrogram - Telegram MTProto API Client Library for Python
#  Copyright (C) 2017-present Dan <https://github.com/delivrance>
#
#  This file is part of Pyrogram.
#
#  Pyrogram is free software: you can redistribute it and/or modify
#  it under the terms of the GNU Lesser General Public License as published
#  by the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  Pyrogram is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU Lesser General Public License for more details.
#
#  You should have received a copy of the GNU Lesser General Public License
#  along with Pyrogram.  If not, see <http://www.gnu.org/licenses/>.

from io import BytesIO

from pyrogram.raw.core.primitives import Int, Long, Int128, Int256, Bool, Bytes, String, Double, Vector
from pyrogram.raw.core import TLObject
from pyrogram import raw
from typing import List, Optional, Any

# # # # # # # # # # # # # # # # # # # # # # # #
#               !!! WARNING !!!               #
#          This is a generated file!          #
# All changes made in this file will be lost! #
# # # # # # # # # # # # # # # # # # # # # # # #


[docs] class WalletState(TLObject): # type: ignore """ Constructor of :obj:`~pyrogram.raw.base.WalletState`. Details: - Layer: ``230`` - ID: ``95C5346B`` Parameters: address (``str``): N/A public_key (``bytes``): N/A balance (``int`` ``64-bit``): N/A backup_enabled (``bool``, *optional*): N/A can_export_phrase (``bool``, *optional*): N/A can_enable_backup (``bool``, *optional*): N/A Functions: This object can be returned by 4 functions. .. currentmodule:: pyrogram.raw.functions .. autosummary:: :nosignatures: wallet.GetState wallet.ReplaceWallet wallet.DisableBackup wallet.EnableBackup """ __slots__: List[str] = ["address", "public_key", "balance", "backup_enabled", "can_export_phrase", "can_enable_backup"] ID = 0x95c5346b QUALNAME = "types.WalletState" def __init__(self, *, address: str, public_key: bytes, balance: int, backup_enabled: Optional[bool] = None, can_export_phrase: Optional[bool] = None, can_enable_backup: Optional[bool] = None) -> None: self.address = address # string self.public_key = public_key # bytes self.balance = balance # long self.backup_enabled = backup_enabled # flags.0?true self.can_export_phrase = can_export_phrase # flags.1?true self.can_enable_backup = can_enable_backup # flags.2?true @staticmethod def read(b: BytesIO, *args: Any) -> "WalletState": flags = Int.read(b) backup_enabled = True if flags & (1 << 0) else False can_export_phrase = True if flags & (1 << 1) else False can_enable_backup = True if flags & (1 << 2) else False address = String.read(b) public_key = Bytes.read(b) balance = Long.read(b) return WalletState(address=address, public_key=public_key, balance=balance, backup_enabled=backup_enabled, can_export_phrase=can_export_phrase, can_enable_backup=can_enable_backup) def write(self, *args) -> bytes: b = BytesIO() b.write(Int(self.ID, False)) flags = 0 flags |= (1 << 0) if self.backup_enabled else 0 flags |= (1 << 1) if self.can_export_phrase else 0 flags |= (1 << 2) if self.can_enable_backup else 0 b.write(Int(flags)) b.write(String(self.address)) b.write(Bytes(self.public_key)) b.write(Long(self.balance)) return b.getvalue()