From 6c70956f4fbaa3b350761edfecfbf1df6731dd1f Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 4 Dec 2020 19:31:03 -0500 Subject: [PATCH] Remove -exchange option which jl777 used to steal from KMD miners and notary node ops --- src/hush_defs.h | 1 - src/hush_globals.h | 2 +- src/hush_utils.h | 14 ++++++---- src/wallet/wallet.cpp | 60 ++++++++----------------------------------- 4 files changed, 20 insertions(+), 57 deletions(-) diff --git a/src/hush_defs.h b/src/hush_defs.h index d04cd61dd..29ef81c31 100644 --- a/src/hush_defs.h +++ b/src/hush_defs.h @@ -527,7 +527,6 @@ extern uint8_t ASSETCHAINS_CCDISABLES[256]; extern int32_t USE_EXTERNAL_PUBKEY; extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; -extern int32_t KOMODO_EXCHANGEWALLET; extern std::string DONATION_PUBKEY; extern uint8_t ASSETCHAINS_PRIVATE; extern int32_t USE_EXTERNAL_PUBKEY; diff --git a/src/hush_globals.h b/src/hush_globals.h index 58c482e6a..6f4ca97b9 100644 --- a/src/hush_globals.h +++ b/src/hush_globals.h @@ -50,7 +50,7 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100; unsigned int WITNESS_CACHE_SIZE = _COINBASE_MATURITY+10; uint256 KOMODO_EARLYTXID; -int32_t KOMODO_MININGTHREADS = -1,IS_HUSH_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,HUSH_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS,ASSETCHAINS_CBMATURITY,KOMODO_NSPV; +int32_t KOMODO_MININGTHREADS = -1,IS_HUSH_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,HUSH_PASSPORT_INITDONE,KOMODO_PAX,HUSH_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS,ASSETCHAINS_CBMATURITY,KOMODO_NSPV; int32_t HUSH_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,ASSETCHAINS_SELFIMPORT,ASSETCHAINS_CCLIB; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_MARMARA; diff --git a/src/hush_utils.h b/src/hush_utils.h index 579d6cc73..a268992a9 100644 --- a/src/hush_utils.h +++ b/src/hush_utils.h @@ -1779,12 +1779,16 @@ void hush_args(char *argv0) { KOMODO_MININGTHREADS = GetArg("-genproclimit",-1); } - if ( (KOMODO_EXCHANGEWALLET= GetBoolArg("-exchange", false)) != 0 ) - fprintf(stderr,"KOMODO_EXCHANGEWALLET mode active\n"); - DONATION_PUBKEY = GetArg("-donation", ""); - NOTARY_PUBKEY = GetArg("-pubkey", ""); + if ( (GetBoolArg("-exchange", false)) != 0 ) { + printf("The KMD-only feature -exchange is not supported by HUSH!\n"); + printf("jl777 uses this \"feature\" to steal from his own users!\n"); + printf("Learn more at https://duke.hush.is :)\n"); + StartShutdown(); + } + DONATION_PUBKEY = GetArg("-donation", ""); + NOTARY_PUBKEY = GetArg("-pubkey", ""); KOMODO_DEALERNODE = GetArg("-dealer",0); - KOMODO_TESTNODE = GetArg("-testnode",0); + KOMODO_TESTNODE = GetArg("-testnode",0); if ( strlen(NOTARY_PUBKEY.c_str()) == 66 ) { decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 9de10fa00..ec316beff 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3242,8 +3242,7 @@ void CWallet::AvailableCoins(vector& vCoins, bool fOnlyConfirmed, const !IsLockedCoin((*it).first, i) && (pcoin->vout[i].nValue > 0 || fIncludeZeroValue) && (!coinControl || !coinControl->HasSelected() || coinControl->IsSelected((*it).first, i))) { - if ( KOMODO_EXCHANGEWALLET == 0 ) - { + if ( 1 ) { uint32_t locktime; int32_t txheight; CBlockIndex *tipindex; if ( SMART_CHAIN_SYMBOL[0] == 0 && chainActive.LastTip() != 0 && chainActive.LastTip()->GetHeight() >= 60000 ) { @@ -3257,28 +3256,18 @@ void CWallet::AvailableCoins(vector& vCoins, bool fOnlyConfirmed, const //interest = komodo_interestnew(chainActive.LastTip()->GetHeight()+1,pcoin->vout[i].nValue,pcoin->nLockTime,chainActive.LastTip()->nTime); if ( interest != 0 ) { - //printf("wallet nValueRet %.8f += interest %.8f ht.%d lock.%u/%u tip.%u\n",(double)pcoin->vout[i].nValue/COIN,(double)interest/COIN,txheight,locktime,pcoin->nLockTime,tipindex->nTime); - //fprintf(stderr,"wallet nValueRet %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)pcoin->vout[i].nValue/COIN,(double)interest/COIN,chainActive.LastTip()->GetHeight()+1,pcoin->nLockTime,chainActive.LastTip()->nTime); - //ptr = (uint64_t *)&pcoin->vout[i].nValue; - //(*ptr) += interest; ptr = (uint64_t *)&pcoin->vout[i].interest; (*ptr) = interest; //pcoin->vout[i].nValue += interest; - } - else - { + } else { ptr = (uint64_t *)&pcoin->vout[i].interest; (*ptr) = 0; } - } - else - { + } else { ptr = (uint64_t *)&pcoin->vout[i].interest; (*ptr) = 0; } - } - else - { + } else { ptr = (uint64_t *)&pcoin->vout[i].interest; (*ptr) = 0; } @@ -3369,30 +3358,20 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int { setCoinsRet.insert(coin.second); nValueRet += coin.first; - //if ( KOMODO_EXCHANGEWALLET == 0 ) - // *interestp += pcoin->vout[i].interest; return true; } else if (n < nTargetValue + CENT) { vValue.push_back(coin); nTotalLower += n; - //if ( KOMODO_EXCHANGEWALLET == 0 && count < sizeof(interests)/sizeof(*interests) ) - //{ - //fprintf(stderr,"count.%d %.8f\n",count,(double)pcoin->vout[i].interest/COIN); - //interests[count++] = pcoin->vout[i].interest; - //} if ( nTotalLower > 4*nTargetValue + CENT ) { //fprintf(stderr,"why bother with all the utxo if we have double what is needed?\n"); break; } - } - else if (n < coinLowestLarger.first) + } else if (n < coinLowestLarger.first) { coinLowestLarger = coin; - //if ( KOMODO_EXCHANGEWALLET == 0 ) - // lowest_interest = pcoin->vout[i].interest; } } @@ -3402,8 +3381,6 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int { setCoinsRet.insert(vValue[i].second); nValueRet += vValue[i].first; - //if ( KOMODO_EXCHANGEWALLET == 0 && i < count ) - // *interestp += interests[i]; } return true; } @@ -3414,8 +3391,6 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int return false; setCoinsRet.insert(coinLowestLarger.second); nValueRet += coinLowestLarger.first; - //if ( KOMODO_EXCHANGEWALLET == 0 ) - // *interestp += lowest_interest; return true; } @@ -3435,17 +3410,12 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int { setCoinsRet.insert(coinLowestLarger.second); nValueRet += coinLowestLarger.first; - //if ( KOMODO_EXCHANGEWALLET == 0 ) - // *interestp += lowest_interest; - } - else { + } else { for (unsigned int i = 0; i < vValue.size(); i++) if (vfBest[i]) { setCoinsRet.insert(vValue[i].second); nValueRet += vValue[i].first; - //if ( KOMODO_EXCHANGEWALLET == 0 && i < count ) - // *interestp += interests[i]; } LogPrint("selectcoins", "SelectCoins() best subset: "); @@ -3484,8 +3454,7 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, setvout[out.i].nValue; - if ( KOMODO_EXCHANGEWALLET == 0 ) - value += out.tx->vout[out.i].interest; + value += out.tx->vout[out.i].interest; } if (value <= nTargetValue) { CAmount valueWithCoinbase = 0; @@ -3494,8 +3463,7 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, setvout[out.i].nValue; - if ( KOMODO_EXCHANGEWALLET == 0 ) - valueWithCoinbase += out.tx->vout[out.i].interest; + valueWithCoinbase += out.tx->vout[out.i].interest; } fNeedCoinbaseCoinsRet = (valueWithCoinbase >= nTargetValue); } @@ -3508,8 +3476,6 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, setvout[out.i].nValue; - //if ( KOMODO_EXCHANGEWALLET == 0 ) - // *interestp += out.tx->vout[out.i].interest; setCoinsRet.insert(make_pair(out.tx, out.i)); } return (nValueRet >= nTargetValue); @@ -3531,8 +3497,7 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, setvout.size() <= outpoint.n) return false; nValueFromPresetInputs += pcoin->vout[outpoint.n].nValue; - if ( KOMODO_EXCHANGEWALLET == 0 ) - nValueFromPresetInputs += pcoin->vout[outpoint.n].interest; + nValueFromPresetInputs += pcoin->vout[outpoint.n].interest; setPresetCoins.insert(make_pair(pcoin, outpoint.n)); } else return false; // TODO: Allow non-wallet inputs @@ -3747,7 +3712,7 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt //a chance at a free transaction. //But mempool inputs might still be in the mempool, so their age stays 0 //fprintf(stderr,"nCredit %.8f interest %.8f\n",(double)nCredit/COIN,(double)pcoin.first->vout[pcoin.second].interest/COIN); - if ( KOMODO_EXCHANGEWALLET == 0 && SMART_CHAIN_SYMBOL[0] == 0 ) + if ( SMART_CHAIN_SYMBOL[0] == 0 ) { interest2 += pcoin.first->vout[pcoin.second].interest; //fprintf(stderr,"%.8f ",(double)pcoin.first->vout[pcoin.second].interest/COIN); @@ -3757,11 +3722,6 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt age += 1; dPriority += (double)nCredit * age; } - //if ( KOMODO_EXCHANGEWALLET != 0 ) - //{ - //fprintf(stderr,"KOMODO_EXCHANGEWALLET disable interest sum %.8f, interest2 %.8f\n",(double)interest/COIN,(double)interest2/COIN); - //interest = 0; // interest2 also - //} if ( SMART_CHAIN_SYMBOL[0] == 0 && DONATION_PUBKEY.size() == 66 && interest2 > 5000 ) { CScript scriptDonation = CScript() << ParseHex(DONATION_PUBKEY) << OP_CHECKSIG;