Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/app/modules/onboarding/controller.nim
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,12 @@ proc deleteMultiaccount*(self: Controller, keyUid: string): string =
return self.accountsService.deleteMultiaccount(keyUid)

proc restoreKeycardAccountAndLogin*(self: Controller, keyUid, instanceUid: string,
keycardKeys: KeycardExportedKeysDto, thirdpartyServicesEnabled: bool): string =
keycardKeys: KeycardExportedKeysDto, walletXPub: string, thirdpartyServicesEnabled: bool): string =
return self.accountsService.restoreKeycardAccountAndLoginV2(
keyUid,
instanceUid,
keycardKeys,
walletXPub,
thirdpartyServicesEnabled,
)

Expand Down
5 changes: 3 additions & 2 deletions src/app/modules/onboarding/module.nim
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ method onMainFailedToLoad*[T](self: Module[T]) =
method load*[T](self: Module[T]) =
singletonInstance.engine.setRootContextProperty("onboardingModule", self.viewVariant)
self.controller.init()

let loggedInAccount = self.accountsService.fetchLoggedInAccount()
self.resumeLogin = loggedInAccount.isValid()
if (self.resumeLogin):
self.controller.setLoggedInAccount(loggedInAccount)
self.controller.setLoggedInAccount(loggedInAccount)
self.finishAppLoading2()
return

Expand Down Expand Up @@ -247,6 +247,7 @@ method finishOnboardingFlow*[T](self: Module[T], flowInt: int, dataJson: string)
keycardInfo.keyUID,
keycardInfo.instanceUID,
self.exportedKeys,
walletXPub = "",
thirdpartyServicesEnabled,
)
of OnboardingFlow.LoginWithLostKeycardSeedphrase:
Expand Down
2 changes: 1 addition & 1 deletion src/app/modules/shared_modules/add_account/controller.nim
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ proc addNewSeedPhraseKeypair*(self: Controller, seedPhrase: string, doPasswordHa
info "cannot create keystore file if provided password is empty", keypairName=keypairName
return false
let err = self.walletAccountService.addNewSeedPhraseKeypair(seedPhrase, password, doPasswordHashing, keypairName,
accountCreationDetails)
coldWallet = wallet_account_service.ColdWalletTypeNoNone, accountCreationDetails)
if err.len > 0:
info "adding new keypair from seed phrase failed", keypairName=keypairName
return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ proc getKeyUidForSeedPhrase*(self: Controller, seedPhrase: string): string =
proc getKeypairByKeyUid*(self: Controller, keyUid: string): KeypairDto =
return self.walletAccountService.getKeypairByKeyUid(keyUid)

proc addNewKeycardStoredKeypair*(self: Controller, keyUid, keypairName, xpub, coldWallet: string, accounts: seq[wallet_account_service.WalletAccountDto]): string =
return self.walletAccountService.addNewKeycardStoredKeypairNew(keyUid, keypairName, xpub, coldWallet, rootWalletMasterKey="", accounts)
proc addNewColdWalletStoredKeypair*(self: Controller, keyUid, keypairName, xpub, coldWallet: string, accounts: seq[wallet_account_service.WalletAccountDto]): string =
return self.walletAccountService.addNewColdWalletStoredKeypair(keyUid, keypairName, xpub, coldWallet,
rootWalletMasterKey = "", accounts)

