github.com/status-im/status-go@v1.1.0/protocol/requests/restore_account.go (about) 1 package requests 2 3 import ( 4 "errors" 5 ) 6 7 var ( 8 ErrRestoreAccountInvalidMnemonic = errors.New("restore-account: no mnemonic or keycard is set") 9 ErrRestoreAccountMnemonicAndKeycard = errors.New("restore-account: both mnemonic and keycard info are set") 10 ) 11 12 type RestoreAccount struct { 13 Mnemonic string `json:"mnemonic"` 14 15 // Keycard info can be set instead of Mnemonic. 16 // This is to log in using a keycard with existing account. 17 Keycard *KeycardData `json:"keycard"` 18 19 FetchBackup bool `json:"fetchBackup"` 20 21 CreateAccount 22 } 23 24 func (c *RestoreAccount) Validate() error { 25 if len(c.Mnemonic) == 0 && c.Keycard == nil { 26 return ErrRestoreAccountInvalidMnemonic 27 } 28 29 if len(c.Mnemonic) > 0 && c.Keycard != nil { 30 return ErrRestoreAccountMnemonicAndKeycard 31 } 32 33 return c.CreateAccount.Validate(&CreateAccountValidation{ 34 AllowEmptyDisplayName: true, 35 }) 36 } 37 38 type KeycardData struct { 39 KeyUID string `json:"keyUID"` 40 Address string `json:"address"` 41 WhisperPrivateKey string `json:"whisperPrivateKey"` 42 WhisperPublicKey string `json:"whisperPublicKey"` 43 WhisperAddress string `json:"whisperAddress"` 44 WalletPublicKey string `json:"walletPublicKey"` 45 WalletAddress string `json:"walletAddress"` 46 WalletRootAddress string `json:"walletRootAddress"` 47 Eip1581Address string `json:"eip1581Address"` 48 EncryptionPublicKey string `json:"encryptionPublicKey"` 49 }