# 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 WalletTransaction(TLObject): # type: ignore
"""
Constructor of :obj:`~pyrogram.raw.base.WalletTransaction`.
Details:
- Layer: ``230``
- ID: ``952DC143``
Parameters:
id (``str``):
N/A
amount (``int`` ``64-bit``):
N/A
fee (``int`` ``64-bit``):
N/A
date (``int`` ``32-bit``):
N/A
peer (:obj:`WalletTransactionPeer <pyrogram.raw.base.WalletTransactionPeer>`):
N/A
incoming (``bool``, *optional*):
N/A
gasless (``bool``, *optional*):
N/A
failed (``bool``, *optional*):
N/A
key_change (``bool``, *optional*):
N/A
comment_encrypted (``bool``, *optional*):
N/A
comment (``str``, *optional*):
N/A
tx_hash (``str``, *optional*):
N/A
nft (:obj:`wallet.NftItem <pyrogram.raw.base.wallet.NftItem>`, *optional*):
N/A
"""
__slots__: List[str] = ["id", "amount", "fee", "date", "peer", "incoming", "gasless", "failed", "key_change", "comment_encrypted", "comment", "tx_hash", "nft"]
ID = 0x952dc143
QUALNAME = "types.WalletTransaction"
def __init__(self, *, id: str, amount: int, fee: int, date: int, peer: "raw.base.WalletTransactionPeer", incoming: Optional[bool] = None, gasless: Optional[bool] = None, failed: Optional[bool] = None, key_change: Optional[bool] = None, comment_encrypted: Optional[bool] = None, comment: Optional[str] = None, tx_hash: Optional[str] = None, nft: "raw.base.wallet.NftItem" = None) -> None:
self.id = id # string
self.amount = amount # long
self.fee = fee # long
self.date = date # int
self.peer = peer # WalletTransactionPeer
self.incoming = incoming # flags.0?true
self.gasless = gasless # flags.1?true
self.failed = failed # flags.2?true
self.key_change = key_change # flags.5?true
self.comment_encrypted = comment_encrypted # flags.6?true
self.comment = comment # flags.3?string
self.tx_hash = tx_hash # flags.4?string
self.nft = nft # flags.7?wallet.NftItem
@staticmethod
def read(b: BytesIO, *args: Any) -> "WalletTransaction":
flags = Int.read(b)
incoming = True if flags & (1 << 0) else False
gasless = True if flags & (1 << 1) else False
failed = True if flags & (1 << 2) else False
key_change = True if flags & (1 << 5) else False
comment_encrypted = True if flags & (1 << 6) else False
id = String.read(b)
amount = Long.read(b)
fee = Long.read(b)
date = Int.read(b)
peer = TLObject.read(b)
comment = String.read(b) if flags & (1 << 3) else None
tx_hash = String.read(b) if flags & (1 << 4) else None
nft = TLObject.read(b) if flags & (1 << 7) else None
return WalletTransaction(id=id, amount=amount, fee=fee, date=date, peer=peer, incoming=incoming, gasless=gasless, failed=failed, key_change=key_change, comment_encrypted=comment_encrypted, comment=comment, tx_hash=tx_hash, nft=nft)
def write(self, *args) -> bytes:
b = BytesIO()
b.write(Int(self.ID, False))
flags = 0
flags |= (1 << 0) if self.incoming else 0
flags |= (1 << 1) if self.gasless else 0
flags |= (1 << 2) if self.failed else 0
flags |= (1 << 5) if self.key_change else 0
flags |= (1 << 6) if self.comment_encrypted else 0
flags |= (1 << 3) if self.comment is not None else 0
flags |= (1 << 4) if self.tx_hash is not None else 0
flags |= (1 << 7) if self.nft is not None else 0
b.write(Int(flags))
b.write(String(self.id))
b.write(Long(self.amount))
b.write(Long(self.fee))
b.write(Int(self.date))
b.write(self.peer.write())
if self.comment is not None:
b.write(String(self.comment))
if self.tx_hash is not None:
b.write(String(self.tx_hash))
if self.nft is not None:
b.write(self.nft.write())
return b.getvalue()