proc addKeycardOrAccounts*(self: Controller, keyPair: KeycardDto, password: string) =
self.walletAccountService.addKeycardOrAccountsAsync(keyPair, password)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ proc addNewKeycardKeypair*[T](self: Module[T]): string =
colorId: account.colorId,
emoji: account.emoji,
))
return self.controller.addNewKeycardStoredKeypair(self.tmpKeyUid, self.tmpKeypairName, self.tmpXpub,
return self.controller.addNewColdWalletStoredKeypair(self.tmpKeyUid, self.tmpKeypairName, self.tmpXpub,
wallet_account_service.ColdWalletTypeStatusKeycard, walletAccounts)

## #########################################################
Expand Down
9 changes: 5 additions & 4 deletions src/app/modules/shared_modules/keycard_popup/controller.nim
Original file line number Diff line number Diff line change
Expand Up @@ -740,11 +740,12 @@ proc updateKeycardUid*(self: Controller, keyUid: string, keycardUid: string) =
self.tmpKeycardUid = keycardUid
info "update keycard uid failed", oldKeycardUid=self.tmpKeycardUid, newKeycardUid=keycardUid

proc addNewKeycardStoredKeypair*(self: Controller, keyUid, keypairName, rootWalletMasterKey: string,
accounts: seq[WalletAccountDto]): bool =
let err = self.walletAccountService.addNewKeycardStoredKeypair(keyUid, keypairName, rootWalletMasterKey, accounts)
proc addNewColdWalletStoredKeypair*(self: Controller, keyUid, keypairName, walletXPub, coldWallet,
rootWalletMasterKey: string, accounts: seq[WalletAccountDto]): bool =
let err = self.walletAccountService.addNewColdWalletStoredKeypair(keyUid, keypairName, walletXPub, coldWallet,
rootWalletMasterKey, accounts)
if err.len > 0:
info "adding new keypair from keycard failed", keypairName=keypairName, keyUid=keyUid
info "adding new keypair to cold wallet failed", keypairName=keypairName, keyUid=keyUid
return false
return true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ proc addAccountsToWallet(self: CreatingAccountNewSeedPhraseState, controller: Co
colorId: account.getColorId(),
emoji: account.getEmoji()
))
return controller.addNewKeycardStoredKeypair(
return controller.addNewColdWalletStoredKeypair(
keyUid = kpForProcessing.getKeyUid(),
keypairName = kpForProcessing.getName(),
walletXPub = "",
coldWallet = ColdWalletTypeStatusKeycard,
rootWalletMasterKey = kpForProcessing.getDerivedFrom(),
accounts = walletAccounts
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ proc addAccountsToWallet(self: CreatingAccountOldSeedPhraseState, controller: Co
colorId: account.getColorId(),
emoji: account.getEmoji()
))
return controller.addNewKeycardStoredKeypair(
return controller.addNewColdWalletStoredKeypair(
keyUid = kpForProcessing.getKeyUid(),
keypairName = kpForProcessing.getName(),
walletXPub = "",
coldWallet = ColdWalletTypeStatusKeycard,
rootWalletMasterKey = kpForProcessing.getDerivedFrom(),
accounts = walletAccounts
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ proc addAccountsToWallet(self: ImportingFromKeycardState, controller: Controller
colorId: account.getColorId(),
emoji: account.getEmoji()
))
return controller.addNewKeycardStoredKeypair(
return controller.addNewColdWalletStoredKeypair(
keyUid = kpForProcessing.getKeyUid(),
keypairName = kpForProcessing.getName(),
walletXPub = "",
coldWallet = ColdWalletTypeStatusKeycard,
rootWalletMasterKey = kpForProcessing.getDerivedFrom(),
accounts = walletAccounts
)
Expand Down
6 changes: 5 additions & 1 deletion src/app_service/service/accounts/dto/keycard_data.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ type
walletRootAddress*: string
eip1581Address*: string
encryptionPublicKey*: string
walletXPub*: string
coldWallet*: string

proc toJson*(self: KeycardData): JsonNode =
result = %*{
Expand All @@ -24,5 +26,7 @@ proc toJson*(self: KeycardData): JsonNode =
"walletAddress": self.walletAddress,
"walletRootAddress": self.walletRootAddress,
"eip1581Address": self.eip1581Address,
"encryptionPublicKey": self.encryptionPublicKey
"encryptionPublicKey": self.encryptionPublicKey,
"walletXPub": self.walletXPub,
"coldWallet": self.coldWallet
}
6 changes: 6 additions & 0 deletions src/app_service/service/accounts/service.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ./dto/restore_account_request

from ../keycard/service import KeycardEvent, KeyDetails
from ../keycardV2/dto import KeycardExportedKeysDto, KeyDetailsV2
from ../wallet_account/dto/keypair_dto import ColdWalletTypeStatusKeycard
import backend/general as status_general
import backend/core as status_core
import backend/privacy as status_privacy
Expand Down Expand Up @@ -270,6 +271,8 @@ QtObject:
walletRootAddress: keycardData.walletRootKey.address,
eip1581Address: keycardData.eip1581Key.address,
encryptionPublicKey: keycardData.encryptionKey.publicKey,
walletXPub: "",
coldWallet: ColdWalletTypeStatusKeycard,
)

var request = RestoreAccountRequest(
Expand All @@ -284,6 +287,7 @@ QtObject:
keyUid: string,
instanceUid: string,
keycardKeys: KeycardExportedKeysDto,
walletXPub: string,
thirdpartyServicesEnabled: bool
): string =

Expand All @@ -298,6 +302,8 @@ QtObject:
walletRootAddress: keycardKeys.walletRootKey.address,
eip1581Address: keycardKeys.eip1581Key.address,
encryptionPublicKey: keycardKeys.encryptionKey.publicKey,
walletXPub: walletXPub,
coldWallet: ColdWalletTypeStatusKeycard,
)

var request = RestoreAccountRequest(
Expand Down
29 changes: 9 additions & 20 deletions src/app_service/service/wallet_account/service_account.nim
Original file line number Diff line number Diff line change
Expand Up @@ -402,12 +402,13 @@ proc makePrivateKeyKeypairFullyOperable*(self: Service, keyUid, privateKey, pass

## Mandatory fields for all accounts are `path`, `name`, `emoji`, `colorId`
proc addNewSeedPhraseKeypair*(self: Service, seedPhrase, password: string, doPasswordHashing: bool,
keypairName: string, accountCreationDetails: AccountCreationDetails): string =
keypairName, coldWallet: string, accountCreationDetails: AccountCreationDetails): string =
var finalPassword = password
if password.len > 0 and doPasswordHashing:
finalPassword = utils.hashPassword(password)
try:
var response = status_go_accounts.addKeypairViaSeedPhrase(seedPhrase, finalPassword, keypairName, accountCreationDetails)
var response = status_go_accounts.addKeypairViaSeedPhrase(seedPhrase, finalPassword, keypairName, coldWallet,
accountCreationDetails)
if not response.error.isNil:
error "status-go error adding keypair", procName="addNewSeedPhraseKeypair", errCode=response.error.code, errDesription=response.error.message
return response.error.message
Expand All @@ -418,32 +419,20 @@ proc addNewSeedPhraseKeypair*(self: Service, seedPhrase, password: string, doPas
error "error: ", procName="addNewSeedPhraseKeypair", errName=e.name, errDesription=e.msg
return e.msg

proc addNewKeycardStoredKeypair*(self: Service, keyUid, keypairName, rootWalletMasterKey: string, accounts: seq[WalletAccountDto]): string =
try:
var response = status_go_accounts.addKeypairStoredToKeycard(keyUid, rootWalletMasterKey, keypairName, accounts)
if not response.error.isNil:
error "status-go error adding keypair", procName="addNewKeycardStoredKeypair", errCode=response.error.code, errDesription=response.error.message
return response.error.message

for i in 0 ..< accounts.len:
self.addNewKeypairsAccountsToLocalStoreAndNotify()
return ""
except Exception as e:
error "error: ", procName="addNewKeycardStoredKeypair", errName=e.name, errDesription=e.msg
return e.msg

proc addNewKeycardStoredKeypairNew*(self: Service, keyUid, keypairName, xpub, coldWallet, rootWalletMasterKey: string = "", accounts: seq[WalletAccountDto]): string =
proc addNewColdWalletStoredKeypair*(self: Service, keyUid, keypairName, walletXPub, coldWallet, rootWalletMasterKey: string,
accounts: seq[WalletAccountDto]): string =
try:
var response = status_go_accounts.addKeypairStoredToKeycardNew(keyUid, rootWalletMasterKey, keypairName, xpub, coldWallet, accounts)
var response = status_go_accounts.addKeypairStoredToColdWallet(keyUid, rootWalletMasterKey, keypairName, walletXPub,
coldWallet, accounts)
if not response.error.isNil:
error "status-go error adding keypair", procName="addNewKeycardStoredKeypair", errCode=response.error.code, errDesription=response.error.message
error "status-go error adding keypair", procName="addNewColdWalletStoredKeypair", errCode=response.error.code, errDesription=response.error.message
return response.error.message

for i in 0 ..< accounts.len:
self.addNewKeypairsAccountsToLocalStoreAndNotify()
return ""
except Exception as e:
error "error: ", procName="addNewKeycardStoredKeypair", errName=e.name, errDesription=e.msg
error "error: ", procName="addNewColdWalletStoredKeypair", errName=e.name, errDesription=e.msg
return e.msg

proc makeSeedPhraseKeypairFullyOperable*(self: Service, keyUid, mnemonic, password: string, doPasswordHashing: bool): string =
Expand Down
34 changes: 7 additions & 27 deletions src/backend/accounts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@ proc addKeypairViaPrivateKey*(privateKey, password, name: string, accountCreatio
let payload = %* [privateKey, password, name, accountCreationDetails]
return core.callPrivateRPC("accounts_addKeypairViaPrivateKey", payload)

proc addKeypairViaSeedPhrase*(seedPhrase, password, name: string, accountCreationDetails: AccountCreationDetails): RpcResponse[JsonNode] =
let payload = %* [seedPhrase, password, name, accountCreationDetails]
proc addKeypairViaSeedPhrase*(seedPhrase, password, name, coldWallet: string,
accountCreationDetails: AccountCreationDetails): RpcResponse[JsonNode] =
let payload = %* [seedPhrase, password, name, coldWallet, accountCreationDetails]
return core.callPrivateRPC("accounts_addKeypairViaSeedPhrase", payload)

proc addKeypairStoredToKeycard*(keyUID, masterAddress, name: string, walletAccounts: seq[WalletAccountDto]): RpcResponse[JsonNode] =
proc addKeypairStoredToColdWallet*(keyUID, masterAddress, name, walletXPub, coldWallet: string,
walletAccounts: seq[WalletAccountDto]): RpcResponse[JsonNode] =
var accountsJson: JsonNode = %* []
for acc in walletAccounts:
accountsJson.add(%*{
Expand All @@ -92,30 +94,8 @@ proc addKeypairStoredToKeycard*(keyUID, masterAddress, name: string, walletAccou
}
)

let payload = %* [keyUID, masterAddress, name, accountsJson]
return core.callPrivateRPC("accounts_addKeypairStoredToKeycard", payload)

proc addKeypairStoredToKeycardNew*(keyUID, masterAddress, name, xpub, coldWallet: string, walletAccounts: seq[WalletAccountDto]): RpcResponse[JsonNode] =
var accountsJson: JsonNode = %* []
for acc in walletAccounts:
accountsJson.add(%*{
"address": acc.address,
"key-uid": acc.keyUID,
"wallet": acc.isWallet,
"chat": acc.isChat,
"type": acc.walletType,
"path": acc.path,
"public-key": acc.publicKey,
"name": acc.name,
"emoji": acc.emoji,
"colorId": acc.colorId,
"hidden": acc.hideFromTotalBalance
# other fields are set on the status-go side
}
)

let payload = %* [keyUID, masterAddress, name, xpub, coldWallet, accountsJson]
return core.callPrivateRPC("accounts_addKeypairStoredToKeycardNew", payload)
let payload = %* [keyUID, masterAddress, name, walletXPub, coldWallet, accountsJson]
return core.callPrivateRPC("accounts_addKeypairStoredToColdWallet", payload)

## Adds a new account without creating a Keystore file and notifies paired devices
proc addAccountWithoutKeystoreFileCreation*(name, address, path, publicKey, keyUid, accountType, colorId, emoji: string, hideFromTotalBalance: bool):
Expand Down
2 changes: 1 addition & 1 deletion vendor/status-go
Submodule status-go updated 29 files
+115 −95 internal/accounts-management/README.md
+1 −0 internal/accounts-management/common/const.go
+11 −0 internal/accounts-management/generator/types.go
+1 −1 internal/accounts-management/manager_test.go
+16 −6 internal/accounts-management/persistence_operations.go
+20 −5 pkg/backend/geth_backend.go
+2 −1 pkg/backend/test_helpers.go
+1 −0 pkg/messaging/layers/segmentation/migrations/sqlite/1778713126_add_original_payload_length.up.sql
+2 −0 pkg/messaging/layers/segmentation/protobuf/segment_message.proto
+21 −12 pkg/messaging/layers/segmentation/segmenter.go
+45 −0 pkg/messaging/layers/segmentation/segmenter_test.go
+4 −4 pkg/messaging/layers/segmentation/sqlite_persistence.go
+3 −3 protocol/accounts_manager_interface.go
+5 −5 protocol/messenger_wallet.go
+14 −10 protocol/requests/restore_account.go
+3 −3 server/pairing/sync_device_test.go
+5 −17 services/accounts/accounts.go
+4 −4 services/personal/service_test.go
+4 −4 services/wallet/api.go
+12 −5 tests-functional/clients/services/accounts.py
+3 −0 tests-functional/resources/constants.py
+20 −4 tests-functional/tests/test_add_account.py
+18 −6 tests-functional/tests/test_add_keypair_stored_to_cold_wallet.py
+56 −9 tests-functional/tests/test_add_keypair_via_seed_phrase.py
+7 −1 tests-functional/tests/test_get_keypair_by_keyuid.py
+5 −1 tests-functional/tests/test_get_num_of_addresses_to_generate_for_keypair.py
+11 −2 tests-functional/tests/test_migrate_non_profile_keycard_keypair_to_app.py
+27 −4 tests-functional/tests/test_remaining_keypair_capacity.py
+7 −1 tests-functional/tests/test_update_keypair_name.py
Loading