Commit Graph

2510 Commits

Author SHA1 Message Date
e3247d946e cleanup: rebrand residual user-facing "HUSH" strings to DragonX
Sweeps the leftover coin-name strings in RPC help text, RPC output, and log
messages that the currency-unit change didn't cover:

- RPC help: "mining reward amount in HUSH" -> DRAGONX (mining.cpp x2);
  "at least minbal HUSH" -> DRAGONX (rpcwallet.cpp); "the HUSH address" /
  "(string) HUSH address" -> DragonX (rawtransaction.cpp)
- RPC output: the SMART_CHAIN_SYMBOL[0]==0 ? "HUSH" : SYMBOL coin-name fallback
  (crosschain/misc/mining/blockchain) -> "DRAGONX"; the notarizations JSON key
  make_pair("HUSH", ...) -> "DRAGONX"
- Logs: "HUSH blocktime changing", "stopping HUSH HTTP/REST/RPC",
  "HUSH raw magic=" -> DragonX

Left untouched (verified): the 82 "HUSH3"/ishush3 chain-symbol consensus checks;
hush_globals.h CURRENCIES[] price-oracle basket (internal lookup, dead feature
on DragonX); hush.h notarization debug printf; a commented-out cout in main.cpp.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-21 15:37:57 -05:00
bf3c33c53a revert(net): remove header-accept RandomX check; keep nMinimumChainWork + #8
An adversarial re-review found the header-accept RandomX check (b9fdc7981 +
7e9b2c661 header-PoW + d2124a303 defer) to be a persistent source of
consensus-liveness bugs: it derives the RandomX key from the ACTIVE chain
(hush_chainactive), the wrong branch for reorg/side-branch/catch-up headers, so
it repeatedly false-rejected validly-mined headers and DoS(100)-hard-banned
honest peers (IBD-tail catch-up and deep-reorg cases); the defer fix and an
extend-tip fix each addressed one case while leaving/creating others (an
extend-tip variant re-opened an unbounded post-IBD side-branch flood). It only
mitigated a low-harm resource DoS -- forged headers bloat mapBlockIndex memory/
disk but are never SELECTED (nMinimumChainWork) and the full RandomX + target
check still runs at block-connect. Revert to fCheckPOW=0 at header-accept
(original behavior). A comment in AcceptBlockHeader records that any re-attempt
must derive the key from the header's OWN ancestry (pindexPrev->GetAncestor),
never the active chain.

Also hardens two issues the same review found:
- #8 IBD header cap now bounds against the VALIDATED chainActive.Height()
  (attacker-hard) instead of pindexBestHeader, which a forward-extending flood
  advanced in lockstep, defeating the cap.
- opreturn_burn only emits a change output above the dust threshold; a sub-dust
  change made the returned tx non-standard/unrelayable.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-14 20:24:45 -05:00
b5050d06c0 fix(wallet): opreturn_burn return change + widen txfee to CAmount
#10 (HIGH) opreturn_burn selected UTXOs for nAmount+txfee but pushed only the
burn vout and returned - so the entire selected-input surplus was silently paid
as miner fee (e.g. a 500-coin UTXO burning 10 lost ~490). Push a change output
for (inputs - nAmount - txfee). Also widen the int32_t txfee (which truncated
large CAmount fees) to CAmount and MoneyRange-validate.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-14 11:21:28 -05:00
14e3fb6708 fix(wallet): reserve miner fee during z_sendmany note selection
The Sapling note-selection loop stopped once total_value >= nTotalOut, ignoring
the miner fee, so a wallet with notes covering the amount but not amount+fee
selected too few notes and failed later with a spurious "insufficient funds".
Reserve the fee (default or user-supplied) in the selection target.

Leto eb4fc52273.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-13 16:06:39 -05:00
4351d5b733 fix(nspv/wallet): bound nSPV request buffers + fix uninitialized fee / null-deref
hush_nSPV_fullnode.h: bound the REMOTERPC method strcpy and json memcpy to their
fixed buffers (method[64], json[11000]); add lower-length and memcpy-source bounds
to the UTXOS/TXIDS coinaddr[64] copies and the MEMPOOL handler. These paths
deserialize attacker-controlled request bytes -> stack overflow / OOB read. The
nSPV server is opt-in via -nspv_msg (off by default; DragonX uses lightwalletd).

