ByteHelpers: ToHex(): Do not retun null
MODIFY
WalletWasabi.Tests/UnitTests/Crypto/GroupElements/GeneralTests.cs
WalletWasabi.Tests/UnitTests/Crypto/GroupElements/GeneralTests.cs
@@ -303,5 +303,13 @@ namespace WalletWasabi.Tests.UnitTests.Crypto.GroupElements
var hex = ByteHelpers.ToHex(ge.ToBytes());
Assert.Equal(expectedHex, hex);
}
+
+ [Fact]
+ public void ToHex()
+ {
+ Assert.Throws<NullReferenceException>(() => ByteHelpers.ToHex(null!));
+ Assert.Equal("", ByteHelpers.ToHex(Array.Empty<byte>()));
+ Assert.Equal("0102", ByteHelpers.ToHex(0x01, 0x02));
+ }
}
}

MODIFY
WalletWasabi/Helpers/ByteHelpers.cs
WalletWasabi/Helpers/ByteHelpers.cs
@@ -106,13 +106,8 @@ namespace System
/// <summary>
/// Fastest byte array to hex implementation in C#
/// </summary>
- public static string? ToHex(params byte[] bytes)
+ public static string ToHex(params byte[] bytes)
{
- if (bytes is null)
- {
- return null;
- }
-
if (bytes.Length == 0)
{
return "";

ByteHelpers: ToHex(): Do not retun null