upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/main_gui.cpp
diff options
context:
space:
mode:
authorVictorio Nascimento <155357371+Vic-Nas@users.noreply.github.com>2026-07-27 16:45:28 -0400
committerGitHub <noreply@github.com>2026-07-27 17:45:28 -0300
commit6ca1a1d6799474f8ca977b93ab630af7ace879c2 (patch)
treea0312ebc10fc6a56742d0e5caa85c31eb6d3eaa7 /src/main_gui.cpp
parent56df9830d5a002ff9ce3fac47e497673f8159e39 (diff)
Add Linux GUI installer via Wine (#3)
* Add Linux GUI installer via Wine * Fix launcher creation and add BTF_RELAY env var support * Pool server, Linux GUI, unified binary, README update * Root Makefile: make linux / make windows, cleaner README * Remove headless.cpp * Fix XPM color count mismatch causing toolbar image errors on Linux * XPM icons: same code on Windows and Linux, no ifdefs around image loading * Fix GTK icon crash and Linux printf format * btfrv: 10s socket timeout on relay connects * Faster peer discovery: more dials per pass, shorter backoff and sleep * Parallel btf peer connections * Fix GetMyExternalIP - was disabled, now uses modern IP echo services * Fix tunnel disconnect on idle and restore external IP detection * Filter stale Nostr descriptors * Sort peers by freshness, fresh first * Pool: add .btf Stratum listener — miners connect via rendezvous, no port forwarding needed * btf pool: self-replacing listeners, one per relay, no queuing between miners * Mining modes: solo/operator/participant — pool server on-demand, participant Stratum client * Status bar: show external IP and .btf address * README: clean rewrite, concept-first, minimal * make linux produces AppImage * make linux produces AppImage * Pool dashboard: connect instructions, tabs, share bars * Perf fixes: GetMyExternalIP threaded, btf listener counted * Perf fixes: GetMyExternalIP threaded, btf listener counted * Fix pool payouts: defer until coinbase maturity * Pool: clean mode switching, IP warning * Pool: clean mode switching * Fix gPoolRunning: remove static * AppImage: use real icon from bitcoin.ico * Fix exit crash; Mining menu * Fix exit crash; Mining menu * Fix exit crash; Mining menu * Fix exit crash; Mining menu * Fix exit crash; Mining menu * Windows build: use mingw32-make * Windows build: simpler make invocation * Add deps-windows target * Windows build fixes * Windows build fixes * Windows makefile: fix obj dir * Windows: output to repo root * Windows: bundle DLLs into zip * Replace wxWidgets with ImGui+GLFW: same build on Linux and Windows * Fix %I64d that slipped back through rebase (main.h, net.h) * MinGW: add _mkdir shim for non-MSVC Windows; fix %I64d * Fix gPoolRunning extern outside ifndef _WIN32 * Remove -lboost_system: boost is header-only in this codebase * Status bar: copy buttons for IP and .btf address * Windows: add app icon via windres, strip wx stuff from rc file * Clean GUI: single Options menu item, bigger font, better spacing, cleaner options dialog; update README * GUI: embed Roboto font at 16px for clear readability on all platforms * Windows: windres depends on obj dir target * Fix balance hidden off-screen: put on own line below address bar * Windows: inline mkdir in every rule, remove dir target that confused make * Windows: move all target to top so it's the default rule * Fix pool server not starting: always start when operator selected, re-sync dialog state on open * Write debug.log to data directory (AppData/Roaming/Bitflash on Windows) * Participant miner: use wallet address as username so payouts go to wallet * Add .gitattributes to lock LF line endings, prevent CRLF drift * Refactor pool mining to btf-only transport * Persist pool settings and startup wiring * Prune stale peers and expose pool queries * Fix build regressions and add CLI mode/arg parity * Fix rpc miner stats declaration order * Centralize pool runtime extern declarations * Separate operator/participant dashboards and restore peer stats * Add live telemetry strip and clearer per-mode runtime metrics * Reduce mining dashboard clutter and remove manual pool entry * Count only authorized pool miners * Seed initial pool job on startup * Use a real share target for pool work * Switch pool accounting to round-based shares * Fix nostr pool announcer stats call sites * Fix pool stats definition order * Improve pool worker status display * Add mutex include for participant status * Replace ImClamp in dashboard layout * Clarify participant work status * Log participant status transitions * Reduce peer discovery log noise * Add participant status badge * Track participant auth acknowledgements * Log and validate pool job delivery --------- Co-authored-by: Bitflash Pool Dev <pool@bitflash>
Diffstat (limited to 'src/main_gui.cpp')
-rw-r--r--src/main_gui.cpp169
1 files changed, 169 insertions, 0 deletions
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
new file mode 100644
index 0000000..b7377da
--- /dev/null
+++ b/src/main_gui.cpp
@@ -0,0 +1,169 @@
1// Bitflash entry point — starts node threads then runs GUI (or headless).
2
3#include "headers_core.h"
4#ifndef _WIN32
5#include <csignal>
6#endif
7
8int RunGUI(int argc, char* argv[]);
9
10// Global definitions (were in ui.cpp, now here)
11map<string,string> mapAddressBook;
12bool gPoolServerRunning = false;
13
14static bool arg(int argc, char* argv[], const char* key)
15{
16 for (int i=1;i<argc;i++) { string s=argv[i]; if(s==key||s.substr(0,s.find('='))==key) return true; }
17 return false;
18}
19static string argval(int argc, char* argv[], const char* key)
20{
21 for (int i=1;i<argc;i++) {
22 string s=argv[i]; size_t eq=s.find('=');
23 if(eq!=string::npos && s.substr(0,eq)==key) return s.substr(eq+1);
24 }
25 return "";
26}
27
28static string argval2(int argc, char* argv[], const char* keySlash, const char* keyDash)
29{
30 string v = argval(argc, argv, keySlash);
31 if (!v.empty())
32 return v;
33 return argval(argc, argv, keyDash);
34}
35
36static void PrintUsage()
37{
38 printf("Bitflash command-line options\n");
39 printf("\n");
40 printf("General:\n");
41 printf(" /help, -help, --help, /?\n");
42 printf(" /datadir=PATH\n");
43 printf(" /debug\n");
44 printf(" /gen\n");
45 printf(" /nogui or /daemon\n");
46 printf("\n");
47 printf("Mining mode:\n");
48 printf(" /operator\n");
49 printf(" /participant=POOL_BTF_ADDRESS\n");
50 printf(" /solomine\n");
51 printf("\n");
52 printf("Pool operator announcement:\n");
53 printf(" /poolname=NAME\n");
54 printf(" /poolfee=PCT\n");
55 printf(" /pooldashboard=URL (alias: /pooldash=URL)\n");
56 printf("\n");
57 printf(".btf and rendezvous:\n");
58 printf(" /connectbtf=PEER_BTF_ADDRESS\n");
59 printf(" /rvrelay=HOST:PORT\n");
60 printf(" /announcerelay=HOST:PORT\n");
61 printf("\n");
62 printf("Each option also accepts '-' instead of '/'.\n");
63}
64
65static void ParseStartupArguments(int argc, char* argv[])
66{
67 if (arg(argc,argv,"/datadir") || arg(argc,argv,"-datadir"))
68 strSetDataDir = argval2(argc, argv, "/datadir", "-datadir");
69
70 if (arg(argc,argv,"/debug") || arg(argc,argv,"-debug"))
71 fDebug = true;
72
73 if (arg(argc,argv,"/gen") || arg(argc,argv,"-gen"))
74 fGenerateBitcoins = 1;
75
76 if (arg(argc,argv,"/solomine") || arg(argc,argv,"-solomine"))
77 fSoloMineTest = true;
78
79 if (arg(argc,argv,"/operator") || arg(argc,argv,"-operator"))
80 nMineMode = MINE_OPERATOR;
81
82 if (arg(argc,argv,"/participant") || arg(argc,argv,"-participant"))
83 {
84 nMineMode = MINE_PARTICIPANT;
85 strParticipantPool = argval2(argc, argv, "/participant", "-participant");
86 }
87
88 string poolName = argval2(argc, argv, "/poolname", "-poolname");
89 if (!poolName.empty())
90 strPoolName = poolName;
91
92 string poolDash = argval2(argc, argv, "/pooldashboard", "-pooldashboard");
93 if (poolDash.empty())
94 poolDash = argval2(argc, argv, "/pooldash", "-pooldash");
95 if (!poolDash.empty())
96 strPoolDashboardUrl = poolDash;
97
98 string poolFee = argval2(argc, argv, "/poolfee", "-poolfee");
99 if (!poolFee.empty())
100 dPoolFeePercent = atof(poolFee.c_str());
101
102 string btfConnect = argval2(argc, argv, "/connectbtf", "-connectbtf");
103 if (!btfConnect.empty())
104 strBtfConnect = btfConnect;
105
106 string rvRelay = argval2(argc, argv, "/rvrelay", "-rvrelay");
107 if (!rvRelay.empty())
108 {
109 vBtfMeetingRelays.clear();
110 vBtfMeetingRelays.push_back(rvRelay);
111 }
112
113 string announceRelay = argval2(argc, argv, "/announcerelay", "-announcerelay");
114 if (!announceRelay.empty())
115 strBtfAnnounceRelay = announceRelay;
116}
117
118int main(int argc, char* argv[])
119{
120 if (arg(argc,argv,"/help") || arg(argc,argv,"-help") ||
121 arg(argc,argv,"--help") || arg(argc,argv,"/?"))
122 {
123 PrintUsage();
124 return 0;
125 }
126
127 ParseStartupArguments(argc, argv);
128
129 printf("Loading addresses...\n");
130 if (!LoadAddresses()) printf("Warning: error loading addr.dat\n");
131 printf("Loading block index...\n");
132 string strErrors;
133 if (!LoadBlockIndex()) { fprintf(stderr,"LoadBlockIndex failed\n"); return 1; }
134 printf("Loading wallet...\n");
135 if (!LoadWallet()) { fprintf(stderr,"LoadWallet failed\n"); return 1; }
136 printf("Height=%d\n", nBestHeight);
137 ReacceptWalletTransactions();
138
139 if (!StartNode(strErrors)) { fprintf(stderr,"StartNode: %s\n",strErrors.c_str()); return 1; }
140
141 if (nMineMode == MINE_OPERATOR) {
142 gPoolServerRunning = true;
143 gPoolRunning = true;
144 if (_beginthread(ThreadRPCServer, 0, NULL) == (uintptr_t)-1)
145 printf("Error: _beginthread(ThreadRPCServer) failed\n");
146 }
147 if (fGenerateBitcoins)
148 if (_beginthread(ThreadBitcoinMiner, 0, NULL) == (uintptr_t)-1)
149 printf("Error: _beginthread(ThreadBitcoinMiner) failed\n");
150
151 bool fHeadless = arg(argc,argv,"/nogui") || arg(argc,argv,"-nogui") ||
152 arg(argc,argv,"/daemon") || arg(argc,argv,"-daemon");
153
154 if (fHeadless) {
155#ifndef _WIN32
156 auto sig=[](int){fShutdown=true;};
157 signal(SIGINT,sig); signal(SIGTERM,sig);
158#endif
159 printf("Running headless. Ctrl-C to stop.\n");
160 while (!fShutdown) Sleep(500);
161 StopNode();
162 return 0;
163 }
164
165 int ret = RunGUI(argc, argv);
166 fShutdown = true;
167 StopNode();
168 return ret;
169}