public bool UnlockAccount(Address address, SecureString passphrase, TimeSpan?timeSpan) { if (address is null || address == Address.Zero) { return(false); } if (!_passwords.ContainsKey(address)) { if (_logger.IsError) { _logger.Error("Account does not exist."); } return(false); } if (!CheckPassword(address, passphrase)) { if (_logger.IsError) { _logger.Error("Password is invalid."); } return(false); } AccountUnlocked?.Invoke(this, new AccountUnlockedEventArgs(address)); _isUnlocked[address] = true; return(true); }
public bool UnlockAccount(Address address, SecureString passphrase, TimeSpan?timeSpan) { if (address == Address.Zero) { return(false); } else if (IsUnlocked(address)) { return(true); } else { (PrivateKey key, Result result) = _keyStore.GetKey(address, passphrase); if (result.ResultType == ResultType.Success) { if (_logger.IsInfo) { _logger.Info($"Unlocking account: {address}"); } _unlockedAccounts.Add(key.Address.ToString(), _protectedPrivateKeyFactory.Create(key), new CacheItemPolicy() { Priority = CacheItemPriority.NotRemovable, AbsoluteExpiration = _timestamper.UtcNowOffset + (timeSpan ?? DefaultExpirationTime) }); AccountUnlocked?.Invoke(this, new AccountUnlockedEventArgs(address)); return(true); } if (_logger.IsError) { _logger.Error($"Failed to unlock the account: {address}"); } return(false); } }
public bool UnlockAccount(Address address, SecureString passphrase, TimeSpan?timeSpan) { if (address == Address.Zero) { return(false); } if (_unlockedAccounts.ContainsKey(address)) { return(true); } (PrivateKey key, Result result) = _keyStore.GetKey(address, passphrase); if (result.ResultType == ResultType.Success) { if (_logger.IsInfo) { _logger.Info($"Unlocking account: {address}"); } _unlockedAccounts.Add(key.Address, key); AccountUnlocked?.Invoke(this, new AccountUnlockedEventArgs(address)); return(true); } if (_logger.IsError) { _logger.Error($"Failed to unlock the account: {address}"); } return(false); }
public bool UnlockAccount(Address address, SecureString passphrase, TimeSpan?timeSpan) { if (address == Address.Zero) { return(false); } else if (IsUnlocked(address)) { return(true); } else { (PrivateKey key, Result result) = _keyStore.GetKey(address, passphrase); if (result.ResultType == ResultType.Success) { if (_logger.IsInfo) { _logger.Info($"Unlocking account: {address}"); } _unlockedAccounts.Set(key.Address.ToString(), _protectedPrivateKeyFactory.Create(key)); AccountUnlocked?.Invoke(this, new AccountUnlockedEventArgs(address)); return(true); } if (_logger.IsError) { _logger.Error($"Failed to unlock the account: {address}"); } return(false); } }
public bool UnlockAccount(Address address, SecureString passphrase, TimeSpan timeSpan) { AccountUnlocked?.Invoke(this, new AccountUnlockedEventArgs(address)); return(true); }
public bool UnlockAccount(Address address, SecureString passphrase, TimeSpan timeSpan) { AccountUnlocked?.Invoke(this, new AccountUnlockedEventArgs(address)); throw new NotSupportedException(); }