From 6acd9884274a3886f772ff4aefa517570c47bb25 Mon Sep 17 00:00:00 2001 From: itailiors <78041027+itailiors@users.noreply.github.com> Date: Sat, 3 Aug 2024 21:54:06 +0300 Subject: [PATCH 1/8] Add button to display raw transaction JSON for addresses and amounts --- src/Angor/Client/Pages/Wallet.razor | 130 +++++++++++++++++++--------- 1 file changed, 90 insertions(+), 40 deletions(-) diff --git a/src/Angor/Client/Pages/Wallet.razor b/src/Angor/Client/Pages/Wallet.razor index 14cbad59..8331e6d2 100644 --- a/src/Angor/Client/Pages/Wallet.razor +++ b/src/Angor/Client/Pages/Wallet.razor @@ -621,52 +621,55 @@ else - @foreach (var addressInfo in accountBalanceInfo.AccountInfo.AllAddresses()) - { - var total = addressInfo.Balance; - var count = addressInfo.UtxoData.Count(); + @foreach (var addressInfo in accountBalanceInfo.AccountInfo.AllAddresses()) + { + var total = addressInfo.Balance; + var count = addressInfo.UtxoData.Count(); - if (total > 0) + if (total > 0) + { + + @addressInfo.Address + @Money.Satoshis(total).ToUnit(MoneyUnit.BTC) @network.CoinTicker + @addressInfo.HdPath + @count + + + + + @if (IsExpanded(addressInfo.Address)) { - - @addressInfo.Address - @Money.Satoshis(total).ToUnit(MoneyUnit.BTC) @network.CoinTicker - @addressInfo.HdPath - @count - - @if (IsExpanded(addressInfo.Address)) - { - - -
-
- -
- - - - - - - - - @foreach (var addressUtxoItem in addressInfo.UtxoData) - { - - - - - } - -
CoinAmount
@($"{addressUtxoItem.outpoint}")@Money.Satoshis(addressUtxoItem.value).ToUnit(MoneyUnit.BTC) @network.CoinTicker
-
+ + +
+
+ +
+ + + + + + + + + @foreach (var addressUtxoItem in addressInfo.UtxoData) + { + + + + + } + +
CoinAmount
@($"{addressUtxoItem.outpoint}")@Money.Satoshis(addressUtxoItem.value).ToUnit(MoneyUnit.BTC) @network.CoinTicker
- - - } +
+ + } } + }
@@ -713,6 +716,9 @@ else private bool showBackupConfirmationError = false; private int activeTab = 1; + + private bool showRawTransactionModal = false; + private string rawTransactionJson = string.Empty; private int feeRange = 0; @@ -1255,4 +1261,48 @@ else { isShowExtraWord = !isShowExtraWord; } + + + + private void ShowRawTransactionJson(AddressInfo addressInfo) + { + rawTransactionJson = GetRawTransactionJson(addressInfo); + showRawTransactionModal = true; + } + + + private string GetRawTransactionJson(AddressInfo addressInfo) + { + var options = new JsonSerializerOptions + { + WriteIndented = true + }; + return JsonSerializer.Serialize(addressInfo, options); + } + } + +@if (showRawTransactionModal) +{ + +} + From 92521f9f16cd2d8b714811d59b75c11c4ba8a8f3 Mon Sep 17 00:00:00 2001 From: itailiors <78041027+itailiors@users.noreply.github.com> Date: Sat, 3 Aug 2024 21:57:04 +0300 Subject: [PATCH 2/8] fix spaces --- src/Angor/Client/Pages/Wallet.razor | 82 ++++++++++++++--------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/src/Angor/Client/Pages/Wallet.razor b/src/Angor/Client/Pages/Wallet.razor index 8331e6d2..454978d1 100644 --- a/src/Angor/Client/Pages/Wallet.razor +++ b/src/Angor/Client/Pages/Wallet.razor @@ -621,55 +621,55 @@ else - @foreach (var addressInfo in accountBalanceInfo.AccountInfo.AllAddresses()) - { - var total = addressInfo.Balance; - var count = addressInfo.UtxoData.Count(); - - if (total > 0) + @foreach (var addressInfo in accountBalanceInfo.AccountInfo.AllAddresses()) { - - @addressInfo.Address - @Money.Satoshis(total).ToUnit(MoneyUnit.BTC) @network.CoinTicker - @addressInfo.HdPath - @count - - - - - @if (IsExpanded(addressInfo.Address)) + var total = addressInfo.Balance; + var count = addressInfo.UtxoData.Count(); + + if (total > 0) { - - -
-
- -
- - - - - - - - - @foreach (var addressUtxoItem in addressInfo.UtxoData) - { + + + + + + + + @if (IsExpanded(addressInfo.Address)) + { + + + @foreach (var addressUtxoItem in addressInfo.UtxoData) + { + + + + + } + +
CoinAmount
@addressInfo.Address@Money.Satoshis(total).ToUnit(MoneyUnit.BTC) @network.CoinTicker@addressInfo.HdPath@count + +
+
+
+ +
+ + - - + + - } - -
@($"{addressUtxoItem.outpoint}")@Money.Satoshis(addressUtxoItem.value).ToUnit(MoneyUnit.BTC) @network.CoinTickerCoinAmount
+ +
@($"{addressUtxoItem.outpoint}")@Money.Satoshis(addressUtxoItem.value).ToUnit(MoneyUnit.BTC) @network.CoinTicker
+
-
- - + + + } } } - } From 16e2c8f1dabbdf3e2e1cf5566277bfd111110198 Mon Sep 17 00:00:00 2001 From: itailiors <78041027+itailiors@users.noreply.github.com> Date: Sat, 3 Aug 2024 21:58:14 +0300 Subject: [PATCH 3/8] Update Wallet.razor --- src/Angor/Client/Pages/Wallet.razor | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Angor/Client/Pages/Wallet.razor b/src/Angor/Client/Pages/Wallet.razor index 454978d1..dfd5c95f 100644 --- a/src/Angor/Client/Pages/Wallet.razor +++ b/src/Angor/Client/Pages/Wallet.razor @@ -647,19 +647,19 @@ else
- - - - - - - @foreach (var addressUtxoItem in addressInfo.UtxoData) - { - - + + - } + + + @foreach (var addressUtxoItem in addressInfo.UtxoData) + { + + + + + }
CoinAmount
@($"{addressUtxoItem.outpoint}")@Money.Satoshis(addressUtxoItem.value).ToUnit(MoneyUnit.BTC) @network.CoinTickerCoinAmount
@($"{addressUtxoItem.outpoint}")@Money.Satoshis(addressUtxoItem.value).ToUnit(MoneyUnit.BTC) @network.CoinTicker
From b71fa71c6b20b43d133d969484f6764c4a18b768 Mon Sep 17 00:00:00 2001 From: itailiors <78041027+itailiors@users.noreply.github.com> Date: Wed, 7 Aug 2024 12:41:27 +0300 Subject: [PATCH 4/8] milad comment + option to copy --- src/Angor/Client/Pages/Wallet.razor | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Angor/Client/Pages/Wallet.razor b/src/Angor/Client/Pages/Wallet.razor index dfd5c95f..81dafa1c 100644 --- a/src/Angor/Client/Pages/Wallet.razor +++ b/src/Angor/Client/Pages/Wallet.razor @@ -618,6 +618,7 @@ else Amount Path UTXO count + View Raw Json @@ -634,7 +635,7 @@ else @addressInfo.HdPath @count - + @if (IsExpanded(addressInfo.Address)) @@ -925,6 +926,13 @@ else ClearWalletWords(); StateHasChanged(); } + + private async Task CopyStringToClipboard(string msg) + { + await _clipboardService.WriteTextAsync(msg); + notificationComponent.ShowNotificationMessage("Copied to clipboard!", 3); + StateHasChanged(); + } private void ClearWalletWords() { @@ -1291,15 +1299,15 @@ else - From 25cdb6067069ef4faf50a4fe6e996eba6b9aea5b Mon Sep 17 00:00:00 2001 From: itailiors <78041027+itailiors@users.noreply.github.com> Date: Thu, 8 Aug 2024 19:08:50 +0300 Subject: [PATCH 5/8] remove duplicate --- src/Angor/Client/Pages/Investor.razor | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Angor/Client/Pages/Investor.razor b/src/Angor/Client/Pages/Investor.razor index a417ff2d..1bb31631 100644 --- a/src/Angor/Client/Pages/Investor.razor +++ b/src/Angor/Client/Pages/Investor.razor @@ -18,7 +18,6 @@ @inject IRelayService _RelayService @inject ISignService _SignService @inject ISerializer serializer -@inject ISignService _SignService @inject IEncryptionService _encryptionService @inject IJSRuntime JS From aed8e08413137409f089685749987bd22a8be2af Mon Sep 17 00:00:00 2001 From: itailiors <78041027+itailiors@users.noreply.github.com> Date: Thu, 29 Aug 2024 19:11:13 +0300 Subject: [PATCH 6/8] reformat --- src/Angor/Client/Pages/Investor.razor | 72 +++++++++++++-------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/src/Angor/Client/Pages/Investor.razor b/src/Angor/Client/Pages/Investor.razor index d020d52d..7dde825d 100644 --- a/src/Angor/Client/Pages/Investor.razor +++ b/src/Angor/Client/Pages/Investor.razor @@ -1,12 +1,4 @@ @page "/investor" -@using Angor.Client.Storage -@using Angor.Shared.Models -@using Blockcore.NBitcoin -@using Angor.Client.Models -@using Angor.Shared -@using Angor.Shared.Services -@using Blockcore.NBitcoin.DataEncoders -@using Nostr.Client.Messages @inject ILogger _Logger @inject IClientStorage storage; @@ -22,11 +14,19 @@ @inject IJSRuntime JS +@using Angor.Client.Models +@using Angor.Client.Storage +@using Angor.Shared +@using Angor.Shared.Models +@using Angor.Shared.Services +@using Blockcore.NBitcoin +@using Blockcore.NBitcoin.DataEncoders +@using Nostr.Client.Messages @inherits BaseComponent @if (!hasWallet) { - NavigationManager.NavigateTo($"/wallet"); + NavigationManager.NavigateTo("/wallet"); return; } @@ -36,7 +36,7 @@
- +
@@ -63,11 +63,10 @@
-
- - + +
@@ -75,7 +74,7 @@
- +
Funded Projects

@TotalFundedProjects

@@ -86,7 +85,7 @@
- +
Total invested

@Money.Satoshis(TotalInvested).ToUnit(MoneyUnit.BTC) @network.CoinTicker

@@ -97,7 +96,7 @@
- +
Wallet

@Money.Satoshis(TotalWallet).ToUnit(MoneyUnit.BTC) @network.CoinTicker

@@ -108,7 +107,7 @@
- +
In Recovery

@Money.Satoshis(TotalInRecovery).ToUnit(MoneyUnit.BTC) @network.CoinTicker

@@ -137,7 +136,6 @@
-
@@ -161,7 +159,7 @@ { Stats.TryGetValue(project.ProjectInfo.ProjectIdentifier, out var stats); var nostrPubKey = project.ProjectInfo.NostrPubKey; - investmentRequestsMap.TryGetValue(nostrPubKey, out bool hasInvestmentRequests); + investmentRequestsMap.TryGetValue(nostrPubKey, out var hasInvestmentRequests); @@ -216,6 +216,7 @@ + @code { bool RefreshBalanceTriggered; @@ -223,16 +224,16 @@ private List projects = new(); - long TotalInvested = 0; - long TotalWallet = 0; - int TotalFundedProjects = 0; - long TotalInRecovery = 0; + long TotalInvested; + long TotalWallet; + int TotalFundedProjects; + long TotalInRecovery; - private Dictionary investmentRequestsMap = new Dictionary(); + private readonly Dictionary investmentRequestsMap = new(); public Dictionary Stats = new(); - private Investments scannedInvestments = new(); + private readonly Investments scannedInvestments = new(); protected override async Task OnInitializedAsync() { @@ -270,7 +271,7 @@ await Task.WhenAll(tasks); - scannedInvestments.ProjectIdentifiers = new(); + scannedInvestments.ProjectIdentifiers = new List(); RefreshBalanceTriggered = false; StateHasChanged(); @@ -296,7 +297,6 @@ await RefreshBalance(); } - } private async Task HandleSignatureReceivedAsync(string nostrPubKey, string signatureContent) @@ -324,7 +324,7 @@ project.SignaturesInfo.TimeOfSignatureRequest.Value, project.SignaturesInfo.SignatureRequestEventId, async signatureContent => await HandleSignatureReceivedAsync(project.ProjectInfo.NostrPubKey, signatureContent) - ); + ); } } } @@ -383,7 +383,7 @@ var projectIdList = serializer.Deserialize(decryptedString); - bool foundNewProjects = false; + var foundNewProjects = false; foreach (var investment in projectIdList.ProjectIdentifiers) { if (projects.Any(x => x.ProjectInfo.ProjectIdentifier == investment.ProjectIdentifier) || @@ -428,10 +428,10 @@ var investorNostrPubKey = investorNostrPrivateKey.PubKey.ToHex()[2..]; var investorProject = new InvestorProject - { - TransactionId = investment.TransactionId, - AmountInvested = investment.TotalAmount, - }; + { + TransactionId = investment.TransactionId, + AmountInvested = investment.TotalAmount + }; DateTime? createdAt = null; string? eventId = null; @@ -496,11 +496,11 @@ }, project.NostrPubKey); }); - } private void NavigateToPenalties() { NavigationManager.NavigateTo("/penalties"); } -} + +} \ No newline at end of file From b2b7855fe88cea41445915f55f7fc76884fde7c2 Mon Sep 17 00:00:00 2001 From: itailiors <78041027+itailiors@users.noreply.github.com> Date: Wed, 30 Oct 2024 22:41:22 +0200 Subject: [PATCH 7/8] merge and fixup for comments --- src/Angor/Client/Pages/Wallet.razor | 173 ++++++++++++++-------------- 1 file changed, 89 insertions(+), 84 deletions(-) diff --git a/src/Angor/Client/Pages/Wallet.razor b/src/Angor/Client/Pages/Wallet.razor index 1b196c6b..c0495def 100644 --- a/src/Angor/Client/Pages/Wallet.razor +++ b/src/Angor/Client/Pages/Wallet.razor @@ -1,12 +1,5 @@ @page "/wallet" -@using System.Text.Json -@using Angor.Client.Storage -@using Angor.Shared -@using Angor.Shared.Models -@using Blockcore.NBitcoin -@using Blockcore.Networks - @inject HttpClient _httpClient; @inject IClientStorage storage; @inject ICacheStorage _cacheStorage; @@ -19,6 +12,12 @@ @inject NavMenuState NavMenuState @inject IEncryptionService _encryptionService @inject IClipboardService ClipboardService +@using System.Text.Json +@using Angor.Client.Storage +@using Angor.Shared +@using Angor.Shared.Models +@using Blockcore.NBitcoin +@using Blockcore.Networks @inherits BaseComponent Wallet and balances @@ -471,8 +470,8 @@ else var outpointStr = addressUtxoItem.outpoint.ToString(); var outpointLength = outpointStr.Length; var shortenedOutpoint = outpointLength > 20 - ? $"{outpointStr.Substring(0, 10)} ... {outpointStr.Substring(outpointLength - 10)}" - : outpointStr; + ? $"{outpointStr.Substring(0, 10)} ... {outpointStr.Substring(outpointLength - 10)}" + : outpointStr; var valueInBTC = Money.Satoshis(addressUtxoItem.value).ToUnit(MoneyUnit.BTC); var coinTicker = network.CoinTicker; @@ -487,7 +486,7 @@ else @@ -614,13 +613,13 @@ else
@@ -184,7 +182,9 @@ @Money.Satoshis(project.AmountInvested ?? 0).ToUnit(MoneyUnit.BTC) @network.CoinTicker @if (!project.SignaturesInfo?.Signatures.Any() ?? false) { - + + + } -
- - - - - - - + + + + + + + @foreach (var addressInfo in accountBalanceInfo.AccountInfo.AllAddresses()) @@ -628,50 +627,50 @@ else var total = addressInfo.Balance; var count = addressInfo.UtxoData.Count(); - if (total > 0) + if (total > 0) + { + + + + + + + + @if (IsExpanded(addressInfo.Address)) { - - - - - - - - @if (IsExpanded(addressInfo.Address)) - { - - + - - } + + + } } + }
AddressAmountPathUTXO countView Raw Json
AddressAmountPathUTXO countView Raw Json
@addressInfo.Address@Money.Satoshis(total).ToUnit(MoneyUnit.BTC) @network.CoinTicker@addressInfo.HdPath@count + +
@addressInfo.Address@Money.Satoshis(total).ToUnit(MoneyUnit.BTC) @network.CoinTicker@addressInfo.HdPath@count - -
-
-
- -
- - - - - - - - - @foreach (var addressUtxoItem in addressInfo.UtxoData) - { - - - - - } - -
CoinAmount
@($"{addressUtxoItem.outpoint}")@Money.Satoshis(addressUtxoItem.value).ToUnit(MoneyUnit.BTC) @network.CoinTicker
-
+
+
+
+ +
+ + + + + + + + + @foreach (var addressUtxoItem in addressInfo.UtxoData) + { + + + + + } + +
CoinAmount
@($"{addressUtxoItem.outpoint}")@Money.Satoshis(addressUtxoItem.value).ToUnit(MoneyUnit.BTC) @network.CoinTicker
-
@@ -722,6 +721,9 @@ else private int FeePosition = 1; private SendInfo _sendInfo = new(); + private bool showRawTransactionModal; + private string rawTransactionJson = string.Empty; + private readonly AccountBalanceInfo accountBalanceInfo = new(); private readonly FeeEstimations FeeEstimations = new(); @@ -1244,7 +1246,7 @@ else } catch (Exception ex) { - Logger.LogError(ex, $"Failed to read clipboard contents"); + Logger.LogError(ex, "Failed to read clipboard contents"); } } @@ -1283,8 +1285,12 @@ else Logger.LogError("Failed to fetch the fiat value for the total balance."); return; } - - + + fiatValues["TotalBalance"] = fiatValuesList.First(); + + Logger.LogInformation($"Fiat value for total balance: {fiatValuesList.First()}"); + } + private void ShowRawTransactionJson(AddressInfo addressInfo) { @@ -1292,7 +1298,6 @@ else showRawTransactionModal = true; } - private string GetRawTransactionJson(AddressInfo addressInfo) { var options = new JsonSerializerOptions @@ -1302,37 +1307,37 @@ else return JsonSerializer.Serialize(addressInfo, options); } + private async Task CopyStringToClipboard(string msg) + { + await _clipboardService.WriteTextAsync(msg); + notificationComponent.ShowNotificationMessage("Copied to clipboard!", 3); + StateHasChanged(); + } + + } + @if (showRawTransactionModal) { -