private void OnSyncedWallet(Wallet wallet)
{
var accountBalances = wallet.CalculateBalances(2); // TODO: configurable confirmations
var accountViewModels = wallet.EnumerateAccounts()
.Zip(accountBalances, (a, bals) => new AccountViewModel(a.Item1, a.Item2, bals))
.ToList();
var txSet = wallet.RecentTransactions;
var recentTx = txSet.UnminedTransactions
.Select(x => new TransactionViewModel(wallet, x.Value, BlockIdentity.Unmined))
.Concat(txSet.MinedTransactions.ReverseList().SelectMany(b => b.Transactions.Select(tx => new TransactionViewModel(wallet, tx, b.Identity))))
.Take(10);
var overviewViewModel = (OverviewViewModel)SingletonViewModelLocator.Resolve("Overview");
App.Current.Dispatcher.Invoke(() =>
{
foreach (var vm in accountViewModels)
Accounts.Add(vm);
foreach (var tx in recentTx)
overviewViewModel.RecentTransactions.Add(tx);
});
TotalBalance = wallet.TotalBalance;
TransactionCount = txSet.TransactionCount();
SyncedBlockHeight = wallet.ChainTip.Height;
SelectedAccount = accountViewModels[0];
RaisePropertyChanged(nameof(TotalBalance));
RaisePropertyChanged(nameof(AccountNames));
overviewViewModel.AccountsCount = accountViewModels.Count();
var shell = (ShellViewModel)ViewModelLocator.ShellViewModel;
shell.StartupWizardVisible = false;
}