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 WalletDisableBackupRequest struct {
Flags bin .Fields
Password InputCheckPasswordSRPClass
NewPublicKey []byte
Proof WalletOwnershipProof
}
const WalletDisableBackupRequestTypeID = 0xb0bf0da
var (
_ bin .Encoder = &WalletDisableBackupRequest {}
_ bin .Decoder = &WalletDisableBackupRequest {}
_ bin .BareEncoder = &WalletDisableBackupRequest {}
_ bin .BareDecoder = &WalletDisableBackupRequest {}
)
func (d *WalletDisableBackupRequest ) Zero () bool {
if d == nil {
return true
}
if !(d .Flags .Zero ()) {
return false
}
if !(d .Password == nil ) {
return false
}
if !(d .NewPublicKey == nil ) {
return false
}
if !(d .Proof .Zero ()) {
return false
}
return true
}
func (d *WalletDisableBackupRequest ) String () string {
if d == nil {
return "WalletDisableBackupRequest(nil)"
}
type Alias WalletDisableBackupRequest
return fmt .Sprintf ("WalletDisableBackupRequest%+v" , Alias (*d ))
}
func (d *WalletDisableBackupRequest ) FillFrom (from interface {
GetPassword () (value InputCheckPasswordSRPClass , ok bool )
GetNewPublicKey () (value []byte , ok bool )
GetProof () (value WalletOwnershipProof , ok bool )
}) {
if val , ok := from .GetPassword (); ok {
d .Password = val
}
if val , ok := from .GetNewPublicKey (); ok {
d .NewPublicKey = val
}
if val , ok := from .GetProof (); ok {
d .Proof = val
}
}
func (*WalletDisableBackupRequest ) TypeID () uint32 {
return WalletDisableBackupRequestTypeID
}
func (*WalletDisableBackupRequest ) TypeName () string {
return "wallet.disableBackup"
}
func (d *WalletDisableBackupRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "wallet.disableBackup" ,
ID : WalletDisableBackupRequestTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Password" ,
SchemaName : "password" ,
Null : !d .Flags .Has (0 ),
},
{
Name : "NewPublicKey" ,
SchemaName : "new_public_key" ,
Null : !d .Flags .Has (1 ),
},
{
Name : "Proof" ,
SchemaName : "proof" ,
Null : !d .Flags .Has (2 ),
},
}
return typ
}
func (d *WalletDisableBackupRequest ) SetFlags () {
if !(d .Password == nil ) {
d .Flags .Set (0 )
}
if !(d .NewPublicKey == nil ) {
d .Flags .Set (1 )
}
if !(d .Proof .Zero ()) {
d .Flags .Set (2 )
}
}
func (d *WalletDisableBackupRequest ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode wallet.disableBackup#b0bf0da as nil" )
}
b .PutID (WalletDisableBackupRequestTypeID )
return d .EncodeBare (b )
}
func (d *WalletDisableBackupRequest ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode wallet.disableBackup#b0bf0da as nil" )
}
d .SetFlags ()
if err := d .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode wallet.disableBackup#b0bf0da: field flags: %w" , err )
}
if d .Flags .Has (0 ) {
if d .Password == nil {
return fmt .Errorf ("unable to encode wallet.disableBackup#b0bf0da: field password is nil" )
}
if err := d .Password .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode wallet.disableBackup#b0bf0da: field password: %w" , err )
}
}
if d .Flags .Has (1 ) {
b .PutBytes (d .NewPublicKey )
}
if d .Flags .Has (2 ) {
if err := d .Proof .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode wallet.disableBackup#b0bf0da: field proof: %w" , err )
}
}
return nil
}
func (d *WalletDisableBackupRequest ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode wallet.disableBackup#b0bf0da to nil" )
}
if err := b .ConsumeID (WalletDisableBackupRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode wallet.disableBackup#b0bf0da: %w" , err )
}
return d .DecodeBare (b )
}
func (d *WalletDisableBackupRequest ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode wallet.disableBackup#b0bf0da to nil" )
}
{
if err := d .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode wallet.disableBackup#b0bf0da: field flags: %w" , err )
}
}
if d .Flags .Has (0 ) {
value , err := DecodeInputCheckPasswordSRP (b )
if err != nil {
return fmt .Errorf ("unable to decode wallet.disableBackup#b0bf0da: field password: %w" , err )
}
d .Password = value
}
if d .Flags .Has (1 ) {
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode wallet.disableBackup#b0bf0da: field new_public_key: %w" , err )
}
d .NewPublicKey = value
}
if d .Flags .Has (2 ) {
if err := d .Proof .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode wallet.disableBackup#b0bf0da: field proof: %w" , err )
}
}
return nil
}
func (d *WalletDisableBackupRequest ) SetPassword (value InputCheckPasswordSRPClass ) {
d .Flags .Set (0 )
d .Password = value
}
func (d *WalletDisableBackupRequest ) GetPassword () (value InputCheckPasswordSRPClass , ok bool ) {
if d == nil {
return
}
if !d .Flags .Has (0 ) {
return value , false
}
return d .Password , true
}
func (d *WalletDisableBackupRequest ) SetNewPublicKey (value []byte ) {
d .Flags .Set (1 )
d .NewPublicKey = value
}
func (d *WalletDisableBackupRequest ) GetNewPublicKey () (value []byte , ok bool ) {
if d == nil {
return
}
if !d .Flags .Has (1 ) {
return value , false
}
return d .NewPublicKey , true
}
func (d *WalletDisableBackupRequest ) SetProof (value WalletOwnershipProof ) {
d .Flags .Set (2 )
d .Proof = value
}
func (d *WalletDisableBackupRequest ) GetProof () (value WalletOwnershipProof , ok bool ) {
if d == nil {
return
}
if !d .Flags .Has (2 ) {
return value , false
}
return d .Proof , true
}
func (d *WalletDisableBackupRequest ) GetPasswordAsNotEmpty () (*InputCheckPasswordSRP , bool ) {
if value , ok := d .GetPassword (); ok {
return value .AsNotEmpty ()
}
return nil , false
}
func (c *Client ) WalletDisableBackup (ctx context .Context , request *WalletDisableBackupRequest ) (WalletStateClass , error ) {
var result WalletStateBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .WalletState , nil
}
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 .