return ErrDuplicateIndex
}
- currentIndex := uint64(0)
- if rawIndexBytes := m.store.GetAccountIndex(account.XPubs); rawIndexBytes != nil {
- currentIndex = common.BytesToUnit64(rawIndexBytes)
- }
+ currentIndex := m.store.GetAccountIndex(account.XPubs)
return m.saveAccount(account, account.KeyIndex > currentIndex)
}
}
acctIndex := uint64(1)
- if rawIndexBytes := m.store.GetAccountIndex(xpubs); rawIndexBytes != nil {
- acctIndex = common.BytesToUnit64(rawIndexBytes) + 1
+ if currentIndex := m.store.GetAccountIndex(xpubs); currentIndex != 0 {
+ acctIndex = currentIndex + 1
}
account, err := CreateAccount(xpubs, quorum, alias, acctIndex, deriveRule)
if err != nil {
SetAccount(*Account, bool) error
GetAccountIDByAccountAlias(string) string
GetAccountByAccountID(string) (*Account, error)
- GetAccountIndex([]chainkd.XPub) []byte
+ GetAccountIndex([]chainkd.XPub) uint64
DeleteAccountByAccountAlias(string)
DeleteAccountByAccountID(string)
DeleteRawProgram(common.Hash)
// GetAccountIDByAccountAlias get account ID by account alias
func (store *AccountStore) GetAccountIDByAccountAlias(accountAlias string) string {
accountID := store.accountDB.Get(accountAliasKey(accountAlias))
-
return string(accountID)
}
}
// GetAccountIndex get account index by account xpubs
-func (store *AccountStore) GetAccountIndex(xpubs []chainkd.XPub) []byte {
- return store.accountDB.Get(accountIndexKey(xpubs))
+func (store *AccountStore) GetAccountIndex(xpubs []chainkd.XPub) uint64 {
+ currentIndex := uint64(0)
+ if rawIndexBytes := store.accountDB.Get(accountIndexKey(xpubs)); rawIndexBytes != nil {
+ currentIndex = common.BytesToUnit64(rawIndexBytes)
+ }
+ return currentIndex
}
// DeleteAccountByAccountAlias delete account by account alias