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/selftest.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/selftest.cpp')
| -rw-r--r-- | src/selftest.cpp | 77 |
1 files changed, 76 insertions, 1 deletions
diff --git a/src/selftest.cpp b/src/selftest.cpp index 034e1f7..9f7106f 100644 --- a/src/selftest.cpp +++ b/src/selftest.cpp | |||
| @@ -6,10 +6,12 @@ | |||
| 6 | // and against a temporary data directory. | 6 | // and against a temporary data directory. |
| 7 | 7 | ||
| 8 | #include "headers_core.h" | 8 | #include "headers_core.h" |
| 9 | #include "btfaddr.h" | ||
| 9 | #include "bip32.h" | 10 | #include "bip32.h" |
| 10 | #include "proxy.h" | 11 | #include "proxy.h" |
| 11 | #include "selftest.h" | 12 | #include "selftest.h" |
| 12 | #include "sockcount.h" | 13 | #include "sockcount.h" |
| 14 | #include "tor.h" | ||
| 13 | #include "walletcmd.h" | 15 | #include "walletcmd.h" |
| 14 | 16 | ||
| 15 | extern int RunPoolStratumSelfTest(); | 17 | extern int RunPoolStratumSelfTest(); |
| @@ -587,6 +589,34 @@ static int RunWalletHDSelfTest() | |||
| 587 | "the recovery audit finds wallet.dat-only immature mining rewards") ? 0 : 1; | 589 | "the recovery audit finds wallet.dat-only immature mining rewards") ? 0 : 1; |
| 588 | nFail += Check(audit.nLegacyImmatureTx == 1, | 590 | nFail += Check(audit.nLegacyImmatureTx == 1, |
| 589 | "the recovery audit counts wallet.dat-only immature mining rewards") ? 0 : 1; | 591 | "the recovery audit counts wallet.dat-only immature mining rewards") ? 0 : 1; |
| 592 | |||
| 593 | CKey keyLegacyHD11; | ||
| 594 | nSchemaForLegacyAudit = nHDKeySchema; | ||
| 595 | nHDKeySchema = HD_SCHEMA_LEGACY; | ||
| 596 | if (!DeriveHDKey(11, keyLegacyHD11, strError)) | ||
| 597 | throw std::runtime_error("legacy compatibility index 11 derivation failed: " + strError); | ||
| 598 | nHDKeySchema = nSchemaForLegacyAudit; | ||
| 599 | if (!AddKey(keyLegacyHD11)) | ||
| 600 | throw std::runtime_error("could not store the legacy compatibility index 11 key"); | ||
| 601 | |||
| 602 | std::map<unsigned int, std::vector<unsigned char> > mapLegacyProbe; | ||
| 603 | mapLegacyProbe[0] = keyAuditLegacyHD.GetPubKey(); | ||
| 604 | mapLegacyProbe[11] = keyLegacyHD11.GetPubKey(); | ||
| 605 | |||
| 606 | CWalletTx wtxLegacyHD11; | ||
| 607 | wtxLegacyHD11.vout.push_back(CTxOut(19 * COIN, CScript() << keyLegacyHD11.GetPubKey() << OP_CHECKSIG)); | ||
| 608 | CRITICAL_BLOCK(cs_mapWallet) | ||
| 609 | { | ||
| 610 | mapWallet.clear(); | ||
| 611 | mapWallet[wtxLegacyHD11.GetHash()] = wtxLegacyHD11; | ||
| 612 | } | ||
| 613 | nFail += Check(WalletLastUsedPubKeyIndexNext(mapLegacyProbe) == 12, | ||
| 614 | "restore collapses legacy hdnext to the last used compatibility index plus one") ? 0 : 1; | ||
| 615 | |||
| 616 | CRITICAL_BLOCK(cs_mapWallet) | ||
| 617 | mapWallet.clear(); | ||
| 618 | nFail += Check(WalletLastUsedPubKeyIndexNext(mapLegacyProbe) == 0, | ||
| 619 | "restore does not persist legacy hdnext at the scan depth when no compatibility key was used") ? 0 : 1; | ||
| 590 | } | 620 | } |
| 591 | catch (const std::exception& e) | 621 | catch (const std::exception& e) |
| 592 | { | 622 | { |
| @@ -1505,6 +1535,14 @@ static int RunSocks5ProxySelfTest() | |||
| 1505 | !BtfIsTorOnionHost("relay.example") && | 1535 | !BtfIsTorOnionHost("relay.example") && |
| 1506 | !BtfIsTorOnionHost(".onion"), | 1536 | !BtfIsTorOnionHost(".onion"), |
| 1507 | "detects .onion hosts without accepting lookalikes") ? 0 : 1; | 1537 | "detects .onion hosts without accepting lookalikes") ? 0 : 1; |
| 1538 | std::string onion; | ||
| 1539 | nFail += Check(btf::NormalizeOnionEndpoint("ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCD.onion.:8433", onion) && | ||
| 1540 | onion == "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd.onion:8433", | ||
| 1541 | "normalizes v3 onion peer endpoint") ? 0 : 1; | ||
| 1542 | nFail += Check(!btf::NormalizeOnionEndpoint("short.onion:8433", onion) && | ||
| 1543 | !btf::NormalizeOnionEndpoint("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd.onion:0", onion) && | ||
| 1544 | !btf::NormalizeOnionEndpoint("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabc1.onion:8433", onion), | ||
| 1545 | "rejects malformed onion peer endpoints") ? 0 : 1; | ||
| 1508 | 1546 | ||
| 1509 | BtfClearSocks5Proxy(); | 1547 | BtfClearSocks5Proxy(); |
| 1510 | nFail += Check(!BtfSocks5ProxyEnabled(), "starts disabled after clear") ? 0 : 1; | 1548 | nFail += Check(!BtfSocks5ProxyEnabled(), "starts disabled after clear") ? 0 : 1; |
| @@ -1554,6 +1592,41 @@ static int RunSocks5ProxySelfTest() | |||
| 1554 | return nFail == 0 ? 0 : 1; | 1592 | return nFail == 0 ? 0 : 1; |
| 1555 | } | 1593 | } |
| 1556 | 1594 | ||
| 1595 | static int RunManagedTorSelfTest() | ||
| 1596 | { | ||
| 1597 | printf("managed-tor self-test\n"); | ||
| 1598 | int nFail = 0; | ||
| 1599 | |||
| 1600 | std::string torrc = BtfBuildManagedTorrcForTest("C:/Bitflash Managed Tor/data", | ||
| 1601 | "C:/Bitflash Managed Tor/onion-service", | ||
| 1602 | 19050, 19051, 8433); | ||
| 1603 | nFail += Check(torrc.find("DataDirectory \"C:/Bitflash Managed Tor/data\"") != std::string::npos, | ||
| 1604 | "quotes the Tor data directory") ? 0 : 1; | ||
| 1605 | nFail += Check(torrc.find("SocksPort 127.0.0.1:19050") != std::string::npos, | ||
| 1606 | "binds SOCKS5 to localhost only") ? 0 : 1; | ||
| 1607 | nFail += Check(torrc.find("ControlPort 127.0.0.1:19051") != std::string::npos && | ||
| 1608 | torrc.find("CookieAuthentication 1") != std::string::npos, | ||
| 1609 | "binds an authenticated Tor control port to localhost only") ? 0 : 1; | ||
| 1610 | nFail += Check(torrc.find("IsolateSOCKSAuth") != std::string::npos && | ||
| 1611 | torrc.find("IsolateClientAddr") != std::string::npos && | ||
| 1612 | torrc.find("IsolateDestAddr") != std::string::npos && | ||
| 1613 | torrc.find("IsolateDestPort") != std::string::npos, | ||
| 1614 | "enables strict Tor stream isolation") ? 0 : 1; | ||
| 1615 | nFail += Check(torrc.find("HiddenServiceDir \"C:/Bitflash Managed Tor/onion-service\"") != std::string::npos, | ||
| 1616 | "writes a hidden service directory") ? 0 : 1; | ||
| 1617 | nFail += Check(torrc.find("HiddenServiceVersion 3") != std::string::npos, | ||
| 1618 | "requests a v3 onion service") ? 0 : 1; | ||
| 1619 | nFail += Check(torrc.find("HiddenServicePort 8433 127.0.0.1:8433") != std::string::npos, | ||
| 1620 | "maps the onion service to the Bitflash P2P listener") ? 0 : 1; | ||
| 1621 | nFail += Check(BtfManagedTorStatus() == "disabled", | ||
| 1622 | "managed Tor starts disabled") ? 0 : 1; | ||
| 1623 | |||
| 1624 | printf("%s (%d failure%s)\n", nFail == 0 ? "ALL TESTS PASSED" : "TESTS FAILED", | ||
| 1625 | nFail, nFail == 1 ? "" : "s"); | ||
| 1626 | fflush(stdout); | ||
| 1627 | return nFail == 0 ? 0 : 1; | ||
| 1628 | } | ||
| 1629 | |||
| 1557 | int RunSelfTest(const std::string& name) | 1630 | int RunSelfTest(const std::string& name) |
| 1558 | { | 1631 | { |
| 1559 | AttachTerminal(); | 1632 | AttachTerminal(); |
| @@ -1580,8 +1653,10 @@ int RunSelfTest(const std::string& name) | |||
| 1580 | return RunParseMoneySelfTest(); | 1653 | return RunParseMoneySelfTest(); |
| 1581 | if (name == "socks5-proxy") | 1654 | if (name == "socks5-proxy") |
| 1582 | return RunSocks5ProxySelfTest(); | 1655 | return RunSocks5ProxySelfTest(); |
| 1656 | if (name == "managed-tor") | ||
| 1657 | return RunManagedTorSelfTest(); | ||
| 1583 | 1658 | ||
| 1584 | printf("Unknown self-test '%s'\n", name.c_str()); | 1659 | printf("Unknown self-test '%s'\n", name.c_str()); |
| 1585 | printf("Known self-tests: wallet-keypool, wallet-hd, wallet-format, wallet-crypto, wallet-encrypt, net-message, consensus-limits, pool-stratum, payout-ledger, parse-money, socks5-proxy\n"); | 1660 | printf("Known self-tests: wallet-keypool, wallet-hd, wallet-format, wallet-crypto, wallet-encrypt, net-message, consensus-limits, pool-stratum, payout-ledger, parse-money, socks5-proxy, managed-tor\n"); |
| 1586 | return 1; | 1661 | return 1; |
| 1587 | } | 1662 | } |