mirror of
https://github.com/status-im/status-keycard-go.git
synced 2025-02-07 12:03:30 +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()
|
return restartErr()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *KeycardFlow) requireKeys() error {
|
||||||
|
if f.cardInfo.keyUID != "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return f.pauseAndRestart(SwapCard, ErrorNoKeys)
|
||||||
|
}
|
||||||
|
|
||||||
func (f *KeycardFlow) closeKeycard(kc *keycardContext) {
|
func (f *KeycardFlow) closeKeycard(kc *keycardContext) {
|
||||||
if kc != nil {
|
if kc != nil {
|
||||||
kc.stop()
|
kc.stop()
|
||||||
@ -221,13 +229,51 @@ func (f *KeycardFlow) getAppInfoFlow(kc *keycardContext) (FlowStatus, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *KeycardFlow) recoverAccountFlow(kc *keycardContext) (FlowStatus, error) {
|
func (f *KeycardFlow) recoverAccountFlow(kc *keycardContext) (FlowStatus, error) {
|
||||||
err := f.openSCAndAuthenticate(kc)
|
err := f.requireKeys()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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) {
|
func (f *KeycardFlow) unpairThisFlow(kc *keycardContext) (FlowStatus, error) {
|
||||||
|
@ -51,6 +51,7 @@ const (
|
|||||||
ErrorConnection = "connection-error"
|
ErrorConnection = "connection-error"
|
||||||
ErrorUnknownFlow = "unknown-flow"
|
ErrorUnknownFlow = "unknown-flow"
|
||||||
ErrorNotAKeycard = "not-a-keycard"
|
ErrorNotAKeycard = "not-a-keycard"
|
||||||
|
ErrorNoKeys = "no-keys"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -63,6 +64,12 @@ const (
|
|||||||
PUKRetries = "puk-retries"
|
PUKRetries = "puk-retries"
|
||||||
PairingPass = "pairing-pass"
|
PairingPass = "pairing-pass"
|
||||||
PIN = "pin"
|
PIN = "pin"
|
||||||
|
MasterKey = "master-key"
|
||||||
|
WalleRootKey = "wallet-root-key"
|
||||||
|
WalletKey = "wallet-key"
|
||||||
|
EIP1581Key = "eip1581-key"
|
||||||
|
WhisperKey = "whisper-key"
|
||||||
|
EncKey = "encryption-key"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
2
types.go
2
types.go
@ -112,5 +112,5 @@ type ApplicationStatus struct {
|
|||||||
type KeyPair struct {
|
type KeyPair struct {
|
||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
PublicKey hexString `json:"publicKey"`
|
PublicKey hexString `json:"publicKey"`
|
||||||
PrivateKey hexString `json:"privateKey"`
|
PrivateKey hexString `json:"privateKey,omitempty"`
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user