fix: default derived from for status account (#2651)

This commit is contained in:
Anthony Laibe 2022-05-09 10:00:48 +02:00 committed by GitHub
parent c71ccdb4e2
commit 2485e84bf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 4 deletions

View File

@ -533,7 +533,7 @@ func (db *Database) SetUseMailservers(value bool) error {
return db.SaveSettingField(UseMailservers, value)
}
func (db *Database) GetWalletRoodAddress() (rst types.Address, err error) {
func (db *Database) GetWalletRootAddress() (rst types.Address, err error) {
err = db.makeSelectRow(WalletRootAddress).Scan(&rst)
if err == sql.ErrNoRows {
return rst, nil

View File

@ -50,7 +50,23 @@ func (api *API) SaveAccounts(ctx context.Context, accounts []accounts.Account) e
}
func (api *API) GetAccounts(ctx context.Context) ([]accounts.Account, error) {
return api.db.GetAccounts()
accounts, err := api.db.GetAccounts()
if err != nil {
return nil, err
}
for i := range accounts {
account := &accounts[i]
if account.Wallet && account.DerivedFrom == "" {
address, err := api.db.GetWalletRootAddress()
if err != nil {
return nil, err
}
account.DerivedFrom = address.Hex()
}
}
return accounts, nil
}
func (api *API) DeleteAccount(ctx context.Context, address types.Address) error {
@ -142,8 +158,7 @@ func (api *API) GenerateAccount(
color string,
emoji string,
) error {
address, err := api.db.GetWalletRoodAddress()
address, err := api.db.GetWalletRootAddress()
if err != nil {
return err
}