status-go/protocol/requests/restore_account.go

50 lines
1.4 KiB
Go
Raw Permalink Normal View History

2023-03-21 17:02:04 +00:00
package requests
import (
"errors"
)
var (
ErrRestoreAccountInvalidMnemonic = errors.New("restore-account: no mnemonic or keycard is set")
ErrRestoreAccountMnemonicAndKeycard = errors.New("restore-account: both mnemonic and keycard info are set")
)
2023-03-21 17:02:04 +00:00
type RestoreAccount struct {
Mnemonic string `json:"mnemonic"`
// Keycard info can be set instead of Mnemonic.
// This is to log in using a keycard with existing account.
Keycard *KeycardData `json:"keycard"`
FetchBackup bool `json:"fetchBackup"`
2023-03-21 17:02:04 +00:00
CreateAccount
}
func (c *RestoreAccount) Validate() error {
if len(c.Mnemonic) == 0 && c.Keycard == nil {
2023-03-21 17:02:04 +00:00
return ErrRestoreAccountInvalidMnemonic
}
if len(c.Mnemonic) > 0 && c.Keycard != nil {
return ErrRestoreAccountMnemonicAndKeycard
}
2024-03-28 15:01:44 +00:00
return c.CreateAccount.Validate(&CreateAccountValidation{
AllowEmptyDisplayName: true,
})
2023-03-21 17:02:04 +00:00
}
type KeycardData struct {
KeyUID string `json:"keyUID"`
Address string `json:"address"`
WhisperPrivateKey string `json:"whisperPrivateKey"`
WhisperPublicKey string `json:"whisperPublicKey"`
WhisperAddress string `json:"whisperAddress"`
WalletPublicKey string `json:"walletPublicKey"`
WalletAddress string `json:"walletAddress"`
WalletRootAddress string `json:"walletRootAddress"`
Eip1581Address string `json:"eip1581Address"`
EncryptionPublicKey string `json:"encryptionPublicKey"`
}