-
Notifications
You must be signed in to change notification settings - Fork 0
/
Launcher.bat
221 lines (211 loc) · 9.61 KB
/
Launcher.bat
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
@Echo OFF
REM IMPORTANT: DONT SHARE YOUR BATCHFILES - TAKE SECURITY SERIOUS! STAY SAFE
REM Edit your password so you don't constantly need to confirm the password when interacting with the cli Wallet!
set mypassword=NEVERSHAREYOURBATCHFILESORPASSWORD!
REM Only replace the following Variables if necessary (not everything in 1 folder)
REM Define Folders of our executables (by default our execution directory)
REM Some examples provided below, if in Doubdt, Rightclick the folder in Windows Explorer and choose "Copy Path"
set NodeLocation=%cd%
set WalletLocation=%cd%
set NgrokLocation=%cd%
set RegexHelperLocation=%cd%
set TransactionFilename=transaction.tx
set Responsefilenameending=tx.response
REM Set to "TRUE" for detailed messaged, to "FALSE" if not
set Debugmode=TRUE
REM Set to "TRUE" if Launcher should Quit instantly when choosing "quit"
set CloseFast=FALSE
set Backupfolder=%cd%\Backups
REM An Example if the Wallet is in a subfolder called "mwc-wallet" =>
REM set WalletLocation=%cd%\mwc-wallet
REM An Example if the Wallet AND this Script Are in a subfolder and the Node is "above" us =>
REM set NodeLocation=%cd%\..\
REM An Example for a copied path =>
REM set NodeLocation=C:\_Custom\Bitcoin_Wallets\mwc\CLI\mwc-wallet
REM Define which folders to search for Slatefiles, supply more by adding \\"folderlocation"\\"folderpath2" and so on
set folderstocheckforslatefiles=c:\users\%username%\downloads\\%NodeLocation%\\%cd%\\c:\users\%username%\Desktop
REM No Further editing needed, Logic part down here
REM Pre-Setup
For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a%%b)
REM Make sure everything is as we assume - Sanity Check time <3
REM Check if User edited Password =)
IF "%mypassword%" == "NEVERSHAREYOURBATCHFILESORPASSWORD!" Echo [ERROR:] You didn't change the password, please make sure to edit "mypassword" of the File "Launcher.bat" in %cd% (Rightclick and choose edit) && goto Quit
REM Check if Node exists where we expect it
IF EXIST "%NodeLocation%\mwc.exe" (
Echo [INFO:] Located Node
) ELSE (
Echo [ERROR:] Cannot locate Node! && Echo Please make sure your mwc.exe is actually saved under: && Echo %NodeLocation% or edit the variable NodeLocation
goto Quit
)
REM Check if CLI Wallet exists where we expect it
IF EXIST "%WalletLocation%\mwc-wallet.exe" (
Echo [INFO:] Located Wallet
) ELSE (
Echo [ERROR:] Cannot locate Wallet! && Echo Please make sure your mwc-wallet.exe is actually saved under: && Echo %WalletLocation% or edit the variable WalletLocation
goto Quit
)
REM Check if Ngrok exists where we expect it
IF EXIST "%NgrokLocation%\ngrok.exe" (
Echo [INFO:] Located Ngrok
) ELSE (
Echo [WARN:] Cannot locate Ngrok! (Optional Component) && ECHO Please make sure your ngrok.exe is actually saved under %NgrokLocation% or edit the variable NgrokLocation && Echo You can Download it from https://ngrok.com/download
)
REM Just "Log" our Slatefiles just in case, Code shouldn't delete stuff ;)
IF EXIST "%Backupfolder%" (
If "%Debugmode%" == "TRUE" Echo [INFO:] Located Backup Folder for processed Slatefiles
) ELSE (
mkdir %Backupfolder%
If "%Debugmode%" == "TRUE" Echo [INFO:] Created Backup Folder for processed Slatefiles in %WalletLocation%\Backups\
)
REM Setup Node as needed for everything
cd %NodeLocation%\ && start /min mwc.exe
Echo [WARN:] MWC-Node starting please give it a Moment to synchronize! && Echo. && Echo. && Echo "What do you want to do? (Type letter and press Enter)"
REM Define Interactive modes (Ask for startup vars?)
set /p mode=(S)end, (F)inalize, (L)isten, (I)nfo, (Scan), (C)ommandprompt, (Q)uit
Echo.
GOTO %mode%
REM ####Modes####
:S
:s
REM Go in Wallet Dir
cd %WalletLocation%\
REM Send a transaction, ask which mode
Echo (Hint: Type "File" or "HTTP" completely!) && Echo.
set /p method=Send by (File) or (HTTP)
Echo.
set /p Amount=What Amount to send? (Enter how many MWC you want to send as a number and press Enter)
Echo.
goto %method%
:File
:file
REM Move old Slatefile in Backupfolder
IF EXIST "%WalletLocation%\%TransactionFilename%" (
Echo [INFO:] Located a TransactionFile in Walletfolder, Moving to Backupfolder so we can create a new one
If "%Debugmode%" == "TRUE" Echo [INFO:]Moved old Slatefile to Backups before creating new one
move /Y "%WalletLocation%\%TransactionFilename%" "%WalletLocation%\Backups\%DATE%_%mytime%__%TransactionFilename%" > nul 2>&1
) ELSE (
REM not needed but here cuz im lazy, find the egg, keep it =)
)
mwc-wallet.exe -p %mypassword% send -m file -d %TransactionFilename% %Amount%
Echo [INFO:]Your payment File will be located in %WalletLocation%\%TransactionFilename%
Echo.
goto Redo
:HTTP
:http
mwc-wallet.exe -p %mypassword% send -d %URL% %Amount%
Echo.
goto Redo
:F
:f
REM Go in Wallet Dir
cd %WalletLocation%\
REM Check if we can find old transactionfile!
IF EXIST "%WalletLocation%\%TransactionFilename%" If "%Debugmode%" == "TRUE" ECHO [INFO:] Located old Transactionfile in Walletfolder. Moving to Backupfolder
IF EXIST "%WalletLocation%\%TransactionFilename%" move /Y "%WalletLocation%\%TransactionFilename%" "%Backupfolder%\%DATE%_%mytime%__%TransactionFilename%" > nul 2>&1
) ELSE (
)
REM Check if we can find the file to process, if not search or inform user!
IF EXIST "%WalletLocation%\%Responsefilenameending%" (
Echo [INFO:] Located a Responsefile in Walletfolder. Going to assume it s the correct one and process
IF EXIST "%WalletLocation%\%Responsefilenameending%" goto finishFinalize
) ELSE (
IF not EXIST %RegexHelperLocation%\RegExCHLPR.exe goto warnnoslatefilealgo
If "%Debugmode%" == "TRUE" ECHO Searching a Responsefile in specified Folderss
)
REM Call Regex Helper to quickly grab most current Slatefile if found in different folders
for /f "tokens=*" %%i in ('%RegexHelperLocation%\RegExCHLPR.exe %folderstocheckforslatefiles% .response') do set "foundSlateFile=%%i"
timeout 1
IF DEFINED foundSlateFile move /Y "%foundSlateFile%" "%WalletLocation%\%Responsefilenameending%" > nul 2>&1
If "%Debugmode%" == "TRUE" echo Current Slatefile according to Algo: %foundSlateFile%
timeout 1
REM Found it and moved it, no need to inform so bail
IF EXIST "%WalletLocation%\%Responsefilenameending%" goto finishFinalize
REM If we arrive here no Slatefile was found, let user know Fileending might be different
Echo [WARN:] Cannot locate Responsefilename! (Not in Downloads nor in any of the specified Folders)
Echo Please make sure your Responsefiles Name ends with %Responsefilenameending%
goto finishFinalize
:warnnoslatefilealgo
Echo [WARN:] Cannot locate Responsefilename! (Not in %WalletLocation%)
Echo Didn't find RegexCHLPR.exe to search for it in specified folders, please place Slatefile in your Wallet Folder
:finishFinalize
REM Finalize a transaction
Echo. && Echo. && Echo.
mwc-wallet.exe -p %mypassword% finalize -i %Responsefilenameending%
REM Wait for Slatefile to be accessible again to move it when done (just to make sure it isnt locked)
timeout 3
If "%Debugmode%" == "TRUE" ECHO Moving processed Slate File into Backup Folder
echo "%WalletLocation%\%Responsefilenameending%" "%Backupfolder%\%DATE%_%mytime%__%Responsefilenameending%"
move /Y "%WalletLocation%\%Responsefilenameending%" "%Backupfolder%\%DATE%_%mytime%__%Responsefilenameending%"
Echo.
goto Redo
:L
:l
REM Go in Wallet Dir and start Wallet listen mode
cd %WalletLocation%\ && start /min cmd.exe /c "mwc-wallet.exe -p %mypassword% listen"
Echo. && Echo. && Echo. && Echo Wallet is listening now =)
rem Echo Enter your password in the newly entered windows and your Wallet will be listening!
If not Exist %NgrokLocation%\ngrok.exe goto Redo
set /p UsingNgrok=Should we start Ngrok? (Y)es or (N)o (Enter Letter in parenthesis and press Enter)
IF "%UsingNgrok%" == "y" goto ngrokjumper
IF "%UsingNgrok%" == "Y" goto ngrokjumper
IF "%UsingNgrok%" == "yes" goto ngrokjumper
IF "%UsingNgrok%" == "Yes" goto ngrokjumper
Echo. && Echo.
goto Redo
:ngrokjumper
cd %NgrokLocation%\
start cmd.exe /c "ngrok.exe http 3415"
ECHO Use The HTTP Forwarding Addres displayed by Ngrok for Withdrawals (Only valid for 8 Hours!)
Echo.
goto Redo
:I
:i
REM Go in Wallet Dir
cd %WalletLocation%\
mwc-wallet.exe -p %mypassword% info
Echo.
goto Redo
:Scan
:scan
REM Go in Wallet Dir
cd %WalletLocation%\
mwc-wallet.exe -p %mypassword% scan -d
Echo.
goto Redo
:Redo
Echo. && Echo. && Echo.
REM Define Interactive modes (Ask for startup vars?)
Echo "Anything else you want to do? (Type letter and press Enter)"
Echo.
set /p mode=(S)end, (F)inalize, (L)isten, (I)nfo, (Scan), (C)ommandprompt, (Q)uit
Echo.
GOTO %mode%
:Q
:Quit
Echo.
Echo This Window will close itself, the MWC-Wallet and the MWC-Node as soon as you press [Enter]
Echo [WARN:] This will close all of your command prompts!
ECHO.
Echo Stay safe out there! NEVER SHARE YOUR BATCHFILES!!!
If "%CloseFast%" == "FALSE" pause
taskkill /IM mwc.exe /F
taskkill /IM mwc-wallet.exe /F
taskkill /IM ngrok.exe /F
taskkill /IM cmd.exe /F
quit
:C
:c
REM Interactive Shell/Commandprompt
REM Go in Wallet Dir and give control back to user
cd %WalletLocation%\ && cmd /k Echo type mwc-wallet.exe help to get a list of commands or mwc-wallet.exe init to initialize a new wallet
REM Author MrT, Version 0.5
:: Just a "Wrapper" around MWC Node and Wallet to make interaction a bit more Userfriendly
:: Replace the Variables if Needed I assume the following:
:: This File, MWC-Wallet.exe and MWC.exe are all in the same Folder!
:: Dev Notes: Tested:
:: -Listen
:: -Send (File)
:: -Info
:: -CmdPrompt
:: -Quit
:: -Finalize