Skip to content

Commit

Permalink
Merge pull request #6572 from molnard/bp_1_1_13_0
Browse files Browse the repository at this point in the history
[BACKPORT] Update to v1.1.13.0
  • Loading branch information
molnard committed Oct 29, 2021
2 parents 8803b3f + 9cdfa34 commit 04db51a
Show file tree
Hide file tree
Showing 16 changed files with 58 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public void VerifyBitcoindBinaryChecksumHashes()

Dictionary<OSPlatform, string> expectedHashes = new Dictionary<OSPlatform, string>()
{
{ OSPlatform.Windows, "e51379c1950092514182494b9998152d9ad6d527358dd730945b2ea4e7ee5a51" },
{ OSPlatform.Linux, "62d849c713c00821dbcca328651c287864c2d489aeafbd8a1a3f8b32870d4d8a" },
{ OSPlatform.OSX, "e84db05bef03f62a7da36f1006c4734b9f417320f256cd67aa9bd1fcef5f87a5" },
{ OSPlatform.Windows, "957d43d6290ad1bda3e4ee6dc1303a7dac56c378ad4a4b4896610fb02f4fe177" },
{ OSPlatform.Linux, "72c713789869010a70f264a03261e7fcb9e2dc3052ba618f2e5056fb45cdc6e5" },
{ OSPlatform.OSX, "182cd983fba123b77d6deaefee4669b9e256dda8274c86249e6f4b852dd02924" },
};

foreach (var item in expectedHashes)
Expand Down
3 changes: 2 additions & 1 deletion WalletWasabi/Blockchain/Keys/KeyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
using System.Linq;
using System.Security;
Expand Down Expand Up @@ -530,7 +531,7 @@ public IEnumerable<byte[]> GetPubKeyScriptBytes()
{
lock (HdPubKeyScriptBytesLock)
{
return HdPubKeyScriptBytes;
return HdPubKeyScriptBytes.ToImmutableArray();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ private ProcessedResult ProcessNoLock(SmartTransaction tx)
{
uint256 txId = tx.GetHash();

// If we already have the transaction, then let's work on that.
if (TransactionStore.TryGetTransaction(txId, out var foundTx))
{
foundTx.TryUpdate(tx);
tx = foundTx;
result = new ProcessedResult(tx);
}

// Performance ToDo: txids could be cached in a hashset here by the AllCoinsView and then the contains would be fast.
if (!tx.Transaction.IsCoinBase && !Coins.AsAllCoinsView().CreatedBy(txId).Any()) // Transactions we already have and processed would be "double spends" but they shouldn't.
{
Expand Down
2 changes: 1 addition & 1 deletion WalletWasabi/Blockchain/Transactions/TransactionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public TransactionFactory(Network network, KeyManager keyManager, ICoinsView coi
{
KeyManager.AssertCleanKeysIndexed(isInternal: true);
KeyManager.AssertLockedInternalKeysIndexed(14);
changeHdPubKey = KeyManager.GetKeys(KeyState.Clean, true).RandomElement();
changeHdPubKey = KeyManager.GetKeys(KeyState.Clean, true).FirstOrDefault();

builder.SetChange(changeHdPubKey.P2wpkhScript);
}
Expand Down
4 changes: 2 additions & 2 deletions WalletWasabi/Helpers/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ public static class Constants

public const long MaxSatoshisSupply = 2_100_000_000_000_000L;

public static readonly Version ClientVersion = new Version(1, 1, 12, 9);
public static readonly Version ClientVersion = new Version(1, 1, 13, 0);
public static readonly Version HwiVersion = new Version("2.0.2");
public static readonly Version BitcoinCoreVersion = new Version("0.21.0");
public static readonly Version BitcoinCoreVersion = new Version("0.21.1");
public static readonly Version LegalDocumentsVersion = new Version(2, 0);

public static readonly NodeRequirement NodeRequirements = new NodeRequirement
Expand Down
14 changes: 7 additions & 7 deletions WalletWasabi/Http/Models/HeaderSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ private static void ValidateAndCorrectHeaders(HeaderSection hs)
foreach (var f in hs.Fields)
{
// if we find host
if (f.Name == "Host")
if (f.Name.Equals("Host", StringComparison.OrdinalIgnoreCase))
{
// if host is not first
if (hs.Fields.First().Name != "Host")
if (!hs.Fields.First().Name.Equals("Host", StringComparison.OrdinalIgnoreCase))
{
// then correct host
hostToCorrect = f;
Expand Down Expand Up @@ -102,7 +102,7 @@ private static void ValidateAndCorrectHeaders(HeaderSection hs)
var allParts = new HashSet<string>();
foreach (var field in hs.Fields)
{
if (field.Name == "Content-Length")
if (field.Name.Equals("Content-Length", StringComparison.OrdinalIgnoreCase))
{
var parts = field.Value.Trim().Split(',');
foreach (var part in parts)
Expand All @@ -117,7 +117,7 @@ private static void ValidateAndCorrectHeaders(HeaderSection hs)
{
throw new InvalidDataException("Invalid Content-Length.");
}
hs.Fields.RemoveAll(x => x.Name == "Content-Length");
hs.Fields.RemoveAll(x => x.Name.Equals("Content-Length", StringComparison.OrdinalIgnoreCase));
hs.Fields.Add(new HeaderField("Content-Length", allParts.First()));
}
}
Expand All @@ -131,7 +131,7 @@ public HttpRequestContentHeaders ToHttpRequestHeaders()
message.Content.Headers.ContentLength = null;
foreach (var field in Fields)
{
if (field.Name.StartsWith("Content-", StringComparison.Ordinal))
if (field.Name.StartsWith("Content-", StringComparison.OrdinalIgnoreCase))
{
message.Content.Headers.TryAddWithoutValidation(field.Name, field.Value);
}
Expand All @@ -157,7 +157,7 @@ public HttpResponseContentHeaders ToHttpResponseHeaders()
message.Content.Headers.ContentLength = null;
foreach (var field in Fields)
{
if (field.Name.StartsWith("Content-", StringComparison.Ordinal))
if (field.Name.StartsWith("Content-", StringComparison.OrdinalIgnoreCase))
{
message.Content.Headers.TryAddWithoutValidation(field.Name, field.Value);
}
Expand Down Expand Up @@ -191,7 +191,7 @@ public static HeaderSection CreateNew(HttpHeaders headers)
{
if (contentHeaders.ContentLength != null)
{
if (hs.Fields.All(x => x.Name != "Content-Length"))
if (hs.Fields.All(x => !x.Name.Equals("Content-Length", StringComparison.OrdinalIgnoreCase)))
{
hs.Fields.Add(new HeaderField("Content-Length", contentHeaders.ContentLength.ToString()));
}
Expand Down
Binary file modified WalletWasabi/Microservices/Binaries/lin64/bitcoind
Binary file not shown.
Binary file modified WalletWasabi/Microservices/Binaries/osx64/bitcoind
Binary file not shown.
Binary file modified WalletWasabi/Microservices/Binaries/win64/bitcoind.exe
100644 → 100755
Binary file not shown.
Binary file modified WalletWasabi/TorDaemons/data-folder.zip
Binary file not shown.
6 changes: 3 additions & 3 deletions WalletWasabi/TorDaemons/digests.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
621eb6ff196c9cd3262c3a13f8c9f2821f65083db53957bc993ae51bd3616865
efd78d3ed57072772617dfb106859f5faebe7cdf0a91ba0a7ac3976a31ce0371
13b2a562aebb29307c23fa1eee1a22dd53b941d8919695d37771b37bd75d15bf
5d5f175bf154f5f4cd2c460b9d4ea80c8219d07441f626e13a4d01c1408a0c28
957768c0a005a9b6a1db1c52fc747ce39303415b412128731965ab3932c1fff4
f6c8a3bd07b939e7c736a1e811df907611b763d0f8dbfafa721d8bf6ebfec691
Binary file modified WalletWasabi/TorDaemons/tor-linux64.zip
Binary file not shown.
Binary file modified WalletWasabi/TorDaemons/tor-osx64.zip
Binary file not shown.
Binary file modified WalletWasabi/TorDaemons/tor-win64.zip
Binary file not shown.
19 changes: 15 additions & 4 deletions WalletWasabi/TorSocks5/TorHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,21 @@ public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, Can
// in forwarded messages.
request.Version = HttpProtocol.HTTP11.Version;

if (TorSocks5Client != null && !TorSocks5Client.IsConnected)
string requestScheme = request.RequestUri.Scheme;
if (TorSocks5Client != null)
{
TorSocks5Client?.Dispose();
TorSocks5Client = null;
bool toDispose =
!TorSocks5Client.IsConnected
||
(requestScheme == "http" && TorSocks5Client.Stream is SslStream)
||
(requestScheme == "https" && !(TorSocks5Client.Stream is SslStream));

if (toDispose)
{
TorSocks5Client?.Dispose();
TorSocks5Client = null;
}
}

if (TorSocks5Client is null || !TorSocks5Client.IsConnected)
Expand All @@ -195,7 +206,7 @@ public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, Can
await TorSocks5Client.ConnectToDestinationAsync(host, request.RequestUri.Port).ConfigureAwait(false);

Stream stream = TorSocks5Client.TcpClient.GetStream();
if (request.RequestUri.Scheme == "https")
if (requestScheme == "https")
{
SslStream sslStream = new SslStream(stream, leaveInnerStreamOpen: true);

Expand Down
18 changes: 17 additions & 1 deletion WalletWasabi/TorSocks5/TorProcessManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public TorProcessManager(EndPoint torSocks5EndPoint, string logFile)
public string LogFile { get; }

public static bool RequestFallbackAddressUsage { get; private set; } = false;
private DateTimeOffset? RequestFallbackSince { get; set; } = null;

public Process TorProcess { get; private set; }

Expand Down Expand Up @@ -271,10 +272,14 @@ public void StartMonitor(TimeSpan torMisbehaviorCheckPeriod, TimeSpan checkIfRun
}
// Check if it changed in the meantime...
if (TorHttpClient.LatestTorException is TorSocks5FailureResponseException torEx2 && torEx2.RepField == RepField.HostUnreachable)
if (TorHttpClient.LatestTorException is TorSocks5FailureResponseException torEx2
&& torEx2.RepField == RepField.HostUnreachable
&& !RequestFallbackAddressUsage)
{
// Fallback here...
RequestFallbackAddressUsage = true;
RequestFallbackSince = DateTimeOffset.UtcNow;
Logger.LogInfo($"Backend onion unreachable - using fallback mechanism.");
}
}
}
Expand All @@ -286,6 +291,17 @@ public void StartMonitor(TimeSpan torMisbehaviorCheckPeriod, TimeSpan checkIfRun
}
}
}
else
{
if (RequestFallbackAddressUsage
&& !(RequestFallbackSince is null)
&& DateTimeOffset.UtcNow - RequestFallbackSince > TimeSpan.FromHours(24))
{
Logger.LogInfo($"Disabling fallback mechanism, using backend's onion address.");
RequestFallbackAddressUsage = false;
RequestFallbackSince = null;
}
}
}
catch (Exception ex) when (ex is OperationCanceledException || ex is TaskCanceledException || ex is TimeoutException)
{
Expand Down

0 comments on commit 04db51a

Please sign in to comment.