diff --git a/src/Helpers/ValidationHelper.cs b/src/Helpers/ValidationHelper.cs index d75dcbc5..f81bb291 100644 --- a/src/Helpers/ValidationHelper.cs +++ b/src/Helpers/ValidationHelper.cs @@ -87,13 +87,13 @@ public static void ValidateWithdrawalAmount(ValidatorEventArgs obj, Boolean isAm decimal minimum = Constants.MINIMUM_WITHDRAWAL_BTC_AMOUNT; decimal maximum = Constants.MAXIMUM_WITHDRAWAL_BTC_AMOUNT; - if (amount < minimum && !isAmountDisabled) + if (amount < minimum && isAmountDisabled) { obj.Status = ValidationStatus.Error; obj.ErrorText = $"Error, the minimum amount to withdraw is at least {minimum:f8} BTC"; } - if (amount > maximum && !isAmountDisabled) + if (amount > maximum && isAmountDisabled) { obj.Status = ValidationStatus.Error; obj.ErrorText = $"Error, the maximum amount to withdraw is {maximum:f8} BTC"; diff --git a/src/Pages/ChannelRequests.razor b/src/Pages/ChannelRequests.razor index 47b55444..169b871e 100644 --- a/src/Pages/ChannelRequests.razor +++ b/src/Pages/ChannelRequests.razor @@ -149,7 +149,7 @@ @if (Constants.MAXIMUM_WITHDRAWAL_BTC_AMOUNT < _amount) { - @($"Amount in Satoshis. Maximum {Constants.MAXIMUM_WITHDRAWAL_BTC_AMOUNT}.") + @($"Amount in BTC. Maximum {Constants.MAXIMUM_WITHDRAWAL_BTC_AMOUNT}.") } else { diff --git a/src/Pages/Wallets.razor b/src/Pages/Wallets.razor index 531d50de..35b3d752 100644 --- a/src/Pages/Wallets.razor +++ b/src/Pages/Wallets.razor @@ -471,7 +471,7 @@ - Amount + Amount diff --git a/src/Pages/Withdrawals.razor b/src/Pages/Withdrawals.razor index f14e72c6..efa5ef6f 100644 --- a/src/Pages/Withdrawals.razor +++ b/src/Pages/Withdrawals.razor @@ -148,10 +148,7 @@ - - - - + @@ -169,26 +166,19 @@ } - @if (!_isAmountDisabled) - { - - + + @if (Constants.MAXIMUM_WITHDRAWAL_BTC_AMOUNT < _amount) { - @($"Amount in Satoshis. Maximum {Constants.MAXIMUM_WITHDRAWAL_BTC_AMOUNT}.") + @($"Maximum amount {Constants.MAXIMUM_WITHDRAWAL_BTC_AMOUNT} BTC.") } else { - @($"Amount in Satoshis. Minimum {_minimumChannelCapacity:f8}. Current amount: {Math.Round(PriceConversionService.SatToUsdConversion(new Money(_amount, MoneyUnit.BTC).Satoshi, _btcPrice), 2)} USD") + @($"Amount in BTC. Minimum {_minimumChannelCapacity:f8}. Current amount: {Math.Round(PriceConversionService.SatToUsdConversion(new Money(_amount, MoneyUnit.BTC).Satoshi, _btcPrice), 2)} USD") } - } - else - { - - }
or use @@ -257,7 +247,7 @@

Withdrawal requests

+ IsWalletWithdrawalValidation="false"/> @inject IToastService ToastService @inject IWalletWithdrawalRequestRepository WalletWithdrawalRequestRepository @@ -438,7 +428,7 @@ private List _userPendingRequests = new(); private List _availableWallets = new(); private List? _allRequests; - private List _allWalletRequests = new(); + private List _withdrawalRequests = new(); private List? _channelRequests; private string? mempoolUrl = Constants.MEMPOOL_ENDPOINT; private bool _isFinanceManager; @@ -463,7 +453,6 @@ private CancelOrRejectPopup? _rejectCancelModalRef; private bool _isNodeManager = false; private WalletWithdrawalRequestStatus? _rejectCancelStatus = WalletWithdrawalRequestStatus.Rejected; - private bool _isAmountDisabled; private decimal? _selectedRequestWalletBalance; private List? _manageableNodes; private decimal _maxWithdrawal = Constants.MAXIMUM_WITHDRAWAL_BTC_AMOUNT; @@ -553,7 +542,7 @@ if (LoggedUser?.Id != null) _userPendingRequests = await WalletWithdrawalRequestRepository.GetUnsignedPendingRequestsByUser(LoggedUser.Id); - _allWalletRequests = (await WalletWithdrawalRequestRepository.GetAll()).Except(_userPendingRequests).ToList(); + _withdrawalRequests = (await WalletWithdrawalRequestRepository.GetAll()).Except(_userPendingRequests).ToList(); _availableWallets = await WalletRepository.GetAvailableWallets(false); //TODO Fix BIP39 withdrawals, until then, manual hack to filter them out @@ -698,7 +687,6 @@ if (LoggedUser != null) { obj.UserRequestorId = LoggedUser.Id; - _isAmountDisabled = false; _selectedRequestWalletBalance = null; } } diff --git a/src/Shared/UTXOSelectorModal.razor b/src/Shared/UTXOSelectorModal.razor index a4dcc5fb..e1a352ff 100644 --- a/src/Shared/UTXOSelectorModal.razor +++ b/src/Shared/UTXOSelectorModal.razor @@ -141,7 +141,7 @@ private Validation _validation { get; set; } = new(); [Parameter] - public bool isAmountValidatioEnabled { get; set; } = true; + public bool IsWalletWithdrawalValidation { get; set; } = true; public void ClearModal() { @@ -219,14 +219,22 @@ if (e.Value is not List) return; var selectedUTXOsValue = ((List)e.Value).Sum(x => ((Money)x.Value).ToUnit(MoneyUnit.BTC)); if (selectedUTXOsValue == 0) return; - var minimumChannelValue = new Money(Constants.MINIMUM_CHANNEL_CAPACITY_SATS).ToUnit(MoneyUnit.BTC); - var maxChannelRegtestValue = new Money(Constants.MAXIMUM_CHANNEL_CAPACITY_SATS_REGTEST).ToUnit(MoneyUnit.BTC); - if (selectedUTXOsValue < minimumChannelValue && isAmountValidatioEnabled) + decimal minimumValue; + if (IsWalletWithdrawalValidation) { - e.ErrorText = $"The combined amount of the UTXOs selected must be greater than {minimumChannelValue:f8} BTC"; + minimumValue = Constants.MINIMUM_WITHDRAWAL_BTC_AMOUNT; + } + else + { + minimumValue = new Money(Constants.MINIMUM_CHANNEL_CAPACITY_SATS).ToUnit(MoneyUnit.BTC); + } + var maxChannelRegtestValue = new Money(Constants.MAXIMUM_CHANNEL_CAPACITY_SATS_REGTEST).ToUnit(MoneyUnit.BTC); + if (selectedUTXOsValue < minimumValue) + { + e.ErrorText = $"The combined amount of the UTXOs selected must be greater than {minimumValue:f8} BTC"; e.Status = ValidationStatus.Error; } - else if (selectedUTXOsValue > maxChannelRegtestValue && network == Network.RegTest && isAmountValidatioEnabled) + else if (selectedUTXOsValue > maxChannelRegtestValue && network == Network.RegTest && IsWalletWithdrawalValidation) { e.ErrorText = $"The combined amount of the UTXOs selected must be lower than {maxChannelRegtestValue:f8} BTC"; e.Status = ValidationStatus.Error;