hygiene: Phase 3 — dead-code excision (~7,100 lines)
Third phase of the code-hygiene remediation: remove provably-dead code.
Each in-file deletion was adversarially verified (a per-finding investigator
plus a skeptic that greps the tree to refute deletability); the sanity grep
confirms zero dangling references, and the tree builds and self-mines clean.
Removed wholesale:
- src/cc/dapps/ (9 files, ~6,939 lines): a git-tracked but never-built Komodo
DEX / z-migration tool (hushdex.c, zmigrate.c, cJSON.c, ...). Nothing in
Makefile.am/configure.ac references it.
In-file dead code:
- pow.cpp: the `#ifdef original_algo` oldRT_CST_RST function (the macro is
never defined in source or build flags) and two `if ( 0 )` debug blocks.
- walletdb.cpp: the "orphaned staking transaction" cleanup path (deadTxns) —
DragonX is RandomX PoW with no staking, so the guard is always false and the
block never runs; also drop the now-unused static/extern decls.
- cc/eval.h: the ProcessCC / Eval::ImportCoin / ImportPayout / DisputePayout
declarations that have no definition anywhere in the tree.
- rpc/crosschain.cpp: the crosschainproof stub RPC (returned {} unconditionally)
and its registrations in rpc/server.cpp, rpc/server.h, rpc/client.cpp.
- coins.cpp: the commented-out `//TODO: delete` Sprout PushAnchor template.
- wallet.cpp: the permanently-zero KMD `interest2` term in CreateTransaction.
- rpc/net.cpp: hush_longestchain's always-zero `n` var (num > (n>>1) => num>0)
and its `if ( 0 )` debug branch.
- hush_nSPV.h / hush_nSPV_fullnode.h: three `if ( 0 && ... )` dead debug branches.
- net.cpp, crypter.h, saplingconsolidation.cpp (dup set_error_code),
shieldcoinbase.cpp (`donation < 0` on a uint8_t), cclib.cpp (unused
FAUCET2SIZE): single-line dead-code fixes.
Deliberately NOT touched (verification refuted the audit's "dead on DragonX"
premise): the ~2,250-line HUSH3 checkpoint block, the miner notary/timelock
paths, and hush_gateway.h — all reachable at runtime via -ac_name / -ac_*
args (the inherited Komodo assetchain model), and hush_gateway's
hush_opretvalidate is called from ConnectBlock (consensus). Dropping those
requires a deliberate decision to remove HAC/HUSH3 mode, tracked separately.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -131,7 +131,6 @@ src/cc/rogue/rogue
|
||||
src/cc/rogue/rogue.so
|
||||
|
||||
src/cc/rogue/test.zip
|
||||
src/cc/dapps/a.out
|
||||
src/checkfile
|
||||
|
||||
src/foo.zip
|
||||
@@ -154,7 +153,6 @@ src/rogue.scr
|
||||
src/cc/rogue/confdefs.h
|
||||
src/cc/rogue/x64
|
||||
|
||||
src/cc/dapps/a.out
|
||||
src/Makefile.in
|
||||
doc/man/Makefile.in
|
||||
Makefile.in
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "main.h"
|
||||
#include "chain.h"
|
||||
#include "core_io.h"
|
||||
#define FAUCET2SIZE COIN
|
||||
#define EVAL_FAUCET2 EVAL_FIRSTUSER
|
||||
|
||||
#ifdef BUILD_CUSTOMCC
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
# Copyright (c) 2016-2024 The Hush Developers
|
||||
# Distributed under the GPLv3 software license, see the accompanying
|
||||
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
||||
# Just type make to compile all dat dapp code, fellow cypherpunkz
|
||||
|
||||
# we no longer build zmigrate by default, nobody uses that fucking code
|
||||
all: hushdex
|
||||
|
||||
hushdex:
|
||||
$(CC) hushdex.c -o hushdex -lm
|
||||
|
||||
# Just for historical knowledge, to study how fucking stupid
|
||||
# ZEC+KMD were to still support sprout, to this day!!!!!!!!
|
||||
# Hush leads the entire world into the future, sans Sprout turdz
|
||||
zmigrate:
|
||||
$(CC) zmigrate.c -o zmigrate -lm
|
||||
|
||||
clean:
|
||||
rm zmigrate
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
# CryptoCondition dApps
|
||||
|
||||
## Compiling
|
||||
|
||||
To compile all dapps in this directory:
|
||||
|
||||
make
|
||||
|
||||
## zmigrate - Sprout to Sapling Migration dApp
|
||||
|
||||
This tool converts Sprout zaddress funds into Sapling funds in a new Sapling address.
|
||||
This is not applicable to HUSH3, since we have no Sprout funds, but left for historical
|
||||
purposes.
|
||||
|
||||
### Usage
|
||||
|
||||
./zmigrate COIN zsaplingaddr
|
||||
|
||||
The above command may need to be run multiple times to complete the process.
|
||||
|
||||
This CLI implementation will be called by GUI wallets, average users do not
|
||||
need to worry about using this low-level tool.
|
||||
|
||||
## HushDEX
|
||||
|
||||
HushDEX forked from the Subatomic Decentralized App (dapp) and we focus purely
|
||||
on privacy coin swaps, and specifically, shielded swaps between Zcash Protocol
|
||||
coins. These are called z-swaps.
|
||||
|
||||
### Z-swap example
|
||||
|
||||
Alice has 1 ZEC and wants to trade it for 5 HUSH, since she hears HushChat is
|
||||
pretty awesome and ZEC just goes down in price, always. We represent this in
|
||||
a diagram like this
|
||||
|
||||
Alice (ZEC) <> Bob (HUSH)
|
||||
|
||||
HushDEX is only concerns with Sapling shielded addresses (zaddrs) which start
|
||||
with `zs1`. Even though ZEC supports Sprout addresses (which start with `zc`),
|
||||
they cannot be used on HushDEX. Sprout is unsupported on HushDEX.
|
||||
|
||||
So Alice must make sure her ZEC is in a Sapling zaddr, and then she can use
|
||||
HushDEX on her computer, to z-swap with Bob, in a decentralized way, with
|
||||
no centralized service. The system is not completely trustless, users must
|
||||
trust the developers and miners on the relevant chains to not do nefarious
|
||||
things. There is no central authority to decide who gets to do what, it's
|
||||
peer-to-peer like BitTorrent or Tor.
|
||||
|
||||
### Privacy Features of Z-Swaps
|
||||
|
||||
* No KYC
|
||||
* We will not feed the identity theft industry any more free data
|
||||
* No IP address limiting
|
||||
* It is trivial to pay for an IP address from any country in the world
|
||||
* Alice's address never appears in public data
|
||||
* Bob's address never appears in public data
|
||||
* Consequently, Alice and Bob's address cannot be searched for on an explorer
|
||||
* Since you can't see the address of any transaction, you cannot infer if
|
||||
the same address appears as sender or receiver in many transactions.
|
||||
* The amount of the transaction, how much ZEC and how much HUSH, is unknown
|
||||
* It could be pennies or millions
|
||||
* The exchange rate of the transaction never appears on the blockchain
|
||||
* The exchange rate will be leaked to the network p2p layer, but it is never
|
||||
recorded in blockchain history. If you are not there to record it, it is gone.
|
||||
* Realistically, it's simple to run a malicious node which records all exchange rates
|
||||
and so we assume an adversary does this
|
||||
* Since the exchange rate of ZEC/HUSH is already public data, this is not considered valuable
|
||||
information leakage. We are leaking the differential of CEX ZEC/HUSH exchange ratio to
|
||||
this DEX's ratio.
|
||||
* Adversaries watching all possible public data can infer exchange ratios but no amounts
|
||||
or addresses, which is considered a massive blow against blockchain analysis.
|
||||
|
||||
1201
src/cc/dapps/cJSON.c
1201
src/cc/dapps/cJSON.c
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"authorized": [
|
||||
{"dukeleto":"030554bffcf6dfcb34a20c486ff0a5be5546b9cc16fba969216527263f8e98c4af" },
|
||||
{"gilardh":"020554bffcf6dfcb34a20c486ff5a5be5546b9cc06fba9692165272b3f8e98c448" },
|
||||
{"nhdigitalcash":"030554bffcf6dfcb34a20c086ff5a5be5546b9cc16fba9692105272b3f8e98c4a0" },
|
||||
{"miodrag":"02b25de3ee5335518b06f69f4fbabb029cfc737603b100996841d5532b324a5a61" }
|
||||
],
|
||||
"tokens":[
|
||||
],
|
||||
"files":[
|
||||
{"filename":"hushd","prices":[{"HUSH":0.1}, {"ZEC":1}]}
|
||||
],
|
||||
"externalcoins":[
|
||||
{ "BTC":"bitcoin-cli" },
|
||||
{ "HUSH":"hush-cli" },
|
||||
{ "ZEC":"zcash-cli" }
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
gcc -o oraclefeed cc/dapps/oraclefeed.c -lm
|
||||
gcc -o zmigrate cc/dapps/zmigrate.c -lm
|
||||
File diff suppressed because it is too large
Load Diff
@@ -80,21 +80,6 @@ public:
|
||||
bool Error(std::string s) { return state.Error(s); }
|
||||
bool Valid() { return true; }
|
||||
|
||||
/*
|
||||
* Dispute a payout using a VM
|
||||
*/
|
||||
bool DisputePayout(AppVM &vm, std::vector<uint8_t> params, const CTransaction &disputeTx, unsigned int nIn);
|
||||
|
||||
/*
|
||||
* Test an ImportPayout CC Eval condition
|
||||
*/
|
||||
bool ImportPayout(std::vector<uint8_t> params, const CTransaction &importTx, unsigned int nIn);
|
||||
|
||||
/*
|
||||
* Import coin from another chain with same symbol
|
||||
*/
|
||||
bool ImportCoin(std::vector<uint8_t> params, const CTransaction &importTx, unsigned int nIn);
|
||||
|
||||
/*
|
||||
* IO functions
|
||||
*/
|
||||
@@ -281,7 +266,6 @@ typedef std::pair<uint256,MerkleBranch> TxProof;
|
||||
|
||||
uint256 GetMerkleRoot(const std::vector<uint256>& vLeaves);
|
||||
struct CCcontract_info *CCinit(struct CCcontract_info *cp,uint8_t evalcode);
|
||||
bool ProcessCC(struct CCcontract_info *cp,Eval* eval, std::vector<uint8_t> paramsNull, const CTransaction &tx, unsigned int nIn);
|
||||
|
||||
|
||||
#endif /* CC_EVAL_H */
|
||||
|
||||
@@ -214,19 +214,6 @@ void CCoinsViewCache::AbstractPushAnchor(
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: delete
|
||||
/*
|
||||
template<> void CCoinsViewCache::PushAnchor(const SproutMerkleTree &tree)
|
||||
{
|
||||
AbstractPushAnchor<SproutMerkleTree, CAnchorsSproutMap, CAnchorsSproutMap::iterator, CAnchorsSproutCacheEntry>(
|
||||
tree,
|
||||
SPROUT,
|
||||
cacheSproutAnchors,
|
||||
hashSproutAnchor
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
template<> void CCoinsViewCache::PushAnchor(const SaplingMerkleTree &tree)
|
||||
{
|
||||
AbstractPushAnchor<SaplingMerkleTree, CAnchorsSaplingMap, CAnchorsSaplingMap::iterator, CAnchorsSaplingCacheEntry>(
|
||||
|
||||
@@ -568,8 +568,6 @@ uint256 NSPV_opretextract(int32_t *heightp,uint256 *blockhashp,char *symbol,std:
|
||||
((uint8_t *)blockhashp)[i] = opret[i];
|
||||
for (i=0; i<32; i++)
|
||||
((uint8_t *)&desttxid)[i] = opret[4 + 32 + i];
|
||||
if ( 0 && *heightp != 2690 )
|
||||
fprintf(stderr," ntzht.%d %s <- txid.%s size.%d\n",*heightp,(*blockhashp).GetHex().c_str(),(txid).GetHex().c_str(),(int32_t)opret.size());
|
||||
return(desttxid);
|
||||
}
|
||||
|
||||
|
||||
@@ -675,8 +675,6 @@ void hush_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a reque
|
||||
dragon_rwnum(0,&request[len-8],sizeof(skipcount),&skipcount);
|
||||
dragon_rwnum(0,&request[len-4],sizeof(filter),&filter);
|
||||
}
|
||||
if ( 0 && isCC != 0 )
|
||||
fprintf(stderr,"utxos %s isCC.%d skipcount.%d filter.%x\n",coinaddr,isCC,skipcount,filter);
|
||||
memset(&U,0,sizeof(U));
|
||||
if ( (slen= NSPV_getaddressutxos(&U,coinaddr,isCC,skipcount,filter)) > 0 )
|
||||
{
|
||||
@@ -715,8 +713,6 @@ void hush_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a reque
|
||||
dragon_rwnum(0,&request[len-8],sizeof(skipcount),&skipcount);
|
||||
dragon_rwnum(0,&request[len-4],sizeof(filter),&filter);
|
||||
}
|
||||
if ( 0 && isCC != 0 )
|
||||
fprintf(stderr,"txids %s isCC.%d skipcount.%d filter.%d\n",coinaddr,isCC,skipcount,filter);
|
||||
memset(&T,0,sizeof(T));
|
||||
if ( (slen= NSPV_getaddresstxids(&T,coinaddr,isCC,skipcount,filter)) > 0 )
|
||||
{
|
||||
|
||||
@@ -1722,7 +1722,6 @@ void ThreadOpenConnections()
|
||||
boost::this_thread::interruption_point();
|
||||
|
||||
// Add seed nodes if DNS seeds are all down (an infrastructure attack?).
|
||||
// if (addrman.size() == 0 && (GetTime() - nStart > 60)) {
|
||||
if (GetTime() - nStart > 60) {
|
||||
static bool done = false;
|
||||
if (!done) {
|
||||
|
||||
83
src/pow.cpp
83
src/pow.cpp
@@ -97,76 +97,6 @@ bnTarget = RT_CST_RST (bnTarget, ts, cw, numerator, denominator, W, T, past);
|
||||
#define T ASSETCHAINS_BLOCKTIME
|
||||
#define K ((int64_t)1000000)
|
||||
|
||||
#ifdef original_algo
|
||||
arith_uint256 oldRT_CST_RST(int32_t height,uint32_t nTime,arith_uint256 bnTarget,uint32_t *ts,arith_uint256 *ct,int32_t numerator,int32_t denominator,int32_t W,int32_t past)
|
||||
{
|
||||
//if (ts.size() < 2*W || ct.size() < 2*W ) { exit; } // error. a vector was too small
|
||||
//if (ts.size() < past+W || ct.size() < past+W ) { past = min(ct.size(), ts.size()) - W; } // past was too small, adjust
|
||||
int64_t altK; int32_t i,j,k,ii=0; // K is a scaling factor for integer divisions
|
||||
if ( height < 64 )
|
||||
return(bnTarget);
|
||||
//if ( ((ts[0]-ts[W]) * W * 100)/(W-1) < (T * numerator * 100)/denominator )
|
||||
if ( (ts[0] - ts[W]) < (T * numerator)/denominator )
|
||||
{
|
||||
//bnTarget = ((ct[0]-ct[1])/K) * max(K,(K*(nTime-ts[0])*(ts[0]-ts[W])*denominator/numerator)/T/T);
|
||||
bnTarget = ct[0] / arith_uint256(K);
|
||||
//altK = (K * (nTime-ts[0]) * (ts[0]-ts[W]) * denominator * W) / (numerator * (W-1) * (T * T));
|
||||
altK = (K * (nTime-ts[0]) * (ts[0]-ts[W]) * denominator) / (numerator * (T * T));
|
||||
fprintf(stderr,"ht.%d initial altK.%lld %d * %d * %d / %d\n",height,(long long)altK,(nTime-ts[0]),(ts[0]-ts[W]),denominator,numerator);
|
||||
if ( altK > K )
|
||||
altK = K;
|
||||
bnTarget *= arith_uint256(altK);
|
||||
if ( altK < K )
|
||||
return(bnTarget);
|
||||
}
|
||||
/* Check past 24 blocks for any sum of 3 STs < T/2 triggers. This is messy
|
||||
because the blockchain does not allow us to store a variable to know
|
||||
if we are currently in a triggered state that is making a sequence of
|
||||
adjustments to prevTargets, so we have to look for them.
|
||||
Nested loops do this: if block emission has not slowed to be back on track at
|
||||
any time since most recent trigger and we are at current block, aggressively
|
||||
adust prevTarget. */
|
||||
|
||||
for (j=past-1; j>=2; j--)
|
||||
{
|
||||
if ( ts[j]-ts[j+W] < T*numerator/denominator )
|
||||
{
|
||||
ii = 0;
|
||||
for (i=j-2; i>=0; i--)
|
||||
{
|
||||
ii++;
|
||||
// Check if emission caught up. If yes, "trigger stopped at i".
|
||||
// Break loop to try more recent j's to see if trigger activates again.
|
||||
if ( (ts[i] - ts[j+W]) > (ii+W)*T )
|
||||
break;
|
||||
|
||||
// We're here, so there was a TS[j]-TS[j-3] < T/2 trigger in the past and emission rate has not yet slowed up to be back on track so the "trigger is still active", aggressively adjusting target here at block "i"
|
||||
if ( i == 0 )
|
||||
{
|
||||
/* We made it all the way to current block. Emission rate since
|
||||
last trigger never slowed enough to get back on track, so adjust again.
|
||||
If avg last 3 STs = T, this increases target to prevTarget as ST increases to T.
|
||||
This biases it towards ST=~1.75*T to get emission back on track.
|
||||
If avg last 3 STs = T/2, target increases to prevTarget at 2*T.
|
||||
Rarely, last 3 STs can be 1/2 speed => target = prevTarget at T/2, & 1/2 at T.*/
|
||||
|
||||
//bnTarget = ((ct[0]-ct[W])/W/K) * (K*(nTime-ts[0])*(ts[0]-ts[W]))/W/T/T;
|
||||
bnTarget = ct[0];
|
||||
for (k=1; k<W; k++)
|
||||
bnTarget += ct[k];
|
||||
bnTarget /= arith_uint256(W * K);
|
||||
altK = (K * (nTime-ts[0]) * (ts[0]-ts[W])) / (W * T * T);
|
||||
fprintf(stderr,"ht.%d made it to i == 0, j.%d ii.%d altK %lld (%d * %d) %u - %u W.%d\n",height,j,ii,(long long)altK,(nTime-ts[0]),(ts[0]-ts[W]),ts[0],ts[W],W);
|
||||
bnTarget *= arith_uint256(altK);
|
||||
j = 0; // It needed adjusting, we adjusted it, we're finished, so break out of j loop.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return(bnTarget);
|
||||
}
|
||||
#endif
|
||||
|
||||
arith_uint256 RT_CST_RST_outer(int32_t height,uint32_t nTime,arith_uint256 bnTarget,uint32_t *ts,arith_uint256 *ct,int32_t numerator,int32_t denominator,int32_t W,int32_t past)
|
||||
{
|
||||
int64_t outerK; int32_t cmpval; arith_uint256 mintarget = bnTarget / arith_uint256(2);
|
||||
@@ -202,13 +132,6 @@ arith_uint256 RT_CST_RST_target(int32_t height,uint32_t nTime,arith_uint256 bnTa
|
||||
bnTarget /= arith_uint256(width * K);
|
||||
innerK = (K * (nTime-ts[0]) * (ts[0]-ts[width])) / (width * T * T);
|
||||
bnTarget *= arith_uint256(innerK);
|
||||
if ( 0 )
|
||||
{
|
||||
int32_t z;
|
||||
for (z=31; z>=0; z--)
|
||||
fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[z]);
|
||||
fprintf(stderr," ht.%d innerK %lld (%d * %d) %u - %u width.%d\n",height,(long long)innerK,(nTime-ts[0]),(ts[0]-ts[width]),ts[0],ts[width],width);
|
||||
}
|
||||
return(bnTarget);
|
||||
}
|
||||
|
||||
@@ -509,12 +432,6 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
||||
}
|
||||
fprintf(stderr," exp() to the rescue cmp.%d mult.%d for ht.%d\n",mult>1,(int32_t)mult,height);
|
||||
}
|
||||
if ( 0 && zflags[0] == 0 && zawyflag == 0 && mult <= 1 )
|
||||
{
|
||||
bnTarget = zawy_TSA_EMA(height,tipdiff,(bnTarget+ct[0]+ct[1])/arith_uint256(3),ts[0] - ts[1]);
|
||||
if ( bnTarget < origtarget )
|
||||
zawyflag = 3;
|
||||
}
|
||||
}
|
||||
nbits = bnTarget.GetCompact();
|
||||
nbits = (nbits & 0xfffffffc) | zawyflag;
|
||||
|
||||
@@ -169,7 +169,6 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
||||
|
||||
// crosschain
|
||||
{ "assetchainproof", 1},
|
||||
{ "crosschainproof", 1},
|
||||
{ "getproofroot", 2},
|
||||
{ "getNotarizationsForBlock", 0},
|
||||
{ "height_MoM", 1},
|
||||
|
||||
@@ -78,14 +78,6 @@ UniValue assetchainproof(const UniValue& params, bool fHelp, const CPubKey& mypk
|
||||
}
|
||||
|
||||
|
||||
UniValue crosschainproof(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
UniValue ret(UniValue::VOBJ);
|
||||
//fprintf(stderr,"crosschainproof needs to be implemented\n");
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
UniValue height_MoM(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
int32_t height,depth,notarized_height,MoMoMdepth,MoMoMoffset,hushstarti,hushendi; uint256 MoM,MoMoM,hushtxid; uint32_t timestamp = 0; UniValue ret(UniValue::VOBJ); UniValue a(UniValue::VARR);
|
||||
|
||||
@@ -218,7 +218,7 @@ int32_t HUSH_LONGESTCHAIN;
|
||||
static int32_t hush_longest_depth = 0;
|
||||
int32_t hush_longestchain()
|
||||
{
|
||||
int32_t ht,n=0,num=0,maxheight=0,height = 0;
|
||||
int32_t ht,num=0,maxheight=0,height = 0;
|
||||
if ( hush_longest_depth < 0 )
|
||||
hush_longest_depth = 0;
|
||||
if ( hush_longest_depth == 0 )
|
||||
@@ -231,7 +231,6 @@ int32_t hush_longestchain()
|
||||
}
|
||||
BOOST_FOREACH(const CNodeStats& stats, vstats)
|
||||
{
|
||||
//fprintf(stderr,"hush_longestchain iter.%d\n",n);
|
||||
CNodeStateStats statestats;
|
||||
bool fStateStats = GetNodeStateStats(stats.nodeid,statestats);
|
||||
if ( statestats.nSyncHeight < 0 )
|
||||
@@ -251,10 +250,8 @@ int32_t hush_longestchain()
|
||||
height = ht;
|
||||
}
|
||||
hush_longest_depth--;
|
||||
if ( num > (n >> 1) )
|
||||
if ( num > 0 )
|
||||
{
|
||||
if ( 0 && height != HUSH_LONGESTCHAIN )
|
||||
fprintf(stderr,"set %s HUSH_LONGESTCHAIN <- %d\n",SMART_CHAIN_SYMBOL,height);
|
||||
HUSH_LONGESTCHAIN = height;
|
||||
return(height);
|
||||
}
|
||||
|
||||
@@ -335,7 +335,6 @@ static const CRPCCommand vRPCCommands[] =
|
||||
{ "crosschain", "calc_MoM", &calc_MoM, true },
|
||||
{ "crosschain", "height_MoM", &height_MoM, true },
|
||||
{ "crosschain", "assetchainproof", &assetchainproof, true },
|
||||
{ "crosschain", "crosschainproof", &crosschainproof, true },
|
||||
{ "crosschain", "getNotarizationsForBlock", &getNotarizationsForBlock, true },
|
||||
{ "crosschain", "scanNotarizationsDB", &scanNotarizationsDB, true },
|
||||
|
||||
|
||||
@@ -380,7 +380,6 @@ extern UniValue MoMoMdata(const UniValue& params, bool fHelp, const CPubKey& myp
|
||||
extern UniValue calc_MoM(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue height_MoM(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue assetchainproof(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue crosschainproof(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue getNotarizationsForBlock(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue scanNotarizationsDB(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue getimports(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
|
||||
@@ -52,7 +52,6 @@ void AsyncRPCOperation_saplingconsolidation::main() {
|
||||
set_error_code(code);
|
||||
set_error_message(message);
|
||||
} catch (const runtime_error& e) {
|
||||
set_error_code(-1);
|
||||
set_error_code(-1);
|
||||
set_error_message("runtime error: " + string(e.what()));
|
||||
} catch (const logic_error& e) {
|
||||
|
||||
@@ -68,7 +68,7 @@ AsyncRPCOperation_shieldcoinbase::AsyncRPCOperation_shieldcoinbase(
|
||||
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Empty inputs");
|
||||
}
|
||||
|
||||
if (donation < 0 || donation > 10 ) {
|
||||
if (donation > 10 ) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid donation percentage, must be an integer between 0 and 10 inclusive");
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,6 @@ private:
|
||||
// .second is the ciphertext.
|
||||
std::pair<uint256, std::vector<unsigned char>> cryptedMnemonicEntropy;
|
||||
CryptedKeyMap mapCryptedKeys;
|
||||
//CryptedSproutSpendingKeyMap mapCryptedSproutSpendingKeys;
|
||||
CryptedSaplingSpendingKeyMap mapCryptedSaplingSpendingKeys;
|
||||
|
||||
CKeyingMaterial vMasterKey;
|
||||
|
||||
@@ -4359,7 +4359,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount &nFeeRet, int& nC
|
||||
bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRet,
|
||||
int& nChangePosRet, std::string& strFailReason, const CCoinControl* coinControl, bool sign)
|
||||
{
|
||||
uint64_t interest2 = 0; CAmount nValue = 0; unsigned int nSubtractFeeFromAmount = 0;
|
||||
CAmount nValue = 0; unsigned int nSubtractFeeFromAmount = 0;
|
||||
BOOST_FOREACH (const CRecipient& recipient, vecSend)
|
||||
{
|
||||
if (nValue < 0 || recipient.nAmount < 0)
|
||||
@@ -4480,7 +4480,6 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
|
||||
CAmount nValueIn = 0;
|
||||
bool fOnlyCoinbaseCoins = false;
|
||||
bool fNeedCoinbaseCoins = false;
|
||||
interest2 = 0;
|
||||
if (!SelectCoins(nTotalValue, setCoins, nValueIn, fOnlyCoinbaseCoins, fNeedCoinbaseCoins, coinControl))
|
||||
{
|
||||
if (fOnlyCoinbaseCoins && Params().GetConsensus().fCoinbaseMustBeProtected) {
|
||||
@@ -4506,8 +4505,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
|
||||
dPriority += (double)nCredit * age;
|
||||
}
|
||||
|
||||
CAmount nChange = (nValueIn - nValue + interest2);
|
||||
//fprintf(stderr,"wallet change %.8f (%.8f - %.8f) interest2 %.8f total %.8f\n",(double)nChange/COIN,(double)nValueIn/COIN,(double)nValue/COIN,(double)interest2/COIN,(double)nTotalValue/COIN);
|
||||
CAmount nChange = (nValueIn - nValue);
|
||||
if (nSubtractFeeFromAmount == 0)
|
||||
nChange -= nFeeRet;
|
||||
|
||||
|
||||
@@ -46,8 +46,6 @@ const int CHDChain::CURRENT_VERSION;
|
||||
using namespace std;
|
||||
|
||||
static uint64_t nAccountingEntryNumber = 0;
|
||||
static list<uint256> deadTxns;
|
||||
extern CBlockIndex *hush_blockindex(uint256 hash);
|
||||
|
||||
//
|
||||
// CWalletDB
|
||||
@@ -1017,8 +1015,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
|
||||
{
|
||||
// Leave other errors alone, if we try to fix them we might make things worse.
|
||||
fNoncriticalErrors = true; // ... but do warn the user there is something wrong.
|
||||
// set rescan for any error that is not vin-empty on staking chains.
|
||||
if ( deadTxns.empty() && strType == "tx")
|
||||
if ( strType == "tx")
|
||||
SoftSetBoolArg("-rescan", true);
|
||||
}
|
||||
}
|
||||
@@ -1034,29 +1031,6 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
|
||||
result = DB_CORRUPT;
|
||||
}
|
||||
|
||||
if ( !deadTxns.empty() )
|
||||
{
|
||||
// staking chains with vin-empty error is a failed staking tx.
|
||||
// we remove then re add the tx here to stop needing a full rescan, which does not actually fix the problem.
|
||||
int32_t reAdded = 0;
|
||||
BOOST_FOREACH (uint256& hash, deadTxns)
|
||||
{
|
||||
fprintf(stderr, "Removing possible orphaned staking transaction from wallet.%s\n", hash.ToString().c_str());
|
||||
if (!EraseTx(hash))
|
||||
fprintf(stderr, "could not delete tx.%s\n",hash.ToString().c_str());
|
||||
uint256 blockhash; CTransaction tx; CBlockIndex* pindex;
|
||||
if ( GetTransaction(hash,tx,blockhash,false) && (pindex= hush_blockindex(blockhash)) != 0 && chainActive.Contains(pindex) )
|
||||
{
|
||||
CWalletTx wtx(pwallet,tx);
|
||||
pwallet->AddToWallet(wtx, true, NULL);
|
||||
reAdded++;
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "Cleared %li orphaned staking transactions from wallet. Readded %i real transactions.\n",deadTxns.size(),reAdded);
|
||||
fNoncriticalErrors = false;
|
||||
deadTxns.clear();
|
||||
}
|
||||
|
||||
if (fNoncriticalErrors && result == DB_LOAD_OK)
|
||||
result = DB_NONCRITICAL_ERROR;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user