mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 06:24:24 +01:00
Show total balances for each currency on List Wallets Page
This commit is contained in:
committed by
Andrew Camilleri
parent
88c925017d
commit
b7a081b9a4
@@ -259,10 +259,20 @@ namespace BTCPayServer.Controllers
|
||||
{
|
||||
walletVm.Balance = "";
|
||||
}
|
||||
walletVm.Network = wallet.Network;
|
||||
walletVm.CryptoCode = wallet.Network.CryptoCode;
|
||||
walletVm.StoreId = wallet.Store.Id;
|
||||
walletVm.Id = new WalletId(wallet.Store.Id, wallet.Network.CryptoCode);
|
||||
walletVm.StoreName = wallet.Store.StoreName;
|
||||
|
||||
if (wallets.BalanceForCryptoCode.ContainsKey(wallet.Network))
|
||||
{
|
||||
wallets.BalanceForCryptoCode[wallet.Network] = wallets.BalanceForCryptoCode[wallet.Network].Add(await GetBalanceAsMoney(wallet.Wallet, wallet.DerivationStrategy));
|
||||
}
|
||||
else
|
||||
{
|
||||
wallets.BalanceForCryptoCode[wallet.Network] = await GetBalanceAsMoney(wallet.Wallet, wallet.DerivationStrategy);
|
||||
}
|
||||
}
|
||||
|
||||
return View(wallets);
|
||||
@@ -1061,13 +1071,25 @@ namespace BTCPayServer.Controllers
|
||||
return CurrentStore.GetDerivationSchemeSettings(NetworkProvider, walletId.CryptoCode);
|
||||
}
|
||||
|
||||
private static async Task<string> GetBalanceString(BTCPayWallet wallet, DerivationStrategyBase derivationStrategy)
|
||||
private static async Task<IMoney> GetBalanceAsMoney(BTCPayWallet wallet, DerivationStrategyBase derivationStrategy)
|
||||
{
|
||||
using CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));
|
||||
try
|
||||
{
|
||||
var b = await wallet.GetBalance(derivationStrategy, cts.Token);
|
||||
return (b.Available ?? b.Total).ShowMoney(wallet.Network);
|
||||
return (b.Available ?? b.Total);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return NBitcoin.Money.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task<string> GetBalanceString(BTCPayWallet wallet, DerivationStrategyBase derivationStrategy)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (await GetBalanceAsMoney(wallet, derivationStrategy)).ShowMoney(wallet.Network);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user