return nil
}
-// deleteAccountControlPrograms deletes control program matching accountID
-func (m *Manager) deleteAccountControlPrograms(accountID string) error {
- cps, err := m.ListControlProgram()
- if err != nil {
- return err
- }
-
- var hash [32]byte
- for _, cp := range cps {
- if cp.AccountID == accountID {
- sha3pool.Sum256(hash[:], cp.ControlProgram)
- m.store.DeleteControlProgram(bc.NewHash(hash))
- }
- }
-
- m.store.DeleteBip44ContractIndex(accountID)
- m.store.DeleteContractIndex(accountID)
-
- return nil
-}
-
// DeleteAccount deletes the account's ID or alias matching account ID.
func (m *Manager) DeleteAccount(accountID string) (err error) {
m.accountMu.Lock()
return err
}
- // if err := m.deleteAccountControlPrograms(accountID); err != nil {
- // return err
- // }
-
m.cacheMu.Lock()
m.aliasCache.Remove(account.Alias)
m.cacheMu.Unlock()
// DeleteAccount set account account ID, account alias and raw account.
func (store *AccountStore) DeleteAccount(account *acc.Account) error {
-
- // store.DeleteBip44ContractIndex(account.ID)
- // store.DeleteContractIndex(account.ID)
-
store.DeleteAccountUTXOs(account.ID)
batch := store.accountDB.NewBatch()
if store.batch != nil {
batch = store.batch
}
+
// delete account control program
cps, err := store.ListControlPrograms()
if err != nil {
batch.Delete(ContractKey(bc.NewHash(hash)))
}
}
+
// delete bip44 contract index
batch.Delete(Bip44ContractIndexKey(account.ID, false))
batch.Delete(Bip44ContractIndexKey(account.ID, true))
+
// delete contract index
batch.Delete(contractIndexKey(account.ID))
+ // delete account id
batch.Delete(AccountIDKey(account.ID))
batch.Delete(accountAliasKey(account.Alias))
if store.batch == nil {