From f22cbbf1e21d73ab931d41993ec8800264c7c14e Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 16 Sep 2021 14:12:31 -0400 Subject: [PATCH] Cleanup and remove dead code --- src/bitcoind.cpp | 2 +- src/cc/CCPrices.h | 2 +- src/cc/CC_made_easy.md | 4 +- src/cc/cclib.cpp | 2 +- src/cc/gamescc.cpp | 6 +- src/hush.h | 14 +- src/hush_bitcoind.h | 14 +- src/hush_cJSON.h | 4 +- src/hush_ccdata.h | 24 +-- src/hush_defs.h | 24 +-- src/hush_events.h | 26 +-- src/hush_gateway.h | 386 +++++++++++++++++++------------------- src/hush_globals.h | 8 +- src/hush_nSPV_fullnode.h | 2 +- src/hush_nSPV_superlite.h | 8 +- src/hush_notary.h | 14 +- src/hush_pax.h | 18 +- src/hush_structs.h | 4 +- src/hush_utils.h | 8 +- src/main.cpp | 18 +- src/miner.cpp | 20 +- src/rpc/blockchain.cpp | 6 +- src/rpc/crosschain.cpp | 4 +- src/rpc/mining.cpp | 2 +- src/wallet/rpcwallet.cpp | 22 +-- 25 files changed, 321 insertions(+), 321 deletions(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 9ba1b93ae..9e5a2b43a 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -69,7 +69,7 @@ void WaitForShutdown(boost::thread_group* threadGroup) // Tell the main threads to shutdown. if ( ASSETCHAINS_CBOPRET != 0 ) { - komodo_pricesinit(); + hush_pricesinit(); } while (!fShutdown) diff --git a/src/cc/CCPrices.h b/src/cc/CCPrices.h index 5b352d0f6..e715706b9 100644 --- a/src/cc/CCPrices.h +++ b/src/cc/CCPrices.h @@ -23,7 +23,7 @@ #include "hush_defs.h" #include "CCinclude.h" -int32_t komodo_priceget(int64_t *buf64,int32_t ind,int32_t height,int32_t numblocks); +int32_t hush_priceget(int64_t *buf64,int32_t ind,int32_t height,int32_t numblocks); extern void GetHushEarlytxidScriptPub(); extern CScript HUSH_EARLYTXID_SCRIPTPUB; diff --git a/src/cc/CC_made_easy.md b/src/cc/CC_made_easy.md index 48ccde25a..149c5321c 100644 --- a/src/cc/CC_made_easy.md +++ b/src/cc/CC_made_easy.md @@ -84,7 +84,7 @@ However, this is the CC contract basics chapter, so let us ignore mempool issues That means to just follow a known working template and only changing the things where the existing templates are not sufficient, ie. the core differentiator of your CC contract. -In the ~/komodo/src/cc/eval.h file all the eval codes are defined, currently: +In the hush3/src/cc/eval.h file all the eval codes are defined, currently: #define FOREACH_EVAL(EVAL) \ EVAL(EVAL_IMPORTPAYOUT, 0xe1) \ @@ -201,7 +201,7 @@ You do need to be careful not to cause a deadlock as the CC validation code is c Chapter 6 - faucet example Finally, we are ready for the first actual example of a CC contract. The faucet. This is a very simple contract and it ran into some interesting bugs in the first incarnation. -The code in ~/komodo/src/cc/faucet.cpp is the ultimate documentation for it with all the details, so I will just address the conceptual issues here. +The code in hush3/src/cc/faucet.cpp is the ultimate documentation for it with all the details, so I will just address the conceptual issues here. The idea is that people send funds to the faucet by locking it in faucet's global CC address and anybody is allowed to create a faucetget transaction that spends it. diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index c1ae646ca..30df42f3a 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -47,7 +47,7 @@ std::string MYCCLIBNAME = (char *)"sudoku"; #endif #ifndef BUILD_GAMESCC -void komodo_netevent(std::vector payload) {} +void hush_netevent(std::vector payload) {} #endif extern std::string MYCCLIBNAME; diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index e2d563d00..80251819f 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -479,7 +479,7 @@ int32_t games_event(uint32_t timestamp,uint256 gametxid,int32_t eventid,std::vec { GetOpReturnData(games_eventopret(timestamp,mypk,sig,payload),vopret); games_payloadrecv(mypk,timestamp,payload); - komodo_sendmessage(4,8,"events",vopret); + hush_sendmessage(4,8,"events",vopret); return(0); } fprintf(stderr,"games_eventsign error\n"); @@ -539,7 +539,7 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } -void komodo_netevent(std::vector message) +void hush_netevent(std::vector message) { int32_t i,retval,lag,lagerr=0; uint32_t timestamp,now; CPubKey pk; std::vector sig,payload; char str[67]; if ( games_eventdecode(timestamp,pk,sig,payload,message) == 'E' ) @@ -560,7 +560,7 @@ void komodo_netevent(std::vector message) if ( (rand() % 10) == 0 ) { //fprintf(stderr,"relay message.[%d]\n",(int32_t)message.size()); - komodo_sendmessage(2,2,"events",message); + hush_sendmessage(2,2,"events",message); } } } diff --git a/src/hush.h b/src/hush.h index b25dcfcb4..63bbf3dbe 100644 --- a/src/hush.h +++ b/src/hush.h @@ -146,7 +146,7 @@ int32_t hush_parsestatefile(struct hush_state *sp,FILE *fp,char *symbol,char *de errs++; //if ( matched != 0 ) global independent states -> inside *sp //printf("%s.%d load[%s] ht.%d\n",SMART_CHAIN_SYMBOL,ht,symbol,kheight); - hush_eventadd_kmdheight(sp,symbol,ht,kheight,0); + hush_eventadd_hushheight(sp,symbol,ht,kheight,0); } else if ( func == 'T' ) { @@ -157,7 +157,7 @@ int32_t hush_parsestatefile(struct hush_state *sp,FILE *fp,char *symbol,char *de errs++; //if ( matched != 0 ) global independent states -> inside *sp //printf("%s.%d load[%s] ht.%d t.%u\n",SMART_CHAIN_SYMBOL,ht,symbol,kheight,ktimestamp); - hush_eventadd_kmdheight(sp,symbol,ht,kheight,ktimestamp); + hush_eventadd_hushheight(sp,symbol,ht,kheight,ktimestamp); } else if ( func == 'R' ) { @@ -285,7 +285,7 @@ int32_t hush_parsestatefiledata(struct hush_state *sp,uint8_t *filedata,long *fp int32_t kheight; if ( memread(&kheight,sizeof(kheight),filedata,&fpos,datalen) != sizeof(kheight) ) errs++; - hush_eventadd_kmdheight(sp,symbol,ht,kheight,0); + hush_eventadd_hushheight(sp,symbol,ht,kheight,0); } else if ( func == 'T' ) { @@ -296,7 +296,7 @@ int32_t hush_parsestatefiledata(struct hush_state *sp,uint8_t *filedata,long *fp errs++; //if ( matched != 0 ) global independent states -> inside *sp //printf("%s.%d load[%s] ht.%d t.%u\n",SMART_CHAIN_SYMBOL,ht,symbol,kheight,ktimestamp); - hush_eventadd_kmdheight(sp,symbol,ht,kheight,ktimestamp); + hush_eventadd_hushheight(sp,symbol,ht,kheight,ktimestamp); } else if ( func == 'R' ) { @@ -409,7 +409,7 @@ void hush_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotarie if ( fwrite(&HUSHheight,1,sizeof(HUSHheight),fp) != sizeof(HUSHheight) ) errs++; } - hush_eventadd_kmdheight(sp,symbol,height,HUSHheight,HUSHtimestamp); + hush_eventadd_hushheight(sp,symbol,height,HUSHheight,HUSHtimestamp); } else if ( opretbuf != 0 && opretlen > 0 ) { uint16_t olen = opretlen; fputc('R',fp); @@ -711,7 +711,7 @@ int32_t hush_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryi else if ( matched != 0 && i == 0 && j == 1 && opretlen == 149 ) { if ( notaryid >= 0 && notaryid < 64 ) - komodo_paxpricefeed(height,&scriptbuf[len],opretlen); + hush_paxpricefeed(height,&scriptbuf[len],opretlen); } else if ( matched != 0 ) { @@ -792,7 +792,7 @@ int32_t hush_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) if ( pindex->GetHeight() != hwmheight ) { printf("%s hwmheight.%d vs pindex->GetHeight().%d t.%u reorg.%d\n",SMART_CHAIN_SYMBOL,hwmheight,pindex->GetHeight(),(uint32_t)pindex->nTime,hwmheight-pindex->GetHeight()); - komodo_purge_ccdata((int32_t)pindex->GetHeight()); + hush_purge_ccdata((int32_t)pindex->GetHeight()); hwmheight = pindex->GetHeight(); } if (!fJustCheck) diff --git a/src/hush_bitcoind.h b/src/hush_bitcoind.h index e2b4e9fa7..df299d6dd 100644 --- a/src/hush_bitcoind.h +++ b/src/hush_bitcoind.h @@ -950,12 +950,12 @@ int32_t hush_nextheight() else return(hush_longestchain() + 1); } -int32_t hush_isrealtime(int32_t *kmdheightp) +int32_t hush_isrealtime(int32_t *hushheightp) { struct hush_state *sp; CBlockIndex *pindex; if ( (sp= hush_stateptrget((char *)"HUSH3")) != 0 ) - *kmdheightp = sp->CURRENT_HEIGHT; - else *kmdheightp = 0; + *hushheightp = sp->CURRENT_HEIGHT; + else *hushheightp = 0; if ( (pindex= chainActive.LastTip()) != 0 && pindex->GetHeight() >= (int32_t)hush_longestchain() ) return(1); else return(0); @@ -1212,7 +1212,7 @@ void hush_segids(uint8_t *hashbuf,int32_t height,int32_t n) } } -arith_uint256 komodo_adaptivepow_target(int32_t height,arith_uint256 bnTarget,uint32_t nTime) +arith_uint256 hush_adaptivepow_target(int32_t height,arith_uint256 bnTarget,uint32_t nTime) { arith_uint256 origtarget,easy; int32_t diff,tipdiff; int64_t mult; bool fNegative,fOverflow; CBlockIndex *tipindex; if ( height > 10 && (tipindex= hush_chainactive(height - 1)) != 0 ) // disable offchain diffchange @@ -1238,7 +1238,7 @@ arith_uint256 komodo_adaptivepow_target(int32_t height,arith_uint256 bnTarget,ui return(bnTarget); } -arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc) +arith_uint256 hush_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc) { int32_t oldflag = 0,dispflag = 0; CBlockIndex *pindex; arith_uint256 easydiff,bnTarget,hashval,sum,ave; bool fNegative,fOverflow; int32_t i,n,m,ht,percPoS,diff,val; @@ -1543,7 +1543,7 @@ uint64_t hush_checknotarypay(CBlock *pblock,int32_t height) return(0); } -bool komodo_appendACscriptpub() +bool hush_appendACscriptpub() { static bool didinit = false; if ( didinit ) @@ -1638,7 +1638,7 @@ int64_t hush_checkcommission(CBlock *pblock,int32_t height) if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { static bool didinit = false; - if ( !didinit && height > HUSH_EARLYTXID_HEIGHT && HUSH_EARLYTXID != zeroid && komodo_appendACscriptpub() ) + if ( !didinit && height > HUSH_EARLYTXID_HEIGHT && HUSH_EARLYTXID != zeroid && hush_appendACscriptpub() ) { fprintf(stderr, "appended CC_op_return to ASSETCHAINS_SCRIPTPUB.%s\n", ASSETCHAINS_SCRIPTPUB.c_str()); didinit = true; diff --git a/src/hush_cJSON.h b/src/hush_cJSON.h index f83e1896d..d7eb3a4dd 100644 --- a/src/hush_cJSON.h +++ b/src/hush_cJSON.h @@ -36,8 +36,8 @@ * Removal or modification of this copyright notice is prohibited. * * * ******************************************************************************/ -#ifndef komodo_cJSON__h -#define komodo_cJSON__h +#ifndef hush_cJSON__h +#define hush_cJSON__h #include #include #include diff --git a/src/hush_ccdata.h b/src/hush_ccdata.h index e5e431219..420a7243e 100644 --- a/src/hush_ccdata.h +++ b/src/hush_ccdata.h @@ -41,7 +41,7 @@ uint256 hush_calcMoM(int32_t height,int32_t MoMdepth) return BuildMerkleTree(&fMutated, leaves, tree); } -struct hush_ccdata_entry *komodo_allMoMs(int32_t *nump,uint256 *MoMoMp,int32_t kmdstarti,int32_t kmdendi) +struct hush_ccdata_entry *hush_allMoMs(int32_t *nump,uint256 *MoMoMp,int32_t kmdstarti,int32_t kmdendi) { struct hush_ccdata_entry *allMoMs=0; struct hush_ccdata *ccdata,*tmpptr; int32_t i,num,max; bool fMutated; std::vector tree, leaves; @@ -58,7 +58,7 @@ struct hush_ccdata_entry *komodo_allMoMs(int32_t *nump,uint256 *MoMoMp,int32_t k } allMoMs[num].MoM = ccdata->MoMdata.MoM; allMoMs[num].notarized_height = ccdata->MoMdata.notarized_height; - allMoMs[num].kmdheight = ccdata->MoMdata.height; + allMoMs[num].hushheight = ccdata->MoMdata.height; allMoMs[num].txi = ccdata->MoMdata.txi; strcpy(allMoMs[num].symbol,ccdata->symbol); num++; @@ -81,7 +81,7 @@ struct hush_ccdata_entry *komodo_allMoMs(int32_t *nump,uint256 *MoMoMp,int32_t k return(allMoMs); } -int32_t komodo_addpair(struct hush_ccdataMoMoM *mdata,int32_t notarized_height,int32_t offset,int32_t maxpairs) +int32_t hush_addpair(struct hush_ccdataMoMoM *mdata,int32_t notarized_height,int32_t offset,int32_t maxpairs) { if ( maxpairs >= 0) { if ( mdata->numpairs >= maxpairs ) @@ -91,7 +91,7 @@ int32_t komodo_addpair(struct hush_ccdataMoMoM *mdata,int32_t notarized_height,i //fprintf(stderr,"pairs reallocated to %p num.%d\n",mdata->pairs,mdata->numpairs); } } else { - fprintf(stderr,"komodo_addpair.maxpairs %d must be >= 0\n",(int32_t)maxpairs); + fprintf(stderr,"hush_addpair.maxpairs %d must be >= 0\n",(int32_t)maxpairs); return(-1); } mdata->pairs[mdata->numpairs].notarized_height = notarized_height; @@ -100,7 +100,7 @@ int32_t komodo_addpair(struct hush_ccdataMoMoM *mdata,int32_t notarized_height,i return(maxpairs); } -int32_t hush_MoMoMdata(char *hexstr,int32_t hexsize,struct hush_ccdataMoMoM *mdata,char *symbol,int32_t kmdheight,int32_t notarized_height) +int32_t hush_MoMoMdata(char *hexstr,int32_t hexsize,struct hush_ccdataMoMoM *mdata,char *symbol,int32_t hushheight,int32_t notarized_height) { uint8_t hexdata[8192]; struct hush_ccdata *ccdata,*tmpptr; int32_t len,maxpairs,i,retval=-1,depth,starti,endi,CCid=0; struct hush_ccdata_entry *allMoMs; starti = endi = depth = len = maxpairs = 0; @@ -114,7 +114,7 @@ int32_t hush_MoMoMdata(char *hexstr,int32_t hexsize,struct hush_ccdataMoMoM *mda portable_mutex_lock(&HUSH_CC_mutex); DL_FOREACH_SAFE(CC_data,ccdata,tmpptr) { - if ( ccdata->MoMdata.height < kmdheight ) + if ( ccdata->MoMdata.height < hushheight ) { //fprintf(stderr,"%s notarized.%d kmd.%d\n",ccdata->symbol,ccdata->MoMdata.notarized_height,ccdata->MoMdata.height); if ( strcmp(ccdata->symbol,symbol) == 0 ) @@ -140,13 +140,13 @@ int32_t hush_MoMoMdata(char *hexstr,int32_t hexsize,struct hush_ccdataMoMoM *mda mdata->kmdendi = endi; if ( starti != 0 && endi != 0 && endi >= starti ) { - if ( (allMoMs= komodo_allMoMs(&depth,&mdata->MoMoM,starti,endi)) != 0 ) + if ( (allMoMs= hush_allMoMs(&depth,&mdata->MoMoM,starti,endi)) != 0 ) { mdata->MoMoMdepth = depth; for (i=0; inumpairs > 0 ) { @@ -160,7 +160,7 @@ int32_t hush_MoMoMdata(char *hexstr,int32_t hexsize,struct hush_ccdataMoMoM *mda { if ( len + sizeof(uint32_t)*2 > sizeof(hexdata) ) { - fprintf(stderr,"%s %d %d i.%d of %d exceeds hexdata.%d\n",symbol,kmdheight,notarized_height,i,mdata->numpairs,(int32_t)sizeof(hexdata)); + fprintf(stderr,"%s %d %d i.%d of %d exceeds hexdata.%d\n",symbol,hushheight,notarized_height,i,mdata->numpairs,(int32_t)sizeof(hexdata)); break; } len += dragon_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->pairs[i].notarized_height); @@ -171,7 +171,7 @@ int32_t hush_MoMoMdata(char *hexstr,int32_t hexsize,struct hush_ccdataMoMoM *mda init_hexbytes_noT(hexstr,hexdata,len); //fprintf(stderr,"hexstr.(%s)\n",hexstr); retval = 0; - } else fprintf(stderr,"%s %d %d too much hexdata[%d] for hexstr[%d]\n",symbol,kmdheight,notarized_height,len,hexsize); + } else fprintf(stderr,"%s %d %d too much hexdata[%d] for hexstr[%d]\n",symbol,hushheight,notarized_height,len,hexsize); } free(allMoMs); } @@ -179,7 +179,7 @@ int32_t hush_MoMoMdata(char *hexstr,int32_t hexsize,struct hush_ccdataMoMoM *mda return(retval); } -void komodo_purge_ccdata(int32_t height) +void hush_purge_ccdata(int32_t height) { struct hush_ccdata *ccdata,*tmpptr; if ( SMART_CHAIN_SYMBOL[0] == 0 ) @@ -247,7 +247,7 @@ int32_t hush_rwccdata(char *thischain,int32_t rwflag,struct hush_ccdata *ccdata, { for (i=0; inumpairs; i++) { - if ( (np= komodo_npptr(MoMoMdata->pairs[i].notarized_height)) != 0 ) + if ( (np= hush_npptr(MoMoMdata->pairs[i].notarized_height)) != 0 ) { memset(&zero,0,sizeof(zero)); if ( memcmp(&np->MoMoM,&zero,sizeof(np->MoMoM)) == 0 ) diff --git a/src/hush_defs.h b/src/hush_defs.h index c88abe9d6..4d8bd62b8 100644 --- a/src/hush_defs.h +++ b/src/hush_defs.h @@ -594,7 +594,7 @@ extern int32_t ASSETCHAINS_EARLYTXIDCONTRACT; int tx_height( const uint256 &hash ); extern std::vector vAllowListAddress; extern std::map mapHeightEvalActivate; -void komodo_netevent(std::vector payload); +void hush_netevent(std::vector payload); int32_t getacseason(uint32_t timestamp); int32_t gethushseason(int32_t height); @@ -603,8 +603,8 @@ int32_t gethushseason(int32_t height); #define HUSH_KVBINARY 2 #define PRICES_SMOOTHWIDTH 1 #define PRICES_MAXDATAPOINTS 8 -uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume); -int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel); +uint64_t hush_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume); +int32_t hush_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel); int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len); int32_t hush_minerids(uint8_t *minerids,int32_t height,int32_t width); @@ -615,22 +615,22 @@ int32_t hush_longestchain(); int32_t hush_dpowconfs(int32_t height,int32_t numconfs); int8_t hush_segid(int32_t nocache,int32_t height); int32_t hush_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeight); -char *komodo_pricename(char *name,int32_t ind); -int32_t komodo_priceind(const char *symbol); -int32_t komodo_pricesinit(); -int64_t komodo_priceave(int64_t *tmpbuf,int64_t *correlated,int32_t cskip); -int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t rawskip,uint32_t *nonzprices,int32_t smoothwidth); +char *hush_pricename(char *name,int32_t ind); +int32_t hush_priceind(const char *symbol); +int32_t hush_pricesinit(); +int64_t hush_priceave(int64_t *tmpbuf,int64_t *correlated,int32_t cskip); +int64_t hush_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t rawskip,uint32_t *nonzprices,int32_t smoothwidth); int32_t hush_nextheight(); uint32_t hush_heightstamp(int32_t height); -int64_t komodo_pricemult(int32_t ind); -int32_t komodo_priceget(int64_t *buf64,int32_t ind,int32_t height,int32_t numblocks); +int64_t hush_pricemult(int32_t ind); +int32_t hush_priceget(int64_t *buf64,int32_t ind,int32_t height,int32_t numblocks); int32_t hush_currentheight(); int32_t hush_notarized_bracket(struct notarized_checkpoint *nps[2],int32_t height); -arith_uint256 komodo_adaptivepow_target(int32_t height,arith_uint256 bnTarget,uint32_t nTime); +arith_uint256 hush_adaptivepow_target(int32_t height,arith_uint256 bnTarget,uint32_t nTime); 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 payload); +void hush_sendmessage(int32_t minpeers, int32_t maxpeers, const char *message, std::vector payload); CBlockIndex *hush_getblockindex(uint256 hash); int32_t hush_nextheight(); CBlockIndex *hush_blockindex(uint256 hash); diff --git a/src/hush_events.h b/src/hush_events.h index 6d733483d..00832ae23 100644 --- a/src/hush_events.h +++ b/src/hush_events.h @@ -88,7 +88,7 @@ void hush_eventadd_pricefeed(struct hush_state *sp,char *symbol,int32_t height,u memcpy(F.prices,prices,sizeof(*F.prices) * num); hush_eventadd(sp,height,symbol,HUSH_EVENT_PRICEFEED,(uint8_t *)&F,(int32_t)(sizeof(F.num) + sizeof(*F.prices) * num)); if ( sp != 0 ) - komodo_pvals(height,prices,num); + hush_pvals(height,prices,num); } //else fprintf(stderr,"skip pricefeed[%d]\n",num); } @@ -107,7 +107,7 @@ void hush_eventadd_opreturn(struct hush_state *sp,char *symbol,int32_t height,ui hush_eventadd(sp,height,symbol,HUSH_EVENT_OPRETURN,opret,O.oplen); free(opret); if ( sp != 0 ) - komodo_opreturn(height,value,buf,opretlen,txid,vout,symbol); + hush_opreturn(height,value,buf,opretlen,txid,vout,symbol); } } @@ -155,32 +155,32 @@ void hush_event_rewind(struct hush_state *sp,char *symbol,int32_t height) } } -void komodo_setkmdheight(struct hush_state *sp,int32_t kmdheight,uint32_t timestamp) +void hush_sethushheight(struct hush_state *sp,int32_t hushheight,uint32_t timestamp) { if ( sp != 0 ) { - if ( kmdheight > sp->SAVEDHEIGHT ) + if ( hushheight > sp->SAVEDHEIGHT ) { - sp->SAVEDHEIGHT = kmdheight; + sp->SAVEDHEIGHT = hushheight; sp->SAVEDTIMESTAMP = timestamp; } - if ( kmdheight > sp->CURRENT_HEIGHT ) - sp->CURRENT_HEIGHT = kmdheight; + if ( hushheight > sp->CURRENT_HEIGHT ) + sp->CURRENT_HEIGHT = hushheight; } } -void hush_eventadd_kmdheight(struct hush_state *sp,char *symbol,int32_t height,int32_t kmdheight,uint32_t timestamp) +void hush_eventadd_hushheight(struct hush_state *sp,char *symbol,int32_t height,int32_t hushheight,uint32_t timestamp) { uint32_t buf[2]; - if ( kmdheight > 0 ) { - buf[0] = (uint32_t)kmdheight; + if ( hushheight > 0 ) { + buf[0] = (uint32_t)hushheight; buf[1] = timestamp; hush_eventadd(sp,height,symbol,HUSH_EVENT_HUSHHEIGHT,(uint8_t *)buf,sizeof(buf)); if ( sp != 0 ) - komodo_setkmdheight(sp,kmdheight,timestamp); + hush_sethushheight(sp,hushheight,timestamp); } else { - //fprintf(stderr,"REWIND kmdheight.%d\n",kmdheight); - kmdheight = -kmdheight; + //fprintf(stderr,"REWIND hushheight.%d\n",hushheight); + hushheight = -hushheight; hush_eventadd(sp,height,symbol,HUSH_EVENT_REWIND,(uint8_t *)&height,sizeof(height)); if ( sp != 0 ) hush_event_rewind(sp,symbol,height); diff --git a/src/hush_gateway.h b/src/hush_gateway.h index ddaf366a2..b52ab8a1e 100644 --- a/src/hush_gateway.h +++ b/src/hush_gateway.h @@ -45,7 +45,7 @@ int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued, if ( sp->withdrawn > maxval ) maxval = sp->withdrawn; netliability = (sp->issued - maxval) - sp->shorted; - maxallowed = komodo_maxallowed(baseid); + maxallowed = hush_maxallowed(baseid); if ( netliability < maxallowed ) *available = (maxallowed - netliability); //printf("%llu - %llu %s %.8f %.8f %.8f %.8f %.8f\n",(long long)maxallowed,(long long)netliability,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed)); @@ -62,7 +62,7 @@ void pax_keyset(uint8_t *buf,uint256 txid,uint16_t vout,uint8_t type) buf[34] = type; } -struct pax_transaction *komodo_paxfind(uint256 txid,uint16_t vout,uint8_t type) +struct pax_transaction *hush_paxfind(uint256 txid,uint16_t vout,uint8_t type) { struct pax_transaction *pax; uint8_t buf[35]; pthread_mutex_lock(&hush_mutex); @@ -72,16 +72,16 @@ struct pax_transaction *komodo_paxfind(uint256 txid,uint16_t vout,uint8_t type) return(pax); } -struct pax_transaction *komodo_paxfinds(uint256 txid,uint16_t vout) +struct pax_transaction *hush_paxfinds(uint256 txid,uint16_t vout) { struct pax_transaction *pax; int32_t i; uint8_t types[] = { 'I', 'D', 'X', 'A', 'W' }; for (i=0; imarked = mark; //if ( height > 214700 || pax->height > 214700 ) - // printf("mark ht.%d %.8f %.8f\n",pax->height,dstr(pax->komodoshis),dstr(pax->fiatoshis)); + // printf("mark ht.%d %.8f %.8f\n",pax->height,dstr(pax->puposhis),dstr(pax->fiatoshis)); } pthread_mutex_unlock(&hush_mutex); return(pax); } -void komodo_paxdelete(struct pax_transaction *pax) +void hush_paxdelete(struct pax_transaction *pax) { return; // breaks when out of order pthread_mutex_lock(&hush_mutex); @@ -116,7 +116,7 @@ void komodo_paxdelete(struct pax_transaction *pax) pthread_mutex_unlock(&hush_mutex); } -void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,uint8_t type,int32_t height,int32_t otherheight,char *source,int32_t approved) // assetchain context +void hush_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,uint8_t type,int32_t height,int32_t otherheight,char *source,int32_t approved) // assetchain context { struct pax_transaction *pax; uint8_t buf[35]; int32_t addflag = 0; struct hush_state *sp; char str[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN],*s; //if ( HUSH_PAX == 0 ) @@ -148,7 +148,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { strcpy(pax->coinaddr,coinaddr); if ( value != 0 ) - pax->komodoshis = value; + pax->puposhis = value; if ( symbol != 0 ) strcpy(pax->symbol,symbol); if ( source != 0 ) @@ -169,7 +169,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t } } -int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transaction *pax) +int32_t hush_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transaction *pax) { int32_t i,len = 0; if ( rwflag == 1 ) @@ -189,7 +189,7 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio pax->vout += ((uint32_t)opretbuf[len++] << 8); //printf(" txid v.%d\n",pax->vout); } - len += dragon_rwnum(rwflag,&opretbuf[len],sizeof(pax->komodoshis),&pax->komodoshis); + len += dragon_rwnum(rwflag,&opretbuf[len],sizeof(pax->puposhis),&pax->puposhis); len += dragon_rwnum(rwflag,&opretbuf[len],sizeof(pax->fiatoshis),&pax->fiatoshis); len += dragon_rwnum(rwflag,&opretbuf[len],sizeof(pax->height),&pax->height); len += dragon_rwnum(rwflag,&opretbuf[len],sizeof(pax->otherheight),&pax->otherheight); @@ -208,7 +208,7 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio return(len); } -int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t *values,int64_t *srcvalues,int32_t *kmdheights,int32_t *otherheights,int8_t *baseids,uint8_t *rmd160s,uint8_t *opretbuf,int32_t opretlen,int32_t iskomodo) +int32_t hush_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t *values,int64_t *srcvalues,int32_t *hushheights,int32_t *otherheights,int8_t *baseids,uint8_t *rmd160s,uint8_t *opretbuf,int32_t opretlen,int32_t iskomodo) { struct pax_transaction p,*pax; int32_t i,n=0,j,len=0,incr,height,otherheight; uint8_t type,rmd160[20]; uint64_t fiatoshis; char symbol[HUSH_SMART_CHAIN_MAXLEN]; //if ( HUSH_PAX == 0 ) @@ -231,14 +231,14 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t if ( iskomodo != 0 ) { memset(&p,0,sizeof(p)); - len += komodo_rwapproval(0,&opretbuf[len],&p); - if ( values != 0 && srcvalues != 0 && kmdheights != 0 && otherheights != 0 && baseids != 0 && rmd160s != 0 ) + len += hush_rwapproval(0,&opretbuf[len],&p); + if ( values != 0 && srcvalues != 0 && hushheights != 0 && otherheights != 0 && baseids != 0 && rmd160s != 0 ) { txids[n] = p.txid; vouts[n] = p.vout; - values[n] = (strcmp("HUSH3",base) == 0) ? p.komodoshis : p.fiatoshis; - srcvalues[n] = (strcmp("HUSH3",base) == 0) ? p.fiatoshis : p.komodoshis; - kmdheights[n] = p.height; + values[n] = (strcmp("HUSH3",base) == 0) ? p.puposhis : p.fiatoshis; + srcvalues[n] = (strcmp("HUSH3",base) == 0) ? p.fiatoshis : p.puposhis; + hushheights[n] = p.height; otherheights[n] = p.otherheight; memcpy(&rmd160s[n * 20],p.rmd160,20); baseids[n] = hush_baseid(p.source); @@ -246,7 +246,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t { char coinaddr[64]; bitcoin_address(coinaddr,60,&rmd160s[n * 20],20); - printf(">>>>>>> %s: (%s) fiat %.8f kmdheight.%d other.%d -> %s %.8f\n",type=='A'?"approvedA":"issuedX",baseids[n]>=0?CURRENCIES[baseids[n]]:"???",dstr(p.fiatoshis),kmdheights[n],otherheights[n],coinaddr,dstr(values[n])); + printf(">>>>>>> %s: (%s) fiat %.8f hushheight.%d other.%d -> %s %.8f\n",type=='A'?"approvedA":"issuedX",baseids[n]>=0?CURRENCIES[baseids[n]]:"???",dstr(p.fiatoshis),hushheights[n],otherheights[n],coinaddr,dstr(values[n])); } } } @@ -262,22 +262,22 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t vouts[n] = opretbuf[len++]; vouts[n] = (opretbuf[len++] << 8) | vouts[n]; baseids[n] = hush_baseid(base); - if ( (pax= komodo_paxfinds(txids[n],vouts[n])) != 0 ) + if ( (pax= hush_paxfinds(txids[n],vouts[n])) != 0 ) { - values[n] = (strcmp("HUSH3",base) == 0) ? pax->komodoshis : pax->fiatoshis; - srcvalues[n] = (strcmp("HUSH3",base) == 0) ? pax->fiatoshis : pax->komodoshis; - kmdheights[n] = pax->height; + values[n] = (strcmp("HUSH3",base) == 0) ? pax->puposhis : pax->fiatoshis; + srcvalues[n] = (strcmp("HUSH3",base) == 0) ? pax->fiatoshis : pax->puposhis; + hushheights[n] = pax->height; otherheights[n] = pax->otherheight; memcpy(&rmd160s[n * 20],pax->rmd160,20); } } - //printf(" komodo_issued_opreturn issuedtxid v%d i.%d opretlen.%d\n",vouts[n],n,opretlen); + //printf(" hush_issued_opreturn issuedtxid v%d i.%d opretlen.%d\n",vouts[n],n,opretlen); } } return(n); } -int32_t komodo_paxcmp(char *symbol,int32_t kmdheight,uint64_t value,uint64_t checkvalue,uint64_t seed) +int32_t hush_paxcmp(char *symbol,int32_t hushheight,uint64_t value,uint64_t checkvalue,uint64_t seed) { int32_t ratio; if ( seed == 0 && checkvalue != 0 ) @@ -288,7 +288,7 @@ int32_t komodo_paxcmp(char *symbol,int32_t kmdheight,uint64_t value,uint64_t che else { if ( SMART_CHAIN_SYMBOL[0] != 0 ) - printf("ht.%d ignore mismatched %s value %lld vs checkvalue %lld -> ratio.%d\n",kmdheight,symbol,(long long)value,(long long)checkvalue,ratio); + printf("ht.%d ignore mismatched %s value %lld vs checkvalue %lld -> ratio.%d\n",hushheight,symbol,(long long)value,(long long)checkvalue,ratio); return(-1); } } @@ -301,7 +301,7 @@ int32_t komodo_paxcmp(char *symbol,int32_t kmdheight,uint64_t value,uint64_t che return(value != checkvalue); } -uint64_t komodo_paxtotal() +uint64_t hush_paxtotal() { struct pax_transaction *pax,*pax2,*tmp,*tmp2; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN],*str; int32_t i,ht; int64_t checktoshis; uint64_t seed,total = 0; struct hush_state *basesp; if ( HUSH_PASSPORT_INITDONE == 0 ) //HUSH_PAX == 0 || @@ -320,16 +320,16 @@ uint64_t komodo_paxtotal() basesp = hush_stateptrget(str); if ( basesp != 0 && pax->didstats == 0 ) { - if ( pax->type == 'I' && (pax2= komodo_paxfind(pax->txid,pax->vout,'D')) != 0 ) + if ( pax->type == 'I' && (pax2= hush_paxfind(pax->txid,pax->vout,'D')) != 0 ) { if ( pax2->fiatoshis != 0 ) { - pax->komodoshis = pax2->komodoshis; + pax->puposhis = pax2->puposhis; pax->fiatoshis = pax2->fiatoshis; basesp->issued += pax->fiatoshis; pax->didstats = 1; if ( strcmp(str,SMART_CHAIN_SYMBOL) == 0 ) - printf("########### %p issued %s += %.8f kmdheight.%d %.8f other.%d\n",basesp,str,dstr(pax->fiatoshis),pax->height,dstr(pax->komodoshis),pax->otherheight); + printf("########### %p issued %s += %.8f hushheight.%d %.8f other.%d\n",basesp,str,dstr(pax->fiatoshis),pax->height,dstr(pax->puposhis),pax->otherheight); pax2->marked = pax->height; pax->marked = pax->height; } @@ -337,20 +337,20 @@ uint64_t komodo_paxtotal() else if ( pax->type == 'W' ) { //bitcoin_address(coinaddr,addrtype,rmd160,20); - if ( (checktoshis= komodo_paxprice(&seed,pax->height,pax->source,(char *)"HUSH3",(uint64_t)pax->fiatoshis)) != 0 ) + if ( (checktoshis= hush_paxprice(&seed,pax->height,pax->source,(char *)"HUSH3",(uint64_t)pax->fiatoshis)) != 0 ) { - if ( komodo_paxcmp(pax->source,pax->height,pax->komodoshis,checktoshis,seed) != 0 ) + if ( hush_paxcmp(pax->source,pax->height,pax->puposhis,checktoshis,seed) != 0 ) { pax->marked = pax->height; - //printf("WITHDRAW.%s mark <- %d %.8f != %.8f\n",pax->source,pax->height,dstr(checktoshis),dstr(pax->komodoshis)); + //printf("WITHDRAW.%s mark <- %d %.8f != %.8f\n",pax->source,pax->height,dstr(checktoshis),dstr(pax->puposhis)); } else if ( pax->validated == 0 ) { - pax->validated = pax->komodoshis = checktoshis; + pax->validated = pax->puposhis = checktoshis; //int32_t j; for (j=0; j<32; j++) // printf("%02x",((uint8_t *)&pax->txid)[j]); //if ( strcmp(str,SMART_CHAIN_SYMBOL) == 0 ) - // printf(" v%d %p got WITHDRAW.%s kmd.%d ht.%d %.8f -> %.8f/%.8f\n",pax->vout,pax,pax->source,pax->height,pax->otherheight,dstr(pax->fiatoshis),dstr(pax->komodoshis),dstr(checktoshis)); + // printf(" v%d %p got WITHDRAW.%s kmd.%d ht.%d %.8f -> %.8f/%.8f\n",pax->vout,pax,pax->source,pax->height,pax->otherheight,dstr(pax->fiatoshis),dstr(pax->puposhis),dstr(checktoshis)); } } } @@ -362,7 +362,7 @@ uint64_t komodo_paxtotal() { pax->ready = 0; if ( 0 && pax->type == 'A' ) - printf("%p pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d\n",pax,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0); + printf("%p pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d\n",pax,pax->symbol,pax->source,pax->marked,dstr(pax->puposhis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0); if ( pax->marked != 0 ) continue; if ( strcmp(symbol,pax->symbol) == 0 || pax->type == 'A' ) @@ -381,28 +381,28 @@ uint64_t komodo_paxtotal() { if ( pax->validated != 0 ) { - total += pax->komodoshis; + total += pax->puposhis; pax->ready = 1; } else { seed = 0; - checktoshis = komodo_paxprice(&seed,pax->height,pax->source,(char *)"HUSH3",(uint64_t)pax->fiatoshis); - //printf("paxtotal PAX_fiatdest ht.%d price %s %.8f -> HUSH %.8f vs %.8f\n",pax->height,pax->symbol,(double)pax->fiatoshis/COIN,(double)pax->komodoshis/COIN,(double)checktoshis/COIN); - //printf(" v%d %.8f k.%d ht.%d\n",pax->vout,dstr(pax->komodoshis),pax->height,pax->otherheight); + checktoshis = hush_paxprice(&seed,pax->height,pax->source,(char *)"HUSH3",(uint64_t)pax->fiatoshis); + //printf("paxtotal PAX_fiatdest ht.%d price %s %.8f -> HUSH %.8f vs %.8f\n",pax->height,pax->symbol,(double)pax->fiatoshis/COIN,(double)pax->puposhis/COIN,(double)checktoshis/COIN); + //printf(" v%d %.8f k.%d ht.%d\n",pax->vout,dstr(pax->puposhis),pax->height,pax->otherheight); if ( seed != 0 && checktoshis != 0 ) { - if ( checktoshis == pax->komodoshis ) + if ( checktoshis == pax->puposhis ) { - total += pax->komodoshis; - pax->validated = pax->komodoshis; + total += pax->puposhis; + pax->validated = pax->puposhis; pax->ready = 1; } else pax->marked = pax->height; } } } if ( 0 && pax->ready != 0 ) - printf("%p (%c) pax.%s marked.%d %.8f -> %.8f validated.%d approved.%d ready.%d ht.%d\n",pax,pax->type,pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0,pax->ready,pax->height); + printf("%p (%c) pax.%s marked.%d %.8f -> %.8f validated.%d approved.%d ready.%d ht.%d\n",pax,pax->type,pax->symbol,pax->marked,dstr(pax->puposhis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0,pax->ready,pax->height); } } } @@ -415,8 +415,8 @@ static int _paxorder(const void *a,const void *b) #define pax_a (*(struct pax_transaction **)a) #define pax_b (*(struct pax_transaction **)b) uint64_t aval,bval; - aval = pax_a->fiatoshis + pax_a->komodoshis + pax_a->height; - bval = pax_b->fiatoshis + pax_b->komodoshis + pax_b->height; + aval = pax_a->fiatoshis + pax_a->puposhis + pax_a->height; + bval = pax_b->fiatoshis + pax_b->puposhis + pax_b->height; if ( bval > aval ) return(-1); else if ( bval < aval ) @@ -426,7 +426,7 @@ static int _paxorder(const void *a,const void *b) #undef pax_b } -int32_t komodo_pending_withdraws(char *opretstr) // todo: enforce deterministic order +int32_t hush_pending_withdraws(char *opretstr) // todo: enforce deterministic order { struct pax_transaction *pax,*pax2,*tmp,*paxes[64]; uint8_t opretbuf[16384*4]; int32_t i,n,ht,len=0; uint64_t total = 0; if ( HUSH_PAX == 0 || HUSH_PASSPORT_INITDONE == 0 ) @@ -438,12 +438,12 @@ int32_t komodo_pending_withdraws(char *opretstr) // todo: enforce deterministic { if ( pax->type == 'W' ) { - if ( (pax2= komodo_paxfind(pax->txid,pax->vout,'A')) != 0 ) + if ( (pax2= hush_paxfind(pax->txid,pax->vout,'A')) != 0 ) { if ( pax2->approved != 0 ) pax->approved = pax2->approved; } - else if ( (pax2= komodo_paxfind(pax->txid,pax->vout,'X')) != 0 ) + else if ( (pax2= hush_paxfind(pax->txid,pax->vout,'X')) != 0 ) pax->approved = pax->height; //printf("pending_withdraw: pax %s marked.%u approved.%u validated.%llu\n",pax->symbol,pax->marked,pax->approved,(long long)pax->validated); if ( pax->marked == 0 && pax->approved == 0 && pax->validated != 0 ) @@ -453,7 +453,7 @@ int32_t komodo_pending_withdraws(char *opretstr) // todo: enforce deterministic paxes[n++] = pax; //int32_t j; for (j=0; j<32; j++) // printf("%02x",((uint8_t *)&pax->txid)[j]); - //printf(" %s.(kmdht.%d ht.%d marked.%u approved.%d validated %.8f) %.8f\n",pax->source,pax->height,pax->otherheight,pax->marked,pax->approved,dstr(pax->validated),dstr(pax->komodoshis)); + //printf(" %s.(kmdht.%d ht.%d marked.%u approved.%d validated %.8f) %.8f\n",pax->source,pax->height,pax->otherheight,pax->marked,pax->approved,dstr(pax->validated),dstr(pax->puposhis)); } } } @@ -466,16 +466,16 @@ int32_t komodo_pending_withdraws(char *opretstr) // todo: enforce deterministic for (i=0; i>3)*7 ) - len += komodo_rwapproval(1,&opretbuf[len],paxes[i]); + len += hush_rwapproval(1,&opretbuf[len],paxes[i]); } if ( len > 0 ) init_hexbytes_noT(opretstr,opretbuf,len); } - //fprintf(stderr,"komodo_pending_withdraws len.%d PAXTOTAL %.8f\n",len,dstr(komodo_paxtotal())); + //fprintf(stderr,"hush_pending_withdraws len.%d PAXTOTAL %.8f\n",len,dstr(hush_paxtotal())); return(len); } -int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t tokomodo) +int32_t hush_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t tokomodo) { struct pax_transaction *pax,*tmp; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; uint8_t *script,opcode,opret[16384*4],data[16384*4]; int32_t i,baseid,ht,len=0,opretlen=0,numvouts=1; struct hush_state *sp; uint64_t available,deposited,issued,withdrawn,approved,redeemed,mask,sum = 0; if ( HUSH_PASSPORT_INITDONE == 0 )//HUSH_PAX == 0 || @@ -505,7 +505,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to else { opcode = 'X'; - if ( 1 || komodo_paxtotal() == 0 ) + if ( 1 || hush_paxtotal() == 0 ) return(0); } HASH_ITER(hh,PAX,pax,tmp) @@ -517,18 +517,18 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to if ( pax->height > 236000 ) { if ( kmdsp != 0 && kmdsp->NOTARIZED_HEIGHT >= pax->height ) - pax->validated = pax->komodoshis; + pax->validated = pax->puposhis; else if ( kmdsp->CURRENT_HEIGHT > pax->height+30 ) pax->validated = pax->ready = 0; } else { if ( kmdsp != 0 && (kmdsp->NOTARIZED_HEIGHT >= pax->height || kmdsp->CURRENT_HEIGHT > pax->height+30) ) // assumes same chain as notarize - pax->validated = pax->komodoshis; + pax->validated = pax->puposhis; else pax->validated = pax->ready = 0; } #else - pax->validated = pax->komodoshis; + pax->validated = pax->puposhis; #endif } if ( SMART_CHAIN_SYMBOL[0] != 0 && (pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) != 0 || available < pax->fiatoshis) ) @@ -537,7 +537,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to // printf("miner.[%s]: skip %s %.8f when avail %.8f deposited %.8f, issued %.8f withdrawn %.8f approved %.8f redeemed %.8f\n",SMART_CHAIN_SYMBOL,symbol,dstr(pax->fiatoshis),dstr(available),dstr(deposited),dstr(issued),dstr(withdrawn),dstr(approved),dstr(redeemed)); continue; } - /*printf("pax.%s marked.%d %.8f -> %.8f ready.%d validated.%d\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->ready!=0,pax->validated!=0); + /*printf("pax.%s marked.%d %.8f -> %.8f ready.%d validated.%d\n",pax->symbol,pax->marked,dstr(pax->puposhis),dstr(pax->fiatoshis),pax->ready!=0,pax->validated!=0); if ( pax->marked != 0 || (pax->type != 'D' && pax->type != 'A') || pax->ready == 0 ) { printf("reject 2\n"); @@ -564,9 +564,9 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to } else continue; } - //printf("redeem.%d? (%c) %p pax.%s marked.%d %.8f -> %.8f ready.%d validated.%d approved.%d\n",tokomodo,pax->type,pax,pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->ready!=0,pax->validated!=0,pax->approved!=0); + //printf("redeem.%d? (%c) %p pax.%s marked.%d %.8f -> %.8f ready.%d validated.%d approved.%d\n",tokomodo,pax->type,pax,pax->symbol,pax->marked,dstr(pax->puposhis),dstr(pax->fiatoshis),pax->ready!=0,pax->validated!=0,pax->approved!=0); if ( 0 && SMART_CHAIN_SYMBOL[0] != 0 ) - printf("pax.%s marked.%d %.8f -> %.8f\n",SMART_CHAIN_SYMBOL,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); + printf("pax.%s marked.%d %.8f -> %.8f\n",SMART_CHAIN_SYMBOL,pax->marked,dstr(pax->puposhis),dstr(pax->fiatoshis)); if ( opcode == 'I' ) { sum += pax->fiatoshis; @@ -574,7 +574,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to break; } txNew->vout.resize(numvouts+1); - txNew->vout[numvouts].nValue = (opcode == 'I') ? pax->fiatoshis : pax->komodoshis; + txNew->vout[numvouts].nValue = (opcode == 'I') ? pax->fiatoshis : pax->puposhis; txNew->vout[numvouts].scriptPubKey.resize(25); script = (uint8_t *)&txNew->vout[numvouts].scriptPubKey[0]; *script++ = 0x76; @@ -593,8 +593,8 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to } else { - len += komodo_rwapproval(1,&data[len],pax); - PENDING_HUSH_TX += pax->komodoshis; + len += hush_rwapproval(1,&data[len],pax); + PENDING_HUSH_TX += pax->puposhis; 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 ) @@ -665,12 +665,12 @@ int32_t hush_checkvout(int32_t vout,int32_t k,int32_t indallvouts) else return(vout == 0); } -int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max) +int32_t hush_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max) { int32_t i; if ( sizeof(banned_txids)/sizeof(*banned_txids) > max ) { - fprintf(stderr,"komodo_bannedset: buffer too small %d vs %d\n",(int32_t)(sizeof(banned_txids)/sizeof(*banned_txids)),max); + fprintf(stderr,"hush_bannedset: buffer too small %d vs %d\n",(int32_t)(sizeof(banned_txids)/sizeof(*banned_txids)),max); StartShutdown(); } for (i=0; i 195000 || kmdheight <= height) ) + if ( strcmp(base,SMART_CHAIN_SYMBOL) == 0 && (hushheight > 195000 || hushheight <= height) ) { didstats = 0; - if ( komodo_paxcmp(base,kmdheight,value,checktoshis,kmdheight < 225000 ? seed : 0) == 0 ) + if ( hush_paxcmp(base,hushheight,value,checktoshis,hushheight < 225000 ? seed : 0) == 0 ) { - if ( (pax= komodo_paxfind(txid,vout,'D')) == 0 ) + if ( (pax= hush_paxfind(txid,vout,'D')) == 0 ) { if ( (basesp= hush_stateptrget(base)) != 0 ) { basesp->deposited += fiatoshis; didstats = 1; if ( 0 && strcmp(base,SMART_CHAIN_SYMBOL) == 0 ) - printf("########### %p deposited %s += %.8f kmdheight.%d %.8f\n",basesp,base,dstr(fiatoshis),kmdheight,dstr(value)); + printf("########### %p deposited %s += %.8f hushheight.%d %.8f\n",basesp,base,dstr(fiatoshis),hushheight,dstr(value)); } else printf("cant get stateptr.(%s)\n",base); - komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,'D',kmdheight,height,(char *)"HUSH3",0); + hush_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,'D',hushheight,height,(char *)"HUSH3",0); } - if ( (pax= komodo_paxfind(txid,vout,'D')) != 0 ) + if ( (pax= hush_paxfind(txid,vout,'D')) != 0 ) { - pax->height = kmdheight; + pax->height = hushheight; pax->validated = value; - pax->komodoshis = value; + pax->puposhis = value; pax->fiatoshis = fiatoshis; if ( didstats == 0 && pax->didstats == 0 ) { @@ -904,15 +904,15 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 basesp->deposited += fiatoshis; didstats = 1; if ( 0 && strcmp(base,SMART_CHAIN_SYMBOL) == 0 ) - printf("########### %p depositedB %s += %.8f/%.8f kmdheight.%d/%d %.8f/%.8f\n",basesp,base,dstr(fiatoshis),dstr(pax->fiatoshis),kmdheight,pax->height,dstr(value),dstr(pax->komodoshis)); + printf("########### %p depositedB %s += %.8f/%.8f hushheight.%d/%d %.8f/%.8f\n",basesp,base,dstr(fiatoshis),dstr(pax->fiatoshis),hushheight,pax->height,dstr(value),dstr(pax->puposhis)); } } // if ( didstats != 0 ) pax->didstats = 1; - if ( (pax2= komodo_paxfind(txid,vout,'I')) != 0 ) + if ( (pax2= hush_paxfind(txid,vout,'I')) != 0 ) { pax2->fiatoshis = pax->fiatoshis; - pax2->komodoshis = pax->komodoshis; + pax2->puposhis = pax->puposhis; pax->marked = pax2->marked = pax->height; pax2->height = pax->height = height; if ( pax2->didstats == 0 ) @@ -922,7 +922,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 basesp->issued += pax2->fiatoshis; pax2->didstats = 1; if ( 0 && strcmp(base,"USD") == 0 ) - printf("########### %p issueda %s += %.8f kmdheight.%d %.8f other.%d [%d]\n",basesp,base,dstr(pax2->fiatoshis),pax2->height,dstr(pax2->komodoshis),pax2->otherheight,height); + printf("########### %p issueda %s += %.8f hushheight.%d %.8f other.%d [%d]\n",basesp,base,dstr(pax2->fiatoshis),pax2->height,dstr(pax2->puposhis),pax2->otherheight,height); } } } @@ -930,12 +930,12 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } else { - if ( (pax= komodo_paxfind(txid,vout,'D')) != 0 ) + if ( (pax= hush_paxfind(txid,vout,'D')) != 0 ) pax->marked = checktoshis; - if ( kmdheight > 238000 && (kmdheight > 214700 || strcmp(base,SMART_CHAIN_SYMBOL) == 0) ) //seed != 0 && - printf("pax %s deposit %.8f rejected kmdheight.%d %.8f HUSH3 check %.8f seed.%llu\n",base,dstr(fiatoshis),kmdheight,dstr(value),dstr(checktoshis),(long long)seed); + if ( hushheight > 238000 && (hushheight > 214700 || strcmp(base,SMART_CHAIN_SYMBOL) == 0) ) //seed != 0 && + printf("pax %s deposit %.8f rejected hushheight.%d %.8f HUSH3 check %.8f seed.%llu\n",base,dstr(fiatoshis),hushheight,dstr(value),dstr(checktoshis),(long long)seed); } - } //else printf("[%s] %s paxdeposit height.%d vs kmdheight.%d\n",SMART_CHAIN_SYMBOL,base,height,kmdheight); + } //else printf("[%s] %s paxdeposit height.%d vs hushheight.%d\n",SMART_CHAIN_SYMBOL,base,height,hushheight); } //else printf("unsupported size.%d for opreturn D\n",opretlen); } else if ( opretbuf[0] == 'I' ) @@ -943,7 +943,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 tokomodo = 0; if ( strncmp((char *)"HUSH3",(char *)&opretbuf[opretlen-4],3) != 0 && strncmp(SMART_CHAIN_SYMBOL,(char *)&opretbuf[opretlen-4],3) == 0 ) { - if ( (n= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,0)) > 0 ) + if ( (n= hush_issued_opreturn(base,txids,vouts,values,srcvalues,hushheights,otherheights,baseids,rmd160s,opretbuf,opretlen,0)) > 0 ) { for (i=0; itype = opretbuf[0]; strcpy(pax->source,(char *)&opretbuf[opretlen-4]); - if ( (pax2= komodo_paxfind(txids[i],vouts[i],'D')) != 0 && pax2->fiatoshis != 0 && pax2->komodoshis != 0 ) + if ( (pax2= hush_paxfind(txids[i],vouts[i],'D')) != 0 && pax2->fiatoshis != 0 && pax2->puposhis != 0 ) { // realtime path? pax->fiatoshis = pax2->fiatoshis; - pax->komodoshis = pax2->komodoshis; + pax->puposhis = pax2->puposhis; pax->marked = pax2->marked = pax2->height; if ( pax->didstats == 0 ) { @@ -976,15 +976,15 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 pax->height = pax2->height; pax->otherheight = height; if ( 1 && strcmp(CURRENCIES[baseids[i]],"USD") == 0 ) - printf("########### %p issuedb %s += %.8f kmdheight.%d %.8f other.%d [%d]\n",basesp,CURRENCIES[baseids[i]],dstr(pax->fiatoshis),pax->height,dstr(pax->komodoshis),pax->otherheight,height); + printf("########### %p issuedb %s += %.8f hushheight.%d %.8f other.%d [%d]\n",basesp,CURRENCIES[baseids[i]],dstr(pax->fiatoshis),pax->height,dstr(pax->puposhis),pax->otherheight,height); } } } } - if ( (pax= komodo_paxmark(height,txids[i],vouts[i],'I',height)) != 0 ) - komodo_paxdelete(pax); - if ( (pax= komodo_paxmark(height,txids[i],vouts[i],'D',height)) != 0 ) - komodo_paxdelete(pax); + if ( (pax= hush_paxmark(height,txids[i],vouts[i],'I',height)) != 0 ) + hush_paxdelete(pax); + if ( (pax= hush_paxmark(height,txids[i],vouts[i],'D',height)) != 0 ) + hush_paxdelete(pax); } } //else printf("opreturn none issued?\n"); } @@ -999,17 +999,17 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 return(typestr); } tokomodo = 1; - dragon_rwnum(0,&opretbuf[34],sizeof(kmdheight),&kmdheight); + dragon_rwnum(0,&opretbuf[34],sizeof(hushheight),&hushheight); memset(base,0,sizeof(base)); - PAX_pubkey(0,&opretbuf[1],&addrtype,rmd160,base,&shortflag,&komodoshis); + PAX_pubkey(0,&opretbuf[1],&addrtype,rmd160,base,&shortflag,&puposhis); bitcoin_address(coinaddr,addrtype,rmd160,20); - checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,value); + checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,hushheight,base,value); typestr = "withdraw"; - //printf(" [%s] WITHDRAW %s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s) len.%d\n",SMART_CHAIN_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),hush_is_issuer(),strncmp(SMART_CHAIN_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr,opretlen); + //printf(" [%s] WITHDRAW %s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s) len.%d\n",SMART_CHAIN_SYMBOL,base,hushheight,height,dstr(checktoshis),dstr(puposhis),dstr(value),hush_is_issuer(),strncmp(SMART_CHAIN_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr,opretlen); didstats = 0; - //if ( komodo_paxcmp(base,kmdheight,komodoshis,checktoshis,seed) == 0 ) + //if ( hush_paxcmp(base,hushheight,puposhis,checktoshis,seed) == 0 ) { - if ( value != 0 && ((pax= komodo_paxfind(txid,vout,'W')) == 0 || pax->didstats == 0) ) + if ( value != 0 && ((pax= hush_paxfind(txid,vout,'W')) == 0 || pax->didstats == 0) ) { if ( (basesp= hush_stateptrget(base)) != 0 ) { @@ -1019,19 +1019,19 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("########### %p withdrawn %s += %.8f check %.8f\n",basesp,base,dstr(value),dstr(checktoshis)); } if ( 0 && strcmp(base,"RUB") == 0 && (pax == 0 || pax->approved == 0) ) - printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",SMART_CHAIN_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); + printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",SMART_CHAIN_SYMBOL,dstr(value),dstr(puposhis),hushheight,height); } - komodo_gateway_deposit(coinaddr,0,(char *)"HUSH3",value,rmd160,txid,vout,'W',kmdheight,height,source,0); - if ( (pax= komodo_paxfind(txid,vout,'W')) != 0 ) + hush_gateway_deposit(coinaddr,0,(char *)"HUSH3",value,rmd160,txid,vout,'W',hushheight,height,source,0); + if ( (pax= hush_paxfind(txid,vout,'W')) != 0 ) { pax->type = opretbuf[0]; strcpy(pax->source,base); strcpy(pax->symbol,"HUSH3"); - pax->height = kmdheight; + pax->height = hushheight; pax->otherheight = height; - pax->komodoshis = komodoshis; + pax->puposhis = puposhis; } - } // else printf("withdraw %s paxcmp ht.%d %d error value %.8f -> %.8f vs %.8f\n",base,kmdheight,height,dstr(value),dstr(komodoshis),dstr(checktoshis)); + } // else printf("withdraw %s paxcmp ht.%d %d error value %.8f -> %.8f vs %.8f\n",base,hushheight,height,dstr(value),dstr(puposhis),dstr(checktoshis)); // need to allocate pax } else if ( height < 236000 && tokomodo != 0 && opretbuf[0] == 'A' && SMART_CHAIN_SYMBOL[0] == 0 ) @@ -1041,22 +1041,22 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { for (i=0; i 0 ) + if ( (n= hush_issued_opreturn(base,txids,vouts,values,srcvalues,hushheights,otherheights,baseids,rmd160s,opretbuf,opretlen,1)) > 0 ) { for (i=0; isymbol); printf("override neg1 with (%s)\n",pax->symbol); @@ -1066,26 +1066,26 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } didstats = 0; seed = 0; - checktoshis = komodo_paxprice(&seed,kmdheights[i],CURRENCIES[baseids[i]],(char *)"HUSH3",(uint64_t)values[i]); - //printf("PAX_fiatdest ht.%d price %s %.8f -> HUSH3 %.8f vs %.8f\n",kmdheights[i],CURRENCIES[baseids[i]],(double)values[i]/COIN,(double)srcvalues[i]/COIN,(double)checktoshis/COIN); + checktoshis = hush_paxprice(&seed,hushheights[i],CURRENCIES[baseids[i]],(char *)"HUSH3",(uint64_t)values[i]); + //printf("PAX_fiatdest ht.%d price %s %.8f -> HUSH3 %.8f vs %.8f\n",hushheights[i],CURRENCIES[baseids[i]],(double)values[i]/COIN,(double)srcvalues[i]/COIN,(double)checktoshis/COIN); if ( srcvalues[i] == checktoshis ) { - if ( (pax= komodo_paxfind(txids[i],vouts[i],'A')) == 0 ) + if ( (pax= hush_paxfind(txids[i],vouts[i],'A')) == 0 ) { bitcoin_address(coinaddr,60,&rmd160s[i*20],20); - komodo_gateway_deposit(coinaddr,srcvalues[i],CURRENCIES[baseids[i]],values[i],&rmd160s[i*20],txids[i],vouts[i],'A',kmdheights[i],otherheights[i],CURRENCIES[baseids[i]],kmdheights[i]); - if ( (pax= komodo_paxfind(txids[i],vouts[i],'A')) == 0 ) + hush_gateway_deposit(coinaddr,srcvalues[i],CURRENCIES[baseids[i]],values[i],&rmd160s[i*20],txids[i],vouts[i],'A',hushheights[i],otherheights[i],CURRENCIES[baseids[i]],hushheights[i]); + if ( (pax= hush_paxfind(txids[i],vouts[i],'A')) == 0 ) printf("unexpected null pax for approve\n"); else pax->validated = checktoshis; - if ( (pax2= komodo_paxfind(txids[i],vouts[i],'W')) != 0 ) - pax2->approved = kmdheights[i]; - komodo_paxmark(height,txids[i],vouts[i],'W',height); - //komodo_paxmark(height,txids[i],vouts[i],'A',height); + if ( (pax2= hush_paxfind(txids[i],vouts[i],'W')) != 0 ) + pax2->approved = hushheights[i]; + hush_paxmark(height,txids[i],vouts[i],'W',height); + //hush_paxmark(height,txids[i],vouts[i],'A',height); if ( values[i] != 0 && (basesp= hush_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->approved += values[i]; didstats = 1; - //printf("pax.%p ########### %p approved %s += %.8f -> %.8f/%.8f kht.%d %d\n",pax,basesp,CURRENCIES[baseids[i]],dstr(values[i]),dstr(srcvalues[i]),dstr(checktoshis),kmdheights[i],otherheights[i]); + //printf("pax.%p ########### %p approved %s += %.8f -> %.8f/%.8f kht.%d %d\n",pax,basesp,CURRENCIES[baseids[i]],dstr(values[i]),dstr(srcvalues[i]),dstr(checktoshis),hushheights[i],otherheights[i]); } //printf(" i.%d (%s) <- %.8f ADDFLAG APPROVED\n",i,coinaddr,dstr(values[i])); } @@ -1095,39 +1095,39 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->approved += values[i]; didstats = 1; - //printf("pax.%p ########### %p approved %s += %.8f -> %.8f/%.8f kht.%d %d\n",pax,basesp,CURRENCIES[baseids[i]],dstr(values[i]),dstr(srcvalues[i]),dstr(checktoshis),kmdheights[i],otherheights[i]); + //printf("pax.%p ########### %p approved %s += %.8f -> %.8f/%.8f kht.%d %d\n",pax,basesp,CURRENCIES[baseids[i]],dstr(values[i]),dstr(srcvalues[i]),dstr(checktoshis),hushheights[i],otherheights[i]); } } //else printf(" i.%d of n.%d pax.%p baseids[] %d\n",i,n,pax,baseids[i]); - if ( (pax= komodo_paxfind(txids[i],vouts[i],'A')) != 0 ) + if ( (pax= hush_paxfind(txids[i],vouts[i],'A')) != 0 ) { pax->type = opretbuf[0]; - pax->approved = kmdheights[i]; + pax->approved = hushheights[i]; pax->validated = checktoshis; if ( didstats != 0 ) pax->didstats = 1; //if ( strcmp(CURRENCIES[baseids[i]],SMART_CHAIN_SYMBOL) == 0 ) - //printf(" i.%d approved.%d <<<<<<<<<<<<< APPROVED %p\n",i,kmdheights[i],pax); + //printf(" i.%d approved.%d <<<<<<<<<<<<< APPROVED %p\n",i,hushheights[i],pax); } } } } //else printf("n.%d from opreturns\n",n); - //printf("extra.[%d] after %.8f\n",n,dstr(komodo_paxtotal())); + //printf("extra.[%d] after %.8f\n",n,dstr(hush_paxtotal())); } else if ( height < 236000 && opretbuf[0] == 'X' && SMART_CHAIN_SYMBOL[0] == 0 ) { tokomodo = 1; - if ( (n= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,1)) > 0 ) + if ( (n= hush_issued_opreturn(base,txids,vouts,values,srcvalues,hushheights,otherheights,baseids,rmd160s,opretbuf,opretlen,1)) > 0 ) { for (i=0; itype = opretbuf[0]; if ( height < 121842 ) // fields got switched around due to legacy issues and approves @@ -1138,17 +1138,17 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 basesp->redeemed += value; pax->didstats = 1; if ( strcmp(CURRENCIES[baseids[i]],SMART_CHAIN_SYMBOL) == 0 ) - printf("ht.%d %.8f ########### %p redeemed %s += %.8f %.8f kht.%d ht.%d\n",height,dstr(value),basesp,CURRENCIES[baseids[i]],dstr(value),dstr(srcvalues[i]),kmdheights[i],otherheights[i]); + printf("ht.%d %.8f ########### %p redeemed %s += %.8f %.8f kht.%d ht.%d\n",height,dstr(value),basesp,CURRENCIES[baseids[i]],dstr(value),dstr(srcvalues[i]),hushheights[i],otherheights[i]); } } - if ( (pax= komodo_paxmark(height,txids[i],vouts[i],'W',height)) != 0 ) - komodo_paxdelete(pax); - if ( (pax= komodo_paxmark(height,txids[i],vouts[i],'A',height)) != 0 ) - komodo_paxdelete(pax); - if ( (pax= komodo_paxmark(height,txids[i],vouts[i],'X',height)) != 0 ) - komodo_paxdelete(pax); + if ( (pax= hush_paxmark(height,txids[i],vouts[i],'W',height)) != 0 ) + hush_paxdelete(pax); + if ( (pax= hush_paxmark(height,txids[i],vouts[i],'A',height)) != 0 ) + hush_paxdelete(pax); + if ( (pax= hush_paxmark(height,txids[i],vouts[i],'X',height)) != 0 ) + hush_paxdelete(pax); } - } //else printf("komodo_issued_opreturn returned %d\n",n); + } //else printf("hush_issued_opreturn returned %d\n",n); } return(typestr); } @@ -1339,7 +1339,7 @@ long hush_stateind_validate(struct hush_state *sp,char *indfname,uint8_t *fileda return(-1); } -long komodo_indfile_update(FILE *indfp,uint32_t *prevpos100p,long lastfpos,long newfpos,uint8_t func,uint32_t *indcounterp) +long hush_indfile_update(FILE *indfp,uint32_t *prevpos100p,long lastfpos,long newfpos,uint8_t func,uint32_t *indcounterp) { uint32_t tmp; if ( indfp != 0 ) @@ -1375,7 +1375,7 @@ int32_t hush_faststateinit(struct hush_state *sp,char *fname,char *symbol,char * fprintf(stderr,"processing %s %ldKB, validated.%ld\n",fname,datalen/1024,validated); while ( (func= hush_parsestatefiledata(sp,filedata,&fpos,datalen,symbol,dest)) >= 0 ) { - lastfpos = komodo_indfile_update(indfp,&prevpos100,lastfpos,fpos,func,&indcounter); + lastfpos = hush_indfile_update(indfp,&prevpos100,lastfpos,fpos,func,&indcounter); } if ( indfp != 0 ) { @@ -1400,7 +1400,7 @@ int32_t hush_faststateinit(struct hush_state *sp,char *fname,char *symbol,char * { while ( (func= hush_parsestatefiledata(sp,filedata,&fpos,datalen,symbol,dest)) >= 0 ) { - lastfpos = komodo_indfile_update(indfp,&prevpos100,lastfpos,fpos,func,&indcounter); + lastfpos = hush_indfile_update(indfp,&prevpos100,lastfpos,fpos,func,&indcounter); if ( lastfpos != fpos ) fprintf(stderr,"unexpected lastfpos.%ld != %ld\n",lastfpos,fpos); } @@ -1555,7 +1555,7 @@ void hush_passport_iteration() if ( sp != 0 && isrealtime == 0 ) refsp->RTbufs[0][2] = 0; } - //komodo_paxtotal(); // calls hush_isrealtime(), which calls hush_longestchain() + //hush_paxtotal(); // calls hush_isrealtime(), which calls hush_longestchain() refsp->RTmask |= RTmask; if ( expired == 0 && HUSH_PASSPORT_INITDONE == 0 ) { @@ -1574,13 +1574,13 @@ extern std::vector Mineropret; // opreturn data set by the data gatheri #define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"CBCOINBASE",cmdstr,0,0,0) -const char *Cryptos[] = { "HUSH", "ETH" }; // must be on binance (for now) +const char *Cryptos[] = { "HUSH", "ETH" }; // "LTC", "BCHABC", "XMR", "IOTA", "ZEC", "WAVES", "LSK", "DCR", "RVN", "DASH", "XEM", "BTS", "ICX", "HOT", "STEEM", "ENJ", "STRAT" const char *Forex[] = { "BGN","NZD","ILS","RUB","CAD","PHP","CHF","AUD","JPY","TRY","HKD","MYR","HRK","CZK","IDR","DKK","NOK","HUF","GBP","MXN","THB","ISK","ZAR","BRL","SGD","PLN","INR","KRW","RON","CNY","SEK","EUR" }; // must be in ECB list -struct komodo_extremeprice +struct hush_extremeprice { uint256 blockhash; uint32_t pricebits,timestamp; @@ -1588,7 +1588,7 @@ struct komodo_extremeprice int16_t dir,ind; } ExtremePrice; -struct komodo_priceinfo +struct hush_priceinfo { FILE *fp; char symbol[64]; @@ -1598,7 +1598,7 @@ uint32_t PriceCache[HUSH_LOCALPRICE_CACHESIZE][HUSH_MAXPRICES];//4+sizeof(Crypto int64_t PriceMult[HUSH_MAXPRICES]; int32_t hush_cbopretsize(uint64_t flags); -void komodo_PriceCache_shift() +void hush_PriceCache_shift() { int32_t i; for (i=HUSH_LOCALPRICE_CACHESIZE-1; i>0; i--) @@ -1640,9 +1640,9 @@ int32_t hush_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeigh } /* - komodo_pricenew() is passed in a reference price, the change tolerance and the proposed price. it needs to return a clipped price if it is too big and also set a flag if it is at or above the limit + hush_pricenew() is passed in a reference price, the change tolerance and the proposed price. it needs to return a clipped price if it is too big and also set a flag if it is at or above the limit */ -uint32_t komodo_pricenew(char *maxflagp,uint32_t price,uint32_t refprice,int64_t tolerance) +uint32_t hush_pricenew(char *maxflagp,uint32_t price,uint32_t refprice,int64_t tolerance) { uint64_t highprice,lowprice; if ( refprice < 2 ) @@ -1676,13 +1676,13 @@ uint32_t komodo_pricenew(char *maxflagp,uint32_t price,uint32_t refprice,int64_t return(0); } -// komodo_pricecmp() returns -1 if any of the prices are beyond the tolerance -int32_t komodo_pricecmp(int32_t nHeight,int32_t n,char *maxflags,uint32_t *pricebitsA,uint32_t *pricebitsB,int64_t tolerance) +// hush_pricecmp() returns -1 if any of the prices are beyond the tolerance +int32_t hush_pricecmp(int32_t nHeight,int32_t n,char *maxflags,uint32_t *pricebitsA,uint32_t *pricebitsB,int64_t tolerance) { int32_t i; uint32_t newprice; for (i=1; i newprice.%u out of tolerance maxflag.%d\n",nHeight,i,n,pricebitsB[i],pricebitsA[i],newprice,maxflags[i]); return(-1); @@ -1691,14 +1691,14 @@ int32_t komodo_pricecmp(int32_t nHeight,int32_t n,char *maxflags,uint32_t *price return(0); } -// komodo_priceclamp() clamps any price that is beyond tolerance -int32_t komodo_priceclamp(int32_t n,uint32_t *pricebits,uint32_t *refprices,int64_t tolerance) +// hush_priceclamp() clamps any price that is beyond tolerance +int32_t hush_priceclamp(int32_t n,uint32_t *pricebits,uint32_t *refprices,int64_t tolerance) { int32_t i; uint32_t newprice; char maxflags[HUSH_MAXPRICES]; memset(maxflags,0,sizeof(maxflags)); for (i=1; i %u\n",i,n,refprices[i],pricebits[i],newprice); pricebits[i] = newprice; @@ -1707,8 +1707,8 @@ int32_t komodo_priceclamp(int32_t n,uint32_t *pricebits,uint32_t *refprices,int6 return(0); } -// komodo_mineropret() returns a valid pricedata to add to the coinbase opreturn for nHeight -CScript komodo_mineropret(int32_t nHeight) +// hush_mineropret() returns a valid pricedata to add to the coinbase opreturn for nHeight +CScript hush_mineropret(int32_t nHeight) { CScript opret; char maxflags[HUSH_MAXPRICES]; uint32_t pricebits[HUSH_MAXPRICES],prevbits[HUSH_MAXPRICES]; int32_t maxflag,i,n,numzero=0; if ( Mineropret.size() >= PRICES_SIZEBIT0 ) @@ -1726,7 +1726,7 @@ CScript komodo_mineropret(int32_t nHeight) } if ( numzero != 0 ) { - fprintf(stderr," komodo_mineropret numzero.%d vs n.%d\n",numzero,n); + fprintf(stderr," hush_mineropret numzero.%d vs n.%d\n",numzero,n); hush_cbopretupdate(1); sleep(61); } @@ -1735,10 +1735,10 @@ CScript komodo_mineropret(int32_t nHeight) { memcpy(pricebits,Mineropret.data(),Mineropret.size()); memset(maxflags,0,sizeof(maxflags)); - if ( komodo_pricecmp(0,n,maxflags,pricebits,prevbits,PRICES_ERRORRATE) < 0 ) + if ( hush_pricecmp(0,n,maxflags,pricebits,prevbits,PRICES_ERRORRATE) < 0 ) { // if the new prices are outside tolerance, update Mineropret with clamped prices - komodo_priceclamp(n,pricebits,prevbits,PRICES_ERRORRATE); + hush_priceclamp(n,pricebits,prevbits,PRICES_ERRORRATE); //fprintf(stderr,"update Mineropret to clamped prices\n"); memcpy(Mineropret.data(),pricebits,Mineropret.size()); } @@ -1761,7 +1761,7 @@ CScript komodo_mineropret(int32_t nHeight) */ -void komodo_queuelocalprice(int32_t dir,int32_t height,uint32_t timestamp,uint256 blockhash,int32_t ind,uint32_t pricebits) +void hush_queuelocalprice(int32_t dir,int32_t height,uint32_t timestamp,uint256 blockhash,int32_t ind,uint32_t pricebits) { fprintf(stderr,"ExtremePrice dir.%d ht.%d ind.%d cmpbits.%u\n",dir,height,ind,pricebits); ExtremePrice.dir = dir; @@ -1821,7 +1821,7 @@ int32_t hush_opretvalidate(const CBlock *block,CBlockIndex * const previndex,int if ( pricebits[i] == 0 ) pricebits[i] = prevbits[i]; } - if ( komodo_pricecmp(nHeight,n,maxflags,pricebits,prevbits,PRICES_ERRORRATE) < 0 ) + if ( hush_pricecmp(nHeight,n,maxflags,pricebits,prevbits,PRICES_ERRORRATE) < 0 ) { for (i=1; inTime,bhash,i,prevbits[i]); + hush_queuelocalprice(1,nHeight,block->nTime,bhash,i,prevbits[i]); break; } } @@ -1880,7 +1880,7 @@ int32_t hush_opretvalidate(const CBlock *block,CBlockIndex * const previndex,int } if ( j == HUSH_LOCALPRICE_CACHESIZE ) { - komodo_queuelocalprice(-1,nHeight,block->nTime,bhash,i,prevbits[i]); + hush_queuelocalprice(-1,nHeight,block->nTime,bhash,i,prevbits[i]); break; } } @@ -2250,7 +2250,7 @@ void hush_cbopretupdate(int32_t forceflag) if ( (forceflag != 0 || now > lastbtc+120) && get_btcusd(pricebits) == 0 ) { if ( flags == 0 ) - komodo_PriceCache_shift(); + hush_PriceCache_shift(); memcpy(PriceCache[0],pricebits,PRICES_SIZEBIT0); flags |= 1; } @@ -2260,7 +2260,7 @@ void hush_cbopretupdate(int32_t forceflag) { get_dailyfx(forexprices); if ( flags == 0 ) - komodo_PriceCache_shift(); + hush_PriceCache_shift(); flags |= 2; memcpy(&PriceCache[0][size/sizeof(uint32_t)],forexprices,sizeof(forexprices)); } @@ -2272,7 +2272,7 @@ void hush_cbopretupdate(int32_t forceflag) { get_cryptoprices(pricebuf,Cryptos,(int32_t)(sizeof(Cryptos)/sizeof(*Cryptos)),ASSETCHAINS_PRICES); if ( flags == 0 ) - komodo_PriceCache_shift(); + hush_PriceCache_shift(); memcpy(&PriceCache[0][size/sizeof(uint32_t)],pricebuf,(sizeof(Cryptos)/sizeof(*Cryptos)+ASSETCHAINS_PRICES.size()) * sizeof(uint32_t)); flags |= 4; // very rarely we can see flags == 6 case } @@ -2286,7 +2286,7 @@ void hush_cbopretupdate(int32_t forceflag) if ( get_stockprices(now,pricebuf,ASSETCHAINS_STOCKS) == ASSETCHAINS_STOCKS.size() ) { if ( flags == 0 ) - komodo_PriceCache_shift(); + hush_PriceCache_shift(); memcpy(&PriceCache[0][size/sizeof(uint32_t)],pricebuf,ASSETCHAINS_STOCKS.size() * sizeof(uint32_t)); flags |= 8; // very rarely we can see flags == 10 case } @@ -2322,7 +2322,7 @@ void hush_cbopretupdate(int32_t forceflag) pending = 0; } -int64_t komodo_pricemult(int32_t ind) +int64_t hush_pricemult(int32_t ind) { int32_t i,j; if ( (ASSETCHAINS_CBOPRET & 1) != 0 && ind < HUSH_MAXPRICES ) @@ -2352,7 +2352,7 @@ int64_t komodo_pricemult(int32_t ind) return(0); } -char *komodo_pricename(char *name,int32_t ind) +char *hush_pricename(char *name,int32_t ind) { strcpy(name,"error"); if ( (ASSETCHAINS_CBOPRET & 1) != 0 && ind < HUSH_MAXPRICES ) @@ -2416,24 +2416,24 @@ char *komodo_pricename(char *name,int32_t ind) return(0); } // finds index for its symbol name -int32_t komodo_priceind(const char *symbol) +int32_t hush_priceind(const char *symbol) { char name[65]; int32_t i,n = (int32_t)(hush_cbopretsize(ASSETCHAINS_CBOPRET) / sizeof(uint32_t)); for (i=1; i= HUSH_MAXPRICES ) return(-1); - mult = komodo_pricemult(ind); + mult = hush_pricemult(ind); if ( nonzprices != 0 ) memset(nonzprices,0,sizeof(*nonzprices)*PRICES_DAYWINDOW); //for (i=0; i 0 ) + if ( (correlated= hush_pricecorrelated(rngval,ind,&ptr32[offset],-numprices,0,PRICES_SMOOTHWIDTH)) > 0 ) { fseek(PRICES[ind].fp,height * sizeof(int64_t) * PRICES_MAXDATAPOINTS,SEEK_SET); memset(buf,0,sizeof(buf)); @@ -2784,7 +2784,7 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) fseek(PRICES[ind].fp,(height-PRICES_DAYWINDOW+1) * PRICES_MAXDATAPOINTS * sizeof(int64_t),SEEK_SET); if ( fread(ptr64,sizeof(int64_t),PRICES_DAYWINDOW*PRICES_MAXDATAPOINTS,PRICES[ind].fp) == PRICES_DAYWINDOW*PRICES_MAXDATAPOINTS ) { - if ( (smoothed= komodo_priceave(tmpbuf,&ptr64[(PRICES_DAYWINDOW-1)*PRICES_MAXDATAPOINTS+1],-PRICES_MAXDATAPOINTS)) > 0 ) + if ( (smoothed= hush_priceave(tmpbuf,&ptr64[(PRICES_DAYWINDOW-1)*PRICES_MAXDATAPOINTS+1],-PRICES_MAXDATAPOINTS)) > 0 ) { fseek(PRICES[ind].fp,(height * PRICES_MAXDATAPOINTS + 2) * sizeof(int64_t),SEEK_SET); if ( fwrite(&smoothed,1,sizeof(smoothed),PRICES[ind].fp) != sizeof(smoothed) ) @@ -2793,7 +2793,7 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) } else fprintf(stderr,"error price_smoothed ht.%d ind.%d\n",height,ind); } else fprintf(stderr,"error fread ptr64 for ht.%d ind.%d\n",height,ind); } - } else fprintf(stderr,"error komodo_pricecorrelated for ht.%d ind.%d\n",height,ind); + } else fprintf(stderr,"error hush_pricecorrelated for ht.%d ind.%d\n",height,ind); } fprintf(stderr,"height.%d\n",height); } else fprintf(stderr,"error reading rawprices for ht.%d\n",height); @@ -2803,7 +2803,7 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) } else fprintf(stderr,"numprices mismatch, height.%d\n",height); } -int32_t komodo_priceget(int64_t *buf64,int32_t ind,int32_t height,int32_t numblocks) +int32_t hush_priceget(int64_t *buf64,int32_t ind,int32_t height,int32_t numblocks) { FILE *fp; int32_t retval = PRICES_MAXDATAPOINTS; pthread_mutex_lock(&pricemutex); diff --git a/src/hush_globals.h b/src/hush_globals.h index 605d78021..ebb074d03 100644 --- a/src/hush_globals.h +++ b/src/hush_globals.h @@ -26,11 +26,11 @@ int32_t hush_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *not char *hush_issuemethod(char *userpass,char *method,char *params,uint16_t port); void hush_init(int32_t height); int32_t hush_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp); -int32_t hush_isrealtime(int32_t *kmdheightp); -uint64_t komodo_paxtotal(); +int32_t hush_isrealtime(int32_t *hushheightp); +uint64_t hush_paxtotal(); int32_t hush_longestchain(); -uint64_t komodo_maxallowed(int32_t baseid); -int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max); +uint64_t hush_maxallowed(int32_t baseid); +int32_t hush_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max); int32_t hush_checkvout(int32_t vout,int32_t k,int32_t indallvouts); pthread_mutex_t hush_mutex; diff --git a/src/hush_nSPV_fullnode.h b/src/hush_nSPV_fullnode.h index a33013b6a..be4fbce15 100644 --- a/src/hush_nSPV_fullnode.h +++ b/src/hush_nSPV_fullnode.h @@ -863,7 +863,7 @@ int32_t NSPV_getspentinfo(struct NSPV_spentinfo *ptr,uint256 txid,int32_t vout) return(len); } -void komodo_nSPVreq(CNode *pfrom,std::vector request) // received a request +void hush_nSPVreq(CNode *pfrom,std::vector request) // received a request { int32_t len,slen,ind,reqheight,n; std::vector response; uint32_t timestamp = (uint32_t)time(NULL); if ( (len= request.size()) > 0 ) diff --git a/src/hush_nSPV_superlite.h b/src/hush_nSPV_superlite.h index aaa0c1724..585f905f0 100644 --- a/src/hush_nSPV_superlite.h +++ b/src/hush_nSPV_superlite.h @@ -128,9 +128,9 @@ struct NSPV_ntzsproofresp *NSPV_ntzsproof_add(struct NSPV_ntzsproofresp *ptr) return(&NSPV_ntzsproofresp_cache[i]); } -// komodo_nSPVresp is called from async message processing +// hush_nSPVresp is called from async message processing -void komodo_nSPVresp(CNode *pfrom,std::vector response) // received a response +void hush_nSPVresp(CNode *pfrom,std::vector response) // received a response { struct NSPV_inforesp I; int32_t len; uint32_t timestamp = (uint32_t)time(NULL); strncpy(NSPV_lastpeer,pfrom->addr.ToString().c_str(),sizeof(NSPV_lastpeer)-1); @@ -274,9 +274,9 @@ UniValue NSPV_logout() return(result); } -// komodo_nSPV from main polling loop (really this belongs in its own file, but it is so small, it ended up here) +// hush_nSPV from main polling loop (really this belongs in its own file, but it is so small, it ended up here) -void komodo_nSPV(CNode *pto) // polling loop from SendMessages +void hush_nSPV(CNode *pto) // polling loop from SendMessages { uint8_t msg[256]; int32_t i,len=0; uint32_t timestamp = (uint32_t)time(NULL); if ( NSPV_logintime != 0 && timestamp > NSPV_logintime+NSPV_AUTOLOGOUT ) diff --git a/src/hush_notary.h b/src/hush_notary.h index a8f792f8f..d9aa60860 100644 --- a/src/hush_notary.h +++ b/src/hush_notary.h @@ -246,7 +246,7 @@ int32_t hush_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,ui //struct hush_state *hush_stateptr(char *symbol,char *dest); -struct notarized_checkpoint *komodo_npptr_for_height(int32_t height, int *idx) +struct notarized_checkpoint *hush_npptr_for_height(int32_t height, int *idx) { char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; int32_t i; struct hush_state *sp; struct notarized_checkpoint *np = 0; if ( (sp= hush_stateptr(symbol,dest)) != 0 ) @@ -263,13 +263,13 @@ struct notarized_checkpoint *komodo_npptr_for_height(int32_t height, int *idx) return(0); } -struct notarized_checkpoint *komodo_npptr(int32_t height) +struct notarized_checkpoint *hush_npptr(int32_t height) { int idx; - return komodo_npptr_for_height(height, &idx); + return hush_npptr_for_height(height, &idx); } -struct notarized_checkpoint *komodo_npptr_at(int idx) +struct notarized_checkpoint *hush_npptr_at(int idx) { char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct hush_state *sp; if ( (sp= hush_stateptr(symbol,dest)) != 0 ) @@ -278,7 +278,7 @@ struct notarized_checkpoint *komodo_npptr_at(int idx) return(0); } -int32_t komodo_prevMoMheight() +int32_t hush_prevMoMheight() { static uint256 zero; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; int32_t i; struct hush_state *sp; struct notarized_checkpoint *np = 0; @@ -314,7 +314,7 @@ int32_t hush_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *tx { *hashp = sp->NOTARIZED_HASH; *txidp = sp->NOTARIZED_DESTTXID; - *prevMoMheightp = komodo_prevMoMheight(); + *prevMoMheightp = hush_prevMoMheight(); } return(sp->NOTARIZED_HEIGHT); } else return(0); @@ -342,7 +342,7 @@ int32_t hush_dpowconfs(int32_t txheight,int32_t numconfs) int32_t hush_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *hushtxidp,int32_t height,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip) { struct notarized_checkpoint *np = 0; - if ( (np= komodo_npptr(height)) != 0 ) + if ( (np= hush_npptr(height)) != 0 ) { *notarized_htp = np->notarized_height; *MoMp = np->MoM; diff --git a/src/hush_pax.h b/src/hush_pax.h index 242e4d0fe..fe2f946ad 100644 --- a/src/hush_pax.h +++ b/src/hush_pax.h @@ -133,7 +133,7 @@ uint64_t peggy_smooth_coeffs[sizeof(Peggy_inds)/sizeof(*Peggy_inds)] = // numpri 1, 1, 1, 1, 1, 1, 0, 0, // isum 100000000000 }; -uint64_t komodo_maxallowed(int32_t baseid) +uint64_t hush_maxallowed(int32_t baseid) { uint64_t mult,val = COIN * (uint64_t)10000; if ( baseid < 0 || baseid >= 32 ) @@ -144,7 +144,7 @@ uint64_t komodo_maxallowed(int32_t baseid) return(mult * val); } -uint64_t komodo_paxvol(uint64_t volume,uint64_t price) +uint64_t hush_paxvol(uint64_t volume,uint64_t price) { if ( volume < 10000000000 ) return((volume * price) / 1000000000); @@ -170,7 +170,7 @@ void pax_rank(uint64_t *ranked,uint32_t *pvals) int32_t i; uint64_t vals[32],sum = 0; for (i=0; i<32; i++) { - vals[i] = komodo_paxvol(M1SUPPLY[i] / MINDENOMS[i],pvals[i]); + vals[i] = hush_paxvol(M1SUPPLY[i] / MINDENOMS[i],pvals[i]); sum += vals[i]; } for (i=0; i<32; i++) @@ -228,11 +228,11 @@ double PAX_val(uint32_t pval,int32_t baseid) return(0.); } -void komodo_pvals(int32_t height,uint32_t *pvals,uint8_t numpvals) +void hush_pvals(int32_t height,uint32_t *pvals,uint8_t numpvals) { } -uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed) +uint64_t hush_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed) { int32_t i,j,k,ind,zeroes,wt,nonz; int64_t delta; uint64_t lastprice,tolerance,den,densum,sum=0; for (sum=i=zeroes=nonz=0; i= 0x4c ) @@ -2292,7 +2292,7 @@ void hush_args(char *argv0) extralen += symbol.size(); } } - //komodo_pricesinit(); + //hush_pricesinit(); hush_cbopretupdate(1); // will set Mineropret fprintf(stderr,"This blockchain uses data produced from CoinDesk Bitcoin Price Index\n"); } @@ -2325,7 +2325,7 @@ void hush_args(char *argv0) if ( (baseid = hush_baseid(SMART_CHAIN_SYMBOL)) >= 0 && baseid < 32 ) { - //komodo_maxallowed(baseid); + //hush_maxallowed(baseid); if(fDebug) printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,SMART_CHAIN_SYMBOL,(double)MAX_MONEY/SATOSHIDEN); } @@ -2381,7 +2381,7 @@ void hush_args(char *argv0) if ( ASSETCHAINS_RPCPORT == 0 ) ASSETCHAINS_RPCPORT = ASSETCHAINS_P2PPORT + 1; //ASSETCHAINS_NOTARIES = GetArg("-ac_notaries",""); - //komodo_assetchain_pubkeys((char *)ASSETCHAINS_NOTARIES.c_str()); + //hush_assetchain_pubkeys((char *)ASSETCHAINS_NOTARIES.c_str()); dragon_rwnum(1,magic,sizeof(ASSETCHAINS_MAGIC),(void *)&ASSETCHAINS_MAGIC); for (i=0; i<4; i++) sprintf(&magicstr[i<<1],"%02x",magic[i]); diff --git a/src/main.cpp b/src/main.cpp index eabed2626..537016343 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -82,7 +82,7 @@ int32_t hush_block2pubkey33(uint8_t *pubkey33,CBlock *block); bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); void hush_setactivation(int32_t height); void hush_changeblocktime(); -void komodo_pricesupdate(int32_t height,CBlock *pblock); +void hush_pricesupdate(int32_t height,CBlock *pblock); BlockMap mapBlockIndex; CChain chainActive; CBlockIndex *pindexBestHeader = NULL; @@ -1423,7 +1423,7 @@ bool CheckTransaction(uint32_t tiptime,const CTransaction& tx, CValidationState { static uint256 array[64]; static int32_t numbanned,indallvouts; int32_t j,k,n; if ( *(int32_t *)&array[0] == 0 ) - numbanned = komodo_bannedset(&indallvouts,array,(int32_t)(sizeof(array)/sizeof(*array))); + numbanned = hush_bannedset(&indallvouts,array,(int32_t)(sizeof(array)/sizeof(*array))); n = tx.vin.size(); if ( SMART_CHAIN_SYMBOL[0] == 0 ) { @@ -4041,7 +4041,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * { //fprintf(stderr,"%s: HUSH_NSPV_FULLNODE\n", __FUNCTION__); if ( ASSETCHAINS_CBOPRET != 0 ) - komodo_pricesupdate(pindexNew->GetHeight(),pblock); + hush_pricesupdate(pindexNew->GetHeight(),pblock); if ( ASSETCHAINS_SAPLING <= 0 && pindexNew->nTime > HUSH_SAPING_ACTIVATION - 24*3600 ) hush_activate_sapling(pindexNew); if ( ASSETCHAINS_CC != 0 && HUSH_SNAPSHOT_INTERVAL != 0 && (pindexNew->GetHeight() % HUSH_SNAPSHOT_INTERVAL) == 0 && pindexNew->GetHeight() >= HUSH_SNAPSHOT_INTERVAL ) @@ -4472,7 +4472,7 @@ CBlockIndex* AddToBlockIndex(const CBlockHeader& block) if (it != mapBlockIndex.end()) { - if ( it->second != 0 ) // vNodes.size() >= HUSH_LIMITED_NETWORKSIZE, change behavior to allow komodo_ensure to work + if ( it->second != 0 ) // vNodes.size() >= HUSH_LIMITED_NETWORKSIZE { // 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); @@ -4480,7 +4480,7 @@ CBlockIndex* AddToBlockIndex(const CBlockHeader& block) } if ( miPrev != mapBlockIndex.end() && (*miPrev).second == 0 ) { - //fprintf(stderr,"edge case of both block and prevblock in the strange state\n"); + fprintf(stderr,"%s: edge case of both block and prevblock in the strange state\n", __func__); return(0); // return here to avoid the state of pindex->GetHeight() not set and pprev NULL } } @@ -7075,7 +7075,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } std::vector payload; vRecv >> payload; - komodo_netevent(payload); + hush_netevent(payload); return(true); } else if (strCommand == "verack") { pfrom->SetRecvVersion(min(pfrom->nVersion, PROTOCOL_VERSION)); @@ -7275,7 +7275,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, { std::vector payload; vRecv >> payload; - komodo_nSPVreq(pfrom,payload); + hush_nSPVreq(pfrom,payload); } return(true); } else if (strCommand == "nSPV") { @@ -7283,7 +7283,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, { std::vector payload; vRecv >> payload; - komodo_nSPVresp(pfrom,payload); + hush_nSPVresp(pfrom,payload); } return(true); } @@ -8010,7 +8010,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) } if ( HUSH_NSPV_SUPERLITE ) { - komodo_nSPV(pto); + hush_nSPV(pto); return(true); } BOOST_FOREACH(const CBlockReject& reject, state.rejects) diff --git a/src/miner.cpp b/src/miner.cpp index 2f4b7495e..02d52abcd 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -147,8 +147,8 @@ int32_t hush_is_notarytx(const CTransaction& tx); uint64_t hush_notarypay(CMutableTransaction &txNew, std::vector &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 hush_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *script, int32_t len); -CScript komodo_mineropret(int32_t nHeight); -bool komodo_appendACscriptpub(); +CScript hush_mineropret(int32_t nHeight); +bool hush_appendACscriptpub(); CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) { @@ -167,7 +167,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 } } else pk = _pk; - uint64_t deposits,voutsum=0; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params(); + uint64_t deposits,voutsum=0; int32_t isrealtime,hushheight; uint32_t blocktime; const CChainParams& chainparams = Params(); bool fNotarizationBlock = false; std::vector NotarizationNotaries; //fprintf(stderr,"create new block\n"); @@ -612,7 +612,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { static bool didinit = false; - if ( !didinit && nHeight > HUSH_EARLYTXID_HEIGHT && HUSH_EARLYTXID != zeroid && komodo_appendACscriptpub() ) + if ( !didinit && nHeight > HUSH_EARLYTXID_HEIGHT && HUSH_EARLYTXID != zeroid && hush_appendACscriptpub() ) { fprintf(stderr, "appended ccopreturn to ASSETCHAINS_SCRIPTPUB.%s\n", ASSETCHAINS_SCRIPTPUB.c_str()); didinit = true; @@ -667,7 +667,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 int32_t numv = (int32_t)txNew.vout.size(); txNew.vout.resize(numv+1); txNew.vout[numv].nValue = 0; - txNew.vout[numv].scriptPubKey = komodo_mineropret(nHeight); + txNew.vout[numv].scriptPubKey = hush_mineropret(nHeight); //printf("autocreate commision/cbopret.%lld vout[%d]\n",(long long)ASSETCHAINS_CBOPRET,(int32_t)txNew.vout.size()); } pblock->vtx[0] = txNew; @@ -879,7 +879,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, return CreateNewBlock(pubkey, scriptPubKey, gpucount, isStake); } -void komodo_sendmessage(int32_t minpeers,int32_t maxpeers,const char *message,std::vector payload) +void hush_sendmessage(int32_t minpeers,int32_t maxpeers,const char *message,std::vector payload) { int32_t numsent = 0; LOCK(cs_vNodes); @@ -956,7 +956,7 @@ static bool ProcessBlockFound(CBlock* pblock) int32_t hush_baseid(char *origbase); int32_t hush_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); +arith_uint256 hush_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc); int32_t FOUND_BLOCK,HUSH_MAYBEMINED; extern int32_t HUSH_LASTMINED,HUSH_INSYNC; int32_t roundrobin_delay; @@ -1237,7 +1237,7 @@ void static BitcoinMiner() } else Mining_start = 0; //else if ( ASSETCHAINS_ADAPTIVEPOW > 0 ) - // HASHTarget_POW = komodo_adaptivepow_target(Mining_height,HASHTarget,pblock->nTime); + // HASHTarget_POW = hush_adaptivepow_target(Mining_height,HASHTarget,pblock->nTime); gotinvalid = 0; while (true) { @@ -1462,7 +1462,7 @@ void static BitcoinMiner() HASHTarget.SetCompact(pblock->nBits); hashTarget = HASHTarget; savebits = pblock->nBits; - //hashTarget = HASHTarget_POW = komodo_adaptivepow_target(Mining_height,HASHTarget,pblock->nTime); + //hashTarget = HASHTarget_POW = hush_adaptivepow_target(Mining_height,HASHTarget,pblock->nTime); } /*if ( NOTARY_PUBKEY33[0] == 0 ) { @@ -1472,7 +1472,7 @@ void static BitcoinMiner() { // Changing pblock->nTime can change work required on testnet: HASHTarget.SetCompact(pblock->nBits); - HASHTarget_POW = komodo_PoWtarget(&percPoS,HASHTarget,Mining_height,ASSETCHAINS_STAKED); + HASHTarget_POW = hush_PoWtarget(&percPoS,HASHTarget,Mining_height,ASSETCHAINS_STAKED); } }*/ } diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index bf38cc5e2..6bd65e40f 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1027,7 +1027,7 @@ UniValue notaries(const UniValue& params, bool fHelp, const CPubKey& mypk) return ret; } -int32_t komodo_pending_withdraws(char *opretstr); +int32_t hush_pending_withdraws(char *opretstr); int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base); extern char CURRENCIES[][8]; @@ -1037,7 +1037,7 @@ UniValue paxpending(const UniValue& params, bool fHelp, const CPubKey& mypk) if ( fHelp || params.size() != 0 ) throw runtime_error("paxpending needs no args\n"); LOCK(cs_main); - if ( (opretlen= komodo_pending_withdraws(opretbuf)) > 0 ) + if ( (opretlen= hush_pending_withdraws(opretbuf)) > 0 ) ret.push_back(Pair("withdraws", opretbuf)); else ret.push_back(Pair("withdraws", (char *)"")); for (baseid=0; baseid<32; baseid++) @@ -1076,7 +1076,7 @@ UniValue paxprice(const UniValue& params, bool fHelp, const CPubKey& mypk) else height = atoi(params[2].get_str().c_str()); //if ( params.size() == 3 || (basevolume= COIN * atof(params[3].get_str().c_str())) == 0 ) basevolume = 100000; - relvolume = komodo_paxprice(&seed,height,(char *)base.c_str(),(char *)rel.c_str(),basevolume); + relvolume = hush_paxprice(&seed,height,(char *)base.c_str(),(char *)rel.c_str(),basevolume); ret.push_back(Pair("base", base)); ret.push_back(Pair("rel", rel)); ret.push_back(Pair("height", height)); diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index 375bbfbd5..7de8a5d7a 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -57,8 +57,8 @@ bool EnsureWalletIsAvailable(bool avoidException); int32_t hush_MoM(int32_t *notarized_htp,uint256 *MoMp,uint256 *hushtxidp,int32_t nHeight,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip); -int32_t hush_MoMoMdata(char *hexstr,int32_t hexsize,struct hush_ccdataMoMoM *mdata,char *symbol,int32_t kmdheight,int32_t notarized_height); -struct hush_ccdata_entry *komodo_allMoMs(int32_t *nump,uint256 *MoMoMp,int32_t kmdstarti,int32_t kmdendi); +int32_t hush_MoMoMdata(char *hexstr,int32_t hexsize,struct hush_ccdataMoMoM *mdata,char *symbol,int32_t hushheight,int32_t notarized_height); +struct hush_ccdata_entry *hush_allMoMs(int32_t *nump,uint256 *MoMoMp,int32_t kmdstarti,int32_t kmdendi); uint256 hush_calcMoM(int32_t height,int32_t MoMdepth); int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); extern std::string ASSETCHAINS_SELFIMPORT; diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index d179bd590..ab6a75e96 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -52,7 +52,7 @@ using namespace std; extern int32_t ASSETCHAINS_FOUNDERS; uint64_t the_commission(const CBlock *pblock,int32_t height); int32_t hush_blockload(CBlock& block,CBlockIndex *pindex); -arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc); +arith_uint256 hush_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc); /** * Return average network hashes per second based on the last 'lookup' blocks, diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f7cc48433..c2a8484e0 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -614,7 +614,7 @@ int32_t hush_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_t extern int32_t HUSH_PAX; int32_t hush_is_issuer(); int32_t dragon_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp); -int32_t hush_isrealtime(int32_t *kmdheightp); +int32_t hush_isrealtime(int32_t *hushheightp); int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base); int32_t hush_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[DRAGON_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen); int32_t hush_kvcmp(uint8_t *refvalue,uint16_t refvaluesize,uint8_t *value,uint16_t valuesize); @@ -768,7 +768,7 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk) UniValue paxdeposit(const UniValue& params, bool fHelp, const CPubKey& mypk) { - uint64_t available,deposited,issued,withdrawn,approved,redeemed,seed,komodoshis = 0; int32_t height; char destaddr[64]; uint8_t i,pubkey37[33]; + uint64_t available,deposited,issued,withdrawn,approved,redeemed,seed,puposhis = 0; int32_t height; char destaddr[64]; uint8_t i,pubkey37[33]; bool fSubtractFeeFromAmount = false; if ( HUSH_PAX == 0 ) { @@ -793,28 +793,28 @@ UniValue paxdeposit(const UniValue& params, bool fHelp, const CPubKey& mypk) fprintf(stderr,"available %llu vs fiatoshis %llu\n",(long long)available,(long long)fiatoshis); throw runtime_error("paxdeposit not enough available inventory"); } - komodoshis = PAX_fiatdest(&seed,0,destaddr,pubkey37,(char *)params[0].get_str().c_str(),height,(char *)base.c_str(),fiatoshis); + puposhis = PAX_fiatdest(&seed,0,destaddr,pubkey37,(char *)params[0].get_str().c_str(),height,(char *)base.c_str(),fiatoshis); dest.append(destaddr); CBitcoinAddress destaddress(CRYPTO555_HUSHADDR); if (!destaddress.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid dest Bitcoin address"); for (i=0; i<33; i++) fprintf(stderr,"%02x",pubkey37[i]); - fprintf(stderr," ht.%d srcaddr.(%s) %s fiatoshis.%lld -> dest.(%s) komodoshis.%llu seed.%llx\n",height,(char *)params[0].get_str().c_str(),(char *)base.c_str(),(long long)fiatoshis,destaddr,(long long)komodoshis,(long long)seed); + fprintf(stderr," ht.%d srcaddr.(%s) %s fiatoshis.%lld -> dest.(%s) puposhis.%llu seed.%llx\n",height,(char *)params[0].get_str().c_str(),(char *)base.c_str(),(long long)fiatoshis,destaddr,(long long)puposhis,(long long)seed); EnsureWalletIsUnlocked(); CWalletTx wtx; - uint8_t opretbuf[64]; int32_t opretlen; uint64_t fee = komodoshis / 1000; + uint8_t opretbuf[64]; int32_t opretlen; uint64_t fee = puposhis / 1000; if ( fee < 10000 ) fee = 10000; dragon_rwnum(1,&pubkey37[33],sizeof(height),&height); opretlen = hush_opreturnscript(opretbuf,'D',pubkey37,37); - SendMoney(address.Get(),fee,fSubtractFeeFromAmount,wtx,opretbuf,opretlen,komodoshis); + SendMoney(address.Get(),fee,fSubtractFeeFromAmount,wtx,opretbuf,opretlen,puposhis); return wtx.GetHash().GetHex(); } UniValue paxwithdraw(const UniValue& params, bool fHelp, const CPubKey& mypk) { - CWalletTx wtx; std::string dest; int32_t kmdheight; uint64_t seed,komodoshis = 0; char destaddr[64]; uint8_t i,pubkey37[37]; bool fSubtractFeeFromAmount = false; + CWalletTx wtx; std::string dest; int32_t hushheight; uint64_t seed,puposhis = 0; char destaddr[64]; uint8_t i,pubkey37[37]; bool fSubtractFeeFromAmount = false; if ( SMART_CHAIN_SYMBOL[0] == 0 ) return(0); if (!EnsureWalletIsAvailable(fHelp)) @@ -822,26 +822,26 @@ UniValue paxwithdraw(const UniValue& params, bool fHelp, const CPubKey& mypk) throw runtime_error("paxwithdraw deprecated"); if (fHelp || params.size() != 2) throw runtime_error("paxwithdraw address fiatamount"); - if ( hush_isrealtime(&kmdheight) == 0 ) + if ( hush_isrealtime(&hushheight) == 0 ) return(0); LOCK2(cs_main, pwalletMain->cs_wallet); CBitcoinAddress address(params[0].get_str()); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); int64_t fiatoshis = atof(params[1].get_str().c_str()) * COIN; - komodoshis = PAX_fiatdest(&seed,1,destaddr,pubkey37,(char *)params[0].get_str().c_str(),kmdheight,SMART_CHAIN_SYMBOL,fiatoshis); + puposhis = PAX_fiatdest(&seed,1,destaddr,pubkey37,(char *)params[0].get_str().c_str(),hushheight,SMART_CHAIN_SYMBOL,fiatoshis); dest.append(destaddr); CBitcoinAddress destaddress(CRYPTO555_HUSHADDR); if (!destaddress.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid dest Bitcoin address"); for (i=0; i<33; i++) printf("%02x",pubkey37[i]); - printf(" kmdheight.%d srcaddr.(%s) %s fiatoshis.%lld -> dest.(%s) komodoshis.%llu seed.%llx\n",kmdheight,(char *)params[0].get_str().c_str(),SMART_CHAIN_SYMBOL,(long long)fiatoshis,destaddr,(long long)komodoshis,(long long)seed); + printf(" hushheight.%d srcaddr.(%s) %s fiatoshis.%lld -> dest.(%s) puposhis.%llu seed.%llx\n",hushheight,(char *)params[0].get_str().c_str(),SMART_CHAIN_SYMBOL,(long long)fiatoshis,destaddr,(long long)puposhis,(long long)seed); EnsureWalletIsUnlocked(); uint8_t opretbuf[64]; int32_t opretlen; uint64_t fee = fiatoshis / 1000; if ( fee < 10000 ) fee = 10000; - dragon_rwnum(1,&pubkey37[33],sizeof(kmdheight),&kmdheight); + dragon_rwnum(1,&pubkey37[33],sizeof(hushheight),&hushheight); opretlen = hush_opreturnscript(opretbuf,'W',pubkey37,37); SendMoney(destaddress.Get(),fee,fSubtractFeeFromAmount,wtx,opretbuf,opretlen,fiatoshis); return wtx.GetHash().GetHex();