hygiene: Phase 4 — route unconditional debug output through LogPrint
Fourth phase of the code-hygiene remediation, addressing the ~1,082 stray
fprintf(stderr)/printf debug calls so consensus and hot paths stop spewing
to stderr/stdout. Done per-file (18 files) with conservative rules; the tree
builds clean, self-mines, and `verifychain` re-validates the whole chain
(pow/txdb/coins/miner paths) with -debug=1 enabling every converted line —
zero tinyformat/format-arg exceptions.
Net across 18 files: 174 commented-out debug lines deleted, 173 unconditional
live prints converted to LogPrint("<cat>",...)/LogPrintf (net/mining/pow/nspv/
zrpc categories, format strings + args preserved exactly), 40 pure-noise or
sensitive prints deleted, and 194 calls DELIBERATELY LEFT (already behind
fDebug/fZdebug guards, or genuine startup/fatal-error output that must reach
the console before logging init).
Notable:
- Deleted sensitive success-path dumps (nSPV SIG_TXHASH + full tx input/
output/change amounts; kvupdate privkey/pubkey hex) that were writing key
and amount material straight to stderr/stdout.
- Removed the raw 32-byte target hex dumps in the zawy adaptive-PoW helpers
and the legacy one-shot `if(height==340000)` HUSH artifact in pow.cpp.
- Converted per-tx relay + ban/banlist (net), per-setgenerate MININGTHREADS
(rpc/mining), signrawtransaction TXPOW, and per-message nSPV traces.
- Left format/arg-mismatched lines untouched (flagged) to avoid introducing
tinyformat runtime throws.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+52
-96
@@ -770,19 +770,15 @@ int32_t bitcoin_addr2rmd160(uint8_t *addrtypep,uint8_t rmd160[20],char *coinaddr
|
||||
memcpy(rmd160,buf+1,20);
|
||||
if ( (buf[21]&0xff) == hash.bytes[31] && (buf[22]&0xff) == hash.bytes[30] &&(buf[23]&0xff) == hash.bytes[29] && (buf[24]&0xff) == hash.bytes[28] )
|
||||
{
|
||||
//printf("coinaddr.(%s) valid checksum addrtype.%02x\n",coinaddr,*addrtypep);
|
||||
return(20);
|
||||
}
|
||||
else
|
||||
{
|
||||
int32_t i;
|
||||
if ( len > 20 )
|
||||
{
|
||||
hash = bits256_doublesha256(0,buf,len);
|
||||
}
|
||||
for (i=0; i<len; i++)
|
||||
printf("%02x ",buf[i]);
|
||||
printf("\nhex checkhash.(%s) len.%d mismatch %02x %02x %02x %02x vs %02x %02x %02x %02x\n",coinaddr,len,buf[len-1]&0xff,buf[len-2]&0xff,buf[len-3]&0xff,buf[len-4]&0xff,hash.bytes[31],hash.bytes[30],hash.bytes[29],hash.bytes[28]);
|
||||
LogPrintf("\nhex checkhash.(%s) len.%d mismatch %02x %02x %02x %02x vs %02x %02x %02x %02x\n",coinaddr,len,buf[len-1]&0xff,buf[len-2]&0xff,buf[len-3]&0xff,buf[len-4]&0xff,hash.bytes[31],hash.bytes[30],hash.bytes[29],hash.bytes[28]);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
@@ -801,10 +797,6 @@ char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,
|
||||
data[21+i] = hash.bytes[31-i];
|
||||
if ( (coinaddr= bitcoin_base58encode(coinaddr,data,25)) != 0 )
|
||||
{
|
||||
//uint8_t checktype,rmd160[20];
|
||||
//bitcoin_addr2rmd160(&checktype,rmd160,coinaddr);
|
||||
//if ( strcmp(checkaddr,coinaddr) != 0 )
|
||||
// printf("checkaddr.(%s) vs coinaddr.(%s) %02x vs [%02x] memcmp.%d\n",checkaddr,coinaddr,addrtype,checktype,memcmp(rmd160,data+1,20));
|
||||
}
|
||||
return(coinaddr);
|
||||
}
|
||||
@@ -858,7 +850,7 @@ int32_t unhex(char c)
|
||||
int32_t hex;
|
||||
if ( (hex= _unhex(c)) < 0 )
|
||||
{
|
||||
fprintf(stderr,"unhex: illegal hexchar.(%c)\n",c);
|
||||
LogPrintf("unhex: illegal hexchar.(%c)\n",c);
|
||||
}
|
||||
return(hex);
|
||||
}
|
||||
@@ -868,7 +860,6 @@ unsigned char _decode_hex(char *hex) { return((unhex(hex[0])<<4) | unhex(hex[1])
|
||||
int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex)
|
||||
{
|
||||
int32_t adjust,i = 0;
|
||||
//printf("decode.(%s)\n",hex);
|
||||
if ( is_hexstr(hex,n) <= 0 )
|
||||
{
|
||||
memset(bytes,0,n);
|
||||
@@ -881,7 +872,7 @@ int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex)
|
||||
if ( n > 0 )
|
||||
{
|
||||
bytes[0] = unhex(hex[0]);
|
||||
printf("decode_hex n.%d hex[0] (%c) -> %d hex.(%s) [n*2+1: %d] [n*2: %d %c] len.%ld\n",n,hex[0],bytes[0],hex,hex[n*2+1],hex[n*2],hex[n*2],(long)strlen(hex));
|
||||
LogPrintf("decode_hex n.%d hex[0] (%c) -> %d hex.(%s) [n*2+1: %d] [n*2: %d %c] len.%ld\n",n,hex[0],bytes[0],hex,hex[n*2+1],hex[n*2],hex[n*2],(long)strlen(hex));
|
||||
}
|
||||
bytes++;
|
||||
hex++;
|
||||
@@ -918,10 +909,8 @@ int32_t init_hexbytes_noT(char *hexbytes,unsigned char *message,long len)
|
||||
{
|
||||
hexbytes[i*2] = hexbyte((message[i]>>4) & 0xf);
|
||||
hexbytes[i*2 + 1] = hexbyte(message[i] & 0xf);
|
||||
//printf("i.%d (%02x) [%c%c]\n",i,message[i],hexbytes[i*2],hexbytes[i*2+1]);
|
||||
}
|
||||
hexbytes[len*2] = 0;
|
||||
//printf("len.%ld\n",len*2+1);
|
||||
return((int32_t)len*2+1);
|
||||
}
|
||||
|
||||
@@ -1087,7 +1076,7 @@ char *clonestr(char *str)
|
||||
char *clone;
|
||||
if ( str == 0 || str[0] == 0 )
|
||||
{
|
||||
printf("warning cloning nullstr.%p\n",str);
|
||||
LogPrintf("warning cloning nullstr.%p\n",str);
|
||||
#ifdef __APPLE__
|
||||
while ( 1 ) sleep(1);
|
||||
#endif
|
||||
@@ -1109,7 +1098,7 @@ int32_t safecopy(char *dest,char *src,long len)
|
||||
dest[i] = src[i];
|
||||
if ( i == len )
|
||||
{
|
||||
printf("safecopy: %s too long %ld\n",src,len);
|
||||
LogPrintf("safecopy: %s too long %ld\n",src,len);
|
||||
#ifdef __APPLE__
|
||||
//getchar();
|
||||
#endif
|
||||
@@ -1131,7 +1120,6 @@ char *parse_conf_line(char *line,char *field)
|
||||
line++;
|
||||
while ( line[strlen(line)-1] == '\r' || line[strlen(line)-1] == '\n' || line[strlen(line)-1] == ' ' )
|
||||
line[strlen(line)-1] = 0;
|
||||
//printf("LINE.(%s)\n",line);
|
||||
_stripwhite(line,0);
|
||||
return(clonestr(line));
|
||||
}
|
||||
@@ -1141,7 +1129,6 @@ double OS_milliseconds()
|
||||
struct timeval tv; double millis;
|
||||
gettimeofday(&tv,NULL);
|
||||
millis = ((double)tv.tv_sec * 1000. + (double)tv.tv_usec / 1000.);
|
||||
//printf("tv_sec.%ld usec.%d %f\n",tv.tv_sec,tv.tv_usec,millis);
|
||||
return(millis);
|
||||
}
|
||||
|
||||
@@ -1193,7 +1180,7 @@ void queue_enqueue(char *name,queue_t *queue,struct queueitem *item)
|
||||
strcpy(queue->name,name);
|
||||
if ( item == 0 )
|
||||
{
|
||||
printf("FATAL type error: queueing empty value\n");
|
||||
LogPrintf("FATAL type error: queueing empty value\n");
|
||||
return;
|
||||
}
|
||||
lock_queue(queue);
|
||||
@@ -1230,7 +1217,7 @@ void *queue_delete(queue_t *queue,struct queueitem *copy,int32_t copysize)
|
||||
{
|
||||
DL_DELETE(queue->list,item);
|
||||
portable_mutex_unlock(&queue->mutex);
|
||||
printf("name.(%s) deleted item.%p list.%p\n",queue->name,item,queue->list);
|
||||
LogPrintf("name.(%s) deleted item.%p list.%p\n",queue->name,item,queue->list);
|
||||
return(item);
|
||||
}
|
||||
}
|
||||
@@ -1250,7 +1237,6 @@ void *queue_free(queue_t *queue)
|
||||
DL_DELETE(queue->list,item);
|
||||
free(item);
|
||||
}
|
||||
//printf("name.(%s) dequeue.%p list.%p\n",queue->name,item,queue->list);
|
||||
}
|
||||
portable_mutex_unlock(&queue->mutex);
|
||||
return(0);
|
||||
@@ -1268,7 +1254,6 @@ void *queue_clone(queue_t *clone,queue_t *queue,int32_t size)
|
||||
memcpy(ptr,item,size);
|
||||
queue_enqueue(queue->name,clone,ptr);
|
||||
}
|
||||
//printf("name.(%s) dequeue.%p list.%p\n",queue->name,item,queue->list);
|
||||
}
|
||||
portable_mutex_unlock(&queue->mutex);
|
||||
return(0);
|
||||
@@ -1304,7 +1289,6 @@ uint16_t _hush_userpass(char *username,char *password,FILE *fp)
|
||||
{
|
||||
if ( line[0] == '#' )
|
||||
continue;
|
||||
//printf("line.(%s) %p %p\n",line,strstr(line,(char *)"rpcuser"),strstr(line,(char *)"rpcpassword"));
|
||||
if ( (str= strstr(line,(char *)"rpcuser")) != 0 )
|
||||
rpcuser = parse_conf_line(str,(char *)"rpcuser");
|
||||
else if ( (str= strstr(line,(char *)"rpcpassword")) != 0 )
|
||||
@@ -1312,7 +1296,6 @@ uint16_t _hush_userpass(char *username,char *password,FILE *fp)
|
||||
else if ( (str= strstr(line,(char *)"rpcport")) != 0 )
|
||||
{
|
||||
port = atoi(parse_conf_line(str,(char *)"rpcport"));
|
||||
//fprintf(stderr,"rpcport.%u in file\n",port);
|
||||
}
|
||||
}
|
||||
if ( rpcuser != 0 && rpcpassword != 0 )
|
||||
@@ -1320,7 +1303,6 @@ uint16_t _hush_userpass(char *username,char *password,FILE *fp)
|
||||
strcpy(username,rpcuser);
|
||||
strcpy(password,rpcpassword);
|
||||
}
|
||||
//printf("rpcuser.(%s) rpcpassword.(%s) HUSHUSERPASS.(%s) %u\n",rpcuser,rpcpassword,HUSHUSERPASS,port);
|
||||
if ( rpcuser != 0 )
|
||||
free(rpcuser);
|
||||
if ( rpcpassword != 0 )
|
||||
@@ -1340,7 +1322,7 @@ void hush_statefname(char *fname,char *symbol,char *str)
|
||||
else
|
||||
{
|
||||
if ( strcmp(symbol,"ZZZ") != 0 )
|
||||
printf("unexpected fname.(%s) vs %s [%s] n.%d len.%d (%s)\n",fname,symbol,SMART_CHAIN_SYMBOL,n,len,&fname[len - n]);
|
||||
LogPrintf("unexpected fname.(%s) vs %s [%s] n.%d len.%d (%s)\n",fname,symbol,SMART_CHAIN_SYMBOL,n,len,&fname[len - n]);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@@ -1353,7 +1335,6 @@ void hush_statefname(char *fname,char *symbol,char *str)
|
||||
if ( symbol != 0 && symbol[0] != 0)
|
||||
{
|
||||
strcat(fname,symbol);
|
||||
//printf("statefname.(%s) -> (%s)\n",symbol,fname);
|
||||
#ifdef _WIN32
|
||||
strcat(fname,"\\");
|
||||
#else
|
||||
@@ -1361,7 +1342,6 @@ void hush_statefname(char *fname,char *symbol,char *str)
|
||||
#endif
|
||||
}
|
||||
strcat(fname,str);
|
||||
//printf("test.(%s) -> [%s] statename.(%s) %s\n",test,SMART_CHAIN_SYMBOL,symbol,fname);
|
||||
}
|
||||
|
||||
void hush_configfile(char *symbol,uint16_t rpcport)
|
||||
@@ -1398,14 +1378,13 @@ void hush_configfile(char *symbol,uint16_t rpcport)
|
||||
{
|
||||
fprintf(fp,"rpcuser=user%u\nrpcpassword=pass%s\nrpcport=%u\nserver=1\ntxindex=1\nrpcworkqueue=4096\nrpcallowip=127.0.0.1\nrpcbind=127.0.0.1\n",crc,password,rpcport);
|
||||
fclose(fp);
|
||||
printf("Created (%s)\n",fname);
|
||||
} else printf("Couldnt create (%s)\n",fname);
|
||||
LogPrintf("Created (%s)\n",fname);
|
||||
} else LogPrintf("Couldnt create (%s)\n",fname);
|
||||
#endif
|
||||
} else {
|
||||
_hush_userpass(myusername,mypassword,fp);
|
||||
mapArgs["-rpcpassword"] = mypassword;
|
||||
mapArgs["-rpcusername"] = myusername;
|
||||
//fprintf(stderr,"myusername.(%s)\n",myusername);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
@@ -1429,9 +1408,8 @@ void hush_configfile(char *symbol,uint16_t rpcport)
|
||||
DRAGONX_PORT = hushport;
|
||||
sprintf(HUSHUSERPASS,"%s:%s",username,password);
|
||||
fclose(fp);
|
||||
//printf("HUSH.(%s) -> userpass.(%s)\n",fname,HUSHUSERPASS);
|
||||
} else {
|
||||
printf("could not open.(%s)\n",fname);
|
||||
LogPrintf("could not open.(%s)\n",fname);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1466,10 +1444,7 @@ uint32_t hush_smartmagic(char *symbol,uint64_t supply,uint8_t *extraptr,int32_t
|
||||
{
|
||||
vcalc_sha256(0,hash.bytes,extraptr,extralen);
|
||||
crc0 = hash.uints[0];
|
||||
fprintf(stderr,"DragonX raw magic=");
|
||||
int32_t i; for (i=0; i<extralen; i++)
|
||||
fprintf(stderr,"%02x",extraptr[i]);
|
||||
fprintf(stderr," extralen=%d crc0=%x\n",extralen,crc0);
|
||||
LogPrintf("DragonX raw magic extralen=%d crc0=%x\n",extralen,crc0);
|
||||
}
|
||||
|
||||
//TODO: why is this needed?
|
||||
@@ -1497,8 +1472,7 @@ uint16_t hush_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extrap
|
||||
fprintf(stderr,"%s: extralen=%d\n",__func__,extralen);
|
||||
|
||||
*magicp = hush_smartmagic(symbol,supply,extraptr,extralen);
|
||||
//if(fDebug)
|
||||
fprintf(stderr,"%s: extralen=%d, supply=%lu\n",__func__,extralen, supply);
|
||||
LogPrintf("%s: extralen=%d, supply=%lu\n",__func__,extralen, supply);
|
||||
|
||||
return(hush_smartport(*magicp,extralen));
|
||||
}
|
||||
@@ -1620,11 +1594,10 @@ uint64_t hush_sc_block_subsidy(int nHeight)
|
||||
int32_t numhalvings = 0, curEra = 0, sign = 1;
|
||||
static uint64_t cached_subsidy; static int32_t cached_numhalvings; static int cached_era;
|
||||
const bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false;
|
||||
// fprintf(stderr,"%s: ht=%d ishush3=%d\n", __func__, nHeight, ishush3);
|
||||
|
||||
// check for backwards compat, older chains with no explicit rewards had 0.0001 block reward
|
||||
if ( ASSETCHAINS_ENDSUBSIDY[0] == 0 && ASSETCHAINS_REWARD[0] == 0 ) {
|
||||
fprintf(stderr,"%s: defaulting to 0.0001 subsidy\n",__func__);
|
||||
LogPrintf("%s: defaulting to 0.0001 subsidy\n",__func__);
|
||||
subsidy = 10000;
|
||||
} else if ( (ASSETCHAINS_ENDSUBSIDY[0] == 0 && ASSETCHAINS_REWARD[0] != 0) || ASSETCHAINS_ENDSUBSIDY[0] != 0 ) {
|
||||
// if we have an end block in the first era, find our current era
|
||||
@@ -1659,7 +1632,6 @@ uint64_t hush_sc_block_subsidy(int nHeight)
|
||||
// The code below is not compatible with HUSH3 mainnet
|
||||
if ( ASSETCHAINS_DECAY[curEra] == 0 ) {
|
||||
subsidy >>= numhalvings;
|
||||
// fprintf(stderr,"%s: no decay, numhalvings.%d curEra.%d subsidy.%ld nStart.%ld\n",__func__, numhalvings, curEra, subsidy, nStart);
|
||||
} else if ( ASSETCHAINS_DECAY[curEra] == 100000000 && ASSETCHAINS_ENDSUBSIDY[curEra] != 0 ) {
|
||||
if ( curEra == ASSETCHAINS_LASTERA )
|
||||
{
|
||||
@@ -1675,12 +1647,11 @@ uint64_t hush_sc_block_subsidy(int nHeight)
|
||||
}
|
||||
denominator = ASSETCHAINS_ENDSUBSIDY[curEra] - nStart;
|
||||
numerator = denominator - ((ASSETCHAINS_ENDSUBSIDY[curEra] - nHeight) + ((nHeight - nStart) % ASSETCHAINS_HALVING[curEra]));
|
||||
// fprintf(stderr,"%s: numerator=%ld , denominator=%ld at height=%d\n",__func__,numerator, denominator,nHeight);
|
||||
if( denominator ) {
|
||||
subsidy = subsidy - sign * ((subsidyDifference * numerator) / denominator);
|
||||
} else {
|
||||
fprintf(stderr,"%s: invalid denominator=%ld !\n", __func__, denominator);
|
||||
fprintf(stderr,"%s: defaulting to 0.0001 subsidy\n",__func__);
|
||||
LogPrintf("%s: invalid denominator=%ld !\n", __func__, denominator);
|
||||
LogPrintf("%s: defaulting to 0.0001 subsidy\n",__func__);
|
||||
subsidy = 10000;
|
||||
}
|
||||
} else {
|
||||
@@ -1698,13 +1669,13 @@ uint64_t hush_sc_block_subsidy(int nHeight)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr,"%s: curEra.%d > lastEra.%lu\n", __func__, curEra, ASSETCHAINS_LASTERA);
|
||||
LogPrintf("%s: curEra.%d > lastEra.%lu\n", __func__, curEra, ASSETCHAINS_LASTERA);
|
||||
}
|
||||
}
|
||||
uint32_t magicExtra = ASSETCHAINS_STAKED ? ASSETCHAINS_MAGIC : (ASSETCHAINS_MAGIC & 0xffffff);
|
||||
if ( ASSETCHAINS_SUPPLY > 10000000000 ) // over 10 billion?
|
||||
{
|
||||
fprintf(stderr,"%s: Detected supply over 10 billion, danger zone!\n",__func__);
|
||||
LogPrintf("%s: Detected supply over 10 billion, danger zone!\n",__func__);
|
||||
if ( nHeight <= ASSETCHAINS_SUPPLY/1000000000 )
|
||||
{
|
||||
subsidy += (uint64_t)1000000000 * COIN;
|
||||
@@ -1782,7 +1753,7 @@ void hush_args(char *argv0)
|
||||
IS_HUSH_NOTARY = 1;
|
||||
HUSH_MININGTHREADS = 1;
|
||||
mapArgs ["-genproclimit"] = itostr(HUSH_MININGTHREADS);
|
||||
fprintf(stderr,"running as notary.%d %s\n",i,notaries_list[hush_season-1][i][0]);
|
||||
LogPrintf("running as notary.%d %s\n",i,notaries_list[hush_season-1][i][0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1815,7 +1786,7 @@ void hush_args(char *argv0)
|
||||
|
||||
vector<string> more_nodes = mapMultiArgs["-addnode"];
|
||||
if (more_nodes.size() > 0) {
|
||||
fprintf(stderr,"%s: Adding %lu more nodes via custom -addnode arguments\n", __func__, more_nodes.size() );
|
||||
LogPrint("net", "%s: Adding %lu more nodes via custom -addnode arguments\n", __func__, more_nodes.size() );
|
||||
}
|
||||
// Add default DRAGONX nodes after custom addnodes, if applicable
|
||||
if(DRAGONX_nodes.size() > 0) {
|
||||
@@ -1857,19 +1828,19 @@ void hush_args(char *argv0)
|
||||
if ( i > 1 && ccEnablesHeight[i-2] == ecode )
|
||||
break;
|
||||
if ( ecode > 255 || ecode < 0 )
|
||||
fprintf(stderr, "ac_ccactivateht: invalid evalcode.%i must be between 0 and 256.\n", ecode);
|
||||
LogPrintf("ac_ccactivateht: invalid evalcode.%i must be between 0 and 256.\n", ecode);
|
||||
else if ( ht > 0 )
|
||||
{
|
||||
// update global map.
|
||||
mapHeightEvalActivate[ecode] = ht;
|
||||
fprintf(stderr, "ac_ccactivateht: ecode.%i activates at height.%i\n", ecode, mapHeightEvalActivate[ecode]);
|
||||
LogPrintf("ac_ccactivateht: ecode.%i activates at height.%i\n", ecode, mapHeightEvalActivate[ecode]);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if ( (HUSH_REWIND= GetArg("-rewind",0)) != 0 )
|
||||
{
|
||||
printf("HUSH_REWIND %d\n",HUSH_REWIND);
|
||||
LogPrintf("HUSH_REWIND %d\n",HUSH_REWIND);
|
||||
}
|
||||
HUSH_EARLYTXID = Parseuint256(GetArg("-earlytxid","0").c_str());
|
||||
ASSETCHAINS_EARLYTXIDCONTRACT = GetArg("-ac_earlytxidcontract",0);
|
||||
@@ -1887,7 +1858,7 @@ void hush_args(char *argv0)
|
||||
STAKING_MIN_DIFF = ASSETCHAINS_MINDIFF[i];
|
||||
// only worth mentioning if it's not equihash
|
||||
if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH)
|
||||
printf("ASSETCHAINS_ALGO, algorithm set to %s\n", selectedAlgo.c_str());
|
||||
LogPrintf("ASSETCHAINS_ALGO, algorithm set to %s\n", selectedAlgo.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1897,11 +1868,11 @@ void hush_args(char *argv0)
|
||||
{
|
||||
printf("equihash values N.%li and K.%li are not currently available\n", ASSETCHAINS_NK[0], ASSETCHAINS_NK[1]);
|
||||
exit(0);
|
||||
} else printf("ASSETCHAINS_ALGO, algorithm set to equihash with N.%li and K.%li\n", ASSETCHAINS_NK[0], ASSETCHAINS_NK[1]);
|
||||
} else LogPrintf("ASSETCHAINS_ALGO, algorithm set to equihash with N.%li and K.%li\n", ASSETCHAINS_NK[0], ASSETCHAINS_NK[1]);
|
||||
}
|
||||
if (i == ASSETCHAINS_NUMALGOS)
|
||||
{
|
||||
printf("ASSETCHAINS_ALGO, %s not supported. using equihash\n", selectedAlgo.c_str());
|
||||
LogPrintf("ASSETCHAINS_ALGO, %s not supported. using equihash\n", selectedAlgo.c_str());
|
||||
}
|
||||
|
||||
// Set our symbol from -ac_name value
|
||||
@@ -1916,14 +1887,14 @@ void hush_args(char *argv0)
|
||||
} else {
|
||||
ASSETCHAINS_RANDOMX_VALIDATION = 1; // all other RandomX HACs: enforce from height 1
|
||||
}
|
||||
printf("ASSETCHAINS_RANDOMX_VALIDATION set to %d for %s\n", ASSETCHAINS_RANDOMX_VALIDATION, SMART_CHAIN_SYMBOL);
|
||||
LogPrintf("ASSETCHAINS_RANDOMX_VALIDATION set to %d for %s\n", ASSETCHAINS_RANDOMX_VALIDATION, SMART_CHAIN_SYMBOL);
|
||||
}
|
||||
|
||||
ASSETCHAINS_LASTERA = GetArg("-ac_eras", 1);
|
||||
if ( ASSETCHAINS_LASTERA < 1 || ASSETCHAINS_LASTERA > ASSETCHAINS_MAX_ERAS )
|
||||
{
|
||||
ASSETCHAINS_LASTERA = 1;
|
||||
printf("ASSETCHAINS_LASTERA, if specified, must be between 1 and %u. ASSETCHAINS_LASTERA set to %lu\n", ASSETCHAINS_MAX_ERAS, ASSETCHAINS_LASTERA);
|
||||
LogPrintf("ASSETCHAINS_LASTERA, if specified, must be between 1 and %u. ASSETCHAINS_LASTERA set to %lu\n", ASSETCHAINS_MAX_ERAS, ASSETCHAINS_LASTERA);
|
||||
}
|
||||
ASSETCHAINS_LASTERA -= 1;
|
||||
if(fDebug)
|
||||
@@ -1934,7 +1905,7 @@ void hush_args(char *argv0)
|
||||
ASSETCHAINS_TIMEUNLOCKTO = GetArg("-ac_timeunlockto", 0);
|
||||
if ( ASSETCHAINS_TIMEUNLOCKFROM > ASSETCHAINS_TIMEUNLOCKTO )
|
||||
{
|
||||
printf("ASSETCHAINS_TIMELOCKGTE - must specify valid ac_timeunlockfrom and ac_timeunlockto\n");
|
||||
LogPrintf("ASSETCHAINS_TIMELOCKGTE - must specify valid ac_timeunlockfrom and ac_timeunlockto\n");
|
||||
ASSETCHAINS_TIMELOCKGTE = _ASSETCHAINS_TIMELOCKOFF;
|
||||
ASSETCHAINS_TIMEUNLOCKFROM = ASSETCHAINS_TIMEUNLOCKTO = 0;
|
||||
}
|
||||
@@ -1953,7 +1924,7 @@ void hush_args(char *argv0)
|
||||
ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script","");
|
||||
|
||||
|
||||
fprintf(stderr,"%s: Setting custom %s reward isdragonx=%d reward,halving,subsidy chain values...\n",__func__, SMART_CHAIN_SYMBOL, isdragonx);
|
||||
LogPrintf("%s: Setting custom %s reward isdragonx=%d reward,halving,subsidy chain values...\n",__func__, SMART_CHAIN_SYMBOL, isdragonx);
|
||||
if(isdragonx) {
|
||||
// DragonX chain parameters (previously set via wrapper script)
|
||||
// -ac_name=DRAGONX -ac_algo=randomx -ac_halving=3500000 -ac_reward=300000000 -ac_blocktime=36 -ac_private=1
|
||||
@@ -1969,12 +1940,12 @@ void hush_args(char *argv0)
|
||||
if ( ASSETCHAINS_DECAY[i] == 100000000 && ASSETCHAINS_ENDSUBSIDY == 0 )
|
||||
{
|
||||
ASSETCHAINS_DECAY[i] = 0;
|
||||
printf("ERA%u: ASSETCHAINS_DECAY of 100000000 means linear and that needs ASSETCHAINS_ENDSUBSIDY\n", i);
|
||||
LogPrintf("ERA%u: ASSETCHAINS_DECAY of 100000000 means linear and that needs ASSETCHAINS_ENDSUBSIDY\n", i);
|
||||
}
|
||||
else if ( ASSETCHAINS_DECAY[i] > 100000000 )
|
||||
{
|
||||
ASSETCHAINS_DECAY[i] = 0;
|
||||
printf("ERA%u: ASSETCHAINS_DECAY cant be more than 100000000\n", i);
|
||||
LogPrintf("ERA%u: ASSETCHAINS_DECAY cant be more than 100000000\n", i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2000,21 +1971,15 @@ void hush_args(char *argv0)
|
||||
SplitStr(GetArg("-ac_stocks",""), ASSETCHAINS_STOCKS);
|
||||
if ( ASSETCHAINS_STOCKS.size() > 0 )
|
||||
ASSETCHAINS_CBOPRET |= 8;
|
||||
for (i=0; i<ASSETCHAINS_PRICES.size(); i++)
|
||||
fprintf(stderr,"%s ",ASSETCHAINS_PRICES[i].c_str());
|
||||
fprintf(stderr,"%d -ac_prices\n",(int32_t)ASSETCHAINS_PRICES.size());
|
||||
for (i=0; i<ASSETCHAINS_STOCKS.size(); i++)
|
||||
fprintf(stderr,"%s ",ASSETCHAINS_STOCKS[i].c_str());
|
||||
fprintf(stderr,"%d -ac_stocks\n",(int32_t)ASSETCHAINS_STOCKS.size());
|
||||
LogPrintf("%d -ac_prices\n",(int32_t)ASSETCHAINS_PRICES.size());
|
||||
LogPrintf("%d -ac_stocks\n",(int32_t)ASSETCHAINS_STOCKS.size());
|
||||
}
|
||||
hexstr = GetArg("-ac_mineropret","");
|
||||
if ( hexstr.size() != 0 )
|
||||
{
|
||||
Mineropret.resize(hexstr.size()/2);
|
||||
decode_hex(Mineropret.data(),hexstr.size()/2,(char *)hexstr.c_str());
|
||||
for (i=0; i<Mineropret.size(); i++)
|
||||
fprintf(stderr,"%02x",Mineropret[i]);
|
||||
fprintf(stderr," Mineropret\n");
|
||||
LogPrintf(" Mineropret\n");
|
||||
}
|
||||
if ( ASSETCHAINS_COMMISSION != 0 && ASSETCHAINS_FOUNDERS_REWARD != 0 )
|
||||
{
|
||||
@@ -2034,10 +1999,9 @@ void hush_args(char *argv0)
|
||||
{
|
||||
nonz++;
|
||||
prevCCi = ccenables[i];
|
||||
fprintf(stderr,"%d ",(uint8_t)(ccenables[i] & 0xff));
|
||||
}
|
||||
}
|
||||
fprintf(stderr,"nonz.%d ccenables[]\n",nonz);
|
||||
LogPrintf("nonz.%d ccenables[]\n",nonz);
|
||||
if ( nonz > 0 )
|
||||
{
|
||||
for (i=0; i<256; i++)
|
||||
@@ -2137,9 +2101,9 @@ void hush_args(char *argv0)
|
||||
if ( ASSETCHAINS_FOUNDERS_REWARD == 0 )
|
||||
{
|
||||
ASSETCHAINS_COMMISSION = 53846154; // maps to 35%
|
||||
printf("ASSETCHAINS_COMMISSION defaulted to 35%% when founders reward active\n");
|
||||
LogPrintf("ASSETCHAINS_COMMISSION defaulted to 35%% when founders reward active\n");
|
||||
} else {
|
||||
printf("ASSETCHAINS_FOUNDERS_REWARD set to %ld\n", ASSETCHAINS_FOUNDERS_REWARD);
|
||||
LogPrintf("ASSETCHAINS_FOUNDERS_REWARD set to %ld\n", ASSETCHAINS_FOUNDERS_REWARD);
|
||||
}
|
||||
/*else if ( ASSETCHAINS_SELFIMPORT.size() == 0 )
|
||||
{
|
||||
@@ -2151,12 +2115,12 @@ void hush_args(char *argv0)
|
||||
if ( ASSETCHAINS_COMMISSION != 0 )
|
||||
{
|
||||
ASSETCHAINS_COMMISSION = 0;
|
||||
printf("ASSETCHAINS_COMMISSION needs an ASSETCHAINS_OVERRIDE_PUBKEY and cant be more than 100000000 (100%%)\n");
|
||||
LogPrintf("ASSETCHAINS_COMMISSION needs an ASSETCHAINS_OVERRIDE_PUBKEY and cant be more than 100000000 (100%%)\n");
|
||||
}
|
||||
if ( ASSETCHAINS_FOUNDERS != 0 )
|
||||
{
|
||||
ASSETCHAINS_FOUNDERS = 0;
|
||||
printf("ASSETCHAINS_FOUNDERS needs an ASSETCHAINS_OVERRIDE_PUBKEY or ASSETCHAINS_SCRIPTPUB\n");
|
||||
LogPrintf("ASSETCHAINS_FOUNDERS needs an ASSETCHAINS_OVERRIDE_PUBKEY or ASSETCHAINS_SCRIPTPUB\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2224,7 +2188,7 @@ void hush_args(char *argv0)
|
||||
// NOTE: Hush does not use this, we use -ac_script to implement our FR -- Duke
|
||||
if ( ASSETCHAINS_FOUNDERS_REWARD != 0 )
|
||||
{
|
||||
fprintf(stderr, "set founders reward.%lld\n",(long long)ASSETCHAINS_FOUNDERS_REWARD);
|
||||
LogPrintf("set founders reward.%lld\n",(long long)ASSETCHAINS_FOUNDERS_REWARD);
|
||||
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS_REWARD),(void *)&ASSETCHAINS_FOUNDERS_REWARD);
|
||||
}
|
||||
}
|
||||
@@ -2233,14 +2197,12 @@ void hush_args(char *argv0)
|
||||
decode_hex(&extraptr[extralen],ASSETCHAINS_SCRIPTPUB.size()/2,(char *)ASSETCHAINS_SCRIPTPUB.c_str());
|
||||
extralen += ASSETCHAINS_SCRIPTPUB.size()/2;
|
||||
//extralen += dragon_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str());
|
||||
fprintf(stderr,"append ac_script %s\n",ASSETCHAINS_SCRIPTPUB.c_str());
|
||||
LogPrintf("append ac_script %s\n",ASSETCHAINS_SCRIPTPUB.c_str());
|
||||
}
|
||||
if ( ASSETCHAINS_SELFIMPORT.size() > 0 )
|
||||
{
|
||||
memcpy(&extraptr[extralen],(char *)ASSETCHAINS_SELFIMPORT.c_str(),ASSETCHAINS_SELFIMPORT.size());
|
||||
for (i=0; i<ASSETCHAINS_SELFIMPORT.size(); i++)
|
||||
fprintf(stderr,"%c",extraptr[extralen+i]);
|
||||
fprintf(stderr," selfimport\n");
|
||||
LogPrintf(" selfimport\n");
|
||||
extralen += ASSETCHAINS_SELFIMPORT.size();
|
||||
}
|
||||
if ( ASSETCHAINS_BEAMPORT != 0 )
|
||||
@@ -2250,7 +2212,7 @@ void hush_args(char *argv0)
|
||||
if ( ASSETCHAINS_MARMARA != 0 )
|
||||
extraptr[extralen++] = ASSETCHAINS_MARMARA;
|
||||
|
||||
fprintf(stderr,"extralen.%d before disable bits\n",extralen);
|
||||
LogPrintf("extralen.%d before disable bits\n",extralen);
|
||||
|
||||
if ( nonz > 0 ) {
|
||||
memcpy(&extraptr[extralen],disablebits,sizeof(disablebits));
|
||||
@@ -2261,14 +2223,13 @@ void hush_args(char *argv0)
|
||||
for (i=0; i<ASSETCHAINS_CCLIB.size(); i++)
|
||||
{
|
||||
extraptr[extralen++] = ASSETCHAINS_CCLIB[i];
|
||||
fprintf(stderr,"%c",ASSETCHAINS_CCLIB[i]);
|
||||
}
|
||||
fprintf(stderr," <- CCLIB name\n");
|
||||
LogPrintf(" <- CCLIB name\n");
|
||||
}
|
||||
|
||||
if ( ASSETCHAINS_BLOCKTIME != 60 ) {
|
||||
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_BLOCKTIME),(void *)&ASSETCHAINS_BLOCKTIME);
|
||||
fprintf(stderr,"%s: ASSETCHAINS_BLOCKTIME=%d, extralen=%d\n", __func__, ASSETCHAINS_BLOCKTIME, extralen);
|
||||
LogPrintf("%s: ASSETCHAINS_BLOCKTIME=%d, extralen=%d\n", __func__, ASSETCHAINS_BLOCKTIME, extralen);
|
||||
}
|
||||
|
||||
if ( Mineropret.size() != 0 )
|
||||
@@ -2299,7 +2260,7 @@ void hush_args(char *argv0)
|
||||
}
|
||||
//hush_pricesinit();
|
||||
hush_cbopretupdate(1); // will set Mineropret
|
||||
fprintf(stderr,"This blockchain uses data produced from CoinDesk Bitcoin Price Index\n");
|
||||
LogPrintf("This blockchain uses data produced from CoinDesk Bitcoin Price Index\n");
|
||||
}
|
||||
if ( ASSETCHAINS_NK[0] != 0 && ASSETCHAINS_NK[1] != 0 )
|
||||
{
|
||||
@@ -2355,13 +2316,12 @@ void hush_args(char *argv0)
|
||||
MAX_MONEY = HUSH_MAXNVALUE;
|
||||
if(fDebug)
|
||||
fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN);
|
||||
//printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,SMART_CHAIN_SYMBOL,(double)MAX_MONEY/SATOSHIDEN);
|
||||
uint16_t tmpport = hush_port(SMART_CHAIN_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen);
|
||||
if ( GetArg("-port",0) != 0 )
|
||||
{
|
||||
ASSETCHAINS_P2PPORT = GetArg("-port",0);
|
||||
if(ishush3) {
|
||||
fprintf(stderr,"set HUSH3 p2pport.%u\n",ASSETCHAINS_P2PPORT);
|
||||
LogPrintf("set HUSH3 p2pport.%u\n",ASSETCHAINS_P2PPORT);
|
||||
ASSETCHAINS_P2PPORT = 18030;
|
||||
}
|
||||
if(fDebug)
|
||||
@@ -2377,7 +2337,6 @@ void hush_args(char *argv0)
|
||||
boost::this_thread::sleep(boost::posix_time::milliseconds(3000));
|
||||
#endif
|
||||
}
|
||||
//fprintf(stderr,"Got datadir.(%s)\n",dirname);
|
||||
if ( SMART_CHAIN_SYMBOL[0] != 0 )
|
||||
{
|
||||
int32_t hush_baseid(char *origbase);
|
||||
@@ -2395,7 +2354,6 @@ void hush_args(char *argv0)
|
||||
fprintf(stderr,"ac_cbmaturity must be >0, shutting down\n");
|
||||
StartShutdown();
|
||||
}
|
||||
//fprintf(stderr,"ASSETCHAINS_RPCPORT (%s) %u\n",SMART_CHAIN_SYMBOL,ASSETCHAINS_RPCPORT);
|
||||
}
|
||||
if ( ASSETCHAINS_RPCPORT == 0 )
|
||||
ASSETCHAINS_RPCPORT = ASSETCHAINS_P2PPORT + 1;
|
||||
@@ -2411,10 +2369,10 @@ void hush_args(char *argv0)
|
||||
if ( HUSH_CCACTIVATE != 0 )
|
||||
{
|
||||
ASSETCHAINS_CC = 2;
|
||||
fprintf(stderr,"smart utxo CC contracts will activate at height.%d\n",HUSH_CCACTIVATE);
|
||||
LogPrintf("smart utxo CC contracts will activate at height.%d\n",HUSH_CCACTIVATE);
|
||||
} else if ( ccEnablesHeight[0] != 0 ) {
|
||||
ASSETCHAINS_CC = 2;
|
||||
fprintf(stderr,"smart utxo CC contract %d will activate at height.%d\n",(int32_t)ccEnablesHeight[0],(int32_t)ccEnablesHeight[1]);
|
||||
LogPrintf("smart utxo CC contract %d will activate at height.%d\n",(int32_t)ccEnablesHeight[0],(int32_t)ccEnablesHeight[1]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -2448,8 +2406,7 @@ void hush_args(char *argv0)
|
||||
_hush_userpass(username,password,fp);
|
||||
sprintf(iter == 0 ? HUSHUSERPASS : BTCUSERPASS,"%s:%s",username,password);
|
||||
fclose(fp);
|
||||
//printf("HUSH.(%s) -> userpass.(%s)\n",fname,HUSHUSERPASS);
|
||||
} //else printf("couldnt open.(%s)\n",fname);
|
||||
}
|
||||
if ( IS_HUSH_NOTARY == 0 )
|
||||
break;
|
||||
}
|
||||
@@ -2458,7 +2415,6 @@ void hush_args(char *argv0)
|
||||
if ( SMART_CHAIN_SYMBOL[0] != 0 )
|
||||
{
|
||||
BITCOIND_RPCPORT = GetArg("-rpcport", ASSETCHAINS_RPCPORT);
|
||||
//fprintf(stderr,"(%s) port.%u chain params initialized\n",SMART_CHAIN_SYMBOL,BITCOIND_RPCPORT);
|
||||
|
||||
// Set custom cc rulse for chains here
|
||||
if ( strcmp("HUSH3",SMART_CHAIN_SYMBOL) == 0 ) {
|
||||
@@ -2514,7 +2470,7 @@ void hush_prefetch(FILE *fp)
|
||||
{
|
||||
rewind(fp);
|
||||
while ( fread(ignore,1,incr,fp) == incr ) // prefetch
|
||||
fprintf(stderr,".");
|
||||
;
|
||||
free(ignore);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user