From da2f1886ee44d27bb9e7ba43dde63748fb4bbb29 Mon Sep 17 00:00:00 2001 From: dangershony Date: Thu, 5 Dec 2024 23:10:16 +0000 Subject: [PATCH 1/3] dont try to decrypt a failed trx the second time --- src/Angor/Client/Pages/Signatures.razor | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Angor/Client/Pages/Signatures.razor b/src/Angor/Client/Pages/Signatures.razor index dcf9b0bc..665bc048 100644 --- a/src/Angor/Client/Pages/Signatures.razor +++ b/src/Angor/Client/Pages/Signatures.razor @@ -286,6 +286,16 @@ foreach (var pendingSignature in signaturesRequests.Where(_ => _.AmountToInvest == null)) { + if (string.IsNullOrEmpty(pendingSignature.TransactionHex)) + { + // the only way TransactionHex can be null is if it failed + // further down the code and this is the second time we try to + // read it in to a trx structure but still + // for some reason the trx is not valid. + Logger.LogDebug($"pendingSignature.TransactionHex is null"); + continue; + } + pendingSignature.TransactionHex = await encryption.DecryptNostrContentAsync( nostrPrivateKeyHex, pendingSignature.investorNostrPubKey, pendingSignature.TransactionHex); From 31341a4a00b94c8743f1872da911048e6a93d570 Mon Sep 17 00:00:00 2001 From: dangershony Date: Fri, 13 Dec 2024 15:13:28 +0000 Subject: [PATCH 2/3] Add an EncryptedMessage property to not use the TransactionHex for that --- src/Angor/Client/Pages/Signatures.razor | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/Angor/Client/Pages/Signatures.razor b/src/Angor/Client/Pages/Signatures.razor index 665bc048..30cb4402 100644 --- a/src/Angor/Client/Pages/Signatures.razor +++ b/src/Angor/Client/Pages/Signatures.razor @@ -284,20 +284,10 @@ var nostrPrivateKeyHex = Encoders.Hex.EncodeData(nostrPrivateKey.ToBytes()); - foreach (var pendingSignature in signaturesRequests.Where(_ => _.AmountToInvest == null)) + foreach (var pendingSignature in signaturesRequests.Where(_ => _.EncryptedMessage != null && _.AmountToInvest == null)) { - if (string.IsNullOrEmpty(pendingSignature.TransactionHex)) - { - // the only way TransactionHex can be null is if it failed - // further down the code and this is the second time we try to - // read it in to a trx structure but still - // for some reason the trx is not valid. - Logger.LogDebug($"pendingSignature.TransactionHex is null"); - continue; - } - pendingSignature.TransactionHex = await encryption.DecryptNostrContentAsync( - nostrPrivateKeyHex, pendingSignature.investorNostrPubKey, pendingSignature.TransactionHex); + nostrPrivateKeyHex, pendingSignature.investorNostrPubKey, pendingSignature.EncryptedMessage); try { @@ -308,7 +298,7 @@ } catch (Exception e) { - Logger.LogError(pendingSignature.TransactionHex, e); + Logger.LogError(pendingSignature?.TransactionHex ?? e.Message, e); pendingSignature.TransactionHex = null; } } @@ -351,7 +341,7 @@ { investorNostrPubKey = investorNostrPubKey, TimeArrived = timeArrived, - TransactionHex = encryptedMessage, //To be encrypted after js interop is loaded + EncryptedMessage = encryptedMessage, //To be encrypted after js interop is loaded EventId = eventId }; @@ -568,6 +558,7 @@ public DateTime? TimeApproved { get; set; } public string? TransactionHex { get; set; } + public string? EncryptedMessage { get; set; } public string EventId { get; set; } } From c27f7e1e361a4a109277844fb29a9034cf764129 Mon Sep 17 00:00:00 2001 From: dangershony Date: Fri, 13 Dec 2024 15:18:03 +0000 Subject: [PATCH 3/3] add the description to inside the try catch --- src/Angor/Client/Pages/Signatures.razor | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Angor/Client/Pages/Signatures.razor b/src/Angor/Client/Pages/Signatures.razor index 30cb4402..af0866f8 100644 --- a/src/Angor/Client/Pages/Signatures.razor +++ b/src/Angor/Client/Pages/Signatures.razor @@ -286,11 +286,11 @@ foreach (var pendingSignature in signaturesRequests.Where(_ => _.EncryptedMessage != null && _.AmountToInvest == null)) { - pendingSignature.TransactionHex = await encryption.DecryptNostrContentAsync( - nostrPrivateKeyHex, pendingSignature.investorNostrPubKey, pendingSignature.EncryptedMessage); - try { + pendingSignature.TransactionHex = await encryption.DecryptNostrContentAsync( + nostrPrivateKeyHex, pendingSignature.investorNostrPubKey, pendingSignature.EncryptedMessage); + var investorTrx = _networkConfiguration.GetNetwork().CreateTransaction(pendingSignature.TransactionHex); pendingSignature.AmountToInvest = investorTrx.Outputs.AsIndexedOutputs().Skip(2).Take(investorTrx.Outputs.Count - 3) //Todo get the actual outputs with taproot type