rpc/blockchain.cpp: getchaintxstats null-checks pwalletMain (crash under -disablewallet).
wallet/rpcwallet.cpp: z_sendmany initializes nFee to the default miners fee (was read
uninitialized when no fee param supplied).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-13 15:56:09 -05:00
762e25294f fix: guard BuildWitnessCache against an off-active-chain pindex (heap overflow)
BuildWitnessCache sizes its blockCms buffer from pindex->GetHeight() but the
Phase-1 loop walks the active chain (chainActive.Next), terminating only on
pbi==pindex. If a reorg moved pindex off the active chain while the notify
thread lagged (cs_main is released between per-block ChainTip calls) and the new
active tip is taller, the loop never reaches pindex and, once past pindex's
height, writes blockCms[h-startHeight] out of bounds -- a heap overflow.
Rebuilding witnesses for an abandoned block is meaningless anyway, so bail early
when pindex is not on the active chain; cs_main is held for the whole function,
so the check cannot race the loop.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 05:48:39 +02:00
4caf2fc68f Add BIP39 seed phrases (SilentDragonXLite-compatible) and HD transparent keys
Derive transparent (t-addr) keys from the HD seed and add BIP39 mnemonic seed
phrases that are byte-for-byte compatible with SilentDragonXLite, so the same
24 words recover the same shielded and transparent addresses in either wallet.

HD transparent keys:
- Derive t-keys from the seed at m/44'/coin'/0'/0/i (were random CKeys).
- CHDChain gains a version-gated transparent counter; existing wallets load
  unchanged. GenerateNewKey routes through DeriveNewChildKey when enabled
  (-hdtransparent, default on).
- Restore from a seed hex via -hdseed with gap-limit pre-derivation; birthday
  pinned to genesis so the rescan is not clipped.

BIP39 seed phrases:
- Wire the vendored trezor BIP39 lib (src/crypto/bip39) into the build, fix its
  BIP39_WORDS guard, and disable the insecure mnemonic cache.
- Match SDXLite exactly: English wordlist, empty passphrase, PBKDF2 64-byte
  seed, coin type 141, ZIP-32 m/32'/141'/i' and BIP44 m/44'/141'/0'/0/i. Store
  the 32-byte entropy and expand to the 64-byte seed on demand.
- Restore via -mnemonic, create via -usemnemonic, reveal via z_exportmnemonic.

Verified by gtests including a known-answer BIP39 seed vector and z/t address
derivation checks (src/gtest/test_hdtransparent.cpp, test_mnemonic_compat.cpp).
Docs in doc/hd-transparent-keys.md and doc/seed-phrase.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-06 01:57:18 -05:00
82d77344d2 Fix Sapling witness desync and parallelize witness cache rebuild
Wallets upgraded across the 1.0.1->1.0.2 network transition could end up
with note witnesses stuck at a stale height, causing z_sendmany /
z_mergetoaddress to fail to build a valid spend. Root cause was a trio of
issues that let a desynced witnessHeight perpetuate instead of self-healing:

- DecrementNoteWitnesses left witnessRootValidated and the witness deque in
  an asymmetric state on the size<=1 path.
- VerifyAndSetInitialWitness blindly trusted witnessHeight instead of
  validating the cached root against the chain, so a bad height survived.
- UpdatedNoteData copied witnessHeight even when no witnesses were present.
- witnessRootValidated was uninitialized and never serialized, so a garbage
  true value could short-circuit the self-heal.

Fixes:
- Default witnessRootValidated to false (in-memory only; never serialized).
- VerifyAndSetInitialWitness now validates the cached witness root against
  the block's hashFinalSaplingRoot and reseeds on mismatch.
- Symmetric reset of witness state in DecrementNoteWitnesses.
- Guard the witnessHeight copy in UpdatedNoteData behind a non-empty
  witnesses check.
- Defensive majority-root guard in GetSaplingNoteWitnesses.

Also rewrites BuildWitnessCache to rebuild the witness cache in parallel
(per-block commitment extraction + worker pool), cutting a full repair from
~28 min to ~2 min. Tunable via -witnessbuildthreads and -witnessfastrebuild;
output verified byte-identical to the serial path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-28 16:03:23 -05:00
M
d77088c1f2 Fix macOS Sequoia build with GCC 15 and update README
- Update compiler references from gcc-8 to gcc-15 across build system
  (build-mac.sh, darwin.mk, Makefile_custom)
- Use system Rust (rustup) instead of bundled Rust 1.32.0 for librustzcash
  to fix rlib linker incompatibility on macOS Sequoia
- Replace deprecated std::random_shuffle with std::shuffle (net.cpp,
  transaction_builder.cpp, wallet.cpp)
