Ruin txhex ensurement
MODIFY
WalletWasabi.Tests/UnitTests/SmartTransactionTests.cs
WalletWasabi.Tests/UnitTests/SmartTransactionTests.cs
@@ -168,11 +168,9 @@ namespace WalletWasabi.Tests.UnitTests
$"{txHash}:{txHex}:{height}:{blockHash}:{blockIndex}:{label}:{unixSeconds}:{isReplacement}:bar:buz",
// Can leave out some inputs.
$":{txHex}:{height}:{blockHash}:{blockIndex}:{label}:{unixSeconds}:{isReplacement}",
- $"{txHex}:{height}:{blockHash}:{blockIndex}:{label}:{unixSeconds}:{isReplacement}",
$"{txHash}:{txHex}::{blockHash}:{blockIndex}:{label}:{unixSeconds}:{isReplacement}",
$"{txHash}:{txHex}:{height}::{blockIndex}:{label}:{unixSeconds}:{isReplacement}",
- $"{txHash}:{txHex}:{height}:{blockHash}::{label}:{unixSeconds}:{isReplacement}",
- $"{txHex}",
+ $"{txHash}:{txHex}:{height}:{blockHash}::{label}:{unixSeconds}:{isReplacement}"
})
{
stx = SmartTransaction.FromLine(inp, net);

MODIFY
WalletWasabi/Models/SmartTransaction.cs
WalletWasabi/Models/SmartTransaction.cs
@@ -150,18 +150,18 @@ namespace WalletWasabi.Models
var parts = line.Split(':', StringSplitOptions.None).Select(x => x.Trim()).ToArray();
- // Find the Transaction hex, it must be always present.
- (Transaction transaction, int transactionHexIndex) = ParseTransactionHex(expectedNetwork, parts);
+ var transactionString = parts[1];
+ Transaction transaction = Transaction.Parse(transactionString, expectedNetwork);
try
{
// First is redundand txhash serialization.
- var heightString = parts[transactionHexIndex + 1];
- var blockHashString = parts[transactionHexIndex + 2];
- var blockIndexString = parts[transactionHexIndex + 3];
- var labelString = parts[transactionHexIndex + 4];
- var firstSeenString = parts[transactionHexIndex + 5];
- var isReplacementString = parts[transactionHexIndex + 6];
+ var heightString = parts[2];
+ var blockHashString = parts[3];
+ var blockIndexString = parts[4];
+ var labelString = parts[5];
+ var firstSeenString = parts[6];
+ var isReplacementString = parts[7];
if (!Height.TryParse(heightString, out Height height))
{
@@ -195,44 +195,6 @@ namespace WalletWasabi.Models
}
}
- private static (Transaction tx, int txHexIndex) ParseTransactionHex(Network expectedNetwork, string[] parts)
- {
- Transaction tx = null;
- int txHexIndex = 1;
- try
- {
- tx = Transaction.Parse(parts[txHexIndex], expectedNetwork);
- }
- catch
- {
- for (txHexIndex = 0; txHexIndex < parts.Length; txHexIndex++)
- {
- if (txHexIndex == 1)
- {
- continue; // We already checked this.
- }
-
- string part = parts[txHexIndex];
- try
- {
- tx = Transaction.Parse(part, expectedNetwork);
- break;
- }
- catch
- {
- continue;
- }
- }
- }
-
- if (tx is null)
- {
- throw new FormatException($"Transaction hex is not present.");
- }
-
- return (tx, txHexIndex);
- }
-
#endregion LineSerialization
#region Equality

Ruin txhex ensurement