Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix numeric field in the channel request and withdrawal pages. #306

Merged
merged 10 commits into from
Oct 16, 2023
6 changes: 3 additions & 3 deletions src/Helpers/ValidationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static void ValidateChannelCapacity(ValidatorEventArgs obj)
}
}

public static void ValidateWithdrawalAmount(ValidatorEventArgs obj, Boolean isAmountDisabled)
public static void ValidateWithdrawalAmount(ValidatorEventArgs obj)
{
var amount = (decimal)obj.Value;

Expand All @@ -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)
{
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)
{
obj.Status = ValidationStatus.Error;
obj.ErrorText = $"Error, the maximum amount to withdraw is {maximum:f8} BTC";
Expand Down
11 changes: 8 additions & 3 deletions src/Pages/ChannelRequests.razor
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,14 @@
</Feedback>
</NumericPicker>
<FieldHelp>

@($"Amount in Satoshis. Minimum {_minimumChannelCapacity:f8}. Current amount: {Math.Round(PriceConversionService.SatToUsdConversion(new Money(_amount, MoneyUnit.BTC).Satoshi, _btcPrice), 2)} USD")

@if (Constants.MAXIMUM_WITHDRAWAL_BTC_AMOUNT < _amount)
AleksKSoftware marked this conversation as resolved.
Show resolved Hide resolved
{
<span class="text-danger">@($"Amount in BTC. Maximum {Constants.MAXIMUM_WITHDRAWAL_BTC_AMOUNT}.")</span>
AleksKSoftware marked this conversation as resolved.
Show resolved Hide resolved
}
else
{
@($"Amount in Satoshis. Minimum {_minimumChannelCapacity:f8}. Current amount: {Math.Round(PriceConversionService.SatToUsdConversion(new Money(_amount, MoneyUnit.BTC).Satoshi, _btcPrice), 2)} USD")
AleksKSoftware marked this conversation as resolved.
Show resolved Hide resolved
}
</FieldHelp>
</Validation>
<div class="mb-3">
Expand Down
4 changes: 2 additions & 2 deletions src/Pages/Wallets.razor
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,9 @@
</Field>
</Column>
<Column ColumnSize="ColumnSize.Is6">
<Validation Validator="args => ValidationHelper.ValidateWithdrawalAmount(args, _transferAllFunds)">
<Validation Validator="args => ValidationHelper.ValidateWithdrawalAmount(args)">
<Field>
<FieldLabel>Amount</FieldLabel>
<FieldLabel>Amount</FieldLabel>
<FieldBody>
<NumericPicker TValue="decimal" Disabled="_transferAllFunds" @bind-Value="@_amountToTransfer" CurrencySymbol="₿ " Max="@_maxWithdrawal" Min="@_minWithdrawal" Decimals="8">
<Feedback>
Expand Down
Loading