Esempio n. 1
0
        public void LoadFromJson(string json)
        {
            JObject data = JObject.Parse(json);

            if (data["version"].Value <string>() != Version)
            {
                throw new FormatException(String.Format("Invalid wallet version: {0}", data["version"].Value <ulong>()));
            }

            KeyHashes = data["key_hashes"].Value <ulong>();

            IV   = Base58.DecodeWithChecksum(data["encrypted"]["iv"].Value <string>());
            Salt = Base58.DecodeWithChecksum(data["encrypted"]["salt"].Value <string>());

            if (data["watch_addresses"] != null)
            {
                foreach (JToken key in data["watch_addresses"])
                {
                    WatchAddresses.Add(key["addr"].Value <string>(), key["label"] != null ? key["label"].Value <string>() : null);
                }
            }

            if (data["public_addresses"] != null)
            {
                foreach (JToken key in data["public_addresses"])
                {
                    PublicAddresses.Add(key["addr"].Value <string>(), key["label"] != null ? key["label"].Value <string>() : null);
                }
            }

            EncryptedData = Base58.DecodeWithChecksum(data["encrypted"]["data"].Value <string>());
        }
Esempio n. 2
0
 public async Task ImportReadOnlyAddressAsync(AddressDetails addressDetails)
 {
     if (IsLocked)
     {
         throw new LockedException();
     }
     PublicAddresses.Add(addressDetails);
     await SaveAsync();
 }
Esempio n. 3
0
 public async Task ShowAddressAsync(Address address)
 {
     if (IsLocked)
     {
         throw new LockedException();
     }
     if (PrivateKeys.Contains(address) && !PublicAddresses.Contains(address))
     {
         PublicAddresses.Add(PrivateKeys[address]);
         await SaveAsync();
     }
     else
     {
         // TODO: Tailor this message for both the key not being present and the address already being public
         throw new OperationException(String.Format("Address '{0}' isnt private", address));
     }
 }