forked from mcschwa/BTCWalletMiner
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.cs
127 lines (110 loc) · 2.64 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
using ProgramSettings;
using ProgramBitcoin;
class Program
{
public void Entry()
{
var Settings = new Settings();
Settings.displayLogo();
Settings.setColors();
Settings.displayVersion();
Settings.displayFee();
Settings.displayCredits();
requestBitcoinAddress();
}
public void requestBitcoinAddress()
{
Console.Write("Please enter your Bitcoin address: ");
inputUser();
void inputUser()
{
var Settings = new Settings();
var BTCcoinAddress = new BitcoinAddress();
string userInput = Console.ReadLine();
if (userInput.Length >= BTCcoinAddress.minLength && userInput.Length <= BTCcoinAddress.maxLength)
{
InputConfirm(userInput);
}
else
{
inputInvalid();
}
}
void inputInvalid()
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Input invalid. Please try again");
Console.ResetColor();
requestBitcoinAddress();
}
void InputConfirm(string address)
{
Console.Write("Do you confirm that " + address + " is your address: ");
string userInput = Console.ReadLine();
if (userInput == "yes")
{
Settings.userBitcoinAddress.setAddress(userInput); //set the address
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Address confirmed.");
Console.ResetColor();
mineBtc();
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Address not confirmed.");
Console.ResetColor();
requestBitcoinAddress();
}
}
}
public void mineBtc()
{
Boolean Mine = true;
var BTCcoinAddress = new BitcoinAddress();
Random rnd = new Random();
int randomNumber()
{
int number = rnd.Next(BTCcoinAddress.minLength, BTCcoinAddress.maxLength);
return number;
}
string randomBtcAddress(int length)
{
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
return new string(Enumerable.Repeat(chars, length).Select(s => s[rnd.Next(s.Length)]).ToArray());
}
double btcAmountWon()
{
double BTC = (rnd.NextDouble());
return BTC;
}
while (Mine)
{
Thread.Sleep(100);
Console.ForegroundColor = ConsoleColor.DarkCyan;
Console.Write("[+]");
Console.ResetColor();
Console.Write(" " + randomBtcAddress(randomNumber()) + " ");
if (rnd.Next(0, 100) == 0)
{
Mine = false;
Console.ForegroundColor = ConsoleColor.Green;
Console.Write("(" + btcAmountWon() + " BTC)");
Console.ResetColor();
Console.ReadKey();
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("(0 BTC)");
Console.ResetColor();
}
Console.WriteLine("");
}
}
static void Main(string[] args)
{
var Program = new Program();
Program.Entry();
}
}