fix(@desktop/keycard): keystore file for a keypair is not removed once that keypair is migrated to a Keycard

When we're migrating profile or any other keypair to a Keycard
corresponding locally stored keystore files are removed.

Fixes: #8067
This commit is contained in:
Sale Djenic 2022-11-08 14:37:52 +01:00 committed by saledjenic
parent 2ea83c02b0
commit 3d163cfa33
7 changed files with 16 additions and 5 deletions

View File

@ -423,7 +423,8 @@ proc buildAndRegisterUserProfile(self: AppController) =
keycardLocked: false,
accountsAddresses: @[defaultWalletAddress],
keyUid: loggedInAccount.keyUid)
discard self.walletAccountService.addMigratedKeyPair(keyPair)
let keystoreDir = self.accountsService.getKeyStoreDir()
discard self.walletAccountService.addMigratedKeyPair(keyPair, keystoreDir)
proc storeKeyPairForNewKeycardUser*(self: AppController) =
self.storeKeyPair = true

View File

@ -445,7 +445,10 @@ proc getBalanceForAddress*(self: Controller, address: string): float64 =
proc addMigratedKeyPair*(self: Controller, keyPair: KeyPairDto): bool =
if not serviceApplicable(self.walletAccountService):
return
return self.walletAccountService.addMigratedKeyPair(keyPair)
if not serviceApplicable(self.accountsService):
return
let keystoreDir = self.accountsService.getKeyStoreDir()
return self.walletAccountService.addMigratedKeyPair(keyPair, keystoreDir)
proc getAllMigratedKeyPairs*(self: Controller): seq[KeyPairDto] =
if not serviceApplicable(self.walletAccountService):

View File

@ -12,6 +12,7 @@ proc delete*(self: SeedPhraseEnterWordsState) =
method executePrimaryCommand*(self: SeedPhraseEnterWordsState, controller: Controller) =
let mnemonic = controller.getMnemonic()
controller.setSeedPhrase(mnemonic)
controller.storeSeedPhraseToKeycard(mnemonic.split(" ").len, mnemonic)
method executeTertiaryCommand*(self: SeedPhraseEnterWordsState, controller: Controller) =

View File

@ -67,6 +67,9 @@ proc setKeyStoreDir(self: Service, key: string) =
self.keyStoreDir = joinPath(main_constants.ROOTKEYSTOREDIR, key) & main_constants.sep
discard status_general.initKeystore(self.keyStoreDir)
proc getKeyStoreDir*(self: Service): string =
return self.keyStoreDir
proc setDefaultWalletEmoji*(self: Service, emoji: string) =
self.defaultWalletEmoji = emoji

View File

@ -547,13 +547,15 @@ QtObject:
error "error: ", procName=procName, errDesription = errMsg
return false
proc addMigratedKeyPair*(self: Service, keyPair: KeyPairDto): bool =
proc addMigratedKeyPair*(self: Service, keyPair: KeyPairDto, keyStoreDir: string): bool =
try:
let response = backend.addMigratedKeyPair(
keyPair.keycardUid,
keyPair.keycardName,
keyPair.keyUid,
keyPair.accountsAddresses)
keyPair.accountsAddresses,
keyStoreDir
)
result = self.responseHasNoErrors("addMigratedKeyPair", response)
if result:
self.events.emit(SIGNAL_NEW_KEYCARD_SET, KeycardActivityArgs(keyPair: keyPair))

View File

@ -241,6 +241,7 @@ rpc(addMigratedKeyPair, "accounts"):
keyPairName: string
keyUid: string
accountAddresses: seq[string]
keyStoreDir: string
rpc(getAllMigratedKeyPairs, "accounts"):
discard

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit f33c1cec383d8cd7e14af2832b8017d1e204d9cf
Subproject commit 77b7ce5a09502d9f3f8fa9789ce4cf62efa0e96c