- Fix -std=gnu17 -> -std=gnu++17 for C++ targets (libzcash, libhush)
- Fix nodiscard warning in glibcxx_sanity.cpp
- Replace deprecated OSMemoryBarrier with std::atomic_thread_fence in LevelDB
- Add -Wno-error=deprecated-declarations to CXXFLAGS for third-party headers
- Fix REMAINING_ARGS unbound variable in build.sh
- Add --disable-tests handling to build-mac.sh
- Update README with correct macOS build dependencies and instructions
2026-03-19 09:30:50 -05:00
Duke
f8136f5839 DragonX has left the nest 2026-02-28 12:12:45 -05:00
duke
f26f27656a Set a mainnet donation zaddr for z_shieldcoinbase 2026-02-11 11:11:50 -05:00
Duke
874e89e4f0 Only validate donation zaddrs if donating 2025-12-25 12:08:06 -05:00
Duke
2fd88b65e3 Be clear that 0 and 10 are included as valid donation percentages 2025-12-25 12:07:59 -05:00
duke
529e76d01c Merge pull request 'Sync danger to dev' (#479) from danger into dev
Reviewed-on: https://git.hush.is/hush/hush3/pulls/479
2025-12-25 12:02:58 -05:00
Duke
5ecd7629ec Make error message more general for any chain 2025-10-26 09:11:07 -04:00
Duke
9177a51b6d Remove getbalance64 #473 2025-10-16 11:14:01 -04:00
Duke
d206f28ae1 Update z_shieldcoinbase rpc docs 2025-10-16 01:10:46 -04:00
Duke
6435cd51a6 Use static_cast when calculating donation and add some debugging 2025-10-15 13:24:08 -04:00
Duke
42a676d277 Make the shieldcoinbase donation test pass 2025-10-14 12:20:35 -04:00
Duke
ebde772ada WIP donation test 2025-10-14 11:52:05 -04:00
Duke
606b28d6ca Improve rpc errors and docs 2025-10-14 11:00:08 -04:00
Duke
caf7178ffd Allow donation=0 2025-10-14 10:57:40 -04:00
Duke
c3b9b09144 Make rpc error correct for all chains 2025-10-14 03:58:00 -04:00
Duke
23ef00cfd7 WIP donation test 2025-10-13 18:21:51 -04:00
Duke
1f50e635a0 WIP donation 2025-10-13 15:27:30 -04:00
Duke
c078d1606d Merge remote-tracking branch 'origin/dev' into danger 2025-10-13 15:08:19 -04:00
Duke
02a26751bb WIP donation 2025-10-13 15:06:42 -04:00
Duke
cb81fc3b95 Less noise unless -debug is used 2025-09-24 09:30:33 -04:00
Duke
e421dfc6a5 Improve rpc docs of z_listlockunspent 2025-08-23 06:17:32 -04:00
Duke
34829af017 Avoid coredump if witness index does not exist 2025-08-22 07:34:11 -04:00
Duke
fb7d669f14 Remove commented out code 2025-08-22 07:09:15 -04:00
Duke
7e3ce02d87 Bring back sorting notes descending by value which was in find_unspent_notes() 2025-08-22 06:16:25 -04:00
Duke
ae170e9899 Spendable notes are now locked and 1159 seems to be an irrelevant upstream issue 2025-08-22 05:43:21 -04:00
Duke
90f00ac8a4 cleanup 2025-08-21 17:05:16 -04:00
Duke
eb4fc52273 lockzins test finally passes because z_sendmany correctly locks notes now 2025-08-21 16:59:33 -04:00
Duke
6e029a62ac Remove unused header inclusion 2025-08-21 16:14:23 -04:00
Duke
a719e05be4 Add output index to z_listlockunspent 2025-08-21 02:00:19 -04:00
Duke
7c434ba030 Log calls to GetFilteredNotes and only warn when witness root is actually invalid 2025-08-21 01:59:20 -04:00
Duke
b0cbcc6152 Unlock notes+utxos earlier 2025-08-21 01:57:42 -04:00
Duke
cae942a5c9 z_listlockunspent 2025-08-20 15:15:36 -04:00
Duke
c6892b950b Merge branch 'dev' into lockzins 2025-08-13 01:19:34 -04:00
Duke
5d31a77036 Do not throw exception during syncing on regtest 2025-08-12 23:57:27 -04:00
Duke
45f2e6b134 Remove unused code 2025-08-12 23:39:26 -04:00
Duke
0cd2bafa3a Remove unused CLI options and update debian example config 2025-08-12 13:37:44 -04:00
Duke
bd52fc5ee6 Try harder to avoid selecting locked notes to spend 2025-08-11 09:36:45 -04:00
Duke
62da1981bb WIP donation 2025-08-10 13:46:07 -04:00
Duke
d95da694b9 WIP donation via z_shieldcoinbase 2025-08-08 14:53:21 -04:00
Duke
d415277548 Merge branch 'dev' into lockzins 2025-07-29 09:10:42 -04:00
Duke
ab81589bdf Add rpc docs for using * with z_shieldcoinbase 2025-07-24 12:37:58 -04:00
Duke
7e63e2f013 We call them HACs now 2025-06-27 05:32:12 -04:00