Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont try to decrypt a failed trx sig request the second time #196

Merged
merged 3 commits into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/Angor/Client/Pages/Signatures.razor
Original file line number Diff line number Diff line change
Expand Up @@ -284,21 +284,21 @@

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))
{
pendingSignature.TransactionHex = await encryption.DecryptNostrContentAsync(
nostrPrivateKeyHex, pendingSignature.investorNostrPubKey, pendingSignature.TransactionHex);

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
.Sum(_ => _.TxOut.Value.ToUnit(MoneyUnit.BTC));
}
catch (Exception e)
{
Logger.LogError(pendingSignature.TransactionHex, e);
Logger.LogError(pendingSignature?.TransactionHex ?? e.Message, e);
pendingSignature.TransactionHex = null;
}
}
Expand Down Expand Up @@ -341,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
};

Expand Down Expand Up @@ -558,6 +558,7 @@
public DateTime? TimeApproved { get; set; }

public string? TransactionHex { get; set; }
public string? EncryptedMessage { get; set; }

public string EventId { get; set; }
}
Expand Down
Loading