diff options
| author | bitflash-maintainer <noreply@bitflash.invalid> | 2026-08-26 22:41:53 +0000 |
|---|---|---|
| committer | bitflash-maintainer <noreply@bitflash.invalid> | 2026-08-26 22:41:53 +0000 |
| commit | bbe04dc8c96b4c4766d2771d3438233bf82687c0 (patch) | |
| tree | 62e5a1febfb8e9bc38d133ac7981e9ef93918484 /src/main_gui.cpp | |
| parent | 991853fa55a749d28d6f9e507ce72b289df92785 (diff) | |
| parent | 9e39a50d1f110020b0841d31e4b931aa877cc448 (diff) | |
Merge upstream v1.2.19 into the fork
Merges upstream tag v1.2.19 (9e39a50) into merge/upstream-1.2.18 (991853f).
Unlike the 1.2.15->1.2.18 replay, bc3de30 is a true ancestor of our branch via
a9b4f89, so this is an ordinary three-way merge with merge-base bc3de30.
Delta: 36 files, +3265/-163, the Tor onion transport (managed Tor, signed
direct onion endpoints, onion-only dial mode) and the nHDNext restore fix.
src/main.cpp, main.h, script.cpp/h and db.cpp/h are byte-identical between the
two tags, and the poll() socket loop carries no diff hunks, so the merge is
consensus-neutral and the soak-tested socket paths are unchanged. relay/ is
untouched; the payout ledger (rpc.cpp) is untouched.
7 conflict blocks in 6 files, resolved as follows.
Makefile -- VERSION. Ours: stays 1.2.19+sec with the naming comment updated,
so artifacts from this tree cannot be mistaken for the upstream release.
src/Makefile, src/makefile.mingw -- HEADERS list. Ours (no market.h) plus
their tor.h. NODE_OBJS auto-merged correctly: no market.o, tor.o present.
src/selftest.cpp -- known-tests list. Union: payout-ledger (ours) and
managed-tor (theirs).
src/main_gui.cpp -- one block. Our /dumpaddresses kept; their
BtfStopManagedTor() on the StartNode failure path taken. The /rvrelay pin,
/noannounce and the marketplace removal auto-merged and were verified intact.
src/nostr.cpp -- two blocks in ResolveDescriptor. Signature takes both
out-params (our fExchangeOk, their rawOut). The body keeps our
drain-to-EOSE read -- returning early poisons the pooled socket for the next
caller -- and adds their rawOut capture. Our TLS 1.2 floor
(SSL_CTX_set_min_proto_version) is untouched by this merge; upstream 1.2.19
still has no floor of its own.
Upstream's release commit also added four build logs and a compiled Python
cache (build-1219.log, build-17.log, build-appimage.log, build-node.log,
scripts/__pycache__/bitflash_chain.cpython-313.pyc). Removed here; they are
build output, not source.
Diffstat (limited to 'src/main_gui.cpp')
| -rw-r--r-- | src/main_gui.cpp | 96 |
1 files changed, 74 insertions, 22 deletions
diff --git a/src/main_gui.cpp b/src/main_gui.cpp index e941522..e8dacd3 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp | |||
| @@ -1,8 +1,10 @@ | |||
| 1 | // Bitflash entry point -- starts node threads then runs GUI (or headless). | 1 | // Bitflash entry point -- starts node threads then runs GUI (or headless). |
| 2 | 2 | ||
| 3 | #include "headers_core.h" | 3 | #include "headers_core.h" |
| 4 | #include "nostr.h" | ||
| 4 | #include "proxy.h" | 5 | #include "proxy.h" |
| 5 | #include "selftest.h" | 6 | #include "selftest.h" |
| 7 | #include "tor.h" | ||
| 6 | #include "walletcmd.h" | 8 | #include "walletcmd.h" |
| 7 | #include <thread> // hardware_concurrency, to sanity-check /genproclimit | 9 | #include <thread> // hardware_concurrency, to sanity-check /genproclimit |
| 8 | #ifndef _WIN32 | 10 | #ifndef _WIN32 |
| @@ -112,7 +114,7 @@ static void PrintUsage() | |||
| 112 | printf(" /gen\n"); | 114 | printf(" /gen\n"); |
| 113 | printf(" /nogui or /daemon\n"); | 115 | printf(" /nogui or /daemon\n"); |
| 114 | printf(" /selftest=wallet-keypool, wallet-hd, wallet-format, wallet-crypto, wallet-encrypt,\n"); | 116 | printf(" /selftest=wallet-keypool, wallet-hd, wallet-format, wallet-crypto, wallet-encrypt,\n"); |
| 115 | printf(" net-message, consensus-limits, pool-stratum, parse-money, or socks5-proxy\n"); | 117 | printf(" net-message, consensus-limits, pool-stratum, parse-money, socks5-proxy, or managed-tor\n"); |
| 116 | printf("\n"); | 118 | printf("\n"); |
| 117 | printf("Mining mode:\n"); | 119 | printf("Mining mode:\n"); |
| 118 | printf(" /operator\n"); | 120 | printf(" /operator\n"); |
| @@ -137,11 +139,15 @@ static void PrintUsage() | |||
| 137 | printf(" /connectbtf=PEER_BTF_ADDRESS\n"); | 139 | printf(" /connectbtf=PEER_BTF_ADDRESS\n"); |
| 138 | printf(" /rvrelay=HOST:PORT\n"); | 140 | printf(" /rvrelay=HOST:PORT\n"); |
| 139 | printf(" /announcerelay=HOST:PORT\n"); | 141 | printf(" /announcerelay=HOST:PORT\n"); |
| 142 | printf(" /onionservice=HOST.onion:PORT (advertise this node's Tor hidden service)\n"); | ||
| 140 | printf("\n"); | 143 | printf("\n"); |
| 141 | printf("Network:\n"); | 144 | printf("Network:\n"); |
| 142 | printf(" /port=N (P2P listen port, default 8433)\n"); | 145 | printf(" /port=N (P2P listen port, default 8433)\n"); |
| 143 | printf(" /socks=HOST:PORT (SOCKS5 proxy for outbound Nostr and .btf relay dials)\n"); | 146 | printf(" /socks=HOST:PORT (SOCKS5 proxy for Nostr, .btf relay, and onion dials)\n"); |
| 144 | printf(" /tor[=HOST:PORT] (Tor mode; default SOCKS5 proxy is 127.0.0.1:9050)\n"); | 147 | printf(" /tor[=HOST:PORT] (Tor mode; default SOCKS5 proxy is 127.0.0.1:9050)\n"); |
| 148 | printf(" /managedtor[=PATH] (start Tor, create a hidden service, advertise its onion)\n"); | ||
| 149 | printf(" /nomanagedtor (disable automatic bundled Tor startup)\n"); | ||
| 150 | printf(" /oniononly (do not fall back to rendezvous when a .btf onion dial fails)\n"); | ||
| 145 | printf(" /btfseed=ADDRESS:ENCHEX (extra bootstrap peer, repeatable)\n"); | 151 | printf(" /btfseed=ADDRESS:ENCHEX (extra bootstrap peer, repeatable)\n"); |
| 146 | printf("\n"); | 152 | printf("\n"); |
| 147 | printf("Wallet:\n"); | 153 | printf("Wallet:\n"); |
| @@ -295,6 +301,7 @@ static void ParseStartupArguments(int argc, char* argv[]) | |||
| 295 | string btfConnect = argval2(argc, argv, "/connectbtf", "-connectbtf"); | 301 | string btfConnect = argval2(argc, argv, "/connectbtf", "-connectbtf"); |
| 296 | if (!btfConnect.empty()) | 302 | if (!btfConnect.empty()) |
| 297 | strBtfConnect = btfConnect; | 303 | strBtfConnect = btfConnect; |
| 304 | fBtfOnionOnly = arg(argc, argv, "/oniononly") || arg(argc, argv, "-oniononly"); | ||
| 298 | 305 | ||
| 299 | string rvRelay = argval2(argc, argv, "/rvrelay", "-rvrelay"); | 306 | string rvRelay = argval2(argc, argv, "/rvrelay", "-rvrelay"); |
| 300 | if (!rvRelay.empty()) | 307 | if (!rvRelay.empty()) |
| @@ -315,14 +322,67 @@ static void ParseStartupArguments(int argc, char* argv[]) | |||
| 315 | } | 322 | } |
| 316 | } | 323 | } |
| 317 | 324 | ||
| 325 | // net.cpp has described nListenPort as "tunable via /port" since it was | ||
| 326 | // written, but nothing ever read the option, so the port was fixed at 8433 | ||
| 327 | // and a second node could not start on a machine already running one. Parse | ||
| 328 | // it before Tor setup so a managed hidden service maps the real listener. | ||
| 329 | string strPort = argval2(argc, argv, "/port", "-port"); | ||
| 330 | if (!strPort.empty()) | ||
| 331 | { | ||
| 332 | int nPort = atoi(strPort.c_str()); | ||
| 333 | if (nPort <= 0 || nPort > 65535) | ||
| 334 | fprintf(stderr, "Ignoring /port=%s: not a port number\n", strPort.c_str()); | ||
| 335 | else | ||
| 336 | { | ||
| 337 | nListenPort = htons((unsigned short)nPort); | ||
| 338 | // Or we would announce a port we never bound. | ||
| 339 | addrLocalHost.port = nListenPort; | ||
| 340 | } | ||
| 341 | } | ||
| 342 | |||
| 318 | string announceRelay = argval2(argc, argv, "/announcerelay", "-announcerelay"); | 343 | string announceRelay = argval2(argc, argv, "/announcerelay", "-announcerelay"); |
| 319 | if (!announceRelay.empty()) | 344 | if (!announceRelay.empty()) |
| 320 | strBtfAnnounceRelay = announceRelay; | 345 | strBtfAnnounceRelay = announceRelay; |
| 321 | 346 | ||
| 347 | string onionService = argval2(argc, argv, "/onionservice", "-onionservice"); | ||
| 348 | if (!onionService.empty()) | ||
| 349 | { | ||
| 350 | string err; | ||
| 351 | if (!BtfSetLocalOnionEndpoint(onionService, err)) | ||
| 352 | fprintf(stderr, "Ignoring /onionservice=%s: %s\n", onionService.c_str(), err.c_str()); | ||
| 353 | else | ||
| 354 | fprintf(stderr, "Direct onion peer endpoint advertised: %s\n", | ||
| 355 | BtfLocalOnionEndpoint().c_str()); | ||
| 356 | } | ||
| 357 | |||
| 358 | bool fManagedTor = arg(argc, argv, "/managedtor") || arg(argc, argv, "-managedtor"); | ||
| 359 | bool fNoManagedTor = arg(argc, argv, "/nomanagedtor") || arg(argc, argv, "-nomanagedtor"); | ||
| 322 | bool fTorMode = arg(argc, argv, "/tor") || arg(argc, argv, "-tor"); | 360 | bool fTorMode = arg(argc, argv, "/tor") || arg(argc, argv, "-tor"); |
| 323 | if (fTorMode) | 361 | string socksProxy = argval2(argc, argv, "/socks", "-socks"); |
| 362 | string bundledTorPath; | ||
| 363 | bool fAutoManagedTor = !fManagedTor && !fNoManagedTor && !fTorMode && | ||
| 364 | socksProxy.empty() && BtfBundledTorPath(bundledTorPath); | ||
| 365 | if (fManagedTor || fAutoManagedTor) | ||
| 366 | { | ||
| 367 | if (fManagedTor && (fTorMode || !socksProxy.empty())) | ||
| 368 | fprintf(stderr, "Warning: /managedtor takes precedence over /tor and /socks\n"); | ||
| 369 | |||
| 370 | string torPath = fManagedTor ? argval2(argc, argv, "/managedtor", "-managedtor") : bundledTorPath; | ||
| 371 | string err; | ||
| 372 | if (!BtfStartManagedTor(torPath, err)) | ||
| 373 | { | ||
| 374 | if (fAutoManagedTor) | ||
| 375 | fprintf(stderr, "Bundled Tor not enabled automatically: %s\n", err.c_str()); | ||
| 376 | else | ||
| 377 | fprintf(stderr, "Ignoring /managedtor=%s: %s\n", torPath.c_str(), err.c_str()); | ||
| 378 | } | ||
| 379 | else | ||
| 380 | fprintf(stderr, "Managed Tor enabled%s: %s\n", | ||
| 381 | fAutoManagedTor ? " automatically" : "", | ||
| 382 | BtfManagedTorStatus().c_str()); | ||
| 383 | } | ||
| 384 | else if (fTorMode) | ||
| 324 | { | 385 | { |
| 325 | string socksProxy = argval2(argc, argv, "/socks", "-socks"); | ||
| 326 | if (!socksProxy.empty()) | 386 | if (!socksProxy.empty()) |
| 327 | fprintf(stderr, "Warning: /tor takes precedence over /socks=%s\n", | 387 | fprintf(stderr, "Warning: /tor takes precedence over /socks=%s\n", |
| 328 | socksProxy.c_str()); | 388 | socksProxy.c_str()); |
| @@ -337,7 +397,6 @@ static void ParseStartupArguments(int argc, char* argv[]) | |||
| 337 | } | 397 | } |
| 338 | else | 398 | else |
| 339 | { | 399 | { |
| 340 | string socksProxy = argval2(argc, argv, "/socks", "-socks"); | ||
| 341 | if (!socksProxy.empty()) | 400 | if (!socksProxy.empty()) |
| 342 | { | 401 | { |
| 343 | string err; | 402 | string err; |
| @@ -348,6 +407,8 @@ static void ParseStartupArguments(int argc, char* argv[]) | |||
| 348 | BtfSocks5ProxyName().c_str()); | 407 | BtfSocks5ProxyName().c_str()); |
| 349 | } | 408 | } |
| 350 | } | 409 | } |
| 410 | if (fBtfOnionOnly && !BtfSocks5ProxyEnabled()) | ||
| 411 | fprintf(stderr, "Warning: /oniononly without /tor, /managedtor, or /socks cannot dial .onion peers\n"); | ||
| 351 | 412 | ||
| 352 | // /btfseed=ADDRESS:ENCHEX -- extra bootstrap peers, repeatable. Useful for | 413 | // /btfseed=ADDRESS:ENCHEX -- extra bootstrap peers, repeatable. Useful for |
| 353 | // testing the seed path and for private networks that ship no compiled list. | 414 | // testing the seed path and for private networks that ship no compiled list. |
| @@ -368,22 +429,6 @@ static void ParseStartupArguments(int argc, char* argv[]) | |||
| 368 | vBtfExtraSeeds.push_back(make_pair(val.substr(0, colon), val.substr(colon + 1))); | 429 | vBtfExtraSeeds.push_back(make_pair(val.substr(0, colon), val.substr(colon + 1))); |
| 369 | } | 430 | } |
| 370 | 431 | ||
| 371 | // net.cpp has described nListenPort as "tunable via /port" since it was | ||
| 372 | // written, but nothing ever read the option, so the port was fixed at 8433 | ||
| 373 | // and a second node could not start on a machine already running one. | ||
| 374 | string strPort = argval2(argc, argv, "/port", "-port"); | ||
| 375 | if (!strPort.empty()) | ||
| 376 | { | ||
| 377 | int nPort = atoi(strPort.c_str()); | ||
| 378 | if (nPort <= 0 || nPort > 65535) | ||
| 379 | fprintf(stderr, "Ignoring /port=%s: not a port number\n", strPort.c_str()); | ||
| 380 | else | ||
| 381 | { | ||
| 382 | nListenPort = htons((unsigned short)nPort); | ||
| 383 | // Or we would announce a port we never bound. | ||
| 384 | addrLocalHost.port = nListenPort; | ||
| 385 | } | ||
| 386 | } | ||
| 387 | } | 432 | } |
| 388 | 433 | ||
| 389 | // Report a startup failure somewhere the user will actually see it. | 434 | // Report a startup failure somewhere the user will actually see it. |
| @@ -760,7 +805,12 @@ int main(int argc, char* argv[]) | |||
| 760 | return 0; | 805 | return 0; |
| 761 | } | 806 | } |
| 762 | 807 | ||
| 763 | if (!StartNode(strErrors)) { fprintf(stderr,"StartNode: %s\n",strErrors.c_str()); return 1; } | 808 | if (!StartNode(strErrors)) |
| 809 | { | ||
| 810 | fprintf(stderr,"StartNode: %s\n",strErrors.c_str()); | ||
| 811 | BtfStopManagedTor(); | ||
| 812 | return 1; | ||
| 813 | } | ||
| 764 | 814 | ||
| 765 | if (nMineMode == MINE_OPERATOR) { | 815 | if (nMineMode == MINE_OPERATOR) { |
| 766 | gPoolServerRunning = true; | 816 | gPoolServerRunning = true; |
| @@ -793,6 +843,7 @@ int main(int argc, char* argv[]) | |||
| 793 | printf("Running headless. Ctrl-C to stop.\n"); | 843 | printf("Running headless. Ctrl-C to stop.\n"); |
| 794 | while (!fShutdown) Sleep(500); | 844 | while (!fShutdown) Sleep(500); |
| 795 | StopNode(); | 845 | StopNode(); |
| 846 | BtfStopManagedTor(); | ||
| 796 | // Checkpoints, releases wallet.dat from this directory's Berkeley DB | 847 | // Checkpoints, releases wallet.dat from this directory's Berkeley DB |
| 797 | // environment, and closes it. Declared since 2009 and never once | 848 | // environment, and closes it. Declared since 2009 and never once |
| 798 | // called here, which is why a wallet.dat copied elsewhere would not | 849 | // called here, which is why a wallet.dat copied elsewhere would not |
| @@ -812,6 +863,7 @@ int main(int argc, char* argv[]) | |||
| 812 | int ret = RunGUI(argc, argv); | 863 | int ret = RunGUI(argc, argv); |
| 813 | fShutdown = true; | 864 | fShutdown = true; |
| 814 | StopNode(); | 865 | StopNode(); |
| 866 | BtfStopManagedTor(); | ||
| 815 | DBFlush(true); | 867 | DBFlush(true); |
| 816 | return ret; | 868 | return ret; |
| 817 | #endif | 869 | #endif |