diff options
| author | Victorio Nascimento <155357371+Vic-Nas@users.noreply.github.com> | 2026-07-27 16:45:28 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-27 17:45:28 -0300 |
| commit | 6ca1a1d6799474f8ca977b93ab630af7ace879c2 (patch) | |
| tree | a0312ebc10fc6a56742d0e5caa85c31eb6d3eaa7 /src/headless.cpp | |
| parent | 56df9830d5a002ff9ce3fac47e497673f8159e39 (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/headless.cpp')
| -rw-r--r-- | src/headless.cpp | 180 |
1 files changed, 0 insertions, 180 deletions
diff --git a/src/headless.cpp b/src/headless.cpp deleted file mode 100644 index cdb8ac9..0000000 --- a/src/headless.cpp +++ /dev/null | |||
| @@ -1,180 +0,0 @@ | |||
| 1 | // Copyright (c) 2026 Bitflash developers | ||
| 2 | // Distributed under the MIT/X11 software license. | ||
| 3 | // | ||
| 4 | // Headless entry point for the Linux node/miner `bitflash-node`. Replaces the | ||
| 5 | // wxWidgets GUI (ui.cpp) with a command-line daemon: it loads the chain and | ||
| 6 | // wallet, starts the P2P/Nostr node (which auto-discovers .btf peers through | ||
| 7 | // the rendezvous relay), and optionally mines with RandomX. No GUI, no wx. | ||
| 8 | // | ||
| 9 | // ./bitflash-node -gen mine with the CPU, auto-connect peers | ||
| 10 | // ./bitflash-node -gen -datadir=/path use a specific data directory | ||
| 11 | // ./bitflash-node -rvrelay=host:port use a specific rendezvous relay | ||
| 12 | // ./bitflash-node -connectbtf=<addr>.btf pin a specific peer | ||
| 13 | // ./bitflash-node -solomine -gen mine without waiting for a peer (test) | ||
| 14 | |||
| 15 | #include "headers.h" | ||
| 16 | #include <csignal> | ||
| 17 | |||
| 18 | // ---- UI hooks the core references, provided here as headless equivalents ---- | ||
| 19 | |||
| 20 | // The core asks the GUI to repaint on new blocks/transactions; nothing to do. | ||
| 21 | void MainFrameRepaint() {} | ||
| 22 | |||
| 23 | // Wallet address book -- defined in ui.cpp on Windows; the core (db.cpp) reads | ||
| 24 | // and writes it, so the headless build must provide the definition. | ||
| 25 | map<string, string> mapAddressBook; | ||
| 26 | |||
| 27 | // Format a unix timestamp for transaction listings (ui.cpp used wxDateTime). | ||
| 28 | string DateTimeStr(int64 nTime) | ||
| 29 | { | ||
| 30 | time_t t = (time_t)nTime; | ||
| 31 | struct tm* ptm = localtime(&t); | ||
| 32 | if (!ptm) | ||
| 33 | return ""; | ||
| 34 | char buf[64]; | ||
| 35 | strftime(buf, sizeof(buf), "%m/%d/%y %H:%M", ptm); | ||
| 36 | return string(buf); | ||
| 37 | } | ||
| 38 | |||
| 39 | |||
| 40 | // ---- argument parsing (mirrors ui.cpp's ParseParameters) ---- | ||
| 41 | static map<string, string> ParseParameters(int argc, char* argv[]) | ||
| 42 | { | ||
| 43 | map<string, string> mapArgs; | ||
| 44 | for (int i = 0; i < argc; i++) | ||
| 45 | { | ||
| 46 | string s = argv[i]; | ||
| 47 | string val; | ||
| 48 | size_t eq = s.find('='); | ||
| 49 | if (eq != string::npos) | ||
| 50 | { | ||
| 51 | val = s.substr(eq + 1); | ||
| 52 | s = s.substr(0, eq); | ||
| 53 | } | ||
| 54 | for (size_t j = 0; j < s.size(); j++) | ||
| 55 | s[j] = (char)tolower((unsigned char)s[j]); | ||
| 56 | if (!s.empty() && s[0] == '-') | ||
| 57 | s[0] = '/'; | ||
| 58 | mapArgs[s] = val; | ||
| 59 | } | ||
| 60 | return mapArgs; | ||
| 61 | } | ||
| 62 | |||
| 63 | |||
| 64 | static void HandleSignal(int) | ||
| 65 | { | ||
| 66 | fShutdown = true; | ||
| 67 | } | ||
| 68 | |||
| 69 | |||
| 70 | int main(int argc, char* argv[]) | ||
| 71 | { | ||
| 72 | map<string, string> mapArgs = ParseParameters(argc, argv); | ||
| 73 | |||
| 74 | if (mapArgs.count("/?") || mapArgs.count("/help") || mapArgs.count("/h")) | ||
| 75 | { | ||
| 76 | fprintf(stderr, | ||
| 77 | "Bitflash headless node\n" | ||
| 78 | "Usage: %s [options]\n" | ||
| 79 | " -gen generate coins (mine with RandomX)\n" | ||
| 80 | " -datadir=<dir> data directory (default ~/.bitflash)\n" | ||
| 81 | " -port=<n> P2P listen port (default 8433)\n" | ||
| 82 | " -rvrelay=host:port rendezvous meeting relay (has a seed default)\n" | ||
| 83 | " -announcerelay=h:p announce a relay you run so nodes discover it\n" | ||
| 84 | " -connectbtf=<a>.btf keep a connection to a specific .btf peer\n" | ||
| 85 | " -solomine mine without waiting for a peer (testing)\n" | ||
| 86 | " -debug verbose logging\n", | ||
| 87 | argv[0]); | ||
| 88 | return 0; | ||
| 89 | } | ||
| 90 | |||
| 91 | // Parameters (same set the Windows UI honors) | ||
| 92 | if (mapArgs.count("/datadir")) | ||
| 93 | strSetDataDir = mapArgs["/datadir"]; | ||
| 94 | if (mapArgs.count("/port")) | ||
| 95 | nListenPort = htons(atoi(mapArgs["/port"].c_str())); | ||
| 96 | if (mapArgs.count("/proxy")) | ||
| 97 | addrProxy = CAddress(mapArgs["/proxy"].c_str()); | ||
| 98 | if (mapArgs.count("/rvrelay")) | ||
| 99 | vBtfMeetingRelays = { mapArgs["/rvrelay"] }; | ||
| 100 | if (mapArgs.count("/announcerelay")) | ||
| 101 | strBtfAnnounceRelay = mapArgs["/announcerelay"]; | ||
| 102 | if (mapArgs.count("/connectbtf")) | ||
| 103 | strBtfConnect = mapArgs["/connectbtf"]; | ||
| 104 | if (mapArgs.count("/debug")) | ||
| 105 | fDebug = true; | ||
| 106 | if (mapArgs.count("/solomine")) | ||
| 107 | fSoloMineTest = true; | ||
| 108 | if (mapArgs.count("/gen")) | ||
| 109 | fGenerateBitcoins = mapArgs["/gen"].empty() ? true : atoi(mapArgs["/gen"].c_str()); | ||
| 110 | |||
| 111 | printf("\nBitflash headless node starting\n"); | ||
| 112 | |||
| 113 | // | ||
| 114 | // Load data files (mirror of the Windows OnInit2 startup) | ||
| 115 | // | ||
| 116 | printf("Loading addresses...\n"); | ||
| 117 | if (!LoadAddresses()) | ||
| 118 | printf("Error loading addr.dat\n"); | ||
| 119 | |||
| 120 | printf("Loading block index...\n"); | ||
| 121 | if (!LoadBlockIndex()) | ||
| 122 | { | ||
| 123 | printf("Error loading blkindex.dat\n"); | ||
| 124 | return 1; | ||
| 125 | } | ||
| 126 | |||
| 127 | printf("Loading wallet...\n"); | ||
| 128 | if (!LoadWallet()) | ||
| 129 | { | ||
| 130 | printf("Error loading wallet.dat\n"); | ||
| 131 | return 1; | ||
| 132 | } | ||
| 133 | |||
| 134 | printf("Done loading. nBestHeight=%d, wallet keys=%d\n", | ||
| 135 | nBestHeight, (int)mapKeys.size()); | ||
| 136 | |||
| 137 | // Rebroadcast any wallet transactions not yet in a block | ||
| 138 | ReacceptWalletTransactions(); | ||
| 139 | |||
| 140 | // | ||
| 141 | // Start the node (P2P + Nostr discovery + .btf rendezvous) | ||
| 142 | // | ||
| 143 | string strErrors; | ||
| 144 | if (!StartNode(strErrors)) | ||
| 145 | { | ||
| 146 | printf("StartNode failed: %s\n", strErrors.c_str()); | ||
| 147 | return 1; | ||
| 148 | } | ||
| 149 | |||
| 150 | // | ||
| 151 | // Start mining if requested | ||
| 152 | // | ||
| 153 | if (fGenerateBitcoins) | ||
| 154 | { | ||
| 155 | if (_beginthread(ThreadBitcoinMiner, 0, NULL) == (uintptr_t)-1) | ||
| 156 | printf("Error: _beginthread(ThreadBitcoinMiner) failed\n"); | ||
| 157 | else | ||
| 158 | printf("Mining enabled (RandomX, CPU)\n"); | ||
| 159 | } | ||
| 160 | else | ||
| 161 | { | ||
| 162 | printf("Mining disabled (pass -gen to mine)\n"); | ||
| 163 | } | ||
| 164 | |||
| 165 | // | ||
| 166 | // Run until interrupted | ||
| 167 | // | ||
| 168 | signal(SIGINT, HandleSignal); | ||
| 169 | signal(SIGTERM, HandleSignal); | ||
| 170 | printf("Bitflash node running. Press Ctrl-C to stop.\n"); | ||
| 171 | |||
| 172 | while (!fShutdown) | ||
| 173 | Sleep(500); | ||
| 174 | |||
| 175 | printf("Shutting down...\n"); | ||
| 176 | StopNode(); | ||
| 177 | Sleep(500); | ||
| 178 | printf("Bitflash node stopped.\n"); | ||
| 179 | return 0; | ||
| 180 | } | ||