fix: default derived from for status account (#2651)
This commit is contained in:
parent
c71ccdb4e2
commit
2485e84bf5
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue