Add blockstream onion as block explorer
Closes
MODIFY
.gitignore
.gitignore
@@ -271,3 +271,4 @@ lcov.info
\.DS_Store
*.DS_Store
+/WalletWasabi.Backend/wwwroot/onion-index.html

MODIFY
WalletWasabi.Backend/Controllers/HomeController.cs
WalletWasabi.Backend/Controllers/HomeController.cs
@@ -9,7 +9,18 @@ namespace WalletWasabi.Backend.Controllers
[HttpGet("")]
public ActionResult Index()
{
- VirtualFileResult response = File("index.html", "text/html");
+ string host = HttpContext?.Request?.Host.Host;
+
+ VirtualFileResult response;
+ if (!string.IsNullOrWhiteSpace(host) && host.TrimEnd('/').EndsWith(".onion", StringComparison.OrdinalIgnoreCase))
+ {
+ response = File("onion-index.html", "text/html");
+ }
+ else
+ {
+ response = File("index.html", "text/html");
+ }
+
response.LastModified = DateTimeOffset.UtcNow;
return response;
}

MODIFY
WalletWasabi.Backend/Program.cs
WalletWasabi.Backend/Program.cs
@@ -52,6 +52,7 @@ namespace WalletWasabi.Backend
{
Directory.CreateDirectory(UnversionedWebBuilder.UnversionedFolder);
UnversionedWebBuilder.CreateDownloadTextWithVersionHtml();
+ UnversionedWebBuilder.CloneAndUpdateOnionIndexHtml();
string[] allLines = File.ReadAllLines(Global.Coordinator.CoinJoinsFilePath);
foreach (string line in allLines)

MODIFY
WalletWasabi.Backend/UnversionedWebBuilder.cs
WalletWasabi.Backend/UnversionedWebBuilder.cs
@@ -9,10 +9,11 @@ namespace WalletWasabi.Backend
public static class UnversionedWebBuilder
{
#if DEBUG
- public static string UnversionedFolder { get; } = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..\\..\\..\\wwwroot", "unversioned"));
+ public static string RootFolder { get; } = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..\\..\\..\\wwwroot"));
#else
- public static string UnversionedFolder { get; } = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "wwwroot", "unversioned"));
+ public static string RootFolder { get; } = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "wwwroot"));
#endif
+ public static string UnversionedFolder { get; } = Path.GetFullPath(Path.Combine(RootFolder, "unversioned"));
public static string CreateFilePath(string fileName) => Path.Combine(UnversionedFolder, fileName);
@@ -26,6 +27,18 @@ namespace WalletWasabi.Backend
File.WriteAllText(filePath, content);
}
+ public static void CloneAndUpdateOnionIndexHtml()
+ {
+ var filePath = Path.Combine(RootFolder, "onion-index.html");
+ var indexFilePath = Path.Combine(RootFolder, "index.html");
+
+ var content = File.ReadAllText(indexFilePath);
+
+ content.Replace("coinjoins-table.html", "onion-coinjoins-table.html", StringComparison.Ordinal);
+
+ File.WriteAllText(filePath, content);
+ }
+
public static void UpdateMixedTextHtml(Money amount)
{
var filePath = CreateFilePath("mixed-text.html");
@@ -44,17 +57,22 @@ namespace WalletWasabi.Backend
public static void UpdateCoinJoinsHtml(IEnumerable<string> coinJoins)
{
var filePath = CreateFilePath("coinjoins-table.html");
+ var onionFilePath = CreateFilePath("onion-coinjoins-table.html");
var content = HtmlStartLine + "<ul class=\"text-center\" style=\"list-style: none;\">";
+ var onionContent = HtmlStartLine + "<ul class=\"text-center\" style=\"list-style: none;\">";
var endContent = "</ul>";
string blockstreamPath;
+ string onionBlockstreamPath;
if (Global.Config.Network == Network.TestNet)
{
blockstreamPath = "https://blockstream.info/testnet/tx/";
+ onionBlockstreamPath = "http://explorerzydxu5ecjrkwceayqybizmpjjznk5izmitf2modhcusuqlid.onion/testnet/tx/";
}
else
{
blockstreamPath = "https://blockstream.info/tx/";
+ onionBlockstreamPath = "http://explorerzydxu5ecjrkwceayqybizmpjjznk5izmitf2modhcusuqlid.onion/tx/";
}
var coinJoinsList = coinJoins.ToList();
@@ -65,15 +83,19 @@ namespace WalletWasabi.Backend
if (i % 2 == 0)
{
content += $"<li style=\"background:#e6e6e6; margin:5px;\"><a href=\"{blockstreamPath}{cjHash}\" target=\"_blank\">{cjHash}</a></li>";
+ onionContent += $"<li style=\"background:#e6e6e6; margin:5px;\"><a href=\"{onionBlockstreamPath}{cjHash}\" target=\"_blank\">{cjHash}</a></li>";
}
else
{
content += $"<li><a href=\"{blockstreamPath}{cjHash}\" target=\"_blank\">{cjHash}</a></li>";
+ onionContent += $"<li><a href=\"{onionBlockstreamPath}{cjHash}\" target=\"_blank\">{cjHash}</a></li>";
}
}
content += endContent;
+ onionContent += endContent;
File.WriteAllText(filePath, content);
+ File.WriteAllText(onionFilePath, onionContent);
}
}
}

Add blockstream onion as block explorer
Closes https://github.com/zkSNACKs/WalletWasabi/issues/1178