Esempio n. 1
0
        public async Task SetLabelAsync(Address address, string label, bool isPublic = true)
        {
            if (IsLocked)
            {
                throw new LockedException();
            }

            await privateKeyLock.WaitAsync();

            try {
                bool wasUpdated = false;
                if (PrivateAddresses.Contains(address))
                {
                    PrivateKeys[address].Label = label;
                    wasUpdated = true;
                }

                if (isPublic && PublicAddresses.Contains(address))
                {
                    PublicAddresses[address].Label = label;
                    wasUpdated = true;
                }

                if (!wasUpdated)
                {
                    throw new OperationException(String.Format("Could not find address '{0}' in your wallet", address));
                }
            }
            finally {
                privateKeyLock.Release();
            }
            SaveAsync();
        }
Esempio n. 2
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));
            }
        }
Esempio n. 3
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));
     }
 }