Exemple #1
0
        public async Task RemoveAddressAsync(Address address)
        {
            if (IsLocked)
            {
                throw new LockedException();
            }

            if (Addresses.Contains(address))
            {
                if (PrivateKeys.Contains(address))
                {
                    await privateKeyLock.WaitAsync();

                    try {
                        PrivateKeys.Remove(address);
                    }
                    finally {
                        privateKeyLock.Release();
                    }
                }
                if (PublicAddresses.Contains(address))
                {
                    PublicAddresses.Remove(address);
                }

                await SaveAsync();
            }
            else
            {
                throw new OperationException(String.Format("Your wallet doesn't contain the address {0}", address));
            }
        }
Exemple #2
0
 public async Task HideAddressAsync(Address address)
 {
     if (IsLocked)
     {
         throw new LockedException();
     }
     if (PrivateKeys.Contains(address) && PublicAddresses.Contains(address))
     {
         PublicAddresses.Remove(address);
         await SaveAsync();
     }
     else
     {
         // TODO: Tailor this message for both the key not being present and the address already being private
         throw new OperationException(String.Format("Address '{0}' isnt public", address));
     }
 }