Second phase of the code-hygiene remediation, covering the items the
DragonX team introduced or the rebrand missed. No consensus behavior
changes; validated on a local self-mining node.
Log cruft:
- chainparams: route the startup ">>>>>>>>>>" banner and the port line
through LogPrintf/LogPrint("net") instead of fprintf(stderr).
- pow: drop the fprintf(stderr) hash-mismatch dump that duplicated the
LogPrintf copy verbatim.
- miner: gate the RandomXDatasetManager per-alloc/per-VM address dumps and
MemDiag /proc reads behind LogPrint("randomx"); keep a one-line
"allocated shared dataset (N GB)" summary at default verbosity.
Named constants (single source of truth in wallet.h):
- DEFAULT_AUTOSHIELD_FEE/INTERVAL, MIN_AUTOSHIELD_INTERVAL,
DEFAULT_AUTOSHIELD_MIN_UTXOS, AUTOSHIELD_MIN/MAX_FEE for the autoshield
option parsing and help text (were bare 10000/25/5 literals repeated
across init.cpp and wallet.h).
- AUTO_OP_TARGET_HEIGHT_OFFSET replaces the three copy-pasted
`blockHeight + 5` async-op scheduling offsets.
- AUTO_OP_EXPIRY_DELTA replaces the three per-file *_EXPIRY_DELTA=15
constants (sweep/consolidation/autoshield) with one shared value.
- Move DEFAULT_AUTOSHIELD_FEE out of the op header into wallet.h so it no
longer collides when both headers are included.
Error surfacing:
- init: report clamped/out-of-range -autoshieldinterval/-autoshieldfee via
InitWarning() (surfaces to GUI/log) instead of fprintf(stderr).
Rebrand / dead foreign-chain code (approved removals):
- server: drop the HUSH3 special-cases in stop() and HelpExampleCli; the
cli example now shows "dragonx-cli" instead of "hush-cli".
- getinfo (misc): remove the stale dPoW notarization block (notarized,
prevMoMheight, notarizedhash, notarizedtxid, notarizedtxid_height,
HUSHnotarized_height, notarized_confirms) — DragonX is a private chain
from genesis with no active dPoW. Also fixes the hardcoded "HUSH3" that
made getinfo query a foreign chain's notarization.
- delete the dead Komodo notary RPCs getera/getdragonjson/
getnotarysendmany/geterablockheights (getera returned 0;
getnotarysendmany was marked "this is broke") and their registrations.
- remove the dead ASSETCHAINS_EQUIHASH reporting branches in getinfo and
getmininginfo — DragonX is RandomX-only.
chainparams: document why the upstream Equihash params and the literal
Bitcoin genesis are retained under RandomX (do not "fix" them).
Deferred: the hdSeedOrigin int->string switch in z_autoshieldstatus
(no shared helper exists to reuse; low value).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
76 lines
3.5 KiB
C++
76 lines
3.5 KiB
C++
// Copyright (c) 2016-2024 The Hush developers
|
|
// Copyright (c) 2024-2026 The DragonX developers
|
|
// Distributed under the GPLv3 software license, see the accompanying
|
|
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
|
#ifndef ASYNCRPCOPERATION_AUTOSHIELDCOINBASE_H
|
|
#define ASYNCRPCOPERATION_AUTOSHIELDCOINBASE_H
|
|
|
|
#include "amount.h"
|
|
#include "asyncrpcoperation.h"
|
|
#include "univalue.h"
|
|
#include "zcash/Address.hpp"
|
|
#include "zcash/zip32.h"
|
|
|
|
// Sentinel for "not a derived account" (i.e. the configured -autoshieldaddress).
|
|
static const uint32_t AUTOSHIELD_ACCOUNT_NONE = UINT32_MAX;
|
|
|
|
enum class AutoShieldDestStatus {
|
|
Resolved, // destOut/destStrOut are set
|
|
NotFound, // no in-gap account held yet; the operation will derive one
|
|
InvalidOverride, // -autoshieldaddress is set but is not a Sapling address
|
|
NoSeed, // no HD seed available (e.g. locked wallet)
|
|
};
|
|
|
|
// Resolve the auto-shield destination WITHOUT mutating the wallet: the configured
|
|
// -autoshieldaddress if set, else the lowest in-gap seed-derived account the wallet
|
|
// already holds. It deliberately does NOT generate a key, so init can call it purely
|
|
// to answer "where will this send?" -- deriving a fresh account as a side effect of
|
|
// populating a status field would be wrong. The operation's own resolveDestination
|
|
// falls through to generation when this returns NotFound.
|
|
// Caller must hold cs_wallet.
|
|
AutoShieldDestStatus ResolveAutoShieldDestinationReadOnly(
|
|
libzcash::SaplingPaymentAddress& destOut, std::string& destStrOut, uint32_t& accountOut);
|
|
|
|
// A periodic, wallet-local operation that drains matured *transparent* coinbase
|
|
// UTXOs into a wallet-owned Sapling z-address in size-bounded batches. It is the
|
|
// automatic sibling of the manual z_shieldcoinbase RPC and mirrors the dispatch
|
|
// model of AsyncRPCOperation_sweep (self-gathers on the async worker thread,
|
|
// commits via CWallet::CommitAutomatedTx). It never mints a transparent output,
|
|
// so it respects the ac_private=1 transparent-output ban, and it deliberately
|
|
// does NOT toggle mining (unlike z_shieldcoinbase) so it can run every interval
|
|
// on a mining node without thrashing the miner.
|
|
class AsyncRPCOperation_autoshieldcoinbase : public AsyncRPCOperation
|
|
{
|
|
public:
|
|
AsyncRPCOperation_autoshieldcoinbase(int targetHeight);
|
|
virtual ~AsyncRPCOperation_autoshieldcoinbase();
|
|
|
|
// We don't want to be copied or moved around
|
|
AsyncRPCOperation_autoshieldcoinbase(AsyncRPCOperation_autoshieldcoinbase const&) = delete;
|
|
AsyncRPCOperation_autoshieldcoinbase(AsyncRPCOperation_autoshieldcoinbase&&) = delete;
|
|
AsyncRPCOperation_autoshieldcoinbase& operator=(AsyncRPCOperation_autoshieldcoinbase const&) = delete;
|
|
AsyncRPCOperation_autoshieldcoinbase& operator=(AsyncRPCOperation_autoshieldcoinbase&&) = delete;
|
|
|
|
virtual void main();
|
|
virtual void cancel();
|
|
virtual UniValue getStatus() const;
|
|
|
|
private:
|
|
int targetHeight_;
|
|
int numTxCreated_ = 0;
|
|
CAmount amountShielded_ = 0;
|
|
std::vector<std::string> shieldTxIds_;
|
|
|
|
bool main_impl();
|
|
|
|
// Resolve a spendable, wallet-owned Sapling destination: the configured
|
|
// -autoshieldaddress if set, else the first spendable z-addr the wallet
|
|
// holds, else a freshly generated one (requires an unlocked wallet).
|
|
// Returns false if none is available (e.g. locked wallet with no z-addr).
|
|
bool resolveDestination(libzcash::SaplingPaymentAddress& destOut, std::string& destStrOut);
|
|
|
|
void setResult();
|
|
};
|
|
|
|
#endif /* ASYNCRPCOPERATION_AUTOSHIELDCOINBASE_H */
|