public TransactionViewModel(TransactionInfo model) { Model = model; ClipboardNotificationVisible = false; ClipboardNotificationOpacity = 0; }
private void RewriteTable() { var txRecordList = new List <(Height height, Money amount, string label, uint256 transactionId)>(); foreach (SmartCoin coin in Global.WalletService.Coins) { var found = txRecordList.FirstOrDefault(x => x.transactionId == coin.TransactionId); if (found != default) // if found { txRecordList.Remove(found); var foundLabel = found.label != string.Empty ? found.label + ", " : ""; var newRecord = (found.height, found.amount + coin.Amount, $"{foundLabel}{coin.Label}", coin.TransactionId); txRecordList.Add(newRecord); } else { txRecordList.Add((coin.Height, coin.Amount, coin.Label, coin.TransactionId)); } if (coin.SpenderTransactionId != null) { bool guessConfirmed = !Global.MemPoolService.TransactionHashes.Contains(coin.SpenderTransactionId) && coin.Confirmed; // If it's not in the mempool it's likely confirmed && coin is confirmed. var guessHeight = guessConfirmed ? coin.Height : Models.Height.MemPool; var foundSpender = txRecordList.FirstOrDefault(x => x.transactionId == coin.SpenderTransactionId); if (foundSpender != default) // if found { txRecordList.Remove(foundSpender); guessHeight = Math.Max(guessHeight, foundSpender.height); var newRecord = (guessHeight, foundSpender.amount - coin.Amount, foundSpender.label, coin.SpenderTransactionId); txRecordList.Add(newRecord); } else { txRecordList.Add((guessHeight, (Money.Zero - coin.Amount), "", coin.SpenderTransactionId)); } } } txRecordList = txRecordList.OrderByDescending(x => x.height).ToList(); var rememberSelectedTransactionId = SelectedTransaction?.TransactionId; Transactions?.Clear(); foreach (var txr in txRecordList) { var txinfo = new TransactionInfo { Confirmed = txr.height != Models.Height.MemPool && txr.height != Models.Height.Unknown, AmountBtc = $"{txr.amount.ToString(fplus: true, trimExcessZero: true)}", Label = txr.label, TransactionId = txr.transactionId.ToString() }; Transactions.Add(new TransactionViewModel(txinfo)); } if (Transactions.Count > 0 && rememberSelectedTransactionId != null) { var txToSelect = Transactions.FirstOrDefault(x => x.TransactionId == rememberSelectedTransactionId); if (txToSelect != default) { Interlocked.Exchange(ref _disableClipboard, 1); SelectedTransaction = txToSelect; } } }
public TransactionViewModel(TransactionInfo model) { _model = model; _confirmed = model.WhenAnyValue(x => x.Confirmed).ToProperty(this, x => x.Confirmed, model.Confirmed); }
private void RewriteTable() { var txRecordList = new List <(DateTimeOffset dateTime, Height height, Money amount, string label, uint256 transactionId)>(); foreach (SmartCoin coin in Global.WalletService.Coins) { var found = txRecordList.FirstOrDefault(x => x.transactionId == coin.TransactionId); SmartTransaction foundTransaction = Global.WalletService.TransactionCache.First(x => x.GetHash() == coin.TransactionId); DateTimeOffset dateTime; if (foundTransaction.Height.Type == HeightType.Chain) { if (Global.WalletService.ProcessedBlocks.Any(x => x.Value.height == foundTransaction.Height)) { dateTime = Global.WalletService.ProcessedBlocks.First(x => x.Value.height == foundTransaction.Height).Value.dateTime; } else { dateTime = DateTimeOffset.UtcNow; } } else { dateTime = foundTransaction.FirstSeenIfMemPoolTime ?? DateTimeOffset.UtcNow; } if (found != default) // if found { txRecordList.Remove(found); var foundLabel = found.label != string.Empty ? found.label + ", " : ""; var newRecord = (dateTime, found.height, found.amount + coin.Amount, $"{foundLabel}{coin.Label}", coin.TransactionId); txRecordList.Add(newRecord); } else { txRecordList.Add((dateTime, coin.Height, coin.Amount, coin.Label, coin.TransactionId)); } if (coin.SpenderTransactionId != null) { SmartTransaction foundSpenderTransaction = Global.WalletService.TransactionCache.First(x => x.GetHash() == coin.SpenderTransactionId); if (foundSpenderTransaction.Height.Type == HeightType.Chain) { if (Global.WalletService.ProcessedBlocks.Any(x => x.Value.height == foundSpenderTransaction.Height)) { dateTime = Global.WalletService.ProcessedBlocks.First(x => x.Value.height == foundSpenderTransaction.Height).Value.dateTime; } else { dateTime = DateTimeOffset.UtcNow; } } else { dateTime = foundSpenderTransaction.FirstSeenIfMemPoolTime ?? DateTimeOffset.UtcNow; } var foundSpenderCoin = txRecordList.FirstOrDefault(x => x.transactionId == coin.SpenderTransactionId); if (foundSpenderCoin != default) // if found { txRecordList.Remove(foundSpenderCoin); var newRecord = (dateTime, foundSpenderTransaction.Height, foundSpenderCoin.amount - coin.Amount, foundSpenderCoin.label, coin.SpenderTransactionId); txRecordList.Add(newRecord); } else { txRecordList.Add((dateTime, foundSpenderTransaction.Height, (Money.Zero - coin.Amount), "", coin.SpenderTransactionId)); } } } txRecordList = txRecordList.OrderByDescending(x => x.dateTime).ThenBy(x => x.amount).ToList(); var rememberSelectedTransactionId = SelectedTransaction?.TransactionId; Transactions?.Clear(); foreach (var txr in txRecordList) { var txinfo = new TransactionInfo { DateTime = txr.dateTime.ToLocalTime(), Confirmed = txr.height != Models.Height.MemPool && txr.height != Models.Height.Unknown, AmountBtc = $"{txr.amount.ToString(fplus: true, trimExcessZero: true)}", Label = txr.label, TransactionId = txr.transactionId.ToString() }; Transactions.Add(new TransactionViewModel(txinfo)); } if (Transactions.Count > 0 && rememberSelectedTransactionId != null) { var txToSelect = Transactions.FirstOrDefault(x => x.TransactionId == rememberSelectedTransactionId); if (txToSelect != default) { Interlocked.Exchange(ref _disableClipboard, 1); SelectedTransaction = txToSelect; } } }
public TransactionInfoTabViewModel(TransactionInfo transaction) : base(string.Empty) { Transaction = transaction; Title = $"Transaction ({transaction.TransactionId[0..10]}) Details";