private async Task TryRewriteTableAsync() { try { var historyBuilder = new TransactionHistoryBuilder(Global.Wallet); var txRecordList = await Task.Run(historyBuilder.BuildHistorySummary); var tis = txRecordList.Select(txr => new TransactionInfo { DateTime = txr.DateTime.ToLocalTime(), Confirmed = txr.Height.Type == HeightType.Chain, Confirmations = txr.Height.Type == HeightType.Chain ? (int)Global.BitcoinStore.SmartHeaderChain.TipHeight - txr.Height.Value + 1 : 0, AmountBtc = $"{txr.Amount.ToString(fplus: true, trimExcessZero: true)}", Label = txr.Label, BlockHeight = txr.Height.Type == HeightType.Chain ? txr.Height.Value : 0, TransactionId = txr.TransactionId.ToString() }); Transactions?.Clear(); var trs = tis.Select(ti => new TransactionViewModel(ti)); Transactions = new ObservableCollection <TransactionViewModel>(trs.OrderByDescending(t => t.DateTime)); Global.UiConfig.Transactions = tis.ToArray(); Global.UiConfig.ToFile(); // write to file once height is the highest } catch (Exception ex) { Logger.LogError(ex); } }
private async Task UpdateCurrentTransactionAsync() { var historyBuilder = new TransactionHistoryBuilder(_wallet); var txRecordList = await Task.Run(historyBuilder.BuildHistorySummary); var currentTransaction = txRecordList.FirstOrDefault(x => x.TransactionId == TransactionId); if (currentTransaction is { })
public object[] GetHistory() { AssertWalletIsLoaded(); var txHistoryBuilder = new TransactionHistoryBuilder(Global.WalletService); var summary = txHistoryBuilder.BuildHistorySummary(); return(summary.Select(x => new { datetime = x.DateTime, height = x.Height.Value, amount = x.Amount.Satoshi, label = x.Label, tx = x.TransactionId, }).ToArray()); }
public async Task UpdateAsync() { try { var historyBuilder = new TransactionHistoryBuilder(_wallet); var txRecordList = await Task.Run(historyBuilder.BuildHistorySummary); _transactionSourceList.Clear(); var trs = txRecordList.Select(transactionSummary => new HistoryItemViewModel(transactionSummary, _bitcoinStore)); _transactionSourceList.AddRange(trs.Reverse()); } catch (Exception ex) { Logger.LogError(ex); } }
public async Task UpdateAsync() { try { var historyBuilder = new TransactionHistoryBuilder(_wallet); var txRecordList = await Task.Run(historyBuilder.BuildHistorySummary); _transactionSourceList.Clear(); Money balance = Money.Zero; for (var i = 0; i < txRecordList.Count; i++) { var transactionSummary = txRecordList[i]; balance += transactionSummary.Amount; _transactionSourceList.Add(new HistoryItemViewModel(i, transactionSummary, _bitcoinStore, balance)); } } catch (Exception ex) { Logger.LogError(ex); } }
private async Task TryRewriteTableAsync() { try { var historyBuilder = new TransactionHistoryBuilder(WalletService); var txRecordList = await Task.Run(historyBuilder.BuildHistorySummary); var rememberSelectedTransactionId = SelectedTransaction?.TransactionId; Transactions?.Clear(); var trs = txRecordList.Select(txr => new TransactionInfo { DateTime = txr.DateTime.ToLocalTime(), Confirmed = txr.Height.Type == HeightType.Chain, Confirmations = txr.Height.Type == HeightType.Chain ? (int)Global.BitcoinStore.SmartHeaderChain.TipHeight - txr.Height.Value + 1 : 0, AmountBtc = $"{txr.Amount.ToString(fplus: true, trimExcessZero: true)}", Label = txr.Label, BlockHeight = txr.Height.Type == HeightType.Chain ? txr.Height.Value : 0, TransactionId = txr.TransactionId.ToString() }).Select(ti => new TransactionViewModel(ti)); Transactions = new ObservableCollection <TransactionViewModel>(trs); if (Transactions.Count > 0 && !(rememberSelectedTransactionId is null)) { var txToSelect = Transactions.FirstOrDefault(x => x.TransactionId == rememberSelectedTransactionId); if (txToSelect != null) { SelectedTransaction = txToSelect; } } RefreshOrdering(); } catch (Exception ex) { Logger.LogError(ex); } }