fix: generation path (#2637)

This commit is contained in:
Anthony Laibe 2022-04-11 18:35:18 +02:00 committed by GitHub
parent f1cd9120c9
commit 9fef24917a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 6 deletions

View File

@ -386,6 +386,11 @@ var (
dBColumnName: "webview_allow_permission_requests",
valueHandler: BoolHandler,
}
WalletRootAddress = SettingField{
reactFieldName: "wallet-root-address",
dBColumnName: "wallet_root_address",
valueHandler: AddressHandler,
}
SettingFieldRegister = []SettingField{
AnonMetricsShouldSend,
@ -447,6 +452,7 @@ var (
UseMailservers,
Usernames,
WakuBloomFilterMode,
WalletRootAddress,
WalletSetUpPassed,
WalletVisibleTokens,
WebviewAllowPermissionRequests,

View File

@ -532,3 +532,11 @@ func (db *Database) SetPinnedMailservers(mailservers map[string]string) error {
func (db *Database) SetUseMailservers(value bool) error {
return db.SaveSettingField(UseMailservers, value)
}
func (db *Database) GetWalletRoodAddress() (rst types.Address, err error) {
err = db.makeSelectRow(WalletRootAddress).Scan(&rst)
if err == sql.ErrNoRows {
return rst, nil
}
return
}

View File

@ -17,7 +17,7 @@ import (
"github.com/status-im/status-go/params"
)
const pathWalletRoot = "m/44'/60'/0'/0/0"
const pathWalletRoot = "m/44'/60'/0'/0"
const pathDefaultWallet = pathWalletRoot + "/0"
func NewAccountsAPI(manager *account.GethManager, config *params.NodeConfig, db *accounts.Database, feed *event.Feed) *API {
@ -81,7 +81,7 @@ func (api *API) AddAccountWithMnemonic(
return err
}
accountInfos, err := api.manager.AccountsGenerator().StoreDerivedAccounts(generatedAccountInfo.ID, password, []string{pathWalletRoot})
accountInfos, err := api.manager.AccountsGenerator().StoreDerivedAccounts(generatedAccountInfo.ID, password, []string{pathDefaultWallet})
if err != nil {
return err
}
@ -95,8 +95,8 @@ func (api *API) AddAccountWithMnemonic(
}
account := accounts.Account{
Address: types.Address(common.HexToAddress(accountInfos[pathWalletRoot].Address)),
PublicKey: types.HexBytes(accountInfos[pathWalletRoot].PublicKey),
Address: types.Address(common.HexToAddress(accountInfos[pathDefaultWallet].Address)),
PublicKey: types.HexBytes(accountInfos[pathDefaultWallet].PublicKey),
Type: "seed",
Name: name,
Emoji: emoji,
@ -162,7 +162,7 @@ func (api *API) GenerateAccount(
return err
}
address, err := api.db.GetWalletAddress()
address, err := api.db.GetWalletRoodAddress()
if err != nil {
return err
}
@ -195,7 +195,7 @@ func (api *API) GenerateAccount(
Name: name,
Emoji: emoji,
Color: color,
Path: path,
Path: fmt.Sprint(pathWalletRoot, "/", newDerivedPath),
}
err = api.db.SaveSettingField(settings.LatestDerivedPath, newDerivedPath)