Kukks
5 years ago
commit
58e77c930a
4 changed files with 146 additions and 0 deletions
@ -0,0 +1,4 @@ |
|||
bin/ |
|||
obj/ |
|||
/packages/ |
|||
.idea |
@ -0,0 +1,16 @@ |
|||
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00 |
|||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VanityGenerator", "VanityGenerator\VanityGenerator.csproj", "{FCC150E5-0933-4B94-89FA-EFEF07A7B776}" |
|||
EndProject |
|||
Global |
|||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
|||
Debug|Any CPU = Debug|Any CPU |
|||
Release|Any CPU = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
|||
{FCC150E5-0933-4B94-89FA-EFEF07A7B776}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|||
{FCC150E5-0933-4B94-89FA-EFEF07A7B776}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|||
{FCC150E5-0933-4B94-89FA-EFEF07A7B776}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|||
{FCC150E5-0933-4B94-89FA-EFEF07A7B776}.Release|Any CPU.Build.0 = Release|Any CPU |
|||
EndGlobalSection |
|||
EndGlobal |
@ -0,0 +1,114 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading; |
|||
using System.Threading.Channels; |
|||
using System.Threading.Tasks; |
|||
using NBitcoin; |
|||
|
|||
namespace VanityGenerator |
|||
{ |
|||
class Program |
|||
{ |
|||
private static readonly Channel<(string, string)> Found = Channel.CreateUnbounded<(string, string)>(); |
|||
|
|||
|
|||
static async Task Main(string[] args) |
|||
{ |
|||
var toMatch = new List<string>(); |
|||
while (true) |
|||
{ |
|||
Console.Write($"Enter what to match for{(toMatch.Any()? " (or leave blank to start)": string.Empty)}:"); |
|||
var entry = Console.ReadLine(); |
|||
|
|||
|
|||
if (string.IsNullOrEmpty(entry) && toMatch.Any()) |
|||
{ |
|||
Console.WriteLine($"Going to be searching for {string.Join(',', toMatch)}"); |
|||
break; |
|||
} |
|||
|
|||
toMatch.Add(entry); |
|||
|
|||
} |
|||
_ = WriteResults(); |
|||
_ = Hunt(GetSubset(toMatch)); |
|||
} |
|||
|
|||
private static IEnumerable<string> GetSubset(IEnumerable<string> matches) |
|||
{ |
|||
return matches.SelectMany(s => |
|||
{ |
|||
if (s.Length <= 4) |
|||
{ |
|||
return new[] {s.ToLowerInvariant()}; |
|||
} |
|||
else |
|||
{ |
|||
var result = new string[s.Length - 3]; |
|||
for (int x = 4; x <= s.Length; x++) |
|||
{ |
|||
result[x - 4] = s.Substring(0, x).ToLowerInvariant(); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
}); |
|||
} |
|||
|
|||
private static async Task WriteResults() |
|||
{ |
|||
while (await Found.Reader.WaitToReadAsync(CancellationToken.None)) |
|||
{ |
|||
if (Found.Reader.TryRead(out var req)) |
|||
{ |
|||
if (string.IsNullOrEmpty(req.Item1) || string.IsNullOrEmpty(req.Item2)) |
|||
{ |
|||
continue; |
|||
} |
|||
|
|||
await File.WriteAllTextAsync(req.Item1 + ".txt", $"{req.Item1}{Environment.NewLine}{req.Item2}", |
|||
Encoding.UTF8, CancellationToken.None); |
|||
} |
|||
} |
|||
} |
|||
|
|||
private static async Task Hunt(IEnumerable<string> toMatch) |
|||
{ |
|||
while (true) |
|||
{ |
|||
var k = new Key(); |
|||
var segwit = k.PubKey.GetAddress(ScriptPubKeyType.Segwit, Network.Main).ToString().ToLowerInvariant(); |
|||
var segwitp2sh = k.PubKey.GetAddress(ScriptPubKeyType.SegwitP2SH, Network.Main).ToString() |
|||
.ToLowerInvariant(); |
|||
var matchesNative = Matches(toMatch, segwit.Substring(4)); |
|||
var matchesP2SH = Matches(toMatch, segwitp2sh.Substring(1)); |
|||
if (matchesNative.Any() || matchesP2SH.Any()) |
|||
{ |
|||
foreach (var s in matchesNative) |
|||
{ |
|||
var fileName = $"{s} segwit addr={segwit}"; |
|||
var wif = k.GetWif(Network.Main).ToString(); |
|||
Console.WriteLine($"{fileName} wif={wif}"); |
|||
await Found.Writer.WriteAsync((fileName, wif)); |
|||
} |
|||
|
|||
foreach (var s in matchesP2SH) |
|||
{ |
|||
var fileName = $"{s} p2sh addr={segwitp2sh}"; |
|||
var wif = k.GetWif(Network.Main).ToString(); |
|||
Console.WriteLine($"{fileName} wif={wif}"); |
|||
await Found.Writer.WriteAsync((fileName, wif)); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
private static string[] Matches(IEnumerable<string> vanity, string address) |
|||
{ |
|||
return vanity.Where(address.StartsWith).ToArray(); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,12 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<OutputType>Exe</OutputType> |
|||
<TargetFramework>netcoreapp3.1</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="NBitcoin" Version="5.0.33" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
Loading…
Reference in new issue