mirror of
https://github.com/status-im/status-keycard-go.git
synced 2025-01-31 00:28:40 +00:00
implement recover account
This commit is contained in:
parent
e7dd1cc9a3
commit
f284636027
50
flow.go
50
flow.go
@ -152,6 +152,14 @@ func (f *KeycardFlow) pauseAndRestart(action string, errMsg string) error {
|
||||
return restartErr()
|
||||
}
|
||||
|
||||
func (f *KeycardFlow) requireKeys() error {
|
||||
if f.cardInfo.keyUID != "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
return f.pauseAndRestart(SwapCard, ErrorNoKeys)
|
||||
}
|
||||
|
||||
func (f *KeycardFlow) closeKeycard(kc *keycardContext) {
|
||||
if kc != nil {
|
||||
kc.stop()
|
||||
@ -221,13 +229,51 @@ func (f *KeycardFlow) getAppInfoFlow(kc *keycardContext) (FlowStatus, error) {
|
||||
}
|
||||
|
||||
func (f *KeycardFlow) recoverAccountFlow(kc *keycardContext) (FlowStatus, error) {
|
||||
err := f.openSCAndAuthenticate(kc)
|
||||
err := f.requireKeys()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return nil, errors.New("not yet implemented")
|
||||
err = f.openSCAndAuthenticate(kc)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := FlowStatus{}
|
||||
|
||||
key, err := f.exportKey(kc, encryptionPath, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result[EncKey] = key
|
||||
|
||||
key, err = f.exportKey(kc, whisperPath, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result[WhisperKey] = key
|
||||
|
||||
key, err = f.exportKey(kc, walletRoothPath, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result[WalleRootKey] = key
|
||||
|
||||
key, err = f.exportKey(kc, walletPath, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result[WalletKey] = key
|
||||
|
||||
key, err = f.exportKey(kc, masterPath, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result[MasterKey] = key
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (f *KeycardFlow) unpairThisFlow(kc *keycardContext) (FlowStatus, error) {
|
||||
|
@ -51,6 +51,7 @@ const (
|
||||
ErrorConnection = "connection-error"
|
||||
ErrorUnknownFlow = "unknown-flow"
|
||||
ErrorNotAKeycard = "not-a-keycard"
|
||||
ErrorNoKeys = "no-keys"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -63,6 +64,12 @@ const (
|
||||
PUKRetries = "puk-retries"
|
||||
PairingPass = "pairing-pass"
|
||||
PIN = "pin"
|
||||
MasterKey = "master-key"
|
||||
WalleRootKey = "wallet-root-key"
|
||||
WalletKey = "wallet-key"
|
||||
EIP1581Key = "eip1581-key"
|
||||
WhisperKey = "whisper-key"
|
||||
EncKey = "encryption-key"
|
||||
)
|
||||
|
||||
const (
|
||||
|
Loading…
x
Reference in New Issue
Block a user