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:
parent
2ea83c02b0
commit
3d163cfa33
|
@ -423,7 +423,8 @@ proc buildAndRegisterUserProfile(self: AppController) =
|
||||||
keycardLocked: false,
|
keycardLocked: false,
|
||||||
accountsAddresses: @[defaultWalletAddress],
|
accountsAddresses: @[defaultWalletAddress],
|
||||||
keyUid: loggedInAccount.keyUid)
|
keyUid: loggedInAccount.keyUid)
|
||||||
discard self.walletAccountService.addMigratedKeyPair(keyPair)
|
let keystoreDir = self.accountsService.getKeyStoreDir()
|
||||||
|
discard self.walletAccountService.addMigratedKeyPair(keyPair, keystoreDir)
|
||||||
|
|
||||||
proc storeKeyPairForNewKeycardUser*(self: AppController) =
|
proc storeKeyPairForNewKeycardUser*(self: AppController) =
|
||||||
self.storeKeyPair = true
|
self.storeKeyPair = true
|
|
@ -445,7 +445,10 @@ proc getBalanceForAddress*(self: Controller, address: string): float64 =
|
||||||
proc addMigratedKeyPair*(self: Controller, keyPair: KeyPairDto): bool =
|
proc addMigratedKeyPair*(self: Controller, keyPair: KeyPairDto): bool =
|
||||||
if not serviceApplicable(self.walletAccountService):
|
if not serviceApplicable(self.walletAccountService):
|
||||||
return
|
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] =
|
proc getAllMigratedKeyPairs*(self: Controller): seq[KeyPairDto] =
|
||||||
if not serviceApplicable(self.walletAccountService):
|
if not serviceApplicable(self.walletAccountService):
|
||||||
|
|
|
@ -12,6 +12,7 @@ proc delete*(self: SeedPhraseEnterWordsState) =
|
||||||
|
|
||||||
method executePrimaryCommand*(self: SeedPhraseEnterWordsState, controller: Controller) =
|
method executePrimaryCommand*(self: SeedPhraseEnterWordsState, controller: Controller) =
|
||||||
let mnemonic = controller.getMnemonic()
|
let mnemonic = controller.getMnemonic()
|
||||||
|
controller.setSeedPhrase(mnemonic)
|
||||||
controller.storeSeedPhraseToKeycard(mnemonic.split(" ").len, mnemonic)
|
controller.storeSeedPhraseToKeycard(mnemonic.split(" ").len, mnemonic)
|
||||||
|
|
||||||
method executeTertiaryCommand*(self: SeedPhraseEnterWordsState, controller: Controller) =
|
method executeTertiaryCommand*(self: SeedPhraseEnterWordsState, controller: Controller) =
|
||||||
|
|
|
@ -67,6 +67,9 @@ proc setKeyStoreDir(self: Service, key: string) =
|
||||||
self.keyStoreDir = joinPath(main_constants.ROOTKEYSTOREDIR, key) & main_constants.sep
|
self.keyStoreDir = joinPath(main_constants.ROOTKEYSTOREDIR, key) & main_constants.sep
|
||||||
discard status_general.initKeystore(self.keyStoreDir)
|
discard status_general.initKeystore(self.keyStoreDir)
|
||||||
|
|
||||||
|
proc getKeyStoreDir*(self: Service): string =
|
||||||
|
return self.keyStoreDir
|
||||||
|
|
||||||
proc setDefaultWalletEmoji*(self: Service, emoji: string) =
|
proc setDefaultWalletEmoji*(self: Service, emoji: string) =
|
||||||
self.defaultWalletEmoji = emoji
|
self.defaultWalletEmoji = emoji
|
||||||
|
|
||||||
|
|
|
@ -547,13 +547,15 @@ QtObject:
|
||||||
error "error: ", procName=procName, errDesription = errMsg
|
error "error: ", procName=procName, errDesription = errMsg
|
||||||
return false
|
return false
|
||||||
|
|
||||||
proc addMigratedKeyPair*(self: Service, keyPair: KeyPairDto): bool =
|
proc addMigratedKeyPair*(self: Service, keyPair: KeyPairDto, keyStoreDir: string): bool =
|
||||||
try:
|
try:
|
||||||
let response = backend.addMigratedKeyPair(
|
let response = backend.addMigratedKeyPair(
|
||||||
keyPair.keycardUid,
|
keyPair.keycardUid,
|
||||||
keyPair.keycardName,
|
keyPair.keycardName,
|
||||||
keyPair.keyUid,
|
keyPair.keyUid,
|
||||||
keyPair.accountsAddresses)
|
keyPair.accountsAddresses,
|
||||||
|
keyStoreDir
|
||||||
|
)
|
||||||
result = self.responseHasNoErrors("addMigratedKeyPair", response)
|
result = self.responseHasNoErrors("addMigratedKeyPair", response)
|
||||||
if result:
|
if result:
|
||||||
self.events.emit(SIGNAL_NEW_KEYCARD_SET, KeycardActivityArgs(keyPair: keyPair))
|
self.events.emit(SIGNAL_NEW_KEYCARD_SET, KeycardActivityArgs(keyPair: keyPair))
|
||||||
|
|
|
@ -241,6 +241,7 @@ rpc(addMigratedKeyPair, "accounts"):
|
||||||
keyPairName: string
|
keyPairName: string
|
||||||
keyUid: string
|
keyUid: string
|
||||||
accountAddresses: seq[string]
|
accountAddresses: seq[string]
|
||||||
|
keyStoreDir: string
|
||||||
|
|
||||||
rpc(getAllMigratedKeyPairs, "accounts"):
|
rpc(getAllMigratedKeyPairs, "accounts"):
|
||||||
discard
|
discard
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit f33c1cec383d8cd7e14af2832b8017d1e204d9cf
|
Subproject commit 77b7ce5a09502d9f3f8fa9789ce4cf62efa0e96c
|
Loading…
Reference in New Issue