Skip to content

Commit

Permalink
Merge pull request #206 from Elenpay/fee-above-one
Browse files Browse the repository at this point in the history
Fee > 0, show not finalized wallets, try catch utxo list
  • Loading branch information
RodriFS authored Jun 22, 2023
2 parents b1e6323 + 6de48f1 commit 25c11c5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/Pages/ChannelRequests.razor
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
</SelectGroup>
<SelectItem Value="MempoolRecommendedFeesTypes.CustomFee">Custom</SelectItem>
</Select>
<NumericPicker TValue="long" @bind-Value="@FeeAmount" CurrencySymbolPlacement="CurrencySymbolPlacement.Suffix" CurrencySymbol=" sats/vbyte" Min="0" Disabled="@(FeesSelection != MempoolRecommendedFeesTypes.CustomFee)">
<NumericPicker TValue="long" @bind-Value="@FeeAmount" CurrencySymbolPlacement="CurrencySymbolPlacement.Suffix" CurrencySymbol=" sats/vbyte" Min="1" Disabled="@(FeesSelection != MempoolRecommendedFeesTypes.CustomFee)">
<Feedback>
<ValidationError/>
</Feedback>
Expand Down Expand Up @@ -411,7 +411,7 @@
private UTXOSelectorModal _utxoSelectorModalRef;
private List<UTXO> SelectedUTXOs = new();
private MempoolRecommendedFeesTypes FeesSelection;
private long FeeAmount;
private long FeeAmount = 1;
private MempoolRecommendedFees? _recommendedFees;

// New Request integration
Expand Down Expand Up @@ -947,7 +947,7 @@
FeeAmount = _recommendedFees.HalfHourFee;
break;
case MempoolRecommendedFeesTypes.CustomFee:
FeeAmount = 0;
FeeAmount = 1;
break;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Pages/Wallets.razor
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,8 @@

private async Task GetData()
{
_wallets = _showNotAvailableWallets ? (await WalletRepository.GetAll()).Where(x => x.IsArchived || x.IsCompromised).ToList() : await WalletRepository.GetAvailableWallets();
var allWallets = await WalletRepository.GetAll();
_wallets = _showNotAvailableWallets ? allWallets.Where(x => x.IsArchived || x.IsCompromised).ToList() : allWallets.Where(x => !x.IsArchived && !x.IsCompromised).ToList();
var financeManagers = (await ApplicationUserRepository.GetUsersInRole(ApplicationUserRole.FinanceManager));
_financeManagers = financeManagers.Where(x => x.Keys.Any()).ToList();

Expand Down
20 changes: 15 additions & 5 deletions src/Shared/UTXOSelectorModal.razor
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,22 @@
{
limit = 0;
}
var utxosList = await CoinSelectionService.GetAvailableUTXOsAsync(SelectedWallet.GetDerivationStrategy(), _selectedStrategy, limit, new Money(_amount, MoneyUnit.BTC).Satoshi, new Money(_closestTo, MoneyUnit.BTC).Satoshi);
UTXOList = utxosList;
try
{
var utxosList = await CoinSelectionService.GetAvailableUTXOsAsync(SelectedWallet.GetDerivationStrategy(), _selectedStrategy, limit, new Money(_amount, MoneyUnit.BTC).Satoshi, new Money(_closestTo, MoneyUnit.BTC).Satoshi);
UTXOList = utxosList;

// Refresh the list with the new objects, or selection wont be preserved
var hashes = SelectedUTXOs.Select(utxos => utxos.Outpoint.Hash);
SelectedUTXOs = utxosList.Where(utxo => hashes.Contains(utxo.Outpoint.Hash)).ToList();
}
catch
{
UTXOList = new();
SelectedUTXOs = new();
ToastService.ShowError("There was an unexpected error trying to get the UTXOs, please try again later.");
}

// Refresh the list with the new objects, or selection wont be preserved
var hashes = SelectedUTXOs.Select(utxos => utxos.Outpoint.Hash);
SelectedUTXOs = utxosList.Where(utxo => hashes.Contains(utxo.Outpoint.Hash)).ToList();

_btcPrice = PriceConversionHelper.GetBtcToUsdPrice();
await _modalRef.Show();
Expand Down

0 comments on commit 25c11c5

Please sign in to comment.