Browse Source

Deletions and cleanups

pull/32/head
Duke Leto 3 years ago
parent
commit
cf57365698
  1. 4
      build-aux/m4/bitcoin_find_bdb.m4
  2. 4
      src/bitcoind.cpp
  3. 2
      src/cc/CCMarmara.h
  4. 18
      src/cc/CCinclude.h
  5. 4
      src/cc/CCutils.cpp
  6. 8
      src/cc/dice.cpp
  7. 2
      src/cc/games/prices.cpp
  8. 4
      src/cc/oracles.cpp
  9. 2186
      src/cc/prices.cpp
  10. 4
      src/crosschain.cpp
  11. 2
      src/hush.h
  12. 81
      src/hush_bitcoind.h
  13. 12
      src/hush_defs.h
  14. 56
      src/hush_gateway.h
  15. 12
      src/hush_globals.h
  16. 2
      src/hush_nSPV_fullnode.h
  17. 2
      src/hush_pax.h
  18. 45
      src/hush_utils.h
  19. 9
      src/init.cpp
  20. 40
      src/main.cpp
  21. 4
      src/metrics.cpp
  22. 12
      src/miner.cpp
  23. 6
      src/net.cpp
  24. 2
      src/net.h
  25. 2
      src/pow.cpp
  26. 4
      src/rpc/mining.cpp
  27. 4
      src/txmempool.cpp
  28. 6
      src/wallet/rpcwallet.cpp

4
build-aux/m4/bitcoin_find_bdb.m4

@ -38,7 +38,7 @@ AC_DEFUN([BITCOIN_FIND_BDB62],[
done
if test "x$bdbpath" = "xX"; then
AC_MSG_RESULT([no])
AC_MSG_ERROR([libdb_cxx headers missing, Bitcoin Core requires this library for wallet functionality (--disable-wallet to disable wallet functionality)])
AC_MSG_ERROR([libdb_cxx headers missing, Hush source code requires this library for wallet functionality (1) (--disable-wallet to disable wallet functionality)])
elif test "x$bdb62path" = "xX"; then
BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdbpath}],db_cxx)
AC_ARG_WITH([incompatible-bdb],[AS_HELP_STRING([--with-incompatible-bdb], [allow using a bdb version other than 6.2])],[
@ -60,7 +60,7 @@ AC_DEFUN([BITCOIN_FIND_BDB62],[
])
done
if test "x$BDB_LIBS" = "x"; then
AC_MSG_ERROR([libdb_cxx missing, Bitcoin Core requires this library for wallet functionality (--disable-wallet to disable wallet functionality)])
AC_MSG_ERROR([libdb_cxx missing, Hush source code requires this library for wallet functionality (2) (--disable-wallet to disable wallet functionality)])
fi
AC_SUBST(BDB_LIBS)
])

4
src/bitcoind.cpp

@ -60,7 +60,7 @@ extern int32_t ASSETCHAINS_BLOCKTIME;
extern uint64_t ASSETCHAINS_CBOPRET;
void hush_passport_iteration();
int32_t hush_longestchain();
void komodo_cbopretupdate(int32_t forceflag);
void hush_cbopretupdate(int32_t forceflag);
CBlockIndex *hush_chainactive(int32_t height);
void WaitForShutdown(boost::thread_group* threadGroup)
@ -89,7 +89,7 @@ void WaitForShutdown(boost::thread_group* threadGroup)
} else {
//hush_longestchain();
if ( ASSETCHAINS_CBOPRET != 0 )
komodo_cbopretupdate(0);
hush_cbopretupdate(0);
for (i=0; i<=ASSETCHAINS_BLOCKTIME/5; i++)
{
fShutdown = ShutdownRequested();

2
src/cc/CCMarmara.h

@ -32,7 +32,7 @@
#define EVAL_MARMARA 0xef
extern uint8_t ASSETCHAINS_MARMARA;
uint64_t komodo_block_prg(uint32_t nHeight);
uint64_t hush_block_prg(uint32_t nHeight);
int32_t MarmaraGetcreatetxid(uint256 &createtxid,uint256 txid);
int32_t MarmaraGetbatontxid(std::vector<uint256> &creditloop,uint256 &batontxid,uint256 txid);
UniValue MarmaraCreditloop(uint256 txid);

18
src/cc/CCinclude.h

@ -19,9 +19,10 @@
#define CC_INCLUDE_H
/*! \file CCinclude.h
\brief A Documented file.
\brief Cryptoconditions
CCs for teh lulz
Details.
*/
/// \mainpage Brief introduction into cryptocondition contracts
@ -240,8 +241,6 @@ extern CWallet* pwalletMain; //!< global wallet object pointer to access wallet
/// @private seems old-style
bool GetAddressUnspent(uint160 addressHash, int type,std::vector<std::pair<CAddressUnspentKey,CAddressUnspentValue> > &unspentOutputs);
//CBlockIndex *komodo_getblockindex(uint256 hash); //moved to komodo_def.h
//int32_t hush_nextheight(); //moved to komodo_def.h
/// CCgetspenttxid finds the txid of the transaction which spends a transaction output. The function does this without loading transactions from the chain, by using spent index
/// @param[out] spenttxid transaction id of the spending transaction
@ -257,11 +256,6 @@ void CCclearvars(struct CCcontract_info *cp);
UniValue CClib(struct CCcontract_info *cp,char *method,char *jsonstr);
UniValue CClib_info(struct CCcontract_info *cp);
//CBlockIndex *hush_blockindex(uint256 hash); //moved to komodo_def.h
//CBlockIndex *hush_chainactive(int32_t height); //moved to komodo_def.h
//int32_t hush_blockheight(uint256 hash); //moved to komodo_def.h
//void StartShutdown();
static const uint256 zeroid; //!< null uint256 constant
/// \cond INTERNAL
@ -380,11 +374,8 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c
/// returns true if success
bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx);
//void komodo_sendmessage(int32_t minpeers,int32_t maxpeers,const char *message,std::vector<uint8_t> payload); // moved to hush_defs.h
/// @private
int32_t payments_parsehexdata(std::vector<uint8_t> &hexdata,cJSON *item,int32_t len);
// int32_t komodo_blockload(CBlock& block,CBlockIndex *pindex); // this def in hush_defs.h
/// Makes opreturn scriptPubKey for token creation transaction. Normally this function is called internally by the tokencreate rpc. You might need to call this function to create a customized token.
/// The total opreturn length should not exceed 10001 byte
@ -701,7 +692,6 @@ uint64_t stringbits(char *str);
uint256 revuint256(uint256 txid);
char *uint256_str(char *dest,uint256 txid);
char *pubkey33_str(char *dest,uint8_t *pubkey33);
//uint256 Parseuint256(const char *hexstr); // located in komodo_defs
/// \endcond
/// converts public key as array of uint8_t to normal address
@ -795,8 +785,6 @@ int32_t CCCointxidExists(char const *logcategory,uint256 cointxid);
/// @private
uint256 BitcoinGetProofMerkleRoot(const std::vector<uint8_t> &proofData, std::vector<uint256> &txids);
// bool komodo_txnotarizedconfirmed(uint256 txid); //moved to hush_defs.h
/// @private
CPubKey check_signing_pubkey(CScript scriptSig);

4
src/cc/CCutils.cpp

@ -529,7 +529,7 @@ int64_t CCduration(int32_t &numblocks,uint256 txid)
//fprintf(stderr,"CCduration no hashBlock for txid %s\n",uint256_str(str,txid));
return(0);
}
else if ( (pindex= komodo_getblockindex(hashBlock)) == 0 || (txtime= pindex->nTime) == 0 || (txheight= pindex->GetHeight()) <= 0 )
else if ( (pindex= hush_getblockindex(hashBlock)) == 0 || (txtime= pindex->nTime) == 0 || (txheight= pindex->GetHeight()) <= 0 )
{
fprintf(stderr,"CCduration no txtime %u or txheight.%d %p for txid %s\n",txtime,txheight,pindex,uint256_str(str,txid));
return(0);
@ -666,7 +666,7 @@ uint256 BitcoinGetProofMerkleRoot(const std::vector<uint8_t> &proofData, std::ve
}
extern struct NSPV_inforesp NSPV_inforesult;
int32_t komodo_get_current_height()
int32_t hush_get_current_height()
{
if ( HUSH_NSPV_SUPERLITE )
{

8
src/cc/dice.cpp

@ -939,7 +939,7 @@ bool DiceValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx,
if ( (iswin= DiceIsWinner(entropy,entropyvout,txid,tx,vinTx,hash,sbits,minbet,maxbet,maxodds,timeoutblocks,fundingtxid)) != 0 )
{
// will only happen for fundingPubKey
if ( HUSH_INSYNC != 0 && KOMODO_DEALERNODE != 0 )
if ( HUSH_INSYNC != 0 && HUSH_DEALERNODE != 0 )
DiceQueue(iswin,sbits,fundingtxid,txid,tx,entropyvout);
}
else
@ -1791,8 +1791,8 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx
{
if ( myGetTransaction(betTx.vin[0].prevout.hash,entropyTx,hashBlock) != 0 )
{
flag = KOMODO_DEALERNODE != 0;
if ( KOMODO_DEALERNODE != 0 && scriptPubKey == fundingPubKey )
flag = HUSH_DEALERNODE != 0;
if ( HUSH_DEALERNODE != 0 && scriptPubKey == fundingPubKey )
{
bettorentropy = DiceGetEntropy(betTx,'B');
if ( (iswin= DiceIsWinner(hentropyproof,entropyvout,txid,betTx,entropyTx,bettorentropy,sbits,minbet,maxbet,maxodds,timeoutblocks,fundingtxid)) != 0 )
@ -1821,7 +1821,7 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx
}
}
}
if ( didinit == 0 && KOMODO_DEALERNODE == 0 && scriptPubKey == fundingPubKey )
if ( didinit == 0 && HUSH_DEALERNODE == 0 && scriptPubKey == fundingPubKey )
{
strcpy(_planstr,planstr);
dealer0_fundingtxid = fundingtxid;

2
src/cc/games/prices.cpp

@ -71,7 +71,7 @@ int64_t prices_blockinfo(int32_t height,char *acaddr)
std::vector<uint8_t> vopret; CBlockIndex *pindex; CBlock block; CTransaction tx,vintx; uint64_t pricebits; char destaddr[64]; uint32_t aveprice=0,timestamp,uprice; uint256 hashBlock; int64_t dist,mindist=(1LL<<60),prizefund = 0; int32_t mini=-1,i,n,vini,numvouts,iter; struct prices_bar refbar;
if ( (pindex= hush_chainactive(height)) != 0 )
{
if ( komodo_blockload(block,pindex) == 0 )
if ( hush_blockload(block,pindex) == 0 )
{
n = block.vtx.size();
vini = 0;

4
src/cc/oracles.cpp

@ -95,7 +95,7 @@
vout.n-1: opreturn with oracletxid, prevbatontxid and data in proper format
*/
extern int32_t komodo_get_current_height();
extern int32_t hush_get_current_height();
#define PUBKEY_SPOOFING_FIX_ACTIVATION 1563148800
#define CC_MARKER_VALUE 10000
@ -946,7 +946,7 @@ UniValue OracleRegister(const CPubKey& pk, int64_t txfee,uint256 oracletxid,int6
CCERR_RESULT("oraclescc",CCLOG_INFO, stream << "error adding inputs from your Oracles CC address, please fund it first with oraclesfund rpc!");
mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(markerpubkey)) << OP_CHECKSIG));
mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,batonpk));
if (GetLatestTimestamp(komodo_get_current_height())>PUBKEY_SPOOFING_FIX_ACTIVATION) mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG));
if (GetLatestTimestamp(hush_get_current_height())>PUBKEY_SPOOFING_FIX_ACTIVATION) mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG));
return(FinalizeCCTxExt(pk.IsValid(),0,cp,mtx,mypk,txfee,EncodeOraclesOpRet('R',oracletxid,mypk,datafee)));
}
CCERR_RESULT("oraclescc",CCLOG_INFO, stream << "error adding normal inputs");

2186
src/cc/prices.cpp

File diff suppressed because it is too large

4
src/crosschain.cpp

@ -42,7 +42,7 @@
// because it might be disconnecting blocks at the same time.
// TODO: this assumes a blocktime of 75 seconds for HUSH and 60 seconds for other chains
int NOTARISATION_SCAN_LIMIT_BLOCKS = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? 1152 : 1440;
CBlockIndex *komodo_getblockindex(uint256 hash);
CBlockIndex *hush_getblockindex(uint256 hash);
/* On HUSH */
uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int hushHeight,
@ -435,7 +435,7 @@ TxProof GetAssetchainProof(uint256 hash,CTransaction burnTx)
if (blockHash.IsNull())
throw std::runtime_error("tx still in mempool");
blockIndex = komodo_getblockindex(blockHash);
blockIndex = hush_getblockindex(blockHash);
int h = blockIndex->GetHeight();
// The assumption here is that the first notarization for a height GTE than
// the transaction block height will contain the corresponding MoM. If there

2
src/hush.h

@ -515,7 +515,7 @@ int32_t komodo_validate_chain(uint256 srchash,int32_t notarized_height)
static int32_t last_rewind; int32_t rewindtarget; CBlockIndex *pindex; struct hush_state *sp; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN];
if ( (sp= hush_stateptr(symbol,dest)) == 0 )
return(0);
if ( IsInitialBlockDownload() == 0 && ((pindex= komodo_getblockindex(srchash)) == 0 || pindex->GetHeight() != notarized_height) )
if ( IsInitialBlockDownload() == 0 && ((pindex= hush_getblockindex(srchash)) == 0 || pindex->GetHeight() != notarized_height) )
{
if ( sp->NOTARIZED_HEIGHT > 0 && sp->NOTARIZED_HEIGHT < notarized_height )
rewindtarget = sp->NOTARIZED_HEIGHT - 1;

81
src/hush_bitcoind.h

@ -377,7 +377,7 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port)
{
sprintf(url,(char *)"http://127.0.0.1:%u",port);
sprintf(postdata,"{\"method\":\"%s\",\"params\":%s}",method,params);
//printf("[%s] (%s) postdata.(%s) params.(%s) USERPASS.(%s)\n",SMART_CHAIN_SYMBOL,url,postdata,params,KMDUSERPASS);
//printf("[%s] (%s) postdata.(%s) params.(%s) USERPASS.(%s)\n",SMART_CHAIN_SYMBOL,url,postdata,params,HUSHUSERPASS);
retstr2 = bitcoind_RPC(&retstr,(char *)"debug",url,userpass,method,params);
//retstr = curl_post(&cHandle,url,USERPASS,postdata,0,0,0,0);
}
@ -389,17 +389,16 @@ int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heig
char *jsonstr,params[256],*userpass; uint16_t port; cJSON *json,*item; int32_t height = 0,txid_height = 0,txid_confirmations = 0;
params[0] = 0;
*kmdnotarized_heightp = 0;
if ( strcmp(dest,"KMD") == 0 )
{
port = KMD_PORT;
userpass = KMDUSERPASS;
}
else if ( strcmp(dest,"BTC") == 0 )
if ( strcmp(dest,"HUSH3") == 0 ) {
port = HUSH3_PORT;
userpass = HUSHUSERPASS;
} else if ( strcmp(dest,"BTC") == 0 )
{
port = 8332;
port = 8332;
userpass = BTCUSERPASS;
} else {
return(0);
}
else return(0);
if ( userpass[0] != 0 )
{
if ( (jsonstr= komodo_issuemethod(userpass,(char *)"getinfo",params,port)) != 0 )
@ -482,12 +481,12 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t
printf("[%s] src.%s dest.%s params.[%s] ht.%d notarized.%d\n",SMART_CHAIN_SYMBOL,symbol,dest,params,height,NOTARIZED_HEIGHT);
if ( strcmp(dest,"KMD") == 0 )
{
if ( KMDUSERPASS[0] != 0 )
if ( HUSHUSERPASS[0] != 0 )
{
if ( SMART_CHAIN_SYMBOL[0] != 0 )
{
jsonstr = komodo_issuemethod(KMDUSERPASS,(char *)"getrawtransaction",params,KMD_PORT);
//printf("userpass.(%s) got (%s)\n",KMDUSERPASS,jsonstr);
jsonstr = komodo_issuemethod(HUSHUSERPASS,(char *)"getrawtransaction",params,HUSH3_PORT);
//printf("userpass.(%s) got (%s)\n",HUSHUSERPASS,jsonstr);
}
}//else jsonstr = _dex_getrawtransaction();
else return(0); // need universal way to issue DEX* API, since notaries mine most blocks, this ok
@ -556,12 +555,12 @@ CScript komodo_makeopret(CBlock *pblock, bool fNew)
return(opret);
}
/*uint256 komodo_getblockhash(int32_t height)
/*uint256 hush_getblockhash(int32_t height)
{
uint256 hash; char params[128],*hexstr,*jsonstr; cJSON *result; int32_t i; uint8_t revbuf[32];
memset(&hash,0,sizeof(hash));
sprintf(params,"[%d]",height);
if ( (jsonstr= komodo_issuemethod(KMDUSERPASS,(char *)"getblockhash",params,BITCOIND_RPCPORT)) != 0 )
if ( (jsonstr= komodo_issuemethod(HUSHUSERPASS,(char *)"getblockhash",params,BITCOIND_RPCPORT)) != 0 )
{
if ( (result= cJSON_Parse(jsonstr)) != 0 )
{
@ -582,7 +581,7 @@ CScript komodo_makeopret(CBlock *pblock, bool fNew)
return(hash);
}
uint256 _komodo_getblockhash(int32_t height);*/
uint256 _hush_getblockhash(int32_t height);*/
uint64_t komodo_seed(int32_t height)
{
@ -595,9 +594,9 @@ uint64_t komodo_seed(int32_t height)
if ( height > 10 )
height -= 10;
if ( SMART_CHAIN_SYMBOL[0] == 0 )
hash = _komodo_getblockhash(height);
hash = _hush_getblockhash(height);
if ( memcmp(&hash,&zero,sizeof(hash)) == 0 )
hash = komodo_getblockhash(height);
hash = hush_getblockhash(height);
int32_t i;
for (i=0; i<32; i++)
printf("%02x",((uint8_t *)&hash)[i]);
@ -639,7 +638,7 @@ uint32_t komodo_txtime(CScript &opret,uint64_t *valuep,uint256 hash, int32_t n,
return(tx.nLockTime);
}
CBlockIndex *komodo_getblockindex(uint256 hash)
CBlockIndex *hush_getblockindex(uint256 hash)
{
BlockMap::const_iterator it = mapBlockIndex.find(hash);
return((it != mapBlockIndex.end()) ? it->second : NULL);
@ -658,7 +657,7 @@ uint32_t komodo_txtime2(uint64_t *valuep,uint256 hash,int32_t n,char *destaddr)
//fprintf(stderr,"ERROR: %s/v%d locktime.%u\n",hash.ToString().c_str(),n,(uint32_t)tx.nLockTime);
return(0);
}
if ( (pindex= komodo_getblockindex(hashBlock)) != 0 )
if ( (pindex= hush_getblockindex(hashBlock)) != 0 )
txtime = pindex->nTime;
else txtime = tx.nLockTime;
//fprintf(stderr,"%s/v%d locktime.%u\n",hash.ToString().c_str(),n,(uint32_t)tx.nLockTime);
@ -671,7 +670,7 @@ uint32_t komodo_txtime2(uint64_t *valuep,uint256 hash,int32_t n,char *destaddr)
return(txtime);
}
bool komodo_checkopret(CBlock *pblock, CScript &merkleroot)
bool hush_checkopret(CBlock *pblock, CScript &merkleroot)
{
merkleroot = pblock->vtx.back().vout.back().scriptPubKey;
return(merkleroot.IsOpReturn() && merkleroot == komodo_makeopret(pblock, false));
@ -792,7 +791,7 @@ int32_t hush_block2pubkey33(uint8_t *pubkey33,CBlock *block)
return(0);
}
int32_t komodo_blockload(CBlock& block,CBlockIndex *pindex)
int32_t hush_blockload(CBlock& block,CBlockIndex *pindex)
{
block.SetNull();
// Open history file to read
@ -849,7 +848,7 @@ uint32_t hush_heightstamp(int32_t height)
if ( HUSH_LOADINGBLOCKS == 0 )
memset(pindex->pubkey33,0xff,33);
else memset(pindex->pubkey33,0,33);
if ( komodo_blockload(block,pindex) == 0 )
if ( hush_blockload(block,pindex) == 0 )
{
hush_block2pubkey33(pindex->pubkey33,&block);
//for (i=0; i<33; i++)
@ -884,7 +883,7 @@ void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height)
memset(pubkey33,0,33);
if ( pindex != 0 )
{
if ( komodo_blockload(block,pindex) == 0 )
if ( hush_blockload(block,pindex) == 0 )
hush_block2pubkey33(pubkey33,&block);
}
}
@ -928,7 +927,7 @@ int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,uint32_t blo
if ( (pindex= hush_chainactive(height-i)) != 0 )
{
blocktimes[i] = pindex->nTime;
if ( komodo_blockload(block,pindex) == 0 )
if ( hush_blockload(block,pindex) == 0 )
{
hush_block2pubkey33(pubkeys[i],&block);
for (j=0; j<n; j++)
@ -960,7 +959,7 @@ int32_t komodo_minerids(uint8_t *minerids,int32_t height,int32_t width)
continue;
if ( (pindex= hush_chainactive(height-width+i+1)) != 0 )
{
if ( komodo_blockload(block,pindex) == 0 )
if ( hush_blockload(block,pindex) == 0 )
{
hush_block2pubkey33(pubkey33,&block);
for (j=0; j<numnotaries; j++)
@ -1073,9 +1072,9 @@ int32_t komodo_isrealtime(int32_t *kmdheightp)
}
/*
komodo_checkPOW (fast) is called early in the process and should only refer to data immediately available. it is a filter to prevent bad blocks from going into the local DB. The more blocks we can filter out at this stage, the less junk in the local DB that will just get purged later on.
hush_checkPOW (fast) is called early in the process and should only refer to data immediately available. it is a filter to prevent bad blocks from going into the local DB. The more blocks we can filter out at this stage, the less junk in the local DB that will just get purged later on.
komodo_checkPOW (slow) is called right before connecting blocks so all prior blocks can be assumed to be there and all checks must pass
hush_checkPOW (slow) is called right before connecting blocks so all prior blocks can be assumed to be there and all checks must pass
commission must be in coinbase.vout[1] and must be >= 10000 sats
*/
@ -1276,7 +1275,7 @@ int8_t hush_segid(int32_t nocache,int32_t height)
{
if ( nocache == 0 && pindex->segid >= -1 )
return(pindex->segid);
if ( komodo_blockload(block,pindex) == 0 )
if ( hush_blockload(block,pindex) == 0 )
{
txn_count = block.vtx.size();
if ( txn_count > 1 && block.vtx[txn_count-1].vin.size() == 1 && block.vtx[txn_count-1].vout.size() == 1 )
@ -1484,7 +1483,7 @@ uint64_t komodo_notarypayamount(int32_t nHeight, int64_t notarycount)
return(ret);
}
int32_t komodo_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *script, int32_t len)
int32_t hush_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *script, int32_t len)
{
// Check the notarisation is valid, and extract notarised height.
uint64_t voutmask;
@ -1515,7 +1514,7 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector<int8_t> &Notar
return(0);
// Check the notarisation is valid.
int32_t notarizedheight = komodo_getnotarizedheight(timestamp, height, script, len);
int32_t notarizedheight = hush_getnotarizedheight(timestamp, height, script, len);
if ( notarizedheight == 0 )
return(0);
@ -1570,7 +1569,7 @@ bool GetNotarizationNotaries(uint8_t notarypubkeys[64][33], int8_t &numNN, const
return true;
}
uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height)
uint64_t hush_checknotarypay(CBlock *pblock,int32_t height)
{
std::vector<int8_t> NotarizationNotaries; uint8_t *script; int32_t scriptlen;
uint64_t timestamp = pblock->nTime;
@ -1722,7 +1721,7 @@ void GetHushEarlytxidScriptPub()
StartShutdown();
}
int64_t komodo_checkcommission(CBlock *pblock,int32_t height)
int64_t hush_checkcommission(CBlock *pblock,int32_t height)
{
if(fDebug)
fprintf(stderr,"%s at height=%d\n",__func__,height);
@ -1732,7 +1731,7 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height)
checktoshis = the_commission(pblock,height);
if ( checktoshis >= 10000 && pblock->vtx[0].vout.size() < 2 )
{
fprintf(stderr,"ERROR: komodo_checkcommission vsize.%d height.%d commission %.8f has checktoshis=%lu <10000 or less than 2 vouts (vouts=%lu)\n",(int32_t)pblock->vtx[0].vout.size(),height,(double)checktoshis/COIN, checktoshis, pblock->vtx[0].vout.size() );
fprintf(stderr,"ERROR: hush_checkcommission vsize.%d height.%d commission %.8f has checktoshis=%lu <10000 or less than 2 vouts (vouts=%lu)\n",(int32_t)pblock->vtx[0].vout.size(),height,(double)checktoshis/COIN, checktoshis, pblock->vtx[0].vout.size() );
return(-1);
}
else if ( checktoshis != 0 )
@ -1791,14 +1790,14 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height)
bool HUSH_TEST_ASSETCHAIN_SKIP_POW = 0;
int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
int32_t hush_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
{
uint256 hash,merkleroot; arith_uint256 bnTarget,bhash; bool fNegative,fOverflow; uint8_t *script,pubkey33[33],pubkeys[64][33]; int32_t i,scriptlen,possible,PoSperc,is_PoSblock=0,n,failed = 0,notaryid = -1; int64_t checktoshis,value; CBlockIndex *pprev;
if ( HUSH_TEST_ASSETCHAIN_SKIP_POW == 0 && Params().NetworkIDString() == "regtest" )
HUSH_TEST_ASSETCHAIN_SKIP_POW = 1;
if ( !CheckEquihashSolution(pblock, Params()) )
{
fprintf(stderr,"komodo_checkPOW slowflag.%d ht.%d CheckEquihashSolution failed\n",slowflag,height);
fprintf(stderr,"hush_checkPOW slowflag.%d ht.%d CheckEquihashSolution failed\n",slowflag,height);
return(-1);
}
hash = pblock->GetHash();
@ -1855,7 +1854,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
return(-1);
}
} else {
if ( komodo_checkcommission(pblock,height) < 0 )
if ( hush_checkcommission(pblock,height) < 0 )
return(-1);
}
}
@ -1886,7 +1885,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
}
if(fDebug) {
fprintf(stderr,"komodo_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed);
fprintf(stderr,"hush_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed);
}
if ( failed != 0 && possible == 0 && notaryid < 0 ) {
return(-1);
@ -1895,10 +1894,10 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
}
}
int32_t komodo_acpublic(uint32_t tiptime)
int32_t hush_scpublic(uint32_t tiptime)
{
int32_t acpublic = ASSETCHAINS_PUBLIC; CBlockIndex *pindex;
return(acpublic);
// HUSH does not support public blockchains, go use something else if you want no privacy
return 0;
}
int64_t hush_newcoins(int64_t *zfundsp,int64_t *sproutfundsp,int32_t nHeight,CBlock *pblock)
@ -1962,7 +1961,7 @@ int64_t hush_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height)
{
if ( pindex->newcoins == 0 && pindex->zfunds == 0 )
{
if ( komodo_blockload(block,pindex) == 0 ) {
if ( hush_blockload(block,pindex) == 0 ) {
pindex->newcoins = hush_newcoins(&pindex->zfunds,&pindex->sproutfunds,pindex->GetHeight(),&block);
} else {
fprintf(stderr,"error loading block.%d\n",pindex->GetHeight());

12
src/hush_defs.h

@ -26,7 +26,7 @@
#define KOMODO_ELECTION_GAP 2000
#define ROUNDROBIN_DELAY 61
#define HUSH_SMART_CHAIN_MAXLEN 65
#define KOMODO_LIMITED_NETWORKSIZE 4
#define HUSH_LIMITED_NETWORKSIZE 4
#define DRAGON_MAXSCRIPTSIZE 10001
#define HUSH_MAXMEMPOOLTIME 3600 // affects consensus
#define CRYPTO555_PUBSECPSTR "038a1bd41a08f38edda51042988022933c5775dfce81f7bae0b32a9179650352ac"
@ -480,7 +480,7 @@ static const char *notaries_elected[NUM_HUSH_SEASONS][NUM_HUSH_NOTARIES][2] =
#define CLEARBIT(bits,bitoffset) (((uint8_t *)bits)[(bitoffset) >> 3] &= ~(1 << ((bitoffset) & 7)))
#define HUSH_MAXNVALUE (((uint64_t)1 << 63) - 1)
#define KOMODO_BIT63SET(x) ((x) & ((uint64_t)1 << 63))
#define HUSH_BIT63SET(x) ((x) & ((uint64_t)1 << 63))
#define HUSH_VALUETOOBIG(x) ((x) > (uint64_t)10000000001*COIN)
//#ifndef TESTMODE
@ -500,7 +500,7 @@ extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_FOUNDERS_REWARD;
extern int32_t ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER,ASSETCHAINS_BLOCKTIME;
extern uint64_t ASSETCHAINS_TIMELOCKGTE;
extern uint32_t ASSETCHAINS_ALGO,ASSETCHAINS_EQUIHASH,HUSH_INITDONE;
extern int32_t HUSH_MININGTHREADS,HUSH_LONGESTCHAIN,ASSETCHAINS_SEED,IS_HUSH_NOTARY,USE_EXTERNAL_PUBKEY,HUSH_CHOSEN_ONE,KOMODO_ON_DEMAND,HUSH_PASSPORT_INITDONE,ASSETCHAINS_STAKED,HUSH_NSPV;
extern int32_t HUSH_MININGTHREADS,HUSH_LONGESTCHAIN,ASSETCHAINS_SEED,IS_HUSH_NOTARY,USE_EXTERNAL_PUBKEY,HUSH_CHOSEN_ONE,HUSH_ON_DEMAND,HUSH_PASSPORT_INITDONE,ASSETCHAINS_STAKED,HUSH_NSPV;
extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_LASTERA,ASSETCHAINS_CBOPRET;
extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[],ASSETCHAINS_NK[2];
extern const char *ASSETCHAINS_ALGORITHMS[];
@ -509,7 +509,7 @@ extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY,ASSETCHAINS_SCRIPTP
extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_MARMARA;
extern std::vector<std::string> ASSETCHAINS_PRICES,ASSETCHAINS_STOCKS;
extern uint256 HUSH_EARLYTXID;
extern int32_t HUSH_CONNECTING,HUSH_CCACTIVATE,KOMODO_DEALERNODE;
extern int32_t HUSH_CONNECTING,HUSH_CCACTIVATE,HUSH_DEALERNODE;
extern uint32_t ASSETCHAINS_CC;
extern std::string CCerror,ASSETCHAINS_CCLIB;
extern uint8_t ASSETCHAINS_CCDISABLES[256];
@ -562,13 +562,13 @@ bool hush_hardfork_active(uint32_t time);
uint256 Parseuint256(const char *hexstr);
void komodo_sendmessage(int32_t minpeers, int32_t maxpeers, const char *message, std::vector<uint8_t> payload);
CBlockIndex *komodo_getblockindex(uint256 hash);
CBlockIndex *hush_getblockindex(uint256 hash);
int32_t hush_nextheight();
CBlockIndex *hush_blockindex(uint256 hash);
CBlockIndex *hush_chainactive(int32_t height);
int32_t hush_blockheight(uint256 hash);
bool komodo_txnotarizedconfirmed(uint256 txid);
int32_t komodo_blockload(CBlock& block, CBlockIndex *pindex);
int32_t hush_blockload(CBlock& block, CBlockIndex *pindex);
uint32_t hush_chainactive_timestamp();
uint32_t GetLatestTimestamp(int32_t height);

56
src/hush_gateway.h

@ -485,7 +485,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
strcpy(symbol,base);
if ( SMART_CHAIN_SYMBOL[0] != 0 && komodo_baseid(SMART_CHAIN_SYMBOL) < 0 )
return(0);
PENDING_KOMODO_TX = 0;
PENDING_HUSH_TX = 0;
for (i=0; i<3; i++)
{
if ( komodo_isrealtime(&ht) != 0 )
@ -589,13 +589,13 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
data[len++] = ((uint8_t *)&pax->txid)[i];
data[len++] = pax->vout & 0xff;
data[len++] = (pax->vout >> 8) & 0xff;
PENDING_KOMODO_TX += pax->fiatoshis;
PENDING_HUSH_TX += pax->fiatoshis;
}
else
{
len += komodo_rwapproval(1,&data[len],pax);
PENDING_KOMODO_TX += pax->komodoshis;
printf(" len.%d vout.%u DEPOSIT %.8f <- pax.%s pending ht %d %d %.8f | ",len,pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,pax->height,pax->otherheight,dstr(PENDING_KOMODO_TX));
PENDING_HUSH_TX += pax->komodoshis;
printf(" len.%d vout.%u DEPOSIT %.8f <- pax.%s pending ht %d %d %.8f | ",len,pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,pax->height,pax->otherheight,dstr(PENDING_HUSH_TX));
}
if ( numvouts++ >= 64 || sum > COIN )
break;
@ -618,7 +618,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
memcpy(script,opret,opretlen);
for (i=0; i<8; i++)
printf("%02x",opret[i]);
printf(" <- opret, MINER deposits.%d (%s) vouts.%d %.8f opretlen.%d\n",tokomodo,SMART_CHAIN_SYMBOL,numvouts,dstr(PENDING_KOMODO_TX),opretlen);
printf(" <- opret, MINER deposits.%d (%s) vouts.%d %.8f opretlen.%d\n",tokomodo,SMART_CHAIN_SYMBOL,numvouts,dstr(PENDING_HUSH_TX),opretlen);
return(1);
}
return(0);
@ -656,7 +656,7 @@ const char *banned_txids[] =
//"ce567928b5490a17244167af161b1d8dd6ff753fef222fe6855d95b2278a35b3", // missed
};
int32_t komodo_checkvout(int32_t vout,int32_t k,int32_t indallvouts)
int32_t hush_checkvout(int32_t vout,int32_t k,int32_t indallvouts)
{
if ( k < indallvouts )
return(vout == 1);
@ -681,7 +681,7 @@ int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max)
void hush_passport_iteration();
int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtime) // verify above block is valid pax pricing
int32_t hush_check_deposit(int32_t height,const CBlock& block,uint32_t prevtime) // verify above block is valid pax pricing
{
static uint256 array[64]; static int32_t numbanned,indallvouts;
int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,notmatched=0,matched=0,kmdheights[256],otherheights[256]; uint256 hash,txids[256]; char symbol[HUSH_SMART_CHAIN_MAXLEN],base[HUSH_SMART_CHAIN_MAXLEN]; uint16_t vouts[256]; int8_t baseids[256]; uint8_t *script,opcode,rmd160s[256*20]; uint64_t total,subsidy,available,deposited,issued,withdrawn,approved,redeemed,seed; int64_t checktoshis,values[256],srcvalues[256]; struct pax_transaction *pax; struct hush_state *sp; CTransaction tx;
@ -730,7 +730,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim
{
for (k=0; k<numbanned; k++)
{
if ( block.vtx[i].vin[j].prevout.hash == array[k] && komodo_checkvout(block.vtx[i].vin[j].prevout.n,k,indallvouts) != 0 ) //(block.vtx[i].vin[j].prevout.n == 1 || k >= indallvouts) )
if ( block.vtx[i].vin[j].prevout.hash == array[k] && hush_checkvout(block.vtx[i].vin[j].prevout.n,k,indallvouts) != 0 ) //(block.vtx[i].vin[j].prevout.n == 1 || k >= indallvouts) )
{
printf("banned tx.%d being used at ht.%d txi.%d vini.%d\n",k,height,i,j);
return(-1);
@ -804,7 +804,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim
checktoshis = 0;
if ( (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD) && height > 1 )
{
if ( (checktoshis= komodo_checkcommission((CBlock *)&block,height)) < 0 )
if ( (checktoshis= hush_checkcommission((CBlock *)&block,height)) < 0 )
{
fprintf(stderr,"ht.%d checktoshis %.8f overflow.%d total %.8f strangeout.%d\n",height,dstr(checktoshis),overflow,dstr(total),strangeout);
return(-1);
@ -1568,7 +1568,7 @@ void hush_passport_iteration()
extern std::vector<uint8_t> Mineropret; // opreturn data set by the data gathering code
#define PRICES_ERRORRATE (COIN / 100) // maximum acceptable change, set at 1%
#define PRICES_SIZEBIT0 (sizeof(uint32_t) * 4) // 4 uint32_t unixtimestamp, BTCUSD, BTCGBP and BTCEUR
#define KOMODO_LOCALPRICE_CACHESIZE 13
#define HUSH_LOCALPRICE_CACHESIZE 13
#define HUSH_MAXPRICES 2048
#define PRICES_SMOOTHWIDTH 1
@ -1594,14 +1594,14 @@ struct komodo_priceinfo
char symbol[64];
} PRICES[HUSH_MAXPRICES];
uint32_t PriceCache[KOMODO_LOCALPRICE_CACHESIZE][HUSH_MAXPRICES];//4+sizeof(Cryptos)/sizeof(*Cryptos)+sizeof(Forex)/sizeof(*Forex)];
uint32_t PriceCache[HUSH_LOCALPRICE_CACHESIZE][HUSH_MAXPRICES];//4+sizeof(Cryptos)/sizeof(*Cryptos)+sizeof(Forex)/sizeof(*Forex)];
int64_t PriceMult[HUSH_MAXPRICES];
int32_t komodo_cbopretsize(uint64_t flags);
int32_t hush_cbopretsize(uint64_t flags);
void komodo_PriceCache_shift()
{
int32_t i;
for (i=KOMODO_LOCALPRICE_CACHESIZE-1; i>0; i--)
for (i=HUSH_LOCALPRICE_CACHESIZE-1; i>0; i--)
memcpy(PriceCache[i],PriceCache[i-1],sizeof(PriceCache[i]));
memcpy(PriceCache[0],Mineropret.data(),Mineropret.size());
}
@ -1630,7 +1630,7 @@ int32_t hush_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeigh
*seedp = 0;
if ( (pindex= hush_chainactive(nHeight)) != 0 )
{
if ( komodo_blockload(block,pindex) == 0 )
if ( hush_blockload(block,pindex) == 0 )
{
return(_hush_heightpricebits(seedp,heightbits,&block));
}
@ -1727,7 +1727,7 @@ CScript komodo_mineropret(int32_t nHeight)
if ( numzero != 0 )
{
fprintf(stderr," komodo_mineropret numzero.%d vs n.%d\n",numzero,n);
komodo_cbopretupdate(1);
hush_cbopretupdate(1);
sleep(61);
}
}
@ -1856,13 +1856,13 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i
if ( iter == 0 )
break;
// second iteration checks recent prices to see if within local volatility
for (j=0; j<KOMODO_LOCALPRICE_CACHESIZE; j++)
for (j=0; j<HUSH_LOCALPRICE_CACHESIZE; j++)
if ( PriceCache[j][i] >= prevbits[i] )
{
fprintf(stderr,"i.%d within recent localprices[%d] %u >= %u\n",i,j,PriceCache[j][i],prevbits[i]);
break;
}
if ( j == KOMODO_LOCALPRICE_CACHESIZE )
if ( j == HUSH_LOCALPRICE_CACHESIZE )
{
komodo_queuelocalprice(1,nHeight,block->nTime,bhash,i,prevbits[i]);
break;
@ -1872,13 +1872,13 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i
{
if ( iter == 0 )
break;
for (j=0; j<KOMODO_LOCALPRICE_CACHESIZE; j++)
for (j=0; j<HUSH_LOCALPRICE_CACHESIZE; j++)
if ( PriceCache[j][i] <= prevbits[i] )
{
fprintf(stderr,"i.%d within recent localprices[%d] %u <= prev %u\n",i,j,PriceCache[j][i],prevbits[i]);
break;
}
if ( j == KOMODO_LOCALPRICE_CACHESIZE )
if ( j == HUSH_LOCALPRICE_CACHESIZE )
{
komodo_queuelocalprice(-1,nHeight,block->nTime,bhash,i,prevbits[i]);
break;
@ -1891,7 +1891,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i
if ( iter == 0 )
{
fprintf(stderr,"force update prices\n");
komodo_cbopretupdate(1);
hush_cbopretupdate(1);
memcpy(localbits,Mineropret.data(),Mineropret.size());
} else return(-1);
}
@ -2199,10 +2199,10 @@ int32_t get_btcusd(uint32_t pricebits[4])
return(-1);
}
// komodo_cbopretupdate() obtains the external price data and encodes it into Mineropret, which will then be used by the miner and validation
// hush_cbopretupdate() obtains the external price data and encodes it into Mineropret, which will then be used by the miner and validation
// save history, use new data to approve past rejection, where is the auto-reconsiderblock?
int32_t komodo_cbopretsize(uint64_t flags)
int32_t hush_cbopretsize(uint64_t flags)
{
int32_t size = 0;
if ( (ASSETCHAINS_CBOPRET & 1) != 0 )
@ -2220,7 +2220,7 @@ int32_t komodo_cbopretsize(uint64_t flags)
extern uint256 Queued_reconsiderblock;
void komodo_cbopretupdate(int32_t forceflag)
void hush_cbopretupdate(int32_t forceflag)
{
static uint32_t lasttime,lastbtc,pending;
static uint32_t pricebits[4],pricebuf[HUSH_MAXPRICES],forexprices[sizeof(Forex)/sizeof(*Forex)];
@ -2243,7 +2243,7 @@ void komodo_cbopretupdate(int32_t forceflag)
{
//if ( hush_nextheight() > 333 ) // for debug only!
// ASSETCHAINS_CBOPRET = 7;
size = komodo_cbopretsize(ASSETCHAINS_CBOPRET);
size = hush_cbopretsize(ASSETCHAINS_CBOPRET);
if ( Mineropret.size() < size )
Mineropret.resize(size);
size = PRICES_SIZEBIT0;
@ -2418,7 +2418,7 @@ char *komodo_pricename(char *name,int32_t ind)
// finds index for its symbol name
int32_t komodo_priceind(const char *symbol)
{
char name[65]; int32_t i,n = (int32_t)(komodo_cbopretsize(ASSETCHAINS_CBOPRET) / sizeof(uint32_t));
char name[65]; int32_t i,n = (int32_t)(hush_cbopretsize(ASSETCHAINS_CBOPRET) / sizeof(uint32_t));
for (i=1; i<n; i++)
{
komodo_pricename(name,i);
@ -2712,8 +2712,8 @@ int32_t komodo_pricesinit()
fputc(0,PRICES[0].fp);
fflush(PRICES[0].fp);
}
fprintf(stderr,"pricesinit done i.%d num.%d numprices.%d\n",i,num,(int32_t)(komodo_cbopretsize(ASSETCHAINS_CBOPRET)/sizeof(uint32_t)));
if ( i != num || i != komodo_cbopretsize(ASSETCHAINS_CBOPRET)/sizeof(uint32_t) )
fprintf(stderr,"pricesinit done i.%d num.%d numprices.%d\n",i,num,(int32_t)(hush_cbopretsize(ASSETCHAINS_CBOPRET)/sizeof(uint32_t)));
if ( i != num || i != hush_cbopretsize(ASSETCHAINS_CBOPRET)/sizeof(uint32_t) )
{
fprintf(stderr,"fatal error opening prices files, start shutdown\n");
StartShutdown();
@ -2737,7 +2737,7 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock)
if ( numprices == 0 )
{
pthread_mutex_init(&pricemutex,0);
numprices = (int32_t)(komodo_cbopretsize(ASSETCHAINS_CBOPRET) / sizeof(uint32_t));
numprices = (int32_t)(hush_cbopretsize(ASSETCHAINS_CBOPRET) / sizeof(uint32_t));
ptr32 = (uint32_t *)calloc(sizeof(uint32_t),numprices * width);
ptr64 = (int64_t *)calloc(sizeof(int64_t),PRICES_DAYWINDOW*PRICES_MAXDATAPOINTS);
tmpbuf = (int64_t *)calloc(sizeof(int64_t),2*PRICES_DAYWINDOW);

12
src/hush_globals.h

@ -31,7 +31,7 @@ uint64_t komodo_paxtotal();
int32_t hush_longestchain();
uint64_t komodo_maxallowed(int32_t baseid);
int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max);
int32_t komodo_checkvout(int32_t vout,int32_t k,int32_t indallvouts);
int32_t hush_checkvout(int32_t vout,int32_t k,int32_t indallvouts);
pthread_mutex_t komodo_mutex,staked_mutex;
#define KOMODO_ELECTION_GAP 2000 //((SMART_CHAIN_SYMBOL[0] == 0) ? 2000 : 100)
@ -47,7 +47,7 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100;
unsigned int WITNESS_CACHE_SIZE = _COINBASE_MATURITY+10;
uint256 HUSH_EARLYTXID;
int32_t HUSH_MININGTHREADS = -1,IS_HUSH_NOTARY,USE_EXTERNAL_PUBKEY,HUSH_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,HUSH_EXTERNAL_NOTARIES,HUSH_PASSPORT_INITDONE,HUSH_PAX,HUSH_EXCHANGEWALLET,HUSH_REWIND,HUSH_CONNECTING = -1,KOMODO_DEALERNODE,HUSH_EXTRASATOSHI,ASSETCHAINS_FOUNDERS,ASSETCHAINS_CBMATURITY,HUSH_NSPV;
int32_t HUSH_MININGTHREADS = -1,IS_HUSH_NOTARY,USE_EXTERNAL_PUBKEY,HUSH_CHOSEN_ONE,ASSETCHAINS_SEED,HUSH_ON_DEMAND,HUSH_EXTERNAL_NOTARIES,HUSH_PASSPORT_INITDONE,HUSH_PAX,HUSH_EXCHANGEWALLET,HUSH_REWIND,HUSH_CONNECTING = -1,HUSH_DEALERNODE,HUSH_EXTRASATOSHI,ASSETCHAINS_FOUNDERS,ASSETCHAINS_CBMATURITY,HUSH_NSPV;
int32_t HUSH_INSYNC,HUSH_LASTMINED,prevHUSH_LASTMINED,HUSH_CCACTIVATE;
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;
@ -95,8 +95,8 @@ int32_t ASSETCHAINS_OVERWINTER = -1;
int32_t ASSETCHAINS_STAKED;
uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY = 10,ASSETCHAINS_FOUNDERS_REWARD;
uint32_t HUSH_INITDONE;
char KMDUSERPASS[8192+512+1],BTCUSERPASS[8192]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771;
uint64_t PENDING_KOMODO_TX;
char HUSHUSERPASS[8192+512+1],BTCUSERPASS[8192]; uint16_t HUSH3_PORT = 18031,BITCOIND_RPCPORT = 18031;
uint64_t PENDING_HUSH_TX;
extern int32_t HUSH_LOADINGBLOCKS;
unsigned int MAX_BLOCK_SIGOPS = 20000;
int32_t HUSH_TESTNODE, HUSH_SNAPSHOT_INTERVAL;
@ -264,11 +264,11 @@ uint64_t hush_current_supply(uint32_t nHeight)
}
}
}
if ( KOMODO_BIT63SET(cur_money) != 0 )
if ( HUSH_BIT63SET(cur_money) != 0 )
return(HUSH_MAXNVALUE);
if ( ASSETCHAINS_COMMISSION != 0 ) {
uint64_t newval = (cur_money + (cur_money/COIN * ASSETCHAINS_COMMISSION));
if ( KOMODO_BIT63SET(newval) != 0 )
if ( HUSH_BIT63SET(newval) != 0 )
return(HUSH_MAXNVALUE);
else if ( newval < cur_money ) // check for underflow
return(HUSH_MAXNVALUE);

2
src/hush_nSPV_fullnode.h

@ -765,7 +765,7 @@ int32_t NSPV_gettxproof(struct NSPV_txproof *ptr,int32_t vout,uint256 txid,int32
else
{
ptr->height = height;
if ( (pindex= hush_chainactive(height)) != 0 && komodo_blockload(block,pindex) == 0 )
if ( (pindex= hush_chainactive(height)) != 0 && hush_blockload(block,pindex) == 0 )
{
BOOST_FOREACH(const CTransaction&tx, block.vtx)
{

2
src/hush_pax.h

@ -742,7 +742,7 @@ uint64_t PAX_fiatdest(uint64_t *seedp,int32_t tokomodo,char *destaddr,uint8_t pu
if ( bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr) == 20 )
{
PAX_pubkey(1,pubkey33,&addrtype,rmd160,base,&shortflag,tokomodo != 0 ? &komodoshis : &fiatoshis);
bitcoin_address(destaddr,KOMODO_PUBTYPE,pubkey33,33);
bitcoin_address(destaddr,HUSH_PUBTYPE,pubkey33,33);
}
return(komodoshis);
}

45
src/hush_utils.h

@ -49,7 +49,7 @@ typedef struct queue
#define CRYPTO555_HUSHADDR "RFetqf8WUfWnwNeXdknkm8ojk7EXnYFzrv"
#define CRYPTO555_RMD160STR "deadbeefbadcaca748c4986b240ff7d7bc3fffb0"
#define KOMODO_PUBTYPE 60
#define HUSH_PUBTYPE 60
struct sha256_vstate { uint64_t length; uint32_t state[8],curlen; uint8_t buf[64]; };
struct rmd160_vstate { uint64_t length; uint8_t buf[64]; uint32_t curlen, state[5]; };
@ -1025,7 +1025,7 @@ int32_t komodo_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_
// get a pseudo random number that is the same for each block individually at all times and different
// from all other blocks. the sequence is extremely likely, but not guaranteed to be unique for each block chain
uint64_t komodo_block_prg(uint32_t nHeight)
uint64_t hush_block_prg(uint32_t nHeight)
{
int i;
uint8_t hashSrc[8];
@ -1050,7 +1050,7 @@ uint64_t komodo_block_prg(uint32_t nHeight)
// given a block height, this returns the unlock time for that block height, derived from
// the ASSETCHAINS_MAGIC number as well as the block height, providing different random numbers
// for corresponding blocks across chains, but the same sequence in each chain
int64_t komodo_block_unlocktime(uint32_t nHeight)
int64_t hush_block_unlocktime(uint32_t nHeight)
{
uint64_t fromTime, toTime, unlocktime;
@ -1058,7 +1058,7 @@ int64_t komodo_block_unlocktime(uint32_t nHeight)
unlocktime = ASSETCHAINS_TIMEUNLOCKTO;
else
{
unlocktime = komodo_block_prg(nHeight) / (0xffffffffffffffff / ((ASSETCHAINS_TIMEUNLOCKTO - ASSETCHAINS_TIMEUNLOCKFROM) + 1));
unlocktime = hush_block_prg(nHeight) / (0xffffffffffffffff / ((ASSETCHAINS_TIMEUNLOCKTO - ASSETCHAINS_TIMEUNLOCKFROM) + 1));
// boundary and power of 2 can make it exceed to time by 1
unlocktime = unlocktime + ASSETCHAINS_TIMEUNLOCKFROM;
if (unlocktime > ASSETCHAINS_TIMEUNLOCKTO)
@ -1320,7 +1320,7 @@ uint16_t _komodo_userpass(char *username,char *password,FILE *fp)
strcpy(username,rpcuser);
strcpy(password,rpcpassword);
}
//printf("rpcuser.(%s) rpcpassword.(%s) KMDUSERPASS.(%s) %u\n",rpcuser,rpcpassword,KMDUSERPASS,port);
//printf("rpcuser.(%s) rpcpassword.(%s) HUSHUSERPASS.(%s) %u\n",rpcuser,rpcpassword,HUSHUSERPASS,port);
if ( rpcuser != 0 )
free(rpcuser);
if ( rpcpassword != 0 )
@ -1403,9 +1403,7 @@ void komodo_configfile(char *symbol,uint16_t rpcport)
printf("Created (%s)\n",fname);
} else printf("Couldnt create (%s)\n",fname);
#endif
}
else
{
} else {
_komodo_userpass(myusername,mypassword,fp);
mapArgs["-rpcpassword"] = mypassword;
mapArgs["-rpcusername"] = myusername;
@ -1430,10 +1428,10 @@ void komodo_configfile(char *symbol,uint16_t rpcport)
if ( (fp= fopen(fname,"rb")) != 0 )
{
if ( (kmdport= _komodo_userpass(username,password,fp)) != 0 )
KMD_PORT = kmdport;
sprintf(KMDUSERPASS,"%s:%s",username,password);
HUSH3_PORT = kmdport;
sprintf(HUSHUSERPASS,"%s:%s",username,password);
fclose(fp);
//printf("KOMODO.(%s) -> userpass.(%s)\n",fname,KMDUSERPASS);
//printf("HUSH.(%s) -> userpass.(%s)\n",fname,HUSHUSERPASS);
} //else printf("couldnt open.(%s)\n",fname);
}
@ -1492,9 +1490,6 @@ uint16_t hush_smartport(uint32_t magic,int32_t extralen)
else return(16000 + (magic % 49500));
}
// DUKE: extralen is sometimes wrong which causes wrong diffbits?
// This function is only called on startup, blocktime changing code does not modify magic
// Hush 3.5.x and Hush 3.6.x have same history and p2p ports, but different magic??? Seems not.
uint16_t hush_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extraptr,int32_t extralen)
{
if(fDebug)
@ -1629,7 +1624,7 @@ uint64_t hush_block_subsidy(int height)
}
// wrapper for more general supply curves of Hush Smart Chains
uint64_t komodo_ac_block_subsidy(int nHeight)
uint64_t hush_sc_block_subsidy(int nHeight)
{
//fprintf(stderr,"%s: ht.%d\n", __func__, nHeight);
// Find current era, start from beginning reward, and determine current subsidy
@ -1730,7 +1725,7 @@ uint64_t komodo_ac_block_subsidy(int nHeight)
}
extern int64_t MAX_MONEY;
void komodo_cbopretupdate(int32_t forceflag);
void hush_cbopretupdate(int32_t forceflag);
void SplitStr(const std::string& strVal, std::vector<std::string> &outVals);
int8_t equihash_params_possible(uint64_t n, uint64_t k)
@ -1780,7 +1775,7 @@ void hush_args(char *argv0)
}
DONATION_PUBKEY = GetArg("-donation", "");
NOTARY_PUBKEY = GetArg("-pubkey", "");
KOMODO_DEALERNODE = GetArg("-dealer",0);
HUSH_DEALERNODE = GetArg("-dealer",0);
HUSH_TESTNODE = GetArg("-testnode",0);
if ( strlen(NOTARY_PUBKEY.c_str()) == 66 )
@ -1827,12 +1822,12 @@ void hush_args(char *argv0)
ASSETCHAINS_CC = GetArg("-ac_cc",0);
HUSH_CCACTIVATE = GetArg("-ac_ccactivate",0);
ASSETCHAINS_BLOCKTIME = GetArg("-ac_blocktime",60);
ASSETCHAINS_PUBLIC = GetArg("-ac_public",0);
ASSETCHAINS_PUBLIC = 0;
ASSETCHAINS_PRIVATE = GetArg("-ac_private",0);
HUSH_SNAPSHOT_INTERVAL = GetArg("-ac_snapshot",0);
HUSH_SNAPSHOT_INTERVAL = GetArg("-ac_snapshot",0);
Split(GetArg("-ac_nk",""), sizeof(ASSETCHAINS_NK)/sizeof(*ASSETCHAINS_NK), ASSETCHAINS_NK, 0);
fprintf(stderr,".oO Starting HUSH Full Node with genproc=%d notary=%d\n",HUSH_MININGTHREADS, IS_HUSH_NOTARY);
fprintf(stderr,".oO Starting HUSH Full Node (Extreme Privacy!) with genproc=%d notary=%d\n",HUSH_MININGTHREADS, IS_HUSH_NOTARY);
// -ac_ccactivateht=evalcode,height,evalcode,height,evalcode,height....
Split(GetArg("-ac_ccactivateht",""), sizeof(ccEnablesHeight)/sizeof(*ccEnablesHeight), ccEnablesHeight, 0);
@ -2242,7 +2237,7 @@ void hush_args(char *argv0)
}
fprintf(stderr," <- CCLIB name\n");
}
// is this not being run correctly?
if ( ASSETCHAINS_BLOCKTIME != 60 ) {
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_BLOCKTIME),(void *)&ASSETCHAINS_BLOCKTIME);
fprintf(stderr,"%s: ASSETCHAINS_BLOCKTIME=%d, extralen=%d\n", __func__, ASSETCHAINS_BLOCKTIME, extralen);
@ -2275,7 +2270,7 @@ void hush_args(char *argv0)
}
}
//komodo_pricesinit();
komodo_cbopretupdate(1); // will set Mineropret
hush_cbopretupdate(1); // will set Mineropret
fprintf(stderr,"This blockchain uses data produced from CoinDesk Bitcoin Price Index\n");
}
if ( ASSETCHAINS_NK[0] != 0 && ASSETCHAINS_NK[1] != 0 )
@ -2316,7 +2311,7 @@ void hush_args(char *argv0)
if ( ASSETCHAINS_CC >= HUSH_FIRSTFUNGIBLEID && MAX_MONEY < 1000000LL*SATOSHIDEN )
MAX_MONEY = 1000000LL*SATOSHIDEN;
if ( KOMODO_BIT63SET(MAX_MONEY) != 0 )
if ( HUSH_BIT63SET(MAX_MONEY) != 0 )
MAX_MONEY = HUSH_MAXNVALUE;
if(fDebug)
fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN);
@ -2425,9 +2420,9 @@ void hush_args(char *argv0)
if ( (fp= fopen(fname,"rb")) != 0 )
{
_komodo_userpass(username,password,fp);
sprintf(iter == 0 ? KMDUSERPASS : BTCUSERPASS,"%s:%s",username,password);
sprintf(iter == 0 ? HUSHUSERPASS : BTCUSERPASS,"%s:%s",username,password);
fclose(fp);
//printf("KOMODO.(%s) -> userpass.(%s)\n",fname,KMDUSERPASS);
//printf("HUSH.(%s) -> userpass.(%s)\n",fname,HUSHUSERPASS);
} //else printf("couldnt open.(%s)\n",fname);
if ( IS_HUSH_NOTARY == 0 )
break;

9
src/init.cpp

@ -88,7 +88,7 @@ using namespace std;
#include "hush_defs.h"
extern void ThreadSendAlert();
extern bool komodo_dailysnapshot(int32_t height);
extern bool hush_dailysnapshot(int32_t height);
extern int32_t HUSH_LOADINGBLOCKS;
extern char SMART_CHAIN_SYMBOL[];
extern int32_t HUSH_SNAPSHOT_INTERVAL;
@ -431,15 +431,14 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-peerbloomfilters", strprintf(_("Support filtering of blocks and transaction with Bloom filters (default: %u)"), 1));
if (showDebug)
strUsage += HelpMessageOpt("-enforcenodebloom", strprintf("Enforce minimum protocol version to limit use of Bloom filters (default: %u)", 0));
strUsage += HelpMessageOpt("-port=<port>", strprintf(_("Listen for connections on <port> (default: %u or testnet: %u)"), 7770, 17770));
strUsage += HelpMessageOpt("-port=<port>", strprintf(_("Listen for connections on <port> (default: %u or testnet: %u)"), 55555, 55420));
strUsage += HelpMessageOpt("-proxy=<ip:port>", _("Connect through SOCKS5 proxy"));
strUsage += HelpMessageOpt("-proxyrandomize", strprintf(_("Randomize credentials for every proxy connection. This enables Tor stream isolation (default: %u)"), 1));
strUsage += HelpMessageOpt("-seednode=<ip>", _("Connect to a node to retrieve peer addresses, and disconnect"));
strUsage += HelpMessageOpt("-timeout=<n>", strprintf(_("Specify connection timeout in milliseconds (minimum: 1, default: %d)"), DEFAULT_CONNECT_TIMEOUT));
strUsage += HelpMessageOpt("-torcontrol=<ip>:<port>", strprintf(_("Tor control port to use if onion listening enabled (default: %s)"), DEFAULT_TOR_CONTROL));
strUsage += HelpMessageOpt("-torpassword=<pass>", _("Tor control port password (default: empty)"));
strUsage += HelpMessageOpt("-tls=<option>", _("Specify TLS usage (default: 1 => enabled and preferred, yet compatible); other options are -tls=0 to disable TLS and -tls=only to enforce it"));
strUsage += HelpMessageOpt("-tlsfallbacknontls=<0 or 1>", _("If a TLS connection fails, the next connection attempt of the same peer (based on IP address) takes place without TLS (default: 1)"));
strUsage += HelpMessageOpt("-tls=<option>", _("Specify TLS usage (default: 1 => enabled and required); Cannot be turned off."));
strUsage += HelpMessageOpt("-tlsvalidate=<0 or 1>", _("Connect to peers only with valid certificates (default: 0)"));
strUsage += HelpMessageOpt("-tlskeypath=<path>", _("Full path to a private key"));
strUsage += HelpMessageOpt("-tlskeypwd=<password>", _("Password for a private key encryption (default: not set, i.e. private key will be stored unencrypted)"));
@ -1815,7 +1814,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
if ( ASSETCHAINS_CC != 0 && HUSH_SNAPSHOT_INTERVAL != 0 && chainActive.Height() >= HUSH_SNAPSHOT_INTERVAL )
{
if ( !komodo_dailysnapshot(chainActive.Height()) )
if ( !hush_dailysnapshot(chainActive.Height()) )
{
strLoadError = _("daily snapshot failed, please reindex your chain.");
break;

40
src/main.cpp

@ -660,7 +660,7 @@ bool komodo_snapshot2(std::map <std::string, CAmount> &addressAmounts)
int32_t lastSnapShotHeight = 0;
std::vector <std::pair<CAmount, CTxDestination>> vAddressSnapshot;
bool komodo_dailysnapshot(int32_t height)
bool hush_dailysnapshot(int32_t height)
{
int reorglimit = 100;
uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,undo_height,extraoffset;
@ -698,7 +698,7 @@ bool komodo_dailysnapshot(int32_t height)
{
//fprintf(stderr, "undoing block.%i\n",n);
CBlockIndex *pindex; CBlock block;
if ( (pindex= hush_chainactive(n)) == 0 || komodo_blockload(block, pindex) != 0 )
if ( (pindex= hush_chainactive(n)) == 0 || hush_blockload(block, pindex) != 0 )
return false;
// undo transactions in reverse order
for (int32_t i = block.vtx.size() - 1; i >= 0; i--)
@ -1334,7 +1334,7 @@ bool CheckTransaction(uint32_t tiptime,const CTransaction& tx, CValidationState
{
for (k=0; k<numbanned; k++)
{
if ( tx.vin[j].prevout.hash == array[k] && komodo_checkvout(tx.vin[j].prevout.n,k,indallvouts) != 0 ) //(tx.vin[j].prevout.n == 1 || k >= indallvouts) )
if ( tx.vin[j].prevout.hash == array[k] && hush_checkvout(tx.vin[j].prevout.n,k,indallvouts) != 0 ) //(tx.vin[j].prevout.n == 1 || k >= indallvouts) )
{
static uint32_t counter;
if ( counter++ < 100 )
@ -1374,12 +1374,12 @@ int32_t hush_isnotaryvout(char *coinaddr,uint32_t tiptime) {
return(0);
}
int32_t komodo_acpublic(uint32_t tiptime);
int32_t hush_scpublic(uint32_t tiptime);
bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransaction& tx, CValidationState &state)
{
// Basic checks that don't depend on any context
int32_t invalid_private_taddr=0,z_z=0,z_t=0,t_z=0,acpublic = komodo_acpublic(tiptime);
int32_t invalid_private_taddr=0,z_z=0,z_t=0,t_z=0,acpublic = hush_scpublic(tiptime);
/**
* Previously:
* 1. The consensus rule below was:
@ -2260,7 +2260,7 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW)
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
{
return komodo_ac_block_subsidy(nHeight);
return hush_sc_block_subsidy(nHeight);
}
bool IsInitialBlockDownload()
@ -2565,7 +2565,7 @@ namespace Consensus {
// ensure that output of coinbases are not still time locked
if (coins->TotalTxValue() >= ASSETCHAINS_TIMELOCKGTE)
{
uint64_t unlockTime = komodo_block_unlocktime(coins->nHeight);
uint64_t unlockTime = hush_block_unlocktime(coins->nHeight);
if (nSpendHeight < unlockTime) {
return state.DoS(10,
error("CheckInputs(): tried to spend coinbase that is timelocked until block %d", unlockTime),
@ -3196,7 +3196,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
if ( block.vtx[0].vout.size() == 1 )
return state.DoS(100, error("ConnectBlock(): Notaries have not been paid!"), REJECT_INVALID, "bad-cb-amount");
// calculate the notaries compensation and validate the amounts and pubkeys are correct.
notarypaycheque = komodo_checknotarypay((CBlock *)&block,(int32_t)pindex->GetHeight());
notarypaycheque = hush_checknotarypay((CBlock *)&block,(int32_t)pindex->GetHeight());
//fprintf(stderr, "notarypaycheque.%lu\n", notarypaycheque);
if ( notarypaycheque > 0 )
blockReward += notarypaycheque;
@ -3840,18 +3840,18 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) {
return true;
}
int32_t komodo_activate_sapling(CBlockIndex *pindex)
int32_t hush_activate_sapling(CBlockIndex *pindex)
{
uint32_t blocktime,prevtime; CBlockIndex *prev; int32_t i,transition=0,height,prevht;
int32_t activation = 0;
if ( pindex == 0 )
{
fprintf(stderr,"komodo_activate_sapling null pindex\n");
fprintf(stderr,"hush_activate_sapling null pindex\n");
return(0);
}
height = pindex->GetHeight();
blocktime = (uint32_t)pindex->nTime;
//fprintf(stderr,"komodo_activate_sapling.%d starting blocktime %u cmp.%d\n",height,blocktime,blocktime > HUSH_SAPING_ACTIVATION);
//fprintf(stderr,"hush_activate_sapling.%d starting blocktime %u cmp.%d\n",height,blocktime,blocktime > HUSH_SAPING_ACTIVATION);
// avoid trying unless we have at least 30 blocks
if (height < 30)
@ -3880,7 +3880,7 @@ int32_t komodo_activate_sapling(CBlockIndex *pindex)
//fprintf(stderr,"(%d, %u).%d -> (%d, %u).%d\n",prevht,prevtime,prevtime > HUSH_SAPING_ACTIVATION,height,blocktime,blocktime > HUSH_SAPING_ACTIVATION);
if ( prevht+1 != height )
{
fprintf(stderr,"komodo_activate_sapling: unexpected non-contiguous ht %d vs %d\n",prevht,height);
fprintf(stderr,"hush_activate_sapling: unexpected non-contiguous ht %d vs %d\n",prevht,height);
return(0);
}
if ( prevtime <= HUSH_SAPING_ACTIVATION && blocktime > HUSH_SAPING_ACTIVATION )
@ -4008,11 +4008,11 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
if ( ASSETCHAINS_CBOPRET != 0 )
komodo_pricesupdate(pindexNew->GetHeight(),pblock);
if ( ASSETCHAINS_SAPLING <= 0 && pindexNew->nTime > HUSH_SAPING_ACTIVATION - 24*3600 )
komodo_activate_sapling(pindexNew);
hush_activate_sapling(pindexNew);
if ( ASSETCHAINS_CC != 0 && HUSH_SNAPSHOT_INTERVAL != 0 && (pindexNew->GetHeight() % HUSH_SNAPSHOT_INTERVAL) == 0 && pindexNew->GetHeight() >= HUSH_SNAPSHOT_INTERVAL )
{
uint64_t start = time(NULL);
if ( !komodo_dailysnapshot(pindexNew->GetHeight()) )
if ( !hush_dailysnapshot(pindexNew->GetHeight()) )
{
fprintf(stderr, "daily snapshot failed, please reindex your chain\n");
StartShutdown();
@ -4439,7 +4439,7 @@ CBlockIndex* AddToBlockIndex(const CBlockHeader& block)
if (it != mapBlockIndex.end())
{
if ( it->second != 0 ) // vNodes.size() >= KOMODO_LIMITED_NETWORKSIZE, change behavior to allow komodo_ensure to work
if ( it->second != 0 ) // vNodes.size() >= HUSH_LIMITED_NETWORKSIZE, change behavior to allow komodo_ensure to work
{
// this is the strange case where somehow the hash is in the mapBlockIndex via as yet undetermined process, but the pindex for the hash is not there. Theoretically it is due to processing the block headers, but I have seen it get this case without having received it from the block headers or anywhere else... jl777
//fprintf(stderr,"addtoblockindex already there %p\n",it->second);
@ -4928,8 +4928,8 @@ bool CheckBlockHeader(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,
return true;
}
int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtime);
int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height);
int32_t hush_check_deposit(int32_t height,const CBlock& block,uint32_t prevtime);
int32_t hush_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height);
bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const CBlock& block, CValidationState& state,
libzcash::ProofVerifier& verifier,
@ -4961,7 +4961,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C
fprintf(stderr," failed hash ht.%d\n",height);
return state.DoS(50, error("CheckBlock: proof of work failed"),REJECT_INVALID, "high-hash");
}
if ( ASSETCHAINS_STAKED == 0 && komodo_checkPOW(1,(CBlock *)&block,height) < 0 ) // checks Equihash
if ( ASSETCHAINS_STAKED == 0 && hush_checkPOW(1,(CBlock *)&block,height) < 0 ) // checks Equihash
return state.DoS(100, error("CheckBlock: failed slow_checkPOW"),REJECT_INVALID, "failed-slow_checkPOW");
}
@ -5430,7 +5430,7 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo
}
}
fRequested |= fForceProcessing;
if ( checked != 0 && komodo_checkPOW(0,pblock,height) < 0 ) {
if ( checked != 0 && hush_checkPOW(0,pblock,height) < 0 ) {
checked = 0;
//fprintf(stderr,"passed checkblock but failed checkPOW.%d\n",from_miner);
}
@ -5948,7 +5948,7 @@ bool static LoadBlockIndexDB()
if ( ASSETCHAINS_SAPLING <= 0 )
{
fprintf(stderr,"set sapling height, if possible from ht.%d %u\n",(int32_t)pindex->GetHeight(),(uint32_t)pindex->nTime);
komodo_activate_sapling(pindex);
hush_activate_sapling(pindex);
}
}
return true;

4
src/metrics.cpp

@ -36,7 +36,7 @@
#endif
#include <unistd.h>
#include "hush_defs.h"
int64_t komodo_block_unlocktime(uint32_t nHeight);
int64_t hush_block_unlocktime(uint32_t nHeight);
void AtomicTimer::start()
{
@ -361,7 +361,7 @@ int printMetrics(size_t cols, bool mining)
CAmount subsidy = GetBlockSubsidy(height, consensusParams);
if ((std::max(0, COINBASE_MATURITY - (tipHeight - height)) > 0) ||
(tipHeight < komodo_block_unlocktime(height) && subsidy >= ASSETCHAINS_TIMELOCKGTE)) {
(tipHeight < hush_block_unlocktime(height) && subsidy >= ASSETCHAINS_TIMELOCKGTE)) {
immature += subsidy;
} else {
mature += subsidy;

12
src/miner.cpp

@ -140,14 +140,14 @@ int32_t hush_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,ui
int32_t komodo_pax_opreturn(int32_t height,uint8_t *opret,int32_t maxsize);
int32_t komodo_baseid(char *origbase);
int32_t hush_longestchain();
int64_t komodo_block_unlocktime(uint32_t nHeight);
int64_t hush_block_unlocktime(uint32_t nHeight);
uint64_t the_commission(const CBlock *block,int32_t height);
int32_t hush_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33, void *ptr);
int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex);
int32_t hush_is_notarytx(const CTransaction& tx);
uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector<int8_t> &NotarizationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len);
int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp);
int32_t komodo_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *script, int32_t len);
int32_t hush_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *script, int32_t len);
CScript komodo_mineropret(int32_t nHeight);
bool komodo_appendACscriptpub();
@ -407,7 +407,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
// Any attempted notarization needs to be in its own block!
continue;
}
int32_t notarizedheight = komodo_getnotarizedheight(pblock->nTime, nHeight, script, scriptlen);
int32_t notarizedheight = hush_getnotarizedheight(pblock->nTime, nHeight, script, scriptlen);
if ( notarizedheight != 0 )
{
// this is the first one we see, add it to the block as TX1
@ -979,7 +979,7 @@ static bool ProcessBlockFound(CBlock* pblock)
int32_t komodo_baseid(char *origbase);
int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,uint32_t *blocktimes,int32_t *nonzpkeysp,int32_t height);
arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc);
int32_t FOUND_BLOCK,KOMODO_MAYBEMINED;
int32_t FOUND_BLOCK,HUSH_MAYBEMINED;
extern int32_t HUSH_LASTMINED,HUSH_INSYNC;
int32_t roundrobin_delay;
arith_uint256 HASHTarget,HASHTarget_POW;
@ -1250,7 +1250,7 @@ void static BitcoinMiner()
if ( j == 65 )
HUSH_LASTMINED = 0;
} else fprintf(stderr,"no nonz pubkeys\n");
if ( (Mining_height >= 235300 && Mining_height < 236000) || (j == 65 && Mining_height > KOMODO_MAYBEMINED+1 && Mining_height > HUSH_LASTMINED+64) )
if ( (Mining_height >= 235300 && Mining_height < 236000) || (j == 65 && Mining_height > HUSH_MAYBEMINED+1 && Mining_height > HUSH_LASTMINED+64) )
{
HASHTarget = arith_uint256().SetCompact(HUSH_MINDIFF_NBITS);
fprintf(stderr,"I am the chosen one for %s ht.%d\n",SMART_CHAIN_SYMBOL,pindexPrev->GetHeight()+1);
@ -1430,7 +1430,7 @@ void static BitcoinMiner()
// fprintf(stderr,"%02x",((uint8_t *)&hash)[i]);
//fprintf(stderr," <- %s Block found %d\n",SMART_CHAIN_SYMBOL,Mining_height);
//FOUND_BLOCK = 1;
//KOMODO_MAYBEMINED = Mining_height;
//HUSH_MAYBEMINED = Mining_height;
break;
}
} catch (EhSolverCancelledException&) {

6
src/net.cpp

@ -2207,12 +2207,6 @@ CNode::CNode(SOCKET hSocketIn, const CAddress& addrIn, const std::string& addrNa
GetNodeSignals().InitializeNode(GetId(), this);
}
bool CNode::GetTlsFallbackNonTls()
{
LogPrint("tls", "%s():%d - Non-TLS connections no longer supported\n", __func__, __LINE__);
return false;
}
bool CNode::GetTlsValidate()
{
if (tlsValidate == eTlsOption::FALLBACK_UNSET)

2
src/net.h

@ -701,8 +701,6 @@ public:
// resource deallocation on cleanup, called at node shutdown
static void NetCleanup();
// returns the value of the tlsfallbacknontls and tlsvalidate flags set at startup (see init.cpp)
static bool GetTlsFallbackNonTls();
static bool GetTlsValidate();
};

2
src/pow.cpp

@ -676,7 +676,7 @@ bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams& param
int32_t hush_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
int32_t hush_currentheight();
void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height);
bool komodo_checkopret(CBlock *pblock, CScript &merkleroot);
bool hush_checkopret(CBlock *pblock, CScript &merkleroot);
CScript komodo_makeopret(CBlock *pblock, bool fNew);
extern int32_t HUSH_CHOSEN_ONE;
extern char SMART_CHAIN_SYMBOL[HUSH_SMART_CHAIN_MAXLEN];

4
src/rpc/mining.cpp

@ -51,7 +51,7 @@ using namespace std;
extern int32_t ASSETCHAINS_FOUNDERS;
uint64_t the_commission(const CBlock *pblock,int32_t height);
int32_t komodo_blockload(CBlock& block,CBlockIndex *pindex);
int32_t hush_blockload(CBlock& block,CBlockIndex *pindex);
arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc);
/**
@ -1045,7 +1045,7 @@ UniValue getblocksubsidy(const UniValue& params, bool fHelp, const CPubKey& mypk
{
CBlockIndex* pblockIndex = chainActive[nHeight];
CBlock block;
if ( komodo_blockload(block, pblockIndex) == 0 )
if ( hush_blockload(block, pblockIndex) == 0 )
nFoundersReward = the_commission(&block, nHeight);
}
}

4
src/txmempool.cpp

@ -381,7 +381,7 @@ void CTxMemPool::remove(const CTransaction &origTx, std::list<CTransaction>& rem
}
extern uint64_t ASSETCHAINS_TIMELOCKGTE;
int64_t komodo_block_unlocktime(uint32_t nHeight);
int64_t hush_block_unlocktime(uint32_t nHeight);
void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags)
{
@ -404,7 +404,7 @@ void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMem
const CCoins *coins = pcoins->AccessCoins(txin.prevout.hash);
if (nCheckFrequency != 0) assert(coins);
if (!coins || (coins->IsCoinBase() && (((signed long)nMemPoolHeight) - coins->nHeight < COINBASE_MATURITY) &&
((signed long)nMemPoolHeight < komodo_block_unlocktime(coins->nHeight) &&
((signed long)nMemPoolHeight < hush_block_unlocktime(coins->nHeight) &&
coins->IsAvailable(0) && coins->vout[0].nValue >= ASSETCHAINS_TIMELOCKGTE))) {
transactionsToRemove.push_back(tx);
break;

6
src/wallet/rpcwallet.cpp

@ -65,7 +65,7 @@ extern int32_t HUSH_INSYNC;
uint32_t hush_segid32(char *coinaddr);
int32_t hush_dpowconfs(int32_t height,int32_t numconfs);
int32_t hush_isnotaryvout(char *coinaddr,uint32_t tiptime); // from ac_private chains only
CBlockIndex *komodo_getblockindex(uint256 hash);
CBlockIndex *hush_getblockindex(uint256 hash);
extern string randomSietchZaddr();
extern CAmount fConsolidationTxFee;
extern bool fZindex;
@ -2537,7 +2537,7 @@ UniValue walletlock(const UniValue& params, bool fHelp, const CPubKey& mypk)
return NullUniValue;
}
int32_t komodo_acpublic(uint32_t tiptime);
int32_t hush_scpublic(uint32_t tiptime);
UniValue encryptwallet(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
@ -2545,7 +2545,7 @@ UniValue encryptwallet(const UniValue& params, bool fHelp, const CPubKey& mypk)
return NullUniValue;
string enableArg = "developerencryptwallet";
int32_t flag = (komodo_acpublic(0) || SMART_CHAIN_SYMBOL[0] == 0);
int32_t flag = (hush_scpublic(0) || SMART_CHAIN_SYMBOL[0] == 0);
auto fEnableWalletEncryption = fExperimentalMode && GetBoolArg("-" + enableArg, flag);
std::string strWalletEncryptionDisabledMsg = "";

Loading…
Cancel
Save