Beispiel #1
0
 public override bool DeleteAccount(UInt160 scriptHash)
 {
     UserWalletAccount account;
     lock (accounts)
     {
         if (accounts.TryGetValue(scriptHash, out account))
             accounts.Remove(scriptHash);
     }
     if (account != null)
     {
         indexer.UnregisterAccounts(new[] { scriptHash });
         lock (db_lock)
             using (WalletDataContext ctx = new WalletDataContext(path))
             {
                 if (account.HasKey)
                 {
                     Account db_account = ctx.Accounts.First(p => p.PublicKeyHash.SequenceEqual(account.Key.PublicKeyHash.ToArray()));
                     ctx.Accounts.Remove(db_account);
                 }
                 if (account.Contract != null)
                 {
                     Contract db_contract = ctx.Contracts.First(p => p.ScriptHash.SequenceEqual(scriptHash.ToArray()));
                     ctx.Contracts.Remove(db_contract);
                 }
                 //delete address
                 {
                     Address db_address = ctx.Addresses.First(p => p.ScriptHash.SequenceEqual(scriptHash.ToArray()));
                     ctx.Addresses.Remove(db_address);
                 }
                 ctx.SaveChanges();
             }
         return true;
     }
     return false;
 }
Beispiel #2
0
        public override bool DeleteAccount(UInt160 scriptHash)
        {
            bool removed;

            lock (accounts)
            {
                removed = accounts.Remove(scriptHash);
            }
            if (removed)
            {
                WalletIndexer.UnregisterAccounts(new[] { scriptHash });
            }
            return(removed);
        }