hygiene: Phase 5 — correct stale comments + name safe magic numbers

Fifth phase of the code-hygiene remediation, done per-file (18 files) via an
18-agent Workflow with strict guardrails. No consensus or security VALUES
changed (verified: pow/hush_utils/hush_bitcoind/net.h/crypter/stratum have
zero non-comment numeric changes); built clean, self-mined, verifychain=true.

Totals: 57 stale comments corrected, 46 user-facing branding fixes, 6
behavior-preserving named constants, 4 stratum warnings, 77 items deliberately
left (consensus/security values, copyright headers).

- Stale comments -> DragonX: corrected HUSH3/HUSH/Komodo/Equihash/Arrakis
  leftovers that misdescribed the active chain (pow AWT/lwma notes, txdb
  "Equihash solution" -> RandomX, wallet CLTV/overwinter/Sapling@1 notes,
  util datadir provenance, crypter's stale mapSproutSpendingKeys invariant).
  Replaced unprofessional/editorializing comments (profane TODOs, "developers
  are elite") with neutral technical notes, preserving the real design info.
- User-facing branding: dumpwallet header "created by Hush" -> "DragonX";
  RPC help text hushd/hush-cli/hushprivkey/hushaddress/Agama -> dragonx*;
  rebranded provably-dead "HUSH3" symbol-fallback literals to DRAGONX.
- Named constants (same values, non-consensus/non-security): addrman
  peer-selection factors (kChanceFactorGrowth/kChanceScale/deprioritize),
  sietch MIN_ZOUTS, an init notarization-DB cache size.
- Left the security macros (ECC/TFM_TIMING_RESISTANT=420, comment-clarified
  only), the consensus subsidy/commission literals + 128/129 TRANSITION
  (comment only), and copyright headers untouched.
- Added a prominent WARNING that the stratum server is Equihash-era and NOT
  updated for DragonX's RandomX PoW (flagged, not rewritten).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-27 15:19:22 -05:00
co-authored by Claude Opus 4.8
parent cf15b0a399
commit 817c6b2d0e
18 changed files with 251 additions and 141 deletions
+33 -27
View File
@@ -364,7 +364,7 @@ UniValue setaccount(const UniValue& params, bool fHelp, const CPubKey& mypk)
CTxDestination dest = DecodeDestination(params[0].get_str());
if (!IsValidDestination(dest)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Hush address!");
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid DragonX address!");
}
string strAccount;
@@ -411,7 +411,7 @@ UniValue getaccount(const UniValue& params, bool fHelp, const CPubKey& mypk)
CTxDestination dest = DecodeDestination(params[0].get_str());
if (!IsValidDestination(dest)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Hush address!");
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid DragonX address!");
}
std::string strAccount;
@@ -571,7 +571,7 @@ UniValue sendtoaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
CTxDestination dest = DecodeDestination(params[0].get_str());
if (!IsValidDestination(dest)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Hush address!");
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid DragonX address!");
}
// Amount
@@ -705,7 +705,8 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk)
}
}
}
ret.push_back(Pair("coin",(char *)(SMART_CHAIN_SYMBOL[0] == 0 ? "HUSH3" : SMART_CHAIN_SYMBOL)));
// The SMART_CHAIN_SYMBOL[0]==0 fallback is dead on DragonX (symbol is always "DRAGONX"); kept for defensiveness.
ret.push_back(Pair("coin",(char *)(SMART_CHAIN_SYMBOL[0] == 0 ? "DRAGONX" : SMART_CHAIN_SYMBOL)));
height = chainActive.LastTip()->GetHeight();
if ( memcmp(&zeroes,&refpubkey,sizeof(refpubkey)) != 0 )
ret.push_back(Pair("owner",refpubkey.GetHex()));
@@ -895,7 +896,7 @@ UniValue getreceivedbyaddress(const UniValue& params, bool fHelp, const CPubKey&
// Bitcoin address
CTxDestination dest = DecodeDestination(params[0].get_str());
if (!IsValidDestination(dest)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Hush address!");
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid DragonX address!");
}
CScript scriptPubKey = GetScriptForDestination(dest);
if (!IsMine(*pwalletMain, scriptPubKey)) {
@@ -1452,7 +1453,7 @@ UniValue sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk)
CScript tmpspk;
tmpspk << ParseHex(name_) << OP_CHECKSIG;
if ( !ExtractDestination(tmpspk, dest, true) )
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Hush address or pubkey: ") + name_);
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid DragonX address or pubkey: ") + name_);
}
CScript scriptPubKey = GetScriptForDestination(dest);
@@ -2546,7 +2547,7 @@ UniValue encryptwallet(const UniValue& params, bool fHelp, const CPubKey& mypk)
// slack space in .dat files; that is bad if the old data is
// unencrypted private keys. So:
StartShutdown();
return "wallet encrypted; Hush server stopping, restart to run with encrypted wallet. The keypool has been flushed, you need to make a new backup.";
return "wallet encrypted; DragonX server stopping, restart to run with encrypted wallet. The keypool has been flushed, you need to make a new backup.";
}
UniValue lockunspent(const UniValue& params, bool fHelp, const CPubKey& mypk)
@@ -2854,7 +2855,7 @@ UniValue listunspent(const UniValue& params, bool fHelp, const CPubKey& mypk)
" \"txid\" : \"txid\", (string) the transaction id \n"
" \"vout\" : n, (numeric) the vout value\n"
" \"generated\" : true|false (boolean) true if txout is a coinbase transaction output\n"
" \"address\" : \"address\", (string) the Hush address\n"
" \"address\" : \"address\", (string) the DragonX address\n"
" \"account\" : \"account\", (string) DEPRECATED. The associated account, or \"\" for the default account\n"
" \"scriptPubKey\" : \"key\", (string) the script key\n"
" \"amount\" : x.xxx, (numeric) the transaction amount in " + CURRENCY_UNIT + "\n"
@@ -2888,7 +2889,7 @@ UniValue listunspent(const UniValue& params, bool fHelp, const CPubKey& mypk)
const UniValue& input = inputs[idx];
CTxDestination dest = DecodeDestination(input.get_str());
if (!IsValidDestination(dest)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Hush address: ") + input.get_str());
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid DragonX address: ") + input.get_str());
}
if (!destinations.insert(dest).second) {
throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated address: ") + input.get_str());
@@ -3423,7 +3424,7 @@ UniValue z_listreceivedaddress(const UniValue& params, bool fHelp,const CPubKey&
"This function is slow if no filters are given, use z_listreceivedbyaddress if you do not need filters."
"\n"
"\nArguments:\n"
"1. \"hushaddress:\" (string, required) \n"
"1. \"dragonxaddress:\" (string, required) \n"
"\n"
"2. \"Minimum Confimations:\" (numeric, optional, default=0) \n"
"\n"
@@ -3460,13 +3461,13 @@ UniValue z_listreceivedaddress(const UniValue& params, bool fHelp,const CPubKey&
" \"walletconflicts\": [conflicts], An array of wallet conflicts\n"
" \"recieved\": { A list of receives from the transaction\n"
" \"transparentReceived\": [{ An Array of txos received for transparent addresses\n"
" \"address\": \"hushaddress\", (string) Hush transparent address (t-address)\n"
" \"address\": \"dragonxaddress\", (string) DragonX transparent address (t-address)\n"
" \"scriptPubKey\": \"script\", (string) Script for the transparent address (t-address)\n"
" \"amount\": x.xxxx, (numeric) Value of output being received " + CURRENCY_UNIT + ", positive for receives\n"
" \"vout\": : n, (numeric) the vout value\n"
" }],\n"
" \"saplingReceived\": [{ An Array of utxos/notes received for sapling addresses\n"
" \"address\": \"hushaddress\", (string) Shielded address (z-address)\n"
" \"address\": \"dragonxaddress\", (string) Shielded address (z-address)\n"
" \"amount\": x.xxxx, (numeric) Value of output being received " + CURRENCY_UNIT + ", positive for receives\n"
" \"memo\": xxxxx, (string) hexademical string representation of memo field\n"
" \"memoStr\" : \"memo\", (string) Only returned if memo contains valid UTF-8 text.\n"
@@ -3599,12 +3600,12 @@ UniValue z_listsentbyaddress(const UniValue& params, bool fHelp,const CPubKey&)
if (fHelp || params.size() > 5 || params.size() == 3)
throw runtime_error(
"z_listsentbyaddress\n"
"\nReturns decrypted Hush outputs sent to a single address.\n"
"\nReturns decrypted DragonX outputs sent to a single address.\n"
"\n"
"This function only returns information on addresses sent from wallet addresses with full spending keys."
"\n"
"\nArguments:\n"
"1. \"hushaddress:\" (string, required) \n"
"1. \"dragonxaddress:\" (string, required) \n"
"\n"
"2. \"Minimum Confimations:\" (numeric, optional, default=0) \n"
"\n"
@@ -3642,13 +3643,13 @@ UniValue z_listsentbyaddress(const UniValue& params, bool fHelp,const CPubKey&)
" \"sends\": { A list of outputs of where funds were sent to in the transaction,\n"
" only available if the transaction has valid sends (inputs) belonging to the wallet\n"
" \"transparentSends\": [{ An Array of spends (outputs) for transparent addresses of the receipient\n"
" \"address\": \"hushaddress\", (string) Hush transparent address (t-address)\n"
" \"scriptPubKey\": \"script\", (string) Script for the Hush transparent address (t-address)\n"
" \"address\": \"dragonxaddress\", (string) DragonX transparent address (t-address)\n"
" \"scriptPubKey\": \"script\", (string) Script for the DragonX transparent address (t-address)\n"
" \"amount\": x.xxxx, (numeric) Value of output being sent " + CURRENCY_UNIT + ", negative for sends\n"
" \"vout\": : n, (numeric) the vout value\n"
" }],\n"
" \"saplingSends\": [{ An Array of spends (outputs) for sapling addresses\n"
" \"address\": \"hushaddress\", (string) Hush sapling address (z-address) of the receipient\n"
" \"address\": \"dragonxaddress\", (string) DragonX sapling address (z-address) of the receipient\n"
" \"amount\": x.xxxx, (numeric) Value of output being sent" + CURRENCY_UNIT + ", negative for sends\n"
" \"memo\": xxxxx, (string) hexademical string representation of memo field\n"
" \"memoStr\" : \"memo\", (string) Only returned if memo contains valid UTF-8 text.\n"
@@ -4277,7 +4278,7 @@ UniValue z_listunspent(const UniValue& params, bool fHelp, const CPubKey& mypk)
string address = o.get_str();
auto zaddr = DecodePaymentAddress(address);
if (!IsValidPaymentAddress(zaddr)) {
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, address is not a valid Hush zaddr: ") + address);
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, address is not a valid DragonX zaddr: ") + address);
}
auto hasSpendingKey = boost::apply_visitor(HaveSpendingKeyForPaymentAddress(pwalletMain), zaddr);
if (!fIncludeWatchonly && !hasSpendingKey) {
@@ -4820,7 +4821,7 @@ UniValue z_gettotalbalance(const UniValue& params, bool fHelp, const CPubKey& my
// getbalance and "getbalance * 1 true" should return the same number
// but they don't because wtx.GetAmounts() does not handle tx where there are no outputs
// pwalletMain->GetBalance() does not accept min depth parameter
// so we use our own method to get balance of utxos, lulzwtfbbq
// so we use our own method to get balance of utxos
CAmount nBalance = getBalanceTaddr("", nMinDepth, !fIncludeWatchonly);
CAmount nPrivateBalance = getBalanceZaddr("", nMinDepth, !fIncludeWatchonly);
CAmount nTotalBalance = nBalance + nPrivateBalance;
@@ -4856,7 +4857,7 @@ UniValue z_viewtransaction(const UniValue& params, bool fHelp, const CPubKey& my
" \"rk\" : \"rk\", (string) The rk\n"
" \"zkproof\" : \"zkproof\", (string) Hexadecimal string representation of raw zksnark proof\n"
" \"outputPrev\" : n, (numeric) the index of the output within the vShieldedOutput\n"
" \"address\" : \"zcashaddress\", (string) The Hush shielded address involved in the transaction\n"
" \"address\" : \"dragonxaddress\", (string) The DragonX shielded address involved in the transaction\n"
" \"value\" : x.xxx (numeric) The amount in " + CURRENCY_UNIT + "\n"
" \"valueZat\" : xxxx (numeric) The amount in puposhis\n"
" }\n"
@@ -4866,7 +4867,7 @@ UniValue z_viewtransaction(const UniValue& params, bool fHelp, const CPubKey& my
" {\n"
" \"type\" : \"sapling\", (string) The type of address\n"
" \"output\" : n, (numeric) the index of the output within the vShieldedOutput\n"
" \"address\" : \"hushaddress\", (string) The Hush address involved in the transaction\n"
" \"address\" : \"dragonxaddress\", (string) The DragonX address involved in the transaction\n"
" \"outgoing\" : true|false (boolean) True if the output is not for an address in the wallet\n"
" \"value\" : x.xxx (numeric) The amount in " + CURRENCY_UNIT + "\n"
" \"valueZat\" : xxxx (numeric) The amount in puposhis\n"
@@ -5143,7 +5144,8 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk)
LOCK2(cs_main, pwalletMain->cs_wallet);
// Hilarious that Komodo commented this out, opening themselves up to metadata attackz, lulz
// Guard against building shielded transactions before the chain is fully synced;
// sending while behind the tip can leak metadata usable for linkability analysis.
THROW_IF_SYNCING(HUSH_INSYNC);
// Check that the from address is valid.
@@ -5388,6 +5390,9 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk)
// SIETCH: Sprinkle our cave with some magic privacy zdust
// End goal is to have this be as large as possible without slowing xtns down too much
// A value of 7 will provide much stronger linkability privacy versus pre-Sietch operations
// DEFAULT_MIN_ZOUTS (7): default number of dummy z-outputs padded onto each z_sendmany.
// MAX_ZOUTS (50): upper bound for the operator-tunable -sietch-min-zouts arg.
// The effective floor is clamped to [3, MAX_ZOUTS] below.
unsigned int DEFAULT_MIN_ZOUTS=7;
unsigned int MAX_ZOUTS=50;
unsigned int MIN_ZOUTS=GetArg("-sietch-min-zouts", DEFAULT_MIN_ZOUTS);
@@ -5457,9 +5462,8 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk)
txsize += GetSerializeSize(tx, SER_NETWORK, tx.nVersion);
if (fromTaddr) {
txsize += CTXIN_SPEND_DUST_SIZE;
//TODO: On HUSH since block 340k there can no longer be taddr change,
// (except for notary addresses)
// so we can likely make a better estimation of max txsize
// DragonX is ac_private=1 (fully shielded from genesis); transparent outputs are
// banned, so in practice there is no taddr change and this estimate is conservative.
txsize += CTXOUT_REGULAR_SIZE; // There will probably be taddr change
}
txsize += CTXOUT_REGULAR_SIZE * taddrRecipients.size();
@@ -5594,7 +5598,8 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp, const CPubKey& myp
LOCK2(cs_main, pwalletMain->cs_wallet);
// Hilarious that Komodo commented this out, opening themselves up to metadata attackz, lulz
// Guard against building shielded transactions before the chain is fully synced;
// sending while behind the tip can leak metadata usable for linkability analysis.
THROW_IF_SYNCING(HUSH_INSYNC);
// Validate the from address
@@ -5840,7 +5845,8 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp
LOCK2(cs_main, pwalletMain->cs_wallet);
// Hilarious that Komodo commented this out, opening themselves up to metadata attackz, lulz
// Guard against building shielded transactions before the chain is fully synced;
// sending while behind the tip can leak metadata usable for linkability analysis.
THROW_IF_SYNCING(HUSH_INSYNC);
bool useAnyUTXO = false;