package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdjson"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type WalletTransaction struct {
Flags bin .Fields
Incoming bool
Gasless bool
Failed bool
KeyChange bool
CommentEncrypted bool
ID string
Amount int64
Fee int64
Date int
Peer WalletTransactionPeerClass
Comment string
TxHash string
Nft WalletNftItem
}
const WalletTransactionTypeID = 0x952dc143
var (
_ bin .Encoder = &WalletTransaction {}
_ bin .Decoder = &WalletTransaction {}
_ bin .BareEncoder = &WalletTransaction {}
_ bin .BareDecoder = &WalletTransaction {}
)
func (w *WalletTransaction ) Zero () bool {
if w == nil {
return true
}
if !(w .Flags .Zero ()) {
return false
}
if !(w .Incoming == false ) {
return false
}
if !(w .Gasless == false ) {
return false
}
if !(w .Failed == false ) {
return false
}
if !(w .KeyChange == false ) {
return false
}
if !(w .CommentEncrypted == false ) {
return false
}
if !(w .ID == "" ) {
return false
}
if !(w .Amount == 0 ) {
return false
}
if !(w .Fee == 0 ) {
return false
}
if !(w .Date == 0 ) {
return false
}
if !(w .Peer == nil ) {
return false
}
if !(w .Comment == "" ) {
return false
}
if !(w .TxHash == "" ) {
return false
}
if !(w .Nft .Zero ()) {
return false
}
return true
}
func (w *WalletTransaction ) String () string {
if w == nil {
return "WalletTransaction(nil)"
}
type Alias WalletTransaction
return fmt .Sprintf ("WalletTransaction%+v" , Alias (*w ))
}
func (w *WalletTransaction ) FillFrom (from interface {
GetIncoming () (value bool )
GetGasless () (value bool )
GetFailed () (value bool )
GetKeyChange () (value bool )
GetCommentEncrypted () (value bool )
GetID () (value string )
GetAmount () (value int64 )
GetFee () (value int64 )
GetDate () (value int )
GetPeer () (value WalletTransactionPeerClass )
GetComment () (value string , ok bool )
GetTxHash () (value string , ok bool )
GetNft () (value WalletNftItem , ok bool )
}) {
w .Incoming = from .GetIncoming ()
w .Gasless = from .GetGasless ()
w .Failed = from .GetFailed ()
w .KeyChange = from .GetKeyChange ()
w .CommentEncrypted = from .GetCommentEncrypted ()
w .ID = from .GetID ()
w .Amount = from .GetAmount ()
w .Fee = from .GetFee ()
w .Date = from .GetDate ()
w .Peer = from .GetPeer ()
if val , ok := from .GetComment (); ok {
w .Comment = val
}
if val , ok := from .GetTxHash (); ok {
w .TxHash = val
}
if val , ok := from .GetNft (); ok {
w .Nft = val
}
}
func (*WalletTransaction ) TypeID () uint32 {
return WalletTransactionTypeID
}
func (*WalletTransaction ) TypeName () string {
return "walletTransaction"
}
func (w *WalletTransaction ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "walletTransaction" ,
ID : WalletTransactionTypeID ,
}
if w == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Incoming" ,
SchemaName : "incoming" ,
Null : !w .Flags .Has (0 ),
},
{
Name : "Gasless" ,
SchemaName : "gasless" ,
Null : !w .Flags .Has (1 ),
},
{
Name : "Failed" ,
SchemaName : "failed" ,
Null : !w .Flags .Has (2 ),
},
{
Name : "KeyChange" ,
SchemaName : "key_change" ,
Null : !w .Flags .Has (5 ),
},
{
Name : "CommentEncrypted" ,
SchemaName : "comment_encrypted" ,
Null : !w .Flags .Has (6 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "Amount" ,
SchemaName : "amount" ,
},
{
Name : "Fee" ,
SchemaName : "fee" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "Comment" ,
SchemaName : "comment" ,
Null : !w .Flags .Has (3 ),
},
{
Name : "TxHash" ,
SchemaName : "tx_hash" ,
Null : !w .Flags .Has (4 ),
},
{
Name : "Nft" ,
SchemaName : "nft" ,
Null : !w .Flags .Has (7 ),
},
}
return typ
}
func (w *WalletTransaction ) SetFlags () {
if !(w .Incoming == false ) {
w .Flags .Set (0 )
}
if !(w .Gasless == false ) {
w .Flags .Set (1 )
}
if !(w .Failed == false ) {
w .Flags .Set (2 )
}
if !(w .KeyChange == false ) {
w .Flags .Set (5 )
}
if !(w .CommentEncrypted == false ) {
w .Flags .Set (6 )
}
if !(w .Comment == "" ) {
w .Flags .Set (3 )
}
if !(w .TxHash == "" ) {
w .Flags .Set (4 )
}
if !(w .Nft .Zero ()) {
w .Flags .Set (7 )
}
}
func (w *WalletTransaction ) Encode (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't encode walletTransaction#952dc143 as nil" )
}
b .PutID (WalletTransactionTypeID )
return w .EncodeBare (b )
}
func (w *WalletTransaction ) EncodeBare (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't encode walletTransaction#952dc143 as nil" )
}
w .SetFlags ()
if err := w .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode walletTransaction#952dc143: field flags: %w" , err )
}
b .PutString (w .ID )
b .PutLong (w .Amount )
b .PutLong (w .Fee )
b .PutInt (w .Date )
if w .Peer == nil {
return fmt .Errorf ("unable to encode walletTransaction#952dc143: field peer is nil" )
}
if err := w .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode walletTransaction#952dc143: field peer: %w" , err )
}
if w .Flags .Has (3 ) {
b .PutString (w .Comment )
}
if w .Flags .Has (4 ) {
b .PutString (w .TxHash )
}
if w .Flags .Has (7 ) {
if err := w .Nft .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode walletTransaction#952dc143: field nft: %w" , err )
}
}
return nil
}
func (w *WalletTransaction ) Decode (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't decode walletTransaction#952dc143 to nil" )
}
if err := b .ConsumeID (WalletTransactionTypeID ); err != nil {
return fmt .Errorf ("unable to decode walletTransaction#952dc143: %w" , err )
}
return w .DecodeBare (b )
}
func (w *WalletTransaction ) DecodeBare (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't decode walletTransaction#952dc143 to nil" )
}
{
if err := w .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode walletTransaction#952dc143: field flags: %w" , err )
}
}
w .Incoming = w .Flags .Has (0 )
w .Gasless = w .Flags .Has (1 )
w .Failed = w .Flags .Has (2 )
w .KeyChange = w .Flags .Has (5 )
w .CommentEncrypted = w .Flags .Has (6 )
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode walletTransaction#952dc143: field id: %w" , err )
}
w .ID = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode walletTransaction#952dc143: field amount: %w" , err )
}
w .Amount = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode walletTransaction#952dc143: field fee: %w" , err )
}
w .Fee = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode walletTransaction#952dc143: field date: %w" , err )
}
w .Date = value
}
{
value , err := DecodeWalletTransactionPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode walletTransaction#952dc143: field peer: %w" , err )
}
w .Peer = value
}
if w .Flags .Has (3 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode walletTransaction#952dc143: field comment: %w" , err )
}
w .Comment = value
}
if w .Flags .Has (4 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode walletTransaction#952dc143: field tx_hash: %w" , err )
}
w .TxHash = value
}
if w .Flags .Has (7 ) {
if err := w .Nft .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode walletTransaction#952dc143: field nft: %w" , err )
}
}
return nil
}
func (w *WalletTransaction ) SetIncoming (value bool ) {
if value {
w .Flags .Set (0 )
w .Incoming = true
} else {
w .Flags .Unset (0 )
w .Incoming = false
}
}
func (w *WalletTransaction ) GetIncoming () (value bool ) {
if w == nil {
return
}
return w .Flags .Has (0 )
}
func (w *WalletTransaction ) SetGasless (value bool ) {
if value {
w .Flags .Set (1 )
w .Gasless = true
} else {
w .Flags .Unset (1 )
w .Gasless = false
}
}
func (w *WalletTransaction ) GetGasless () (value bool ) {
if w == nil {
return
}
return w .Flags .Has (1 )
}
func (w *WalletTransaction ) SetFailed (value bool ) {
if value {
w .Flags .Set (2 )
w .Failed = true
} else {
w .Flags .Unset (2 )
w .Failed = false
}
}
func (w *WalletTransaction ) GetFailed () (value bool ) {
if w == nil {
return
}
return w .Flags .Has (2 )
}
func (w *WalletTransaction ) SetKeyChange (value bool ) {
if value {
w .Flags .Set (5 )
w .KeyChange = true
} else {
w .Flags .Unset (5 )
w .KeyChange = false
}
}
func (w *WalletTransaction ) GetKeyChange () (value bool ) {
if w == nil {
return
}
return w .Flags .Has (5 )
}
func (w *WalletTransaction ) SetCommentEncrypted (value bool ) {
if value {
w .Flags .Set (6 )
w .CommentEncrypted = true
} else {
w .Flags .Unset (6 )
w .CommentEncrypted = false
}
}
func (w *WalletTransaction ) GetCommentEncrypted () (value bool ) {
if w == nil {
return
}
return w .Flags .Has (6 )
}
func (w *WalletTransaction ) GetID () (value string ) {
if w == nil {
return
}
return w .ID
}
func (w *WalletTransaction ) GetAmount () (value int64 ) {
if w == nil {
return
}
return w .Amount
}
func (w *WalletTransaction ) GetFee () (value int64 ) {
if w == nil {
return
}
return w .Fee
}
func (w *WalletTransaction ) GetDate () (value int ) {
if w == nil {
return
}
return w .Date
}
func (w *WalletTransaction ) GetPeer () (value WalletTransactionPeerClass ) {
if w == nil {
return
}
return w .Peer
}
func (w *WalletTransaction ) SetComment (value string ) {
w .Flags .Set (3 )
w .Comment = value
}
func (w *WalletTransaction ) GetComment () (value string , ok bool ) {
if w == nil {
return
}
if !w .Flags .Has (3 ) {
return value , false
}
return w .Comment , true
}
func (w *WalletTransaction ) SetTxHash (value string ) {
w .Flags .Set (4 )
w .TxHash = value
}
func (w *WalletTransaction ) GetTxHash () (value string , ok bool ) {
if w == nil {
return
}
if !w .Flags .Has (4 ) {
return value , false
}
return w .TxHash , true
}
func (w *WalletTransaction ) SetNft (value WalletNftItem ) {
w .Flags .Set (7 )
w .Nft = value
}
func (w *WalletTransaction ) GetNft () (value WalletNftItem , ok bool ) {
if w == nil {
return
}
if !w .Flags .Has (7 ) {
return value , false
}
return w .Nft , true
}
The pages are generated with Golds v0.8.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .