Browse Source

Clean up dead code and cruft

pull/70/head
Duke Leto 3 years ago
parent
commit
b713f43487
  1. 2
      src/crypto/equihash.h
  2. 76
      src/hush.h
  3. 7
      src/hush_bitcoind.h
  4. 2
      src/hush_ccdata.h
  5. 2
      src/hush_events.h
  6. 2
      src/hush_gateway.h
  7. 2
      src/hush_pax.h
  8. 2
      src/hush_utils.h
  9. 8
      src/wallet/rpcwallet.cpp

2
src/crypto/equihash.h

@ -204,7 +204,7 @@ public:
#include "equihash.tcc"
/*
* Equihash 200,9 (KMD/Zcash)
* Equihash 200,9 (HUSH/ZEC and other ASIC coins)
* Equihash 150,5 (beam)
* Equihash 144,5 (SnowGem)
* Equihash 96,5 (Minex)

76
src/hush.h

@ -82,9 +82,7 @@ int32_t hush_parsestatefile(struct hush_state *sp,FILE *fp,char *symbol,char *de
int32_t func,ht,notarized_height,num,matched=0,MoMdepth; uint256 MoM,notarized_hash,notarized_desttxid; uint8_t pubkeys[64][33];
if ( (func= fgetc(fp)) != EOF )
{
if ( SMART_CHAIN_SYMBOL[0] == 0 && strcmp(symbol,"KMD") == 0 )
matched = 1;
else matched = (strcmp(symbol,SMART_CHAIN_SYMBOL) == 0);
matched = (strcmp(symbol,SMART_CHAIN_SYMBOL) == 0);
if ( fread(&ht,1,sizeof(ht),fp) != sizeof(ht) )
errs++;
if ( 0 && SMART_CHAIN_SYMBOL[0] != 0 && func != 'T' )
@ -98,7 +96,7 @@ int32_t hush_parsestatefile(struct hush_state *sp,FILE *fp,char *symbol,char *de
else
{
//printf("updated %d pubkeys at %s ht.%d\n",num,symbol,ht);
if ( (HUSH_EXTERNAL_NOTARIES != 0 && matched != 0) || (strcmp(symbol,"KMD") == 0 && HUSH_EXTERNAL_NOTARIES == 0) )
if ( (HUSH_EXTERNAL_NOTARIES != 0 && matched != 0) )
hush_eventadd_pubkeys(sp,symbol,ht,num,pubkeys);
}
} else printf("illegal num.%d\n",num);
@ -228,10 +226,9 @@ int32_t hush_parsestatefiledata(struct hush_state *sp,uint8_t *filedata,long *fp
int32_t func= -1,ht,notarized_height,MoMdepth,num,matched=0; uint256 MoM,notarized_hash,notarized_desttxid; uint8_t pubkeys[64][33]; long fpos = *fposp;
if ( fpos < datalen )
{
func = filedata[fpos++];
if ( SMART_CHAIN_SYMBOL[0] == 0 && strcmp(symbol,"KMD") == 0 )
matched = 1;
else matched = (strcmp(symbol,SMART_CHAIN_SYMBOL) == 0);
func = filedata[fpos++];
matched = (strcmp(symbol,SMART_CHAIN_SYMBOL) == 0);
if ( memread(&ht,sizeof(ht),filedata,&fpos,datalen) != sizeof(ht) )
errs++;
if ( func == 'P' )
@ -243,7 +240,7 @@ int32_t hush_parsestatefiledata(struct hush_state *sp,uint8_t *filedata,long *fp
else
{
//printf("updated %d pubkeys at %s ht.%d\n",num,symbol,ht);
if ( (HUSH_EXTERNAL_NOTARIES != 0 && matched != 0) || (strcmp(symbol,"KMD") == 0 && HUSH_EXTERNAL_NOTARIES == 0) )
if ( (HUSH_EXTERNAL_NOTARIES != 0 && matched != 0) )
hush_eventadd_pubkeys(sp,symbol,ht,num,pubkeys);
}
} else printf("illegal num.%d\n",num);
@ -353,7 +350,7 @@ int32_t hush_parsestatefiledata(struct hush_state *sp,uint8_t *filedata,long *fp
return(-1);
}
void hush_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth)
void hush_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t HUSHheight,uint32_t HUSHtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth)
{
static FILE *fp; static int32_t errs,didinit; static uint256 zero;
struct hush_state *sp; char fname[512],symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; int32_t retval,ht,func; uint8_t num,pubkeys[64][33];
@ -394,30 +391,26 @@ void hush_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotarie
if ( fp != 0 ) // write out funcid, height, other fields, call side effect function
{
//printf("fpos.%ld ",ftell(fp));
if ( KMDheight != 0 )
if ( HUSHheight != 0 )
{
if ( KMDtimestamp != 0 )
if ( HUSHtimestamp != 0 )
{
fputc('T',fp);
if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) )
errs++;
if ( fwrite(&KMDheight,1,sizeof(KMDheight),fp) != sizeof(KMDheight) )
if ( fwrite(&HUSHheight,1,sizeof(HUSHheight),fp) != sizeof(HUSHheight) )
errs++;
if ( fwrite(&KMDtimestamp,1,sizeof(KMDtimestamp),fp) != sizeof(KMDtimestamp) )
if ( fwrite(&HUSHtimestamp,1,sizeof(HUSHtimestamp),fp) != sizeof(HUSHtimestamp) )
errs++;
}
else
{
} else {
fputc('K',fp);
if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) )
errs++;
if ( fwrite(&KMDheight,1,sizeof(KMDheight),fp) != sizeof(KMDheight) )
if ( fwrite(&HUSHheight,1,sizeof(HUSHheight),fp) != sizeof(HUSHheight) )
errs++;
}
hush_eventadd_kmdheight(sp,symbol,height,KMDheight,KMDtimestamp);
}
else if ( opretbuf != 0 && opretlen > 0 )
{
hush_eventadd_kmdheight(sp,symbol,height,HUSHheight,HUSHtimestamp);
} else if ( opretbuf != 0 && opretlen > 0 ) {
uint16_t olen = opretlen;
fputc('R',fp);
if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) )
@ -432,8 +425,7 @@ void hush_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotarie
errs++;
if ( fwrite(opretbuf,1,olen,fp) != olen )
errs++;
//printf("create ht.%d R opret[%d] sp.%p\n",height,olen,sp);
//komodo_opreturn(height,opretvalue,opretbuf,olen,txhash,vout);
//printf("create ht.%d R opret[%d] sp.%p\n",height,olen,sp);
hush_eventadd_opreturn(sp,symbol,height,txhash,opretvalue,vout,opretbuf,olen);
}
else if ( notarypubs != 0 && numnotaries > 0 )
@ -687,7 +679,7 @@ int32_t hush_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryi
}
else
{
komodo_rwccdata(SMART_CHAIN_SYMBOL,1,&ccdata,&MoMoMdata);
hush_rwccdata(SMART_CHAIN_SYMBOL,1,&ccdata,&MoMoMdata);
if ( matched != 0 )
printf("[%s] matched.%d VALID (%s) MoM.%s [%d] CCid.%u\n",SMART_CHAIN_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth&0xffff,(MoMdepth>>16)&0xffff);
}
@ -696,8 +688,6 @@ int32_t hush_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryi
memset(&ccdata,0,sizeof(ccdata));
memset(&MoMoMdata,0,sizeof(MoMoMdata));
}
else if ( SMART_CHAIN_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 )
komodo_rwccdata((char *)"KMD",1,&ccdata,0);
if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height )
{
@ -711,36 +701,12 @@ int32_t hush_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryi
}
hush_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0,sp->MoM,sp->MoMdepth);
//if ( SMART_CHAIN_SYMBOL[0] != 0 )
printf("[%s] ht.%d NOTARIZED.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",SMART_CHAIN_SYMBOL,height,sp->NOTARIZED_HEIGHT,SMART_CHAIN_SYMBOL[0]==0?"KMD":SMART_CHAIN_SYMBOL,srchash.ToString().c_str(),SMART_CHAIN_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),opretlen,len,sp->MoM.ToString().c_str(),sp->MoMdepth);
printf("[%s] ht.%d NOTARIZED.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",SMART_CHAIN_SYMBOL,height,sp->NOTARIZED_HEIGHT,SMART_CHAIN_SYMBOL,srchash.ToString().c_str(),"HUSH",desttxid.ToString().c_str(),opretlen,len,sp->MoM.ToString().c_str(),sp->MoMdepth);
if ( SMART_CHAIN_SYMBOL[0] == 0 )
{
if ( signedfp == 0 )
{
char fname[512];
hush_statefname(fname,SMART_CHAIN_SYMBOL,(char *)"hushsignedmasks");
if ( (signedfp= fopen(fname,"rb+")) == 0 )
signedfp = fopen(fname,"wb");
else fseek(signedfp,0,SEEK_END);
}
if ( signedfp != 0 )
{
fwrite(&height,1,sizeof(height),signedfp);
fwrite(&signedmask,1,sizeof(signedmask),signedfp);
fflush(signedfp);
}
if ( opretlen > len && scriptbuf[len] == 'A' )
{
//for (i=0; i<opretlen-len; i++)
// printf("%02x",scriptbuf[len+i]);
//printf(" Found extradata.[%d] %d - %d\n",opretlen-len,opretlen,len);
hush_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len+4+3+(scriptbuf[1] == 0x4d),j,zero,0);
}
}
} //else if ( fJustCheck )
// return (-3); // if the notarisation is only invalid because its out of order it cannot be mined in a block with a valid one!
} else if ( opretlen != 149 && height > 600000 && matched != 0 )
printf("%s validated.%d notarized.%d %llx reject ht.%d NOTARIZED.%d prev.%d %s.%s DESTTXID.%s len.%d opretlen.%d\n",ccdata.symbol,validated,notarized,(long long)signedmask,height,*notarizedheightp,sp->NOTARIZED_HEIGHT,SMART_CHAIN_SYMBOL[0]==0?"KMD":SMART_CHAIN_SYMBOL,srchash.ToString().c_str(),desttxid.ToString().c_str(),len,opretlen);
printf("%s validated.%d notarized.%d %llx reject ht.%d NOTARIZED.%d prev.%d %s.%s DESTTXID.%s len.%d opretlen.%d\n",ccdata.symbol,validated,notarized,(long long)signedmask,height,*notarizedheightp,sp->NOTARIZED_HEIGHT,SMART_CHAIN_SYMBOL,srchash.ToString().c_str(),desttxid.ToString().c_str(),len,opretlen);
}
else if ( matched != 0 && i == 0 && j == 1 && opretlen == 149 )
{
@ -752,7 +718,7 @@ int32_t hush_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryi
//int32_t k; for (k=0; k<scriptlen; k++)
// printf("%02x",scriptbuf[k]);
//printf(" <- script ht.%d i.%d j.%d value %.8f %s\n",height,i,j,dstr(value),SMART_CHAIN_SYMBOL);
if ( opretlen >= 32*2+4 && strcmp(SMART_CHAIN_SYMBOL[0]==0?"KMD":SMART_CHAIN_SYMBOL,(char *)&scriptbuf[len+32*2+4]) == 0 )
if ( opretlen >= 32*2+4 && strcmp(SMART_CHAIN_SYMBOL,(char *)&scriptbuf[len+32*2+4]) == 0 )
{
for (k=0; k<32; k++)
if ( scriptbuf[len+k] != 0 )
@ -985,7 +951,7 @@ int32_t hush_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block)
}
}
if ( !fJustCheck && IS_HUSH_NOTARY != 0 && SMART_CHAIN_SYMBOL[0] == 0 )
printf("%s ht.%d\n",SMART_CHAIN_SYMBOL[0] == 0 ? "KMD" : SMART_CHAIN_SYMBOL,height);
printf("%s ht.%d\n",SMART_CHAIN_SYMBOL,height);
if ( !fJustCheck && pindex->GetHeight() == hwmheight )
hush_stateupdate(height,0,0,0,zero,0,0,0,0,height,(uint32_t)pindex->nTime,0,0,0,0,zero,0);
}

7
src/hush_bitcoind.h

@ -15,7 +15,7 @@
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/
// Hush functions that interact with bitcoind C++
// Hush functions that interact with hushd C++
#include <curl/curl.h>
#include <curl/easy.h>
#include "consensus/params.h"
@ -408,6 +408,7 @@ int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *hushnotarized_hei
if ( (item= jobj(json,(char *)"result")) != 0 )
{
height = jint(item,(char *)"blocks");
//TODO: which key to use?
*hushnotarized_heightp = strcmp(dest,"KMD") == 0 ? jint(item,(char *)"notarized") : height;
}
free_json(json);
@ -570,7 +571,7 @@ CScript hush_makeopret(CBlock *pblock, bool fNew)
}
free_json(result);
}
printf("KMD hash.%d (%s) %x\n",height,jsonstr,*(uint32_t *)&hash);
printf("HUSH3 hash.%d (%s) %x\n",height,jsonstr,*(uint32_t *)&hash);
free(jsonstr);
}
return(hash);
@ -1032,7 +1033,7 @@ int32_t hush_nextheight()
int32_t komodo_isrealtime(int32_t *kmdheightp)
{
struct hush_state *sp; CBlockIndex *pindex;
if ( (sp= hush_stateptrget((char *)"KMD")) != 0 )
if ( (sp= hush_stateptrget((char *)"HUSH3")) != 0 )
*kmdheightp = sp->CURRENT_HEIGHT;
else *kmdheightp = 0;
if ( (pindex= chainActive.LastTip()) != 0 && pindex->GetHeight() >= (int32_t)hush_longestchain() )

2
src/hush_ccdata.h

@ -203,7 +203,7 @@ void komodo_purge_ccdata(int32_t height)
}
// this is just a demo of ccdata processing to create example data for the MoMoM and allMoMs calls
int32_t komodo_rwccdata(char *thischain,int32_t rwflag,struct hush_ccdata *ccdata,struct hush_ccdataMoMoM *MoMoMdata)
int32_t hush_rwccdata(char *thischain,int32_t rwflag,struct hush_ccdata *ccdata,struct hush_ccdataMoMoM *MoMoMdata)
{
uint256 hash,zero; bits256 tmp; int32_t i,nonz; struct hush_ccdata *ptr; struct notarized_checkpoint *np;
return(0); // disable this path as libscott method is much better

2
src/hush_events.h

@ -69,7 +69,7 @@ void hush_eventadd_notarized(struct hush_state *sp,char *symbol,int32_t height,c
void hush_eventadd_pubkeys(struct hush_state *sp,char *symbol,int32_t height,uint8_t num,uint8_t pubkeys[64][33])
{
struct hush_event_pubkeys P;
//printf("eventadd pubkeys ht.%d\n",height);
fprintf(stderr, "%s: eventadd pubkeys height=%d\n",__func__,height);
memset(&P,0,sizeof(P));
P.num = num;
memcpy(P.pubkeys,pubkeys,33 * num);

2
src/hush_gateway.h

@ -610,7 +610,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
for (i=0; i<len; i++)
printf("%02x",data[i]);
printf(" <- data[%d]\n",len);
opretlen = komodo_opreturnscript(opret,opcode,data,len);
opretlen = hush_opreturnscript(opret,opcode,data,len);
txNew->vout.resize(numvouts+1);
txNew->vout[numvouts].nValue = 0;
txNew->vout[numvouts].scriptPubKey.resize(opretlen);

2
src/hush_pax.h

@ -267,7 +267,7 @@ int32_t komodo_pax_opreturn(int32_t height,uint8_t *opret,int32_t maxsize)
}
if ( timestamp > time(NULL)-600 )
{
n = komodo_opreturnscript(opret,'P',data+sizeof(crc32),(int32_t)(fsize-sizeof(crc32)));
n = hush_opreturnscript(opret,'P',data+sizeof(crc32),(int32_t)(fsize-sizeof(crc32)));
if ( 0 && lastcrc != crc32 )
{
for (i=0; i<n; i++)

2
src/hush_utils.h

@ -999,7 +999,7 @@ int32_t komodo_scriptitemlen(int32_t *opretlenp,uint8_t *script)
return(len);
}
int32_t komodo_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_t opretlen)
int32_t hush_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_t opretlen)
{
int32_t offset = 0;
script[offset++] = 0x6a;

8
src/wallet/rpcwallet.cpp

@ -579,7 +579,7 @@ UniValue sendtoaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
#define HUSH_KVDURATION 1440
#define DRAGON_MAXSCRIPTSIZE 10001
uint64_t PAX_fiatdest(uint64_t *seedp,int32_t tokomodo,char *destaddr,uint8_t pubkey37[37],char *coinaddr,int32_t height,char *base,int64_t fiatoshis);
int32_t komodo_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_t opretlen);
int32_t hush_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_t opretlen);
extern int32_t HUSH_PAX;
int32_t komodo_is_issuer();
int32_t dragon_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp);
@ -718,7 +718,7 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk)
coresize += 32;
}
}
if ( (opretlen= komodo_opreturnscript(opretbuf,'K',keyvalue,coresize)) == 40 )
if ( (opretlen= hush_opreturnscript(opretbuf,'K',keyvalue,coresize)) == 40 )
opretlen++;
//for (i=0; i<opretlen; i++)
// printf("%02x",opretbuf[i]);
@ -776,7 +776,7 @@ UniValue paxdeposit(const UniValue& params, bool fHelp, const CPubKey& mypk)
if ( fee < 10000 )
fee = 10000;
dragon_rwnum(1,&pubkey37[33],sizeof(height),&height);
opretlen = komodo_opreturnscript(opretbuf,'D',pubkey37,37);
opretlen = hush_opreturnscript(opretbuf,'D',pubkey37,37);
SendMoney(address.Get(),fee,fSubtractFeeFromAmount,wtx,opretbuf,opretlen,komodoshis);
return wtx.GetHash().GetHex();
}
@ -811,7 +811,7 @@ UniValue paxwithdraw(const UniValue& params, bool fHelp, const CPubKey& mypk)
if ( fee < 10000 )
fee = 10000;
dragon_rwnum(1,&pubkey37[33],sizeof(kmdheight),&kmdheight);
opretlen = komodo_opreturnscript(opretbuf,'W',pubkey37,37);
opretlen = hush_opreturnscript(opretbuf,'W',pubkey37,37);
SendMoney(destaddress.Get(),fee,fSubtractFeeFromAmount,wtx,opretbuf,opretlen,fiatoshis);
return wtx.GetHash().GetHex();
}

Loading…
Cancel
Save