fix(Wallet): derive accounts from imported mnemonic and store correctly

This commit address two bugs:

1. When importing a mnemonic, the resulting "master" account and its address
  was used as account to be stored as opposed to its derived default account
2. The account was stored in the wrong path, resulting in status not being able
  to locate accounts when sending transactions.

Fixes #787
This commit is contained in:
Pascal Precht 2020-09-11 12:29:27 +02:00 committed by Iuri Matias
parent 19e801bba8
commit 361c563a4b
2 changed files with 3 additions and 2 deletions

View File

@ -225,7 +225,7 @@ proc storeDerivedWallet*(account: GeneratedAccount, password: string, walletInde
let hashedPassword = hashPassword(password)
let multiAccount = %* {
"accountID": account.id,
"paths": ["m/" & $walletIndex],
"paths": ["m/44'/60'/0'/0/" & $walletIndex],
"password": hashedPassword
}
let response = parseJson($nim_status.multiAccountStoreDerivedAccounts($multiAccount));

View File

@ -259,7 +259,8 @@ proc generateNewAccount*(self: WalletModel, password: string, accountName: strin
proc addAccountsFromSeed*(self: WalletModel, seed: string, password: string, accountName: string, color: string): string =
let mnemonic = replace(seed, ',', ' ')
let generatedAccount = status_accounts.multiAccountImportMnemonic(mnemonic)
var generatedAccount = status_accounts.multiAccountImportMnemonic(mnemonic)
generatedAccount.derived = status_accounts.deriveAccounts(generatedAccount.id)
return self.addNewGeneratedAccountWithPassword(generatedAccount, password, accountName, color, constants.SEED)
proc addAccountsFromPrivateKey*(self: WalletModel, privateKey: string, password: string, accountName: string, color: string): string =