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:
@@ -20,6 +20,7 @@
|
|||||||
#include "CCinclude.h"
|
#include "CCinclude.h"
|
||||||
#include "hush_structs.h"
|
#include "hush_structs.h"
|
||||||
#include "key_io.h"
|
#include "key_io.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
#ifdef TESTMODE
|
#ifdef TESTMODE
|
||||||
#define MIN_NON_NOTARIZED_CONFIRMS 2
|
#define MIN_NON_NOTARIZED_CONFIRMS 2
|
||||||
@@ -46,7 +47,6 @@ int32_t has_opret(const CTransaction &tx, uint8_t evalcode)
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
for ( auto vout : tx.vout )
|
for ( auto vout : tx.vout )
|
||||||
{
|
{
|
||||||
//fprintf(stderr, "[txid.%s] 1.%i 2.%i 3.%i 4.%i\n",tx.GetHash().GetHex().c_str(), vout.scriptPubKey[0], vout.scriptPubKey[1], vout.scriptPubKey[2], vout.scriptPubKey[3]);
|
|
||||||
if ( vout.scriptPubKey.size() > 3 && vout.scriptPubKey[0] == OP_RETURN && vout.scriptPubKey[2] == evalcode )
|
if ( vout.scriptPubKey.size() > 3 && vout.scriptPubKey[0] == OP_RETURN && vout.scriptPubKey[2] == evalcode )
|
||||||
return i;
|
return i;
|
||||||
i++;
|
i++;
|
||||||
@@ -88,7 +88,6 @@ bool CheckTxFee(const CTransaction &tx, uint64_t txfee, uint32_t height, uint64_
|
|||||||
actualtxfee = valuein-tx.GetValueOut();
|
actualtxfee = valuein-tx.GetValueOut();
|
||||||
if ( actualtxfee > txfee )
|
if ( actualtxfee > txfee )
|
||||||
{
|
{
|
||||||
//fprintf(stderr, "actualtxfee.%li vs txfee.%li\n", actualtxfee, txfee);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -112,7 +111,6 @@ bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey)
|
|||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"ExtractDestination failed\n");
|
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,17 +200,17 @@ bool hush_txnotarizedconfirmed(uint256 txid)
|
|||||||
{
|
{
|
||||||
if ( NSPV_myGetTransaction(txid,tx,hashBlock,txheight,currentheight) == 0 )
|
if ( NSPV_myGetTransaction(txid,tx,hashBlock,txheight,currentheight) == 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"hush_txnotarizedconfirmed cant find txid %s\n",txid.ToString().c_str());
|
LogPrintf("hush_txnotarizedconfirmed cant find txid %s\n",txid.ToString().c_str());
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
else if (txheight<=0)
|
else if (txheight<=0)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"hush_txnotarizedconfirmed no txheight.%d for txid %s\n",txheight,txid.ToString().c_str());
|
LogPrintf("hush_txnotarizedconfirmed no txheight.%d for txid %s\n",txheight,txid.ToString().c_str());
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
else if (txheight>currentheight)
|
else if (txheight>currentheight)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"hush_txnotarizedconfirmed backwards heights for txid %s hts.(%d %d)\n",txid.ToString().c_str(),txheight,currentheight);
|
LogPrintf("hush_txnotarizedconfirmed backwards heights for txid %s hts.(%d %d)\n",txid.ToString().c_str(),txheight,currentheight);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
confirms=1 + currentheight - txheight;
|
confirms=1 + currentheight - txheight;
|
||||||
@@ -221,24 +219,24 @@ bool hush_txnotarizedconfirmed(uint256 txid)
|
|||||||
{
|
{
|
||||||
if ( myGetTransaction(txid,tx,hashBlock) == 0 )
|
if ( myGetTransaction(txid,tx,hashBlock) == 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"hush_txnotarizedconfirmed cant find txid %s\n",txid.ToString().c_str());
|
LogPrintf("hush_txnotarizedconfirmed cant find txid %s\n",txid.ToString().c_str());
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
else if ( hashBlock == zeroid )
|
else if ( hashBlock == zeroid )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"hush_txnotarizedconfirmed no hashBlock for txid %s\n",txid.ToString().c_str());
|
LogPrintf("hush_txnotarizedconfirmed no hashBlock for txid %s\n",txid.ToString().c_str());
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
else if ( (pindex= hush_blockindex(hashBlock)) == 0 || (txheight= pindex->GetHeight()) <= 0 )
|
else if ( (pindex= hush_blockindex(hashBlock)) == 0 || (txheight= pindex->GetHeight()) <= 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"hush_txnotarizedconfirmed no txheight.%d %p for txid %s\n",txheight,pindex,txid.ToString().c_str());
|
LogPrintf("hush_txnotarizedconfirmed no txheight.%d %p for txid %s\n",txheight,pindex,txid.ToString().c_str());
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
else if ( (pindex= chainActive.LastTip()) == 0 || pindex->GetHeight() < txheight )
|
else if ( (pindex= chainActive.LastTip()) == 0 || pindex->GetHeight() < txheight )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"hush_txnotarizedconfirmed backwards heights for txid %s hts.(%d %d)\n",txid.ToString().c_str(),txheight,(int32_t)pindex->GetHeight());
|
LogPrintf("hush_txnotarizedconfirmed backwards heights for txid %s hts.(%d %d)\n",txid.ToString().c_str(),txheight,(int32_t)pindex->GetHeight());
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
confirms=1 + pindex->GetHeight() - txheight;
|
confirms=1 + pindex->GetHeight() - txheight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -393,8 +393,6 @@ void CCoinsViewCache::SetBestBlock(const uint256 &hashBlockIn) {
|
|||||||
|
|
||||||
void BatchWriteNullifiers(CNullifiersMap &mapNullifiers, CNullifiersMap &cacheNullifiers)
|
void BatchWriteNullifiers(CNullifiersMap &mapNullifiers, CNullifiersMap &cacheNullifiers)
|
||||||
{
|
{
|
||||||
//if(fZdebug)
|
|
||||||
// LogPrintf("%s\n", __FUNCTION__);
|
|
||||||
for (CNullifiersMap::iterator child_it = mapNullifiers.begin(); child_it != mapNullifiers.end();) {
|
for (CNullifiersMap::iterator child_it = mapNullifiers.begin(); child_it != mapNullifiers.end();) {
|
||||||
if (child_it->second.flags & CNullifiersCacheEntry::DIRTY) { // Ignore non-dirty entries (optimization).
|
if (child_it->second.flags & CNullifiersCacheEntry::DIRTY) { // Ignore non-dirty entries (optimization).
|
||||||
CNullifiersMap::iterator parent_it = cacheNullifiers.find(child_it->first);
|
CNullifiersMap::iterator parent_it = cacheNullifiers.find(child_it->first);
|
||||||
@@ -518,10 +516,7 @@ unsigned int CCoinsViewCache::GetCacheSize() const {
|
|||||||
const CTxOut &CCoinsViewCache::GetOutputFor(const CTxIn& input) const
|
const CTxOut &CCoinsViewCache::GetOutputFor(const CTxIn& input) const
|
||||||
{
|
{
|
||||||
const CCoins* coins = AccessCoins(input.prevout.hash);
|
const CCoins* coins = AccessCoins(input.prevout.hash);
|
||||||
//fprintf(stderr, "GetOutputFor: input=%s", input.ToString().c_str());
|
|
||||||
//fprintf(stderr, "GetOutputFor: prevout n=%d,txid=%s\n", input.prevout.n, input.prevout.hash.ToString().c_str());
|
|
||||||
assert(coins && coins->IsAvailable(input.prevout.n));
|
assert(coins && coins->IsAvailable(input.prevout.n));
|
||||||
//fprintf(stderr, "GetOutputFor: IsAvailable\n");
|
|
||||||
return coins->vout[input.prevout.n];
|
return coins->vout[input.prevout.n];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -583,7 +578,6 @@ bool CCoinsViewCache::HaveInputs(const CTransaction& tx) const
|
|||||||
const COutPoint &prevout = tx.vin[i].prevout;
|
const COutPoint &prevout = tx.vin[i].prevout;
|
||||||
const CCoins* coins = AccessCoins(prevout.hash);
|
const CCoins* coins = AccessCoins(prevout.hash);
|
||||||
if (!coins || !coins->IsAvailable(prevout.n)) {
|
if (!coins || !coins->IsAvailable(prevout.n)) {
|
||||||
//fprintf(stderr,"HaveInputs missing input %s/v%d\n",prevout.hash.ToString().c_str(),prevout.n);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
33
src/hush.h
33
src/hush.h
@@ -95,7 +95,6 @@ int32_t hush_parsestatefile(struct hush_state *sp,FILE *fp,char *symbol,char *de
|
|||||||
errs++;
|
errs++;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//printf("updated %d pubkeys at %s ht.%d\n",num,symbol,ht);
|
|
||||||
if ( (HUSH_EXTERNAL_NOTARIES != 0 && matched != 0) )
|
if ( (HUSH_EXTERNAL_NOTARIES != 0 && matched != 0) )
|
||||||
hush_eventadd_pubkeys(sp,symbol,ht,num,pubkeys);
|
hush_eventadd_pubkeys(sp,symbol,ht,num,pubkeys);
|
||||||
}
|
}
|
||||||
@@ -131,7 +130,6 @@ int32_t hush_parsestatefile(struct hush_state *sp,FILE *fp,char *symbol,char *de
|
|||||||
uint8_t n,nid; uint256 hash; uint64_t mask;
|
uint8_t n,nid; uint256 hash; uint64_t mask;
|
||||||
n = fgetc(fp);
|
n = fgetc(fp);
|
||||||
nid = fgetc(fp);
|
nid = fgetc(fp);
|
||||||
//printf("U %d %d\n",n,nid);
|
|
||||||
if ( fread(&mask,1,sizeof(mask),fp) != sizeof(mask) )
|
if ( fread(&mask,1,sizeof(mask),fp) != sizeof(mask) )
|
||||||
errs++;
|
errs++;
|
||||||
if ( fread(&hash,1,sizeof(hash),fp) != sizeof(hash) )
|
if ( fread(&hash,1,sizeof(hash),fp) != sizeof(hash) )
|
||||||
@@ -145,7 +143,6 @@ int32_t hush_parsestatefile(struct hush_state *sp,FILE *fp,char *symbol,char *de
|
|||||||
if ( fread(&kheight,1,sizeof(kheight),fp) != sizeof(kheight) )
|
if ( fread(&kheight,1,sizeof(kheight),fp) != sizeof(kheight) )
|
||||||
errs++;
|
errs++;
|
||||||
//if ( matched != 0 ) global independent states -> inside *sp
|
//if ( matched != 0 ) global independent states -> inside *sp
|
||||||
//printf("%s.%d load[%s] ht.%d\n",SMART_CHAIN_SYMBOL,ht,symbol,kheight);
|
|
||||||
hush_eventadd_hushheight(sp,symbol,ht,kheight,0);
|
hush_eventadd_hushheight(sp,symbol,ht,kheight,0);
|
||||||
}
|
}
|
||||||
else if ( func == 'T' )
|
else if ( func == 'T' )
|
||||||
@@ -156,7 +153,6 @@ int32_t hush_parsestatefile(struct hush_state *sp,FILE *fp,char *symbol,char *de
|
|||||||
if ( fread(&ktimestamp,1,sizeof(ktimestamp),fp) != sizeof(ktimestamp) )
|
if ( fread(&ktimestamp,1,sizeof(ktimestamp),fp) != sizeof(ktimestamp) )
|
||||||
errs++;
|
errs++;
|
||||||
//if ( matched != 0 ) global independent states -> inside *sp
|
//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_hushheight(sp,symbol,ht,kheight,ktimestamp);
|
hush_eventadd_hushheight(sp,symbol,ht,kheight,ktimestamp);
|
||||||
}
|
}
|
||||||
else if ( func == 'R' )
|
else if ( func == 'R' )
|
||||||
@@ -186,7 +182,6 @@ int32_t hush_parsestatefile(struct hush_state *sp,FILE *fp,char *symbol,char *de
|
|||||||
int32_t i;
|
int32_t i;
|
||||||
for (i=0; i<olen; i++)
|
for (i=0; i<olen; i++)
|
||||||
fgetc(fp);
|
fgetc(fp);
|
||||||
//printf("illegal olen.%u\n",olen);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( func == 'D' )
|
else if ( func == 'D' )
|
||||||
@@ -200,9 +195,7 @@ int32_t hush_parsestatefile(struct hush_state *sp,FILE *fp,char *symbol,char *de
|
|||||||
if ( numpvals*sizeof(uint32_t) <= sizeof(pvals) && fread(pvals,sizeof(uint32_t),numpvals,fp) == numpvals )
|
if ( numpvals*sizeof(uint32_t) <= sizeof(pvals) && fread(pvals,sizeof(uint32_t),numpvals,fp) == numpvals )
|
||||||
{
|
{
|
||||||
//if ( matched != 0 ) global shared state -> global PVALS
|
//if ( matched != 0 ) global shared state -> global PVALS
|
||||||
//printf("%s load[%s] prices %d\n",SMART_CHAIN_SYMBOL,symbol,ht);
|
|
||||||
hush_eventadd_pricefeed(sp,symbol,ht,pvals,numpvals);
|
hush_eventadd_pricefeed(sp,symbol,ht,pvals,numpvals);
|
||||||
//printf("load pvals ht.%d numpvals.%d\n",ht,numpvals);
|
|
||||||
} else printf("error loading pvals[%d]\n",numpvals);
|
} else printf("error loading pvals[%d]\n",numpvals);
|
||||||
} // else printf("[%s] %s illegal func.(%d %c)\n",SMART_CHAIN_SYMBOL,symbol,func,func);
|
} // else printf("[%s] %s illegal func.(%d %c)\n",SMART_CHAIN_SYMBOL,symbol,func,func);
|
||||||
return(func);
|
return(func);
|
||||||
@@ -239,7 +232,6 @@ int32_t hush_parsestatefiledata(struct hush_state *sp,uint8_t *filedata,long *fp
|
|||||||
errs++;
|
errs++;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//printf("updated %d pubkeys at %s ht.%d\n",num,symbol,ht);
|
|
||||||
if ( (HUSH_EXTERNAL_NOTARIES != 0 && matched != 0) )
|
if ( (HUSH_EXTERNAL_NOTARIES != 0 && matched != 0) )
|
||||||
hush_eventadd_pubkeys(sp,symbol,ht,num,pubkeys);
|
hush_eventadd_pubkeys(sp,symbol,ht,num,pubkeys);
|
||||||
}
|
}
|
||||||
@@ -274,7 +266,6 @@ int32_t hush_parsestatefiledata(struct hush_state *sp,uint8_t *filedata,long *fp
|
|||||||
uint8_t n,nid; uint256 hash; uint64_t mask;
|
uint8_t n,nid; uint256 hash; uint64_t mask;
|
||||||
n = filedata[fpos++];
|
n = filedata[fpos++];
|
||||||
nid = filedata[fpos++];
|
nid = filedata[fpos++];
|
||||||
//printf("U %d %d\n",n,nid);
|
|
||||||
if ( memread(&mask,sizeof(mask),filedata,&fpos,datalen) != sizeof(mask) )
|
if ( memread(&mask,sizeof(mask),filedata,&fpos,datalen) != sizeof(mask) )
|
||||||
errs++;
|
errs++;
|
||||||
if ( memread(&hash,sizeof(hash),filedata,&fpos,datalen) != sizeof(hash) )
|
if ( memread(&hash,sizeof(hash),filedata,&fpos,datalen) != sizeof(hash) )
|
||||||
@@ -295,7 +286,6 @@ int32_t hush_parsestatefiledata(struct hush_state *sp,uint8_t *filedata,long *fp
|
|||||||
if ( memread(&ktimestamp,sizeof(ktimestamp),filedata,&fpos,datalen) != sizeof(ktimestamp) )
|
if ( memread(&ktimestamp,sizeof(ktimestamp),filedata,&fpos,datalen) != sizeof(ktimestamp) )
|
||||||
errs++;
|
errs++;
|
||||||
//if ( matched != 0 ) global independent states -> inside *sp
|
//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_hushheight(sp,symbol,ht,kheight,ktimestamp);
|
hush_eventadd_hushheight(sp,symbol,ht,kheight,ktimestamp);
|
||||||
}
|
}
|
||||||
else if ( func == 'R' )
|
else if ( func == 'R' )
|
||||||
@@ -325,7 +315,6 @@ int32_t hush_parsestatefiledata(struct hush_state *sp,uint8_t *filedata,long *fp
|
|||||||
int32_t i;
|
int32_t i;
|
||||||
for (i=0; i<olen; i++)
|
for (i=0; i<olen; i++)
|
||||||
filedata[fpos++];
|
filedata[fpos++];
|
||||||
//printf("illegal olen.%u\n",olen);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( func == 'D' )
|
else if ( func == 'D' )
|
||||||
@@ -339,9 +328,7 @@ int32_t hush_parsestatefiledata(struct hush_state *sp,uint8_t *filedata,long *fp
|
|||||||
if ( numpvals*sizeof(uint32_t) <= sizeof(pvals) && memread(pvals,(int32_t)(sizeof(uint32_t)*numpvals),filedata,&fpos,datalen) == numpvals*sizeof(uint32_t) )
|
if ( numpvals*sizeof(uint32_t) <= sizeof(pvals) && memread(pvals,(int32_t)(sizeof(uint32_t)*numpvals),filedata,&fpos,datalen) == numpvals*sizeof(uint32_t) )
|
||||||
{
|
{
|
||||||
//if ( matched != 0 ) global shared state -> global PVALS
|
//if ( matched != 0 ) global shared state -> global PVALS
|
||||||
//printf("%s load[%s] prices %d\n",SMART_CHAIN_SYMBOL,symbol,ht);
|
|
||||||
hush_eventadd_pricefeed(sp,symbol,ht,pvals,numpvals);
|
hush_eventadd_pricefeed(sp,symbol,ht,pvals,numpvals);
|
||||||
//printf("load pvals ht.%d numpvals.%d\n",ht,numpvals);
|
|
||||||
} else printf("error loading pvals[%d]\n",numpvals);
|
} else printf("error loading pvals[%d]\n",numpvals);
|
||||||
} // else printf("[%s] %s illegal func.(%d %c)\n",SMART_CHAIN_SYMBOL,symbol,func,func);
|
} // else printf("[%s] %s illegal func.(%d %c)\n",SMART_CHAIN_SYMBOL,symbol,func,func);
|
||||||
*fposp = fpos;
|
*fposp = fpos;
|
||||||
@@ -366,7 +353,6 @@ void hush_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotarie
|
|||||||
printf("[%s] no hush_stateptr\n",SMART_CHAIN_SYMBOL);
|
printf("[%s] no hush_stateptr\n",SMART_CHAIN_SYMBOL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//printf("[%s] (%s) -> (%s)\n",SMART_CHAIN_SYMBOL,symbol,dest);
|
|
||||||
if ( fp == 0 )
|
if ( fp == 0 )
|
||||||
{
|
{
|
||||||
hush_statefname(fname,SMART_CHAIN_SYMBOL,(char *)"hushstate");
|
hush_statefname(fname,SMART_CHAIN_SYMBOL,(char *)"hushstate");
|
||||||
@@ -385,12 +371,10 @@ void hush_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotarie
|
|||||||
}
|
}
|
||||||
if ( height <= 0 )
|
if ( height <= 0 )
|
||||||
{
|
{
|
||||||
//printf("early return: stateupdate height.%d\n",height);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( fp != 0 ) // write out funcid, height, other fields, call side effect function
|
if ( fp != 0 ) // write out funcid, height, other fields, call side effect function
|
||||||
{
|
{
|
||||||
//printf("fpos.%ld ",ftell(fp));
|
|
||||||
if ( HUSHheight != 0 )
|
if ( HUSHheight != 0 )
|
||||||
{
|
{
|
||||||
if ( HUSHtimestamp != 0 )
|
if ( HUSHtimestamp != 0 )
|
||||||
@@ -425,7 +409,6 @@ void hush_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotarie
|
|||||||
errs++;
|
errs++;
|
||||||
if ( fwrite(opretbuf,1,olen,fp) != olen )
|
if ( fwrite(opretbuf,1,olen,fp) != olen )
|
||||||
errs++;
|
errs++;
|
||||||
//printf("create ht.%d R opret[%d] sp.%p\n",height,olen,sp);
|
|
||||||
hush_eventadd_opreturn(sp,symbol,height,txhash,opretvalue,vout,opretbuf,olen);
|
hush_eventadd_opreturn(sp,symbol,height,txhash,opretvalue,vout,opretbuf,olen);
|
||||||
}
|
}
|
||||||
else if ( notarypubs != 0 && numnotaries > 0 )
|
else if ( notarypubs != 0 && numnotaries > 0 )
|
||||||
@@ -441,7 +424,6 @@ void hush_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotarie
|
|||||||
}
|
}
|
||||||
else if ( voutmask != 0 && numvouts > 0 )
|
else if ( voutmask != 0 && numvouts > 0 )
|
||||||
{
|
{
|
||||||
//printf("ht.%d func U %d %d errs.%d hashsize.%ld\n",height,numvouts,notaryid,errs,sizeof(txhash));
|
|
||||||
fputc('U',fp);
|
fputc('U',fp);
|
||||||
if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) )
|
if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) )
|
||||||
errs++;
|
errs++;
|
||||||
@@ -468,13 +450,10 @@ void hush_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotarie
|
|||||||
if ( fwrite(pvals,sizeof(uint32_t),numpvals,fp) != numpvals )
|
if ( fwrite(pvals,sizeof(uint32_t),numpvals,fp) != numpvals )
|
||||||
errs++;
|
errs++;
|
||||||
hush_eventadd_pricefeed(sp,symbol,height,pvals,numpvals);
|
hush_eventadd_pricefeed(sp,symbol,height,pvals,numpvals);
|
||||||
//printf("ht.%d V numpvals[%d]\n",height,numpvals);
|
|
||||||
}
|
}
|
||||||
//printf("save pvals height.%d numpvals.%d\n",height,numpvals);
|
|
||||||
}
|
}
|
||||||
else if ( height != 0 )
|
else if ( height != 0 )
|
||||||
{
|
{
|
||||||
//printf("ht.%d func N ht.%d errs.%d\n",height,NOTARIZED_HEIGHT,errs);
|
|
||||||
if ( sp != 0 )
|
if ( sp != 0 )
|
||||||
{
|
{
|
||||||
if ( sp->MoMdepth != 0 && sp->MoM != zero )
|
if ( sp->MoMdepth != 0 && sp->MoM != zero )
|
||||||
@@ -504,7 +483,6 @@ void hush_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotarie
|
|||||||
|
|
||||||
int32_t hush_validate_chain(uint256 srchash,int32_t notarized_height)
|
int32_t hush_validate_chain(uint256 srchash,int32_t notarized_height)
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"%s\n", __func__);
|
|
||||||
static int32_t last_rewind; int32_t rewindtarget; CBlockIndex *pindex; struct hush_state *sp; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN];
|
static int32_t last_rewind; int32_t rewindtarget; CBlockIndex *pindex; struct hush_state *sp; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN];
|
||||||
if ( (sp= hush_stateptr(symbol,dest)) == 0 )
|
if ( (sp= hush_stateptr(symbol,dest)) == 0 )
|
||||||
return(0);
|
return(0);
|
||||||
@@ -555,11 +533,9 @@ int32_t hush_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryi
|
|||||||
if ( memcmp(crypto555,scriptbuf+1,33) == 0 )
|
if ( memcmp(crypto555,scriptbuf+1,33) == 0 )
|
||||||
{
|
{
|
||||||
*specialtxp = 1;
|
*specialtxp = 1;
|
||||||
//printf(">>>>>>>> ");
|
|
||||||
}
|
}
|
||||||
else if ( hush_chosennotary(&nid,height,scriptbuf + 1,timestamp) >= 0 )
|
else if ( hush_chosennotary(&nid,height,scriptbuf + 1,timestamp) >= 0 )
|
||||||
{
|
{
|
||||||
//printf("found notary.k%d\n",k);
|
|
||||||
if ( notaryid < 64 )
|
if ( notaryid < 64 )
|
||||||
{
|
{
|
||||||
if ( notaryid < 0 )
|
if ( notaryid < 0 )
|
||||||
@@ -569,9 +545,6 @@ int32_t hush_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryi
|
|||||||
}
|
}
|
||||||
else if ( notaryid != nid )
|
else if ( notaryid != nid )
|
||||||
{
|
{
|
||||||
//for (i=0; i<33; i++)
|
|
||||||
// printf("%02x",scriptbuf[i+1]);
|
|
||||||
//printf(" %s mismatch notaryid.%d k.%d\n",SMART_CHAIN_SYMBOL,notaryid,nid);
|
|
||||||
notaryid = 64;
|
notaryid = 64;
|
||||||
*voutmaskp = 0;
|
*voutmaskp = 0;
|
||||||
}
|
}
|
||||||
@@ -605,7 +578,6 @@ int32_t hush_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryi
|
|||||||
} else {
|
} else {
|
||||||
if ( scriptbuf[len] == 'K' )
|
if ( scriptbuf[len] == 'K' )
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"i.%d j.%d KV OPRET len.%d %.8f\n",i,j,opretlen,dstr(value));
|
|
||||||
hush_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen,j,zero,0);
|
hush_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen,j,zero,0);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
@@ -727,9 +699,6 @@ int32_t hush_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryi
|
|||||||
}
|
}
|
||||||
else if ( matched != 0 )
|
else if ( matched != 0 )
|
||||||
{
|
{
|
||||||
//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,(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++)
|
for (k=0; k<32; k++)
|
||||||
@@ -793,7 +762,6 @@ int32_t hush_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block)
|
|||||||
fprintf(stderr,"unexpected null stateptr.[%s]\n",SMART_CHAIN_SYMBOL);
|
fprintf(stderr,"unexpected null stateptr.[%s]\n",SMART_CHAIN_SYMBOL);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"%s connect.%d\n",SMART_CHAIN_SYMBOL,pindex->nHeight);
|
|
||||||
// Wallet Filter. Disabled here. Cant be activated by notaries or pools with some changes.
|
// Wallet Filter. Disabled here. Cant be activated by notaries or pools with some changes.
|
||||||
numnotaries = hush_notaries(pubkeys,pindex->GetHeight(),pindex->GetBlockTime());
|
numnotaries = hush_notaries(pubkeys,pindex->GetHeight(),pindex->GetBlockTime());
|
||||||
calc_rmd160_sha256(rmd160,pubkeys[0],33);
|
calc_rmd160_sha256(rmd160,pubkeys[0],33);
|
||||||
@@ -970,7 +938,6 @@ int32_t hush_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block)
|
|||||||
else
|
else
|
||||||
{ fprintf(stderr,"hush_connectblock: unexpected null pindex\n"); return(0); }
|
{ fprintf(stderr,"hush_connectblock: unexpected null pindex\n"); return(0); }
|
||||||
//HUSH_INITDONE = (uint32_t)time(NULL);
|
//HUSH_INITDONE = (uint32_t)time(NULL);
|
||||||
//fprintf(stderr,"%s end connect.%d\n",SMART_CHAIN_SYMBOL,pindex->GetHeight());
|
|
||||||
if (fJustCheck)
|
if (fJustCheck)
|
||||||
{
|
{
|
||||||
if ( notarizations.size() == 0 )
|
if ( notarizations.size() == 0 )
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ struct NSPV_ntzsresp *NSPV_ntzsresp_add(struct NSPV_ntzsresp *ptr)
|
|||||||
i = (rand() % (sizeof(NSPV_ntzsresp_cache)/sizeof(*NSPV_ntzsresp_cache)));
|
i = (rand() % (sizeof(NSPV_ntzsresp_cache)/sizeof(*NSPV_ntzsresp_cache)));
|
||||||
NSPV_ntzsresp_purge(&NSPV_ntzsresp_cache[i]);
|
NSPV_ntzsresp_purge(&NSPV_ntzsresp_cache[i]);
|
||||||
NSPV_ntzsresp_copy(&NSPV_ntzsresp_cache[i],ptr);
|
NSPV_ntzsresp_copy(&NSPV_ntzsresp_cache[i],ptr);
|
||||||
fprintf(stderr,"ADD CACHE ntzsresp req.%d\n",ptr->reqheight);
|
LogPrint("nspv","ADD CACHE ntzsresp req.%d\n",ptr->reqheight);
|
||||||
return(&NSPV_ntzsresp_cache[i]);
|
return(&NSPV_ntzsresp_cache[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ struct NSPV_txproof *NSPV_txproof_add(struct NSPV_txproof *ptr)
|
|||||||
i = (rand() % (sizeof(NSPV_txproof_cache)/sizeof(*NSPV_txproof_cache)));
|
i = (rand() % (sizeof(NSPV_txproof_cache)/sizeof(*NSPV_txproof_cache)));
|
||||||
NSPV_txproof_purge(&NSPV_txproof_cache[i]);
|
NSPV_txproof_purge(&NSPV_txproof_cache[i]);
|
||||||
NSPV_txproof_copy(&NSPV_txproof_cache[i],ptr);
|
NSPV_txproof_copy(&NSPV_txproof_cache[i],ptr);
|
||||||
fprintf(stderr,"ADD CACHE txproof %s\n",ptr->txid.GetHex().c_str());
|
LogPrint("nspv","ADD CACHE txproof %s\n",ptr->txid.GetHex().c_str());
|
||||||
return(&NSPV_txproof_cache[i]);
|
return(&NSPV_txproof_cache[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ struct NSPV_ntzsproofresp *NSPV_ntzsproof_add(struct NSPV_ntzsproofresp *ptr)
|
|||||||
i = (rand() % (sizeof(NSPV_ntzsproofresp_cache)/sizeof(*NSPV_ntzsproofresp_cache)));
|
i = (rand() % (sizeof(NSPV_ntzsproofresp_cache)/sizeof(*NSPV_ntzsproofresp_cache)));
|
||||||
NSPV_ntzsproofresp_purge(&NSPV_ntzsproofresp_cache[i]);
|
NSPV_ntzsproofresp_purge(&NSPV_ntzsproofresp_cache[i]);
|
||||||
NSPV_ntzsproofresp_copy(&NSPV_ntzsproofresp_cache[i],ptr);
|
NSPV_ntzsproofresp_copy(&NSPV_ntzsproofresp_cache[i],ptr);
|
||||||
fprintf(stderr,"ADD CACHE ntzsproof %s %s\n",ptr->prevtxid.GetHex().c_str(),ptr->nexttxid.GetHex().c_str());
|
LogPrint("nspv","ADD CACHE ntzsproof %s %s\n",ptr->prevtxid.GetHex().c_str(),ptr->nexttxid.GetHex().c_str());
|
||||||
return(&NSPV_ntzsproofresp_cache[i]);
|
return(&NSPV_ntzsproofresp_cache[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,13 +139,13 @@ void hush_nSPVresp(CNode *pfrom,std::vector<uint8_t> response) // received a res
|
|||||||
switch ( response[0] )
|
switch ( response[0] )
|
||||||
{
|
{
|
||||||
case NSPV_INFORESP:
|
case NSPV_INFORESP:
|
||||||
fprintf(stderr,"got version.%d info response %u size.%d height.%d\n",NSPV_inforesult.version,timestamp,(int32_t)response.size(),NSPV_inforesult.height); // update current height and ntrz status
|
LogPrint("nspv","got version.%d info response %u size.%d height.%d\n",NSPV_inforesult.version,timestamp,(int32_t)response.size(),NSPV_inforesult.height); // update current height and ntrz status
|
||||||
I = NSPV_inforesult;
|
I = NSPV_inforesult;
|
||||||
NSPV_inforesp_purge(&NSPV_inforesult);
|
NSPV_inforesp_purge(&NSPV_inforesult);
|
||||||
NSPV_rwinforesp(0,&response[1],&NSPV_inforesult);
|
NSPV_rwinforesp(0,&response[1],&NSPV_inforesult);
|
||||||
if ( NSPV_inforesult.height < I.height )
|
if ( NSPV_inforesult.height < I.height )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"got old info response %u size.%d height.%d\n",timestamp,(int32_t)response.size(),NSPV_inforesult.height); // update current height and ntrz status
|
LogPrint("nspv","got old info response %u size.%d height.%d\n",timestamp,(int32_t)response.size(),NSPV_inforesult.height); // update current height and ntrz status
|
||||||
NSPV_inforesp_purge(&NSPV_inforesult);
|
NSPV_inforesp_purge(&NSPV_inforesult);
|
||||||
NSPV_inforesult = I;
|
NSPV_inforesult = I;
|
||||||
}
|
}
|
||||||
@@ -160,56 +160,56 @@ void hush_nSPVresp(CNode *pfrom,std::vector<uint8_t> response) // received a res
|
|||||||
case NSPV_UTXOSRESP:
|
case NSPV_UTXOSRESP:
|
||||||
NSPV_utxosresp_purge(&NSPV_utxosresult);
|
NSPV_utxosresp_purge(&NSPV_utxosresult);
|
||||||
NSPV_rwutxosresp(0,&response[1],&NSPV_utxosresult);
|
NSPV_rwutxosresp(0,&response[1],&NSPV_utxosresult);
|
||||||
fprintf(stderr,"got utxos response %u size.%d\n",timestamp,(int32_t)response.size());
|
LogPrint("nspv","got utxos response %u size.%d\n",timestamp,(int32_t)response.size());
|
||||||
break;
|
break;
|
||||||
case NSPV_TXIDSRESP:
|
case NSPV_TXIDSRESP:
|
||||||
NSPV_txidsresp_purge(&NSPV_txidsresult);
|
NSPV_txidsresp_purge(&NSPV_txidsresult);
|
||||||
NSPV_rwtxidsresp(0,&response[1],&NSPV_txidsresult);
|
NSPV_rwtxidsresp(0,&response[1],&NSPV_txidsresult);
|
||||||
fprintf(stderr,"got txids response %u size.%d %s CC.%d num.%d\n",timestamp,(int32_t)response.size(),NSPV_txidsresult.coinaddr,NSPV_txidsresult.CCflag,NSPV_txidsresult.numtxids);
|
LogPrint("nspv","got txids response %u size.%d %s CC.%d num.%d\n",timestamp,(int32_t)response.size(),NSPV_txidsresult.coinaddr,NSPV_txidsresult.CCflag,NSPV_txidsresult.numtxids);
|
||||||
break;
|
break;
|
||||||
case NSPV_MEMPOOLRESP:
|
case NSPV_MEMPOOLRESP:
|
||||||
NSPV_mempoolresp_purge(&NSPV_mempoolresult);
|
NSPV_mempoolresp_purge(&NSPV_mempoolresult);
|
||||||
NSPV_rwmempoolresp(0,&response[1],&NSPV_mempoolresult);
|
NSPV_rwmempoolresp(0,&response[1],&NSPV_mempoolresult);
|
||||||
fprintf(stderr,"got mempool response %u size.%d %s CC.%d num.%d funcid.%d %s/v%d\n",timestamp,(int32_t)response.size(),NSPV_mempoolresult.coinaddr,NSPV_mempoolresult.CCflag,NSPV_mempoolresult.numtxids,NSPV_mempoolresult.funcid,NSPV_mempoolresult.txid.GetHex().c_str(),NSPV_mempoolresult.vout);
|
LogPrint("nspv","got mempool response %u size.%d %s CC.%d num.%d funcid.%d %s/v%d\n",timestamp,(int32_t)response.size(),NSPV_mempoolresult.coinaddr,NSPV_mempoolresult.CCflag,NSPV_mempoolresult.numtxids,NSPV_mempoolresult.funcid,NSPV_mempoolresult.txid.GetHex().c_str(),NSPV_mempoolresult.vout);
|
||||||
break;
|
break;
|
||||||
case NSPV_NTZSRESP:
|
case NSPV_NTZSRESP:
|
||||||
NSPV_ntzsresp_purge(&NSPV_ntzsresult);
|
NSPV_ntzsresp_purge(&NSPV_ntzsresult);
|
||||||
NSPV_rwntzsresp(0,&response[1],&NSPV_ntzsresult);
|
NSPV_rwntzsresp(0,&response[1],&NSPV_ntzsresult);
|
||||||
if ( NSPV_ntzsresp_find(NSPV_ntzsresult.reqheight) == 0 )
|
if ( NSPV_ntzsresp_find(NSPV_ntzsresult.reqheight) == 0 )
|
||||||
NSPV_ntzsresp_add(&NSPV_ntzsresult);
|
NSPV_ntzsresp_add(&NSPV_ntzsresult);
|
||||||
fprintf(stderr,"got ntzs response %u size.%d %s prev.%d, %s next.%d\n",timestamp,(int32_t)response.size(),NSPV_ntzsresult.prevntz.txid.GetHex().c_str(),NSPV_ntzsresult.prevntz.height,NSPV_ntzsresult.nextntz.txid.GetHex().c_str(),NSPV_ntzsresult.nextntz.height);
|
LogPrint("nspv","got ntzs response %u size.%d %s prev.%d, %s next.%d\n",timestamp,(int32_t)response.size(),NSPV_ntzsresult.prevntz.txid.GetHex().c_str(),NSPV_ntzsresult.prevntz.height,NSPV_ntzsresult.nextntz.txid.GetHex().c_str(),NSPV_ntzsresult.nextntz.height);
|
||||||
break;
|
break;
|
||||||
case NSPV_NTZSPROOFRESP:
|
case NSPV_NTZSPROOFRESP:
|
||||||
NSPV_ntzsproofresp_purge(&NSPV_ntzsproofresult);
|
NSPV_ntzsproofresp_purge(&NSPV_ntzsproofresult);
|
||||||
NSPV_rwntzsproofresp(0,&response[1],&NSPV_ntzsproofresult);
|
NSPV_rwntzsproofresp(0,&response[1],&NSPV_ntzsproofresult);
|
||||||
if ( NSPV_ntzsproof_find(NSPV_ntzsproofresult.prevtxid,NSPV_ntzsproofresult.nexttxid) == 0 )
|
if ( NSPV_ntzsproof_find(NSPV_ntzsproofresult.prevtxid,NSPV_ntzsproofresult.nexttxid) == 0 )
|
||||||
NSPV_ntzsproof_add(&NSPV_ntzsproofresult);
|
NSPV_ntzsproof_add(&NSPV_ntzsproofresult);
|
||||||
fprintf(stderr,"got ntzproof response %u size.%d prev.%d next.%d\n",timestamp,(int32_t)response.size(),NSPV_ntzsproofresult.common.prevht,NSPV_ntzsproofresult.common.nextht);
|
LogPrint("nspv","got ntzproof response %u size.%d prev.%d next.%d\n",timestamp,(int32_t)response.size(),NSPV_ntzsproofresult.common.prevht,NSPV_ntzsproofresult.common.nextht);
|
||||||
break;
|
break;
|
||||||
case NSPV_TXPROOFRESP:
|
case NSPV_TXPROOFRESP:
|
||||||
NSPV_txproof_purge(&NSPV_txproofresult);
|
NSPV_txproof_purge(&NSPV_txproofresult);
|
||||||
NSPV_rwtxproof(0,&response[1],&NSPV_txproofresult);
|
NSPV_rwtxproof(0,&response[1],&NSPV_txproofresult);
|
||||||
if ( NSPV_txproof_find(NSPV_txproofresult.txid) == 0 )
|
if ( NSPV_txproof_find(NSPV_txproofresult.txid) == 0 )
|
||||||
NSPV_txproof_add(&NSPV_txproofresult);
|
NSPV_txproof_add(&NSPV_txproofresult);
|
||||||
fprintf(stderr,"got txproof response %u size.%d %s ht.%d\n",timestamp,(int32_t)response.size(),NSPV_txproofresult.txid.GetHex().c_str(),NSPV_txproofresult.height);
|
LogPrint("nspv","got txproof response %u size.%d %s ht.%d\n",timestamp,(int32_t)response.size(),NSPV_txproofresult.txid.GetHex().c_str(),NSPV_txproofresult.height);
|
||||||
break;
|
break;
|
||||||
case NSPV_SPENTINFORESP:
|
case NSPV_SPENTINFORESP:
|
||||||
NSPV_spentinfo_purge(&NSPV_spentresult);
|
NSPV_spentinfo_purge(&NSPV_spentresult);
|
||||||
NSPV_rwspentinfo(0,&response[1],&NSPV_spentresult);
|
NSPV_rwspentinfo(0,&response[1],&NSPV_spentresult);
|
||||||
fprintf(stderr,"got spentinfo response %u size.%d\n",timestamp,(int32_t)response.size());
|
LogPrint("nspv","got spentinfo response %u size.%d\n",timestamp,(int32_t)response.size());
|
||||||
break;
|
break;
|
||||||
case NSPV_BROADCASTRESP:
|
case NSPV_BROADCASTRESP:
|
||||||
NSPV_broadcast_purge(&NSPV_broadcastresult);
|
NSPV_broadcast_purge(&NSPV_broadcastresult);
|
||||||
NSPV_rwbroadcastresp(0,&response[1],&NSPV_broadcastresult);
|
NSPV_rwbroadcastresp(0,&response[1],&NSPV_broadcastresult);
|
||||||
fprintf(stderr,"got broadcast response %u size.%d %s retcode.%d\n",timestamp,(int32_t)response.size(),NSPV_broadcastresult.txid.GetHex().c_str(),NSPV_broadcastresult.retcode);
|
LogPrint("nspv","got broadcast response %u size.%d %s retcode.%d\n",timestamp,(int32_t)response.size(),NSPV_broadcastresult.txid.GetHex().c_str(),NSPV_broadcastresult.retcode);
|
||||||
break;
|
break;
|
||||||
case NSPV_CCMODULEUTXOSRESP:
|
case NSPV_CCMODULEUTXOSRESP:
|
||||||
NSPV_utxosresp_purge(&NSPV_utxosresult);
|
NSPV_utxosresp_purge(&NSPV_utxosresult);
|
||||||
NSPV_rwutxosresp(0, &response[1], &NSPV_utxosresult);
|
NSPV_rwutxosresp(0, &response[1], &NSPV_utxosresult);
|
||||||
fprintf(stderr, "got cc module utxos response %u size.%d\n", timestamp, (int32_t)response.size());
|
LogPrint("nspv", "got cc module utxos response %u size.%d\n", timestamp, (int32_t)response.size());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: fprintf(stderr,"unexpected response %02x size.%d at %u\n",response[0],(int32_t)response.size(),timestamp);
|
default: LogPrint("nspv","unexpected response %02x size.%d at %u\n",response[0],(int32_t)response.size(),timestamp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -254,7 +254,7 @@ CNode *NSPV_req(CNode *pnode,uint8_t *msg,int32_t len,uint64_t mask,int32_t ind)
|
|||||||
pnode->PushMessage("getnSPV",request);
|
pnode->PushMessage("getnSPV",request);
|
||||||
pnode->prevtimes[ind] = timestamp;
|
pnode->prevtimes[ind] = timestamp;
|
||||||
return(pnode);
|
return(pnode);
|
||||||
} else fprintf(stderr,"no pnodes\n");
|
} else LogPrint("nspv","no pnodes\n");
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,7 +263,7 @@ UniValue NSPV_logout()
|
|||||||
UniValue result(UniValue::VOBJ);
|
UniValue result(UniValue::VOBJ);
|
||||||
result.push_back(Pair("result","success"));
|
result.push_back(Pair("result","success"));
|
||||||
if ( NSPV_logintime != 0 )
|
if ( NSPV_logintime != 0 )
|
||||||
fprintf(stderr,"scrub wif and privkey from NSPV memory\n");
|
LogPrint("nspv","scrub wif and privkey from NSPV memory\n");
|
||||||
else result.push_back(Pair("status","wasnt logged in"));
|
else result.push_back(Pair("status","wasnt logged in"));
|
||||||
memset(NSPV_ntzsproofresp_cache,0,sizeof(NSPV_ntzsproofresp_cache));
|
memset(NSPV_ntzsproofresp_cache,0,sizeof(NSPV_ntzsproofresp_cache));
|
||||||
memset(NSPV_txproof_cache,0,sizeof(NSPV_txproof_cache));
|
memset(NSPV_txproof_cache,0,sizeof(NSPV_txproof_cache));
|
||||||
@@ -294,7 +294,6 @@ void hush_nSPV(CNode *pto) // polling loop from SendMessages
|
|||||||
len = 0;
|
len = 0;
|
||||||
msg[len++] = NSPV_INFO;
|
msg[len++] = NSPV_INFO;
|
||||||
len += dragon_rwnum(1,&msg[len],sizeof(reqht),&reqht);
|
len += dragon_rwnum(1,&msg[len],sizeof(reqht),&reqht);
|
||||||
//fprintf(stderr,"issue getinfo\n");
|
|
||||||
NSPV_req(pto,msg,len,NODE_NSPV,NSPV_INFO>>1);
|
NSPV_req(pto,msg,len,NODE_NSPV,NSPV_INFO>>1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -485,7 +484,6 @@ UniValue NSPV_ntzsproof_json(struct NSPV_ntzsproofresp *ptr)
|
|||||||
result.push_back(Pair("numhdrs",(int64_t)ptr->common.numhdrs));
|
result.push_back(Pair("numhdrs",(int64_t)ptr->common.numhdrs));
|
||||||
result.push_back(Pair("headers",NSPV_headers_json(ptr->common.hdrs,ptr->common.numhdrs,ptr->common.prevht)));
|
result.push_back(Pair("headers",NSPV_headers_json(ptr->common.hdrs,ptr->common.numhdrs,ptr->common.prevht)));
|
||||||
result.push_back(Pair("lastpeer",NSPV_lastpeer));
|
result.push_back(Pair("lastpeer",NSPV_lastpeer));
|
||||||
//fprintf(stderr,"ntzs_proof %s %d, %s %d\n",ptr->prevtxid.GetHex().c_str(),ptr->common.prevht,ptr->nexttxid.GetHex().c_str(),ptr->common.nextht);
|
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -577,7 +575,7 @@ uint32_t NSPV_blocktime(int32_t hdrheight)
|
|||||||
{
|
{
|
||||||
timestamp = NSPV_inforesult.H.nTime;
|
timestamp = NSPV_inforesult.H.nTime;
|
||||||
NSPV_inforesult = old;
|
NSPV_inforesult = old;
|
||||||
fprintf(stderr,"NSPV_blocktime ht.%d -> t%u\n",hdrheight,timestamp);
|
LogPrint("nspv","NSPV_blocktime ht.%d -> t%u\n",hdrheight,timestamp);
|
||||||
return(timestamp);
|
return(timestamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -588,7 +586,6 @@ uint32_t NSPV_blocktime(int32_t hdrheight)
|
|||||||
UniValue NSPV_addressutxos(char *coinaddr,int32_t CCflag,int32_t skipcount,int32_t filter)
|
UniValue NSPV_addressutxos(char *coinaddr,int32_t CCflag,int32_t skipcount,int32_t filter)
|
||||||
{
|
{
|
||||||
UniValue result(UniValue::VOBJ); uint8_t msg[512]; int32_t i,iter,slen,len = 0;
|
UniValue result(UniValue::VOBJ); uint8_t msg[512]; int32_t i,iter,slen,len = 0;
|
||||||
//fprintf(stderr,"utxos %s NSPV addr %s\n",coinaddr,NSPV_address.c_str());
|
|
||||||
//if ( NSPV_utxosresult.nodeheight >= NSPV_inforesult.height && strcmp(coinaddr,NSPV_utxosresult.coinaddr) == 0 && CCflag == NSPV_utxosresult.CCflag && skipcount == NSPV_utxosresult.skipcount && filter == NSPV_utxosresult.filter )
|
//if ( NSPV_utxosresult.nodeheight >= NSPV_inforesult.height && strcmp(coinaddr,NSPV_utxosresult.coinaddr) == 0 && CCflag == NSPV_utxosresult.CCflag && skipcount == NSPV_utxosresult.skipcount && filter == NSPV_utxosresult.filter )
|
||||||
// return(NSPV_utxosresp_json(&NSPV_utxosresult));
|
// return(NSPV_utxosresp_json(&NSPV_utxosresult));
|
||||||
if ( skipcount < 0 )
|
if ( skipcount < 0 )
|
||||||
@@ -644,7 +641,6 @@ UniValue NSPV_addresstxids(char *coinaddr,int32_t CCflag,int32_t skipcount,int32
|
|||||||
msg[len++] = (CCflag != 0);
|
msg[len++] = (CCflag != 0);
|
||||||
len += dragon_rwnum(1,&msg[len],sizeof(skipcount),&skipcount);
|
len += dragon_rwnum(1,&msg[len],sizeof(skipcount),&skipcount);
|
||||||
len += dragon_rwnum(1,&msg[len],sizeof(filter),&filter);
|
len += dragon_rwnum(1,&msg[len],sizeof(filter),&filter);
|
||||||
//fprintf(stderr,"skipcount.%d\n",skipcount);
|
|
||||||
for (iter=0; iter<3; iter++)
|
for (iter=0; iter<3; iter++)
|
||||||
if ( NSPV_req(0,msg,len,NODE_ADDRINDEX,msg[0]>>1) != 0 )
|
if ( NSPV_req(0,msg,len,NODE_ADDRINDEX,msg[0]>>1) != 0 )
|
||||||
{
|
{
|
||||||
@@ -683,7 +679,7 @@ UniValue NSPV_ccaddresstxids(char *coinaddr,int32_t CCflag,int32_t skipcount,uin
|
|||||||
slen = (int32_t)strlen(coinaddr);
|
slen = (int32_t)strlen(coinaddr);
|
||||||
msg[len++] = slen;
|
msg[len++] = slen;
|
||||||
memcpy(&msg[len],coinaddr,slen), len += slen;
|
memcpy(&msg[len],coinaddr,slen), len += slen;
|
||||||
fprintf(stderr,"(%s) func.%d CC.%d %s skipcount.%d len.%d\n",coinaddr,NSPV_CC_TXIDS,CCflag,filtertxid.GetHex().c_str(),skipcount,len);
|
LogPrint("nspv","(%s) func.%d CC.%d %s skipcount.%d len.%d\n",coinaddr,NSPV_CC_TXIDS,CCflag,filtertxid.GetHex().c_str(),skipcount,len);
|
||||||
for (iter=0; iter<3; iter++)
|
for (iter=0; iter<3; iter++)
|
||||||
if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 )
|
if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 )
|
||||||
{
|
{
|
||||||
@@ -721,7 +717,7 @@ UniValue NSPV_mempooltxids(char *coinaddr,int32_t CCflag,uint8_t funcid,uint256
|
|||||||
slen = (int32_t)strlen(coinaddr);
|
slen = (int32_t)strlen(coinaddr);
|
||||||
msg[len++] = slen;
|
msg[len++] = slen;
|
||||||
memcpy(&msg[len],coinaddr,slen), len += slen;
|
memcpy(&msg[len],coinaddr,slen), len += slen;
|
||||||
fprintf(stderr,"(%s) func.%d CC.%d %s/v%d len.%d\n",coinaddr,funcid,CCflag,txid.GetHex().c_str(),vout,len);
|
LogPrint("nspv","(%s) func.%d CC.%d %s/v%d len.%d\n",coinaddr,funcid,CCflag,txid.GetHex().c_str(),vout,len);
|
||||||
for (iter=0; iter<3; iter++)
|
for (iter=0; iter<3; iter++)
|
||||||
if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 )
|
if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 )
|
||||||
{
|
{
|
||||||
@@ -782,7 +778,7 @@ UniValue NSPV_notarizations(int32_t reqheight)
|
|||||||
uint8_t msg[512]; int32_t i,iter,len = 0; struct NSPV_ntzsresp N,*ptr;
|
uint8_t msg[512]; int32_t i,iter,len = 0; struct NSPV_ntzsresp N,*ptr;
|
||||||
if ( (ptr= NSPV_ntzsresp_find(reqheight)) != 0 )
|
if ( (ptr= NSPV_ntzsresp_find(reqheight)) != 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"FROM CACHE NSPV_notarizations.%d\n",reqheight);
|
LogPrint("nspv","FROM CACHE NSPV_notarizations.%d\n",reqheight);
|
||||||
NSPV_ntzsresp_purge(&NSPV_ntzsresult);
|
NSPV_ntzsresp_purge(&NSPV_ntzsresult);
|
||||||
NSPV_ntzsresp_copy(&NSPV_ntzsresult,ptr);
|
NSPV_ntzsresp_copy(&NSPV_ntzsresult,ptr);
|
||||||
return(NSPV_ntzsresp_json(ptr));
|
return(NSPV_ntzsresp_json(ptr));
|
||||||
@@ -808,7 +804,7 @@ UniValue NSPV_txidhdrsproof(uint256 prevtxid,uint256 nexttxid)
|
|||||||
uint8_t msg[512]; int32_t i,iter,len = 0; struct NSPV_ntzsproofresp P,*ptr;
|
uint8_t msg[512]; int32_t i,iter,len = 0; struct NSPV_ntzsproofresp P,*ptr;
|
||||||
if ( (ptr= NSPV_ntzsproof_find(prevtxid,nexttxid)) != 0 )
|
if ( (ptr= NSPV_ntzsproof_find(prevtxid,nexttxid)) != 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"FROM CACHE NSPV_txidhdrsproof %s %s\n",ptr->prevtxid.GetHex().c_str(),ptr->nexttxid.GetHex().c_str());
|
LogPrint("nspv","FROM CACHE NSPV_txidhdrsproof %s %s\n",ptr->prevtxid.GetHex().c_str(),ptr->nexttxid.GetHex().c_str());
|
||||||
NSPV_ntzsproofresp_purge(&NSPV_ntzsproofresult);
|
NSPV_ntzsproofresp_purge(&NSPV_ntzsproofresult);
|
||||||
NSPV_ntzsproofresp_copy(&NSPV_ntzsproofresult,ptr);
|
NSPV_ntzsproofresp_copy(&NSPV_ntzsproofresult,ptr);
|
||||||
return(NSPV_ntzsproof_json(ptr));
|
return(NSPV_ntzsproof_json(ptr));
|
||||||
@@ -846,7 +842,7 @@ UniValue NSPV_txproof(int32_t vout,uint256 txid,int32_t height)
|
|||||||
uint8_t msg[512]; int32_t i,iter,len = 0; struct NSPV_txproof P,*ptr;
|
uint8_t msg[512]; int32_t i,iter,len = 0; struct NSPV_txproof P,*ptr;
|
||||||
if ( (ptr= NSPV_txproof_find(txid)) != 0 )
|
if ( (ptr= NSPV_txproof_find(txid)) != 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"FROM CACHE NSPV_txproof %s\n",txid.GetHex().c_str());
|
LogPrint("nspv","FROM CACHE NSPV_txproof %s\n",txid.GetHex().c_str());
|
||||||
NSPV_txproof_purge(&NSPV_txproofresult);
|
NSPV_txproof_purge(&NSPV_txproofresult);
|
||||||
NSPV_txproof_copy(&NSPV_txproofresult,ptr);
|
NSPV_txproof_copy(&NSPV_txproofresult,ptr);
|
||||||
return(NSPV_txproof_json(ptr));
|
return(NSPV_txproof_json(ptr));
|
||||||
@@ -856,7 +852,7 @@ UniValue NSPV_txproof(int32_t vout,uint256 txid,int32_t height)
|
|||||||
len += dragon_rwnum(1,&msg[len],sizeof(height),&height);
|
len += dragon_rwnum(1,&msg[len],sizeof(height),&height);
|
||||||
len += dragon_rwnum(1,&msg[len],sizeof(vout),&vout);
|
len += dragon_rwnum(1,&msg[len],sizeof(vout),&vout);
|
||||||
len += dragon_rwbignum(1,&msg[len],sizeof(txid),(uint8_t *)&txid);
|
len += dragon_rwbignum(1,&msg[len],sizeof(txid),(uint8_t *)&txid);
|
||||||
fprintf(stderr,"req txproof %s/v%d at height.%d\n",txid.GetHex().c_str(),vout,height);
|
LogPrint("nspv","req txproof %s/v%d at height.%d\n",txid.GetHex().c_str(),vout,height);
|
||||||
for (iter=0; iter<3; iter++)
|
for (iter=0; iter<3; iter++)
|
||||||
if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 )
|
if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 )
|
||||||
{
|
{
|
||||||
@@ -867,7 +863,7 @@ UniValue NSPV_txproof(int32_t vout,uint256 txid,int32_t height)
|
|||||||
return(NSPV_txproof_json(&NSPV_txproofresult));
|
return(NSPV_txproof_json(&NSPV_txproofresult));
|
||||||
}
|
}
|
||||||
} else sleep(1);
|
} else sleep(1);
|
||||||
fprintf(stderr,"txproof timeout\n");
|
LogPrint("nspv","txproof timeout\n");
|
||||||
memset(&P,0,sizeof(P));
|
memset(&P,0,sizeof(P));
|
||||||
return(NSPV_txproof_json(&P));
|
return(NSPV_txproof_json(&P));
|
||||||
}
|
}
|
||||||
@@ -907,7 +903,6 @@ UniValue NSPV_broadcast(char *hex)
|
|||||||
len += dragon_rwnum(1,&msg[len],sizeof(n),&n);
|
len += dragon_rwnum(1,&msg[len],sizeof(n),&n);
|
||||||
memcpy(&msg[len],data,n), len += n;
|
memcpy(&msg[len],data,n), len += n;
|
||||||
free(data);
|
free(data);
|
||||||
//fprintf(stderr,"send txid.%s\n",txid.GetHex().c_str());
|
|
||||||
for (iter=0; iter<3; iter++)
|
for (iter=0; iter<3; iter++)
|
||||||
if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 )
|
if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ int32_t NSPV_validatehdrs(struct NSPV_ntzsproofresp *ptr)
|
|||||||
int32_t i,height,txidht; CTransaction tx; uint256 blockhash,txid,desttxid;
|
int32_t i,height,txidht; CTransaction tx; uint256 blockhash,txid,desttxid;
|
||||||
if ( (ptr->common.nextht-ptr->common.prevht+1) != ptr->common.numhdrs )
|
if ( (ptr->common.nextht-ptr->common.prevht+1) != ptr->common.numhdrs )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"next.%d prev.%d -> %d vs %d\n",ptr->common.nextht,ptr->common.prevht,ptr->common.nextht-ptr->common.prevht+1,ptr->common.numhdrs);
|
LogPrintf("next.%d prev.%d -> %d vs %d\n",ptr->common.nextht,ptr->common.prevht,ptr->common.nextht-ptr->common.prevht+1,ptr->common.numhdrs);
|
||||||
return(-2);
|
return(-2);
|
||||||
}
|
}
|
||||||
else if ( NSPV_txextract(tx,ptr->nextntz,ptr->nexttxlen) < 0 )
|
else if ( NSPV_txextract(tx,ptr->nextntz,ptr->nexttxlen) < 0 )
|
||||||
@@ -64,7 +64,6 @@ int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int
|
|||||||
struct NSPV_txproof *ptr; int32_t i,offset,retval; int64_t rewards = 0; uint32_t nLockTime; std::vector<uint8_t> proof;
|
struct NSPV_txproof *ptr; int32_t i,offset,retval; int64_t rewards = 0; uint32_t nLockTime; std::vector<uint8_t> proof;
|
||||||
retval = skipvalidation != 0 ? 0 : -1;
|
retval = skipvalidation != 0 ? 0 : -1;
|
||||||
|
|
||||||
//fprintf(stderr,"NSPV_gettx %s/v%d ht.%d\n",txid.GetHex().c_str(),vout,height);
|
|
||||||
if ( (ptr= NSPV_txproof_find(txid)) == 0 )
|
if ( (ptr= NSPV_txproof_find(txid)) == 0 )
|
||||||
{
|
{
|
||||||
NSPV_txproof(vout,txid,height);
|
NSPV_txproof(vout,txid,height);
|
||||||
@@ -75,7 +74,7 @@ int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int
|
|||||||
currentheight=NSPV_inforesult.height;
|
currentheight=NSPV_inforesult.height;
|
||||||
if ( ptr->txid != txid )
|
if ( ptr->txid != txid )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"txproof error %s != %s\n",ptr->txid.GetHex().c_str(),txid.GetHex().c_str());
|
LogPrintf("txproof error %s != %s\n",ptr->txid.GetHex().c_str(),txid.GetHex().c_str());
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
else if ( NSPV_txextract(tx,ptr->tx,ptr->txlen) < 0 || ptr->txlen <= 0 )
|
else if ( NSPV_txextract(tx,ptr->tx,ptr->txlen) < 0 || ptr->txlen <= 0 )
|
||||||
@@ -87,8 +86,7 @@ int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int
|
|||||||
|
|
||||||
//char coinaddr[64];
|
//char coinaddr[64];
|
||||||
//Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); causes crash??
|
//Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); causes crash??
|
||||||
//fprintf(stderr,"%s txid.%s vs hash.%s\n",coinaddr,txid.GetHex().c_str(),tx.GetHash().GetHex().c_str());
|
|
||||||
|
|
||||||
if ( skipvalidation == 0 )
|
if ( skipvalidation == 0 )
|
||||||
{
|
{
|
||||||
if ( ptr->txprooflen > 0 )
|
if ( ptr->txprooflen > 0 )
|
||||||
@@ -99,18 +97,17 @@ int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int
|
|||||||
NSPV_notarizations(height); // gets the prev and next notarizations
|
NSPV_notarizations(height); // gets the prev and next notarizations
|
||||||
if ( NSPV_inforesult.notarization.height >= height && (NSPV_ntzsresult.prevntz.height == 0 || NSPV_ntzsresult.prevntz.height >= NSPV_ntzsresult.nextntz.height) )
|
if ( NSPV_inforesult.notarization.height >= height && (NSPV_ntzsresult.prevntz.height == 0 || NSPV_ntzsresult.prevntz.height >= NSPV_ntzsresult.nextntz.height) )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"issue manual bracket\n");
|
LogPrintf("issue manual bracket\n");
|
||||||
NSPV_notarizations(height-1);
|
NSPV_notarizations(height-1);
|
||||||
NSPV_notarizations(height+1);
|
NSPV_notarizations(height+1);
|
||||||
NSPV_notarizations(height); // gets the prev and next notarizations
|
NSPV_notarizations(height); // gets the prev and next notarizations
|
||||||
}
|
}
|
||||||
if ( NSPV_ntzsresult.prevntz.height != 0 && NSPV_ntzsresult.prevntz.height <= NSPV_ntzsresult.nextntz.height )
|
if ( NSPV_ntzsresult.prevntz.height != 0 && NSPV_ntzsresult.prevntz.height <= NSPV_ntzsresult.nextntz.height )
|
||||||
{
|
{
|
||||||
fprintf(stderr,">>>>> gettx ht.%d prev.%d next.%d\n",height,NSPV_ntzsresult.prevntz.height, NSPV_ntzsresult.nextntz.height);
|
LogPrintf(">>>>> gettx ht.%d prev.%d next.%d\n",height,NSPV_ntzsresult.prevntz.height, NSPV_ntzsresult.nextntz.height);
|
||||||
offset = (height - NSPV_ntzsresult.prevntz.height);
|
offset = (height - NSPV_ntzsresult.prevntz.height);
|
||||||
if ( offset >= 0 && height <= NSPV_ntzsresult.nextntz.height )
|
if ( offset >= 0 && height <= NSPV_ntzsresult.nextntz.height )
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"call NSPV_txidhdrsproof %s %s\n",NSPV_ntzsresult.prevntz.txid.GetHex().c_str(),NSPV_ntzsresult.nextntz.txid.GetHex().c_str());
|
|
||||||
NSPV_txidhdrsproof(NSPV_ntzsresult.prevntz.txid,NSPV_ntzsresult.nextntz.txid);
|
NSPV_txidhdrsproof(NSPV_ntzsresult.prevntz.txid,NSPV_ntzsresult.nextntz.txid);
|
||||||
usleep(10000);
|
usleep(10000);
|
||||||
if ( (retval= NSPV_validatehdrs(&NSPV_ntzsproofresult)) == 0 )
|
if ( (retval= NSPV_validatehdrs(&NSPV_ntzsproofresult)) == 0 )
|
||||||
@@ -119,8 +116,8 @@ int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int
|
|||||||
proofroot = BitcoinGetProofMerkleRoot(proof,txids);
|
proofroot = BitcoinGetProofMerkleRoot(proof,txids);
|
||||||
if ( proofroot != NSPV_ntzsproofresult.common.hdrs[offset].hashMerkleRoot || txids[0] != txid )
|
if ( proofroot != NSPV_ntzsproofresult.common.hdrs[offset].hashMerkleRoot || txids[0] != txid )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"txid.%s vs txids[0] %s\n",txid.GetHex().c_str(),txids[0].GetHex().c_str());
|
LogPrintf("txid.%s vs txids[0] %s\n",txid.GetHex().c_str(),txids[0].GetHex().c_str());
|
||||||
fprintf(stderr,"prooflen.%d proofroot.%s vs %s\n",(int32_t)proof.size(),proofroot.GetHex().c_str(),NSPV_ntzsproofresult.common.hdrs[offset].hashMerkleRoot.GetHex().c_str());
|
LogPrintf("prooflen.%d proofroot.%s vs %s\n",(int32_t)proof.size(),proofroot.GetHex().c_str(),NSPV_ntzsproofresult.common.hdrs[offset].hashMerkleRoot.GetHex().c_str());
|
||||||
retval = -2003;
|
retval = -2003;
|
||||||
} else retval = 0;
|
} else retval = 0;
|
||||||
}
|
}
|
||||||
@@ -162,13 +159,11 @@ int32_t NSPV_vinselect(int32_t *aboveip,int64_t *abovep,int32_t *belowip,int64_t
|
|||||||
belowi = i;
|
belowi = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//printf("value %.8f gap %.8f abovei.%d %.8f belowi.%d %.8f\n",dstr(value),dstr(gap),abovei,dstr(above),belowi,dstr(below));
|
|
||||||
}
|
}
|
||||||
*aboveip = abovei;
|
*aboveip = abovei;
|
||||||
*abovep = above;
|
*abovep = above;
|
||||||
*belowip = belowi;
|
*belowip = belowi;
|
||||||
*belowp = below;
|
*belowp = below;
|
||||||
//printf("above.%d below.%d\n",abovei,belowi);
|
|
||||||
if ( abovei >= 0 && belowi >= 0 )
|
if ( abovei >= 0 && belowi >= 0 )
|
||||||
{
|
{
|
||||||
if ( above < (below >> 1) )
|
if ( above < (below >> 1) )
|
||||||
@@ -195,14 +190,13 @@ int64_t NSPV_addinputs(struct NSPV_utxoresp *used,CMutableTransaction &mtx,int64
|
|||||||
utxos[n++] = ptr[i];
|
utxos[n++] = ptr[i];
|
||||||
}
|
}
|
||||||
remains = total;
|
remains = total;
|
||||||
//fprintf(stderr,"threshold %.8f n.%d for total %.8f\n",(double)threshold/COIN,n,(double)total/COIN);
|
|
||||||
for (i=0; i<maxinputs && n>0; i++)
|
for (i=0; i<maxinputs && n>0; i++)
|
||||||
{
|
{
|
||||||
below = above = 0;
|
below = above = 0;
|
||||||
abovei = belowi = -1;
|
abovei = belowi = -1;
|
||||||
if ( NSPV_vinselect(&abovei,&above,&belowi,&below,utxos,n,remains) < 0 )
|
if ( NSPV_vinselect(&abovei,&above,&belowi,&below,utxos,n,remains) < 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"error finding unspent i.%d of %d, %.8f vs %.8f\n",i,n,(double)remains/COIN,(double)total/COIN);
|
LogPrintf("error finding unspent i.%d of %d, %.8f vs %.8f\n",i,n,(double)remains/COIN,(double)total/COIN);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
if ( belowi < 0 || abovei >= 0 )
|
if ( belowi < 0 || abovei >= 0 )
|
||||||
@@ -210,10 +204,9 @@ int64_t NSPV_addinputs(struct NSPV_utxoresp *used,CMutableTransaction &mtx,int64
|
|||||||
else ind = belowi;
|
else ind = belowi;
|
||||||
if ( ind < 0 )
|
if ( ind < 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"error finding unspent i.%d of %d, %.8f vs %.8f, abovei.%d belowi.%d ind.%d\n",i,n,(double)remains/COIN,(double)total/COIN,abovei,belowi,ind);
|
LogPrintf("error finding unspent i.%d of %d, %.8f vs %.8f, abovei.%d belowi.%d ind.%d\n",i,n,(double)remains/COIN,(double)total/COIN,abovei,belowi,ind);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"i.%d ind.%d abovei.%d belowi.%d n.%d\n",i,ind,abovei,belowi,n);
|
|
||||||
up = &utxos[ind];
|
up = &utxos[ind];
|
||||||
mtx.vin.push_back(CTxIn(up->txid,up->vout,CScript()));
|
mtx.vin.push_back(CTxIn(up->txid,up->vout,CScript()));
|
||||||
used[i] = *up;
|
used[i] = *up;
|
||||||
@@ -221,11 +214,9 @@ int64_t NSPV_addinputs(struct NSPV_utxoresp *used,CMutableTransaction &mtx,int64
|
|||||||
remains -= up->satoshis;
|
remains -= up->satoshis;
|
||||||
utxos[ind] = utxos[--n];
|
utxos[ind] = utxos[--n];
|
||||||
memset(&utxos[n],0,sizeof(utxos[n]));
|
memset(&utxos[n],0,sizeof(utxos[n]));
|
||||||
//fprintf(stderr,"totalinputs %.8f vs total %.8f i.%d vs max.%d\n",(double)totalinputs/COIN,(double)total/COIN,i,maxinputs);
|
|
||||||
if ( totalinputs >= total || (i+1) >= maxinputs )
|
if ( totalinputs >= total || (i+1) >= maxinputs )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"totalinputs %.8f vs total %.8f\n",(double)totalinputs/COIN,(double)total/COIN);
|
|
||||||
if ( totalinputs >= total )
|
if ( totalinputs >= total )
|
||||||
return(totalinputs);
|
return(totalinputs);
|
||||||
return(0);
|
return(0);
|
||||||
@@ -236,21 +227,20 @@ bool NSPV_SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const C
|
|||||||
CTransaction txNewConst(mtx); SignatureData sigdata; CBasicKeyStore keystore; int64_t branchid = NSPV_BRANCHID;
|
CTransaction txNewConst(mtx); SignatureData sigdata; CBasicKeyStore keystore; int64_t branchid = NSPV_BRANCHID;
|
||||||
if ( NSPV_logintime == 0 || time(NULL) > NSPV_logintime+NSPV_AUTOLOGOUT )
|
if ( NSPV_logintime == 0 || time(NULL) > NSPV_logintime+NSPV_AUTOLOGOUT )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"need to be logged in to get myprivkey\n");
|
LogPrintf("need to be logged in to get myprivkey\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
keystore.AddKey(NSPV_key);
|
keystore.AddKey(NSPV_key);
|
||||||
if ( nTime != 0 && nTime < HUSH_SAPING_ACTIVATION )
|
if ( nTime != 0 && nTime < HUSH_SAPING_ACTIVATION )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"use legacy sig validation\n");
|
LogPrintf("use legacy sig validation\n");
|
||||||
branchid = 0;
|
branchid = 0;
|
||||||
}
|
}
|
||||||
if ( ProduceSignature(TransactionSignatureCreator(&keystore,&txNewConst,vini,utxovalue,SIGHASH_ALL),scriptPubKey,sigdata,branchid) != 0 )
|
if ( ProduceSignature(TransactionSignatureCreator(&keystore,&txNewConst,vini,utxovalue,SIGHASH_ALL),scriptPubKey,sigdata,branchid) != 0 )
|
||||||
{
|
{
|
||||||
UpdateTransaction(mtx,vini,sigdata);
|
UpdateTransaction(mtx,vini,sigdata);
|
||||||
fprintf(stderr,"SIG_TXHASH %s vini.%d %.8f\n",SIG_TXHASH.GetHex().c_str(),vini,(double)utxovalue/COIN);
|
|
||||||
return(true);
|
return(true);
|
||||||
} //else fprintf(stderr,"sigerr SIG_TXHASH %s vini.%d %.8f\n",SIG_TXHASH.GetHex().c_str(),vini,(double)utxovalue/COIN);
|
}
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,22 +275,21 @@ std::string NSPV_signtx(int64_t &rewardsum,int64_t &interestsum,UniValue &retcod
|
|||||||
{
|
{
|
||||||
if ( vintx.vout[utxovout].nValue != used[i].satoshis )
|
if ( vintx.vout[utxovout].nValue != used[i].satoshis )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"vintx mismatch %.8f != %.8f\n",(double)vintx.vout[utxovout].nValue/COIN,(double)used[i].satoshis/COIN);
|
LogPrintf("vintx mismatch %.8f != %.8f\n",(double)vintx.vout[utxovout].nValue/COIN,(double)used[i].satoshis/COIN);
|
||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
else if ( utxovout != used[i].vout )
|
else if ( utxovout != used[i].vout )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"vintx vout mismatch %d != %d\n",utxovout,used[i].vout);
|
LogPrintf("vintx vout mismatch %d != %d\n",utxovout,used[i].vout);
|
||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
else if ( NSPV_SignTx(mtx,i,vintx.vout[utxovout].nValue,vintx.vout[utxovout].scriptPubKey,0) == 0 )
|
else if ( NSPV_SignTx(mtx,i,vintx.vout[utxovout].nValue,vintx.vout[utxovout].scriptPubKey,0) == 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"signing error for vini.%d\n",i);
|
LogPrintf("signing error for vini.%d\n",i);
|
||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
} else fprintf(stderr,"couldnt find txid.%s/v%d or it was spent\n",mtx.vin[i].prevout.hash.GetHex().c_str(),utxovout); // of course much better handling is needed
|
} else LogPrintf("couldnt find txid.%s/v%d or it was spent\n",mtx.vin[i].prevout.hash.GetHex().c_str(),utxovout); // of course much better handling is needed
|
||||||
}
|
}
|
||||||
fprintf(stderr,"sign %d inputs %.8f + interest %.8f -> %d outputs %.8f change %.8f\n",(int32_t)mtx.vin.size(),(double)totalinputs/COIN,(double)interest/COIN,(int32_t)mtx.vout.size(),(double)totaloutputs/COIN,(double)change/COIN);
|
|
||||||
return(EncodeHexTx(mtx));
|
return(EncodeHexTx(mtx));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,7 +349,6 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a
|
|||||||
result.push_back(Pair("amount",(double)satoshis/COIN));
|
result.push_back(Pair("amount",(double)satoshis/COIN));
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
printf("%s numutxos.%d balance %.8f\n",NSPV_utxosresult.coinaddr,NSPV_utxosresult.numutxos,(double)NSPV_utxosresult.total/COIN);
|
|
||||||
CScript opret; std::string hex; struct NSPV_utxoresp used[NSPV_MAXVINS]; CMutableTransaction mtx; CTransaction tx; int64_t rewardsum=0,interestsum=0;
|
CScript opret; std::string hex; struct NSPV_utxoresp used[NSPV_MAXVINS]; CMutableTransaction mtx; CTransaction tx; int64_t rewardsum=0,interestsum=0;
|
||||||
mtx.fOverwintered = true;
|
mtx.fOverwintered = true;
|
||||||
mtx.nExpiryHeight = 0;
|
mtx.nExpiryHeight = 0;
|
||||||
@@ -428,7 +416,7 @@ int64_t NSPV_AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total
|
|||||||
NSPV_utxosresp_purge(&ptr->U);
|
NSPV_utxosresp_purge(&ptr->U);
|
||||||
NSPV_utxosresp_copy(&ptr->U,&NSPV_utxosresult);
|
NSPV_utxosresp_copy(&ptr->U,&NSPV_utxosresult);
|
||||||
// }
|
// }
|
||||||
fprintf(stderr,"%s numutxos.%d\n",ptr->U.coinaddr,ptr->U.numutxos);
|
LogPrintf("%s numutxos.%d\n",ptr->U.coinaddr,ptr->U.numutxos);
|
||||||
memset(ptr->used,0,sizeof(ptr->used));
|
memset(ptr->used,0,sizeof(ptr->used));
|
||||||
return(NSPV_addinputs(ptr->used,mtx,total,maxinputs,ptr->U.utxos,ptr->U.numutxos));
|
return(NSPV_addinputs(ptr->used,mtx,total,maxinputs,ptr->U.utxos,ptr->U.numutxos));
|
||||||
} else return(0);
|
} else return(0);
|
||||||
@@ -442,7 +430,7 @@ void NSPV_utxos2CCunspents(struct NSPV_utxosresp *ptr,std::vector<std::pair<CAdd
|
|||||||
CBitcoinAddress address(addrstr);
|
CBitcoinAddress address(addrstr);
|
||||||
if ( address.GetIndexKey(hashBytes, type, ptr->CCflag) == 0 )
|
if ( address.GetIndexKey(hashBytes, type, ptr->CCflag) == 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"couldnt get indexkey\n");
|
LogPrintf("couldnt get indexkey\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (i = 0; i < ptr->numutxos; i ++)
|
for (i = 0; i < ptr->numutxos; i ++)
|
||||||
@@ -466,7 +454,7 @@ void NSPV_txids2CCtxids(struct NSPV_txidsresp *ptr,std::vector<std::pair<CAddres
|
|||||||
CBitcoinAddress address(addrstr);
|
CBitcoinAddress address(addrstr);
|
||||||
if ( address.GetIndexKey(hashBytes, type, ptr->CCflag) == 0 )
|
if ( address.GetIndexKey(hashBytes, type, ptr->CCflag) == 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"couldnt get indexkey\n");
|
LogPrintf("couldnt get indexkey\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (i = 0; i < ptr->numtxids; i ++)
|
for (i = 0; i < ptr->numtxids; i ++)
|
||||||
|
|||||||
148
src/hush_utils.h
148
src/hush_utils.h
@@ -770,19 +770,15 @@ int32_t bitcoin_addr2rmd160(uint8_t *addrtypep,uint8_t rmd160[20],char *coinaddr
|
|||||||
memcpy(rmd160,buf+1,20);
|
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] )
|
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);
|
return(20);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int32_t i;
|
|
||||||
if ( len > 20 )
|
if ( len > 20 )
|
||||||
{
|
{
|
||||||
hash = bits256_doublesha256(0,buf,len);
|
hash = bits256_doublesha256(0,buf,len);
|
||||||
}
|
}
|
||||||
for (i=0; i<len; i++)
|
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]);
|
||||||
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]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(0);
|
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];
|
data[21+i] = hash.bytes[31-i];
|
||||||
if ( (coinaddr= bitcoin_base58encode(coinaddr,data,25)) != 0 )
|
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);
|
return(coinaddr);
|
||||||
}
|
}
|
||||||
@@ -858,7 +850,7 @@ int32_t unhex(char c)
|
|||||||
int32_t hex;
|
int32_t hex;
|
||||||
if ( (hex= _unhex(c)) < 0 )
|
if ( (hex= _unhex(c)) < 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"unhex: illegal hexchar.(%c)\n",c);
|
LogPrintf("unhex: illegal hexchar.(%c)\n",c);
|
||||||
}
|
}
|
||||||
return(hex);
|
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 decode_hex(uint8_t *bytes,int32_t n,char *hex)
|
||||||
{
|
{
|
||||||
int32_t adjust,i = 0;
|
int32_t adjust,i = 0;
|
||||||
//printf("decode.(%s)\n",hex);
|
|
||||||
if ( is_hexstr(hex,n) <= 0 )
|
if ( is_hexstr(hex,n) <= 0 )
|
||||||
{
|
{
|
||||||
memset(bytes,0,n);
|
memset(bytes,0,n);
|
||||||
@@ -881,7 +872,7 @@ int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex)
|
|||||||
if ( n > 0 )
|
if ( n > 0 )
|
||||||
{
|
{
|
||||||
bytes[0] = unhex(hex[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++;
|
bytes++;
|
||||||
hex++;
|
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] = hexbyte((message[i]>>4) & 0xf);
|
||||||
hexbytes[i*2 + 1] = hexbyte(message[i] & 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;
|
hexbytes[len*2] = 0;
|
||||||
//printf("len.%ld\n",len*2+1);
|
|
||||||
return((int32_t)len*2+1);
|
return((int32_t)len*2+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1087,7 +1076,7 @@ char *clonestr(char *str)
|
|||||||
char *clone;
|
char *clone;
|
||||||
if ( str == 0 || str[0] == 0 )
|
if ( str == 0 || str[0] == 0 )
|
||||||
{
|
{
|
||||||
printf("warning cloning nullstr.%p\n",str);
|
LogPrintf("warning cloning nullstr.%p\n",str);
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
while ( 1 ) sleep(1);
|
while ( 1 ) sleep(1);
|
||||||
#endif
|
#endif
|
||||||
@@ -1109,7 +1098,7 @@ int32_t safecopy(char *dest,char *src,long len)
|
|||||||
dest[i] = src[i];
|
dest[i] = src[i];
|
||||||
if ( i == len )
|
if ( i == len )
|
||||||
{
|
{
|
||||||
printf("safecopy: %s too long %ld\n",src,len);
|
LogPrintf("safecopy: %s too long %ld\n",src,len);
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
//getchar();
|
//getchar();
|
||||||
#endif
|
#endif
|
||||||
@@ -1131,7 +1120,6 @@ char *parse_conf_line(char *line,char *field)
|
|||||||
line++;
|
line++;
|
||||||
while ( line[strlen(line)-1] == '\r' || line[strlen(line)-1] == '\n' || line[strlen(line)-1] == ' ' )
|
while ( line[strlen(line)-1] == '\r' || line[strlen(line)-1] == '\n' || line[strlen(line)-1] == ' ' )
|
||||||
line[strlen(line)-1] = 0;
|
line[strlen(line)-1] = 0;
|
||||||
//printf("LINE.(%s)\n",line);
|
|
||||||
_stripwhite(line,0);
|
_stripwhite(line,0);
|
||||||
return(clonestr(line));
|
return(clonestr(line));
|
||||||
}
|
}
|
||||||
@@ -1141,7 +1129,6 @@ double OS_milliseconds()
|
|||||||
struct timeval tv; double millis;
|
struct timeval tv; double millis;
|
||||||
gettimeofday(&tv,NULL);
|
gettimeofday(&tv,NULL);
|
||||||
millis = ((double)tv.tv_sec * 1000. + (double)tv.tv_usec / 1000.);
|
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);
|
return(millis);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1193,7 +1180,7 @@ void queue_enqueue(char *name,queue_t *queue,struct queueitem *item)
|
|||||||
strcpy(queue->name,name);
|
strcpy(queue->name,name);
|
||||||
if ( item == 0 )
|
if ( item == 0 )
|
||||||
{
|
{
|
||||||
printf("FATAL type error: queueing empty value\n");
|
LogPrintf("FATAL type error: queueing empty value\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lock_queue(queue);
|
lock_queue(queue);
|
||||||
@@ -1230,7 +1217,7 @@ void *queue_delete(queue_t *queue,struct queueitem *copy,int32_t copysize)
|
|||||||
{
|
{
|
||||||
DL_DELETE(queue->list,item);
|
DL_DELETE(queue->list,item);
|
||||||
portable_mutex_unlock(&queue->mutex);
|
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);
|
return(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1250,7 +1237,6 @@ void *queue_free(queue_t *queue)
|
|||||||
DL_DELETE(queue->list,item);
|
DL_DELETE(queue->list,item);
|
||||||
free(item);
|
free(item);
|
||||||
}
|
}
|
||||||
//printf("name.(%s) dequeue.%p list.%p\n",queue->name,item,queue->list);
|
|
||||||
}
|
}
|
||||||
portable_mutex_unlock(&queue->mutex);
|
portable_mutex_unlock(&queue->mutex);
|
||||||
return(0);
|
return(0);
|
||||||
@@ -1268,7 +1254,6 @@ void *queue_clone(queue_t *clone,queue_t *queue,int32_t size)
|
|||||||
memcpy(ptr,item,size);
|
memcpy(ptr,item,size);
|
||||||
queue_enqueue(queue->name,clone,ptr);
|
queue_enqueue(queue->name,clone,ptr);
|
||||||
}
|
}
|
||||||
//printf("name.(%s) dequeue.%p list.%p\n",queue->name,item,queue->list);
|
|
||||||
}
|
}
|
||||||
portable_mutex_unlock(&queue->mutex);
|
portable_mutex_unlock(&queue->mutex);
|
||||||
return(0);
|
return(0);
|
||||||
@@ -1304,7 +1289,6 @@ uint16_t _hush_userpass(char *username,char *password,FILE *fp)
|
|||||||
{
|
{
|
||||||
if ( line[0] == '#' )
|
if ( line[0] == '#' )
|
||||||
continue;
|
continue;
|
||||||
//printf("line.(%s) %p %p\n",line,strstr(line,(char *)"rpcuser"),strstr(line,(char *)"rpcpassword"));
|
|
||||||
if ( (str= strstr(line,(char *)"rpcuser")) != 0 )
|
if ( (str= strstr(line,(char *)"rpcuser")) != 0 )
|
||||||
rpcuser = parse_conf_line(str,(char *)"rpcuser");
|
rpcuser = parse_conf_line(str,(char *)"rpcuser");
|
||||||
else if ( (str= strstr(line,(char *)"rpcpassword")) != 0 )
|
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 )
|
else if ( (str= strstr(line,(char *)"rpcport")) != 0 )
|
||||||
{
|
{
|
||||||
port = atoi(parse_conf_line(str,(char *)"rpcport"));
|
port = atoi(parse_conf_line(str,(char *)"rpcport"));
|
||||||
//fprintf(stderr,"rpcport.%u in file\n",port);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( rpcuser != 0 && rpcpassword != 0 )
|
if ( rpcuser != 0 && rpcpassword != 0 )
|
||||||
@@ -1320,7 +1303,6 @@ uint16_t _hush_userpass(char *username,char *password,FILE *fp)
|
|||||||
strcpy(username,rpcuser);
|
strcpy(username,rpcuser);
|
||||||
strcpy(password,rpcpassword);
|
strcpy(password,rpcpassword);
|
||||||
}
|
}
|
||||||
//printf("rpcuser.(%s) rpcpassword.(%s) HUSHUSERPASS.(%s) %u\n",rpcuser,rpcpassword,HUSHUSERPASS,port);
|
|
||||||
if ( rpcuser != 0 )
|
if ( rpcuser != 0 )
|
||||||
free(rpcuser);
|
free(rpcuser);
|
||||||
if ( rpcpassword != 0 )
|
if ( rpcpassword != 0 )
|
||||||
@@ -1340,7 +1322,7 @@ void hush_statefname(char *fname,char *symbol,char *str)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( strcmp(symbol,"ZZZ") != 0 )
|
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;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1353,7 +1335,6 @@ void hush_statefname(char *fname,char *symbol,char *str)
|
|||||||
if ( symbol != 0 && symbol[0] != 0)
|
if ( symbol != 0 && symbol[0] != 0)
|
||||||
{
|
{
|
||||||
strcat(fname,symbol);
|
strcat(fname,symbol);
|
||||||
//printf("statefname.(%s) -> (%s)\n",symbol,fname);
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
strcat(fname,"\\");
|
strcat(fname,"\\");
|
||||||
#else
|
#else
|
||||||
@@ -1361,7 +1342,6 @@ void hush_statefname(char *fname,char *symbol,char *str)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
strcat(fname,str);
|
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)
|
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);
|
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);
|
fclose(fp);
|
||||||
printf("Created (%s)\n",fname);
|
LogPrintf("Created (%s)\n",fname);
|
||||||
} else printf("Couldnt create (%s)\n",fname);
|
} else LogPrintf("Couldnt create (%s)\n",fname);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
_hush_userpass(myusername,mypassword,fp);
|
_hush_userpass(myusername,mypassword,fp);
|
||||||
mapArgs["-rpcpassword"] = mypassword;
|
mapArgs["-rpcpassword"] = mypassword;
|
||||||
mapArgs["-rpcusername"] = myusername;
|
mapArgs["-rpcusername"] = myusername;
|
||||||
//fprintf(stderr,"myusername.(%s)\n",myusername);
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1429,9 +1408,8 @@ void hush_configfile(char *symbol,uint16_t rpcport)
|
|||||||
DRAGONX_PORT = hushport;
|
DRAGONX_PORT = hushport;
|
||||||
sprintf(HUSHUSERPASS,"%s:%s",username,password);
|
sprintf(HUSHUSERPASS,"%s:%s",username,password);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
//printf("HUSH.(%s) -> userpass.(%s)\n",fname,HUSHUSERPASS);
|
|
||||||
} else {
|
} 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);
|
vcalc_sha256(0,hash.bytes,extraptr,extralen);
|
||||||
crc0 = hash.uints[0];
|
crc0 = hash.uints[0];
|
||||||
fprintf(stderr,"DragonX raw magic=");
|
LogPrintf("DragonX raw magic extralen=%d crc0=%x\n",extralen,crc0);
|
||||||
int32_t i; for (i=0; i<extralen; i++)
|
|
||||||
fprintf(stderr,"%02x",extraptr[i]);
|
|
||||||
fprintf(stderr," extralen=%d crc0=%x\n",extralen,crc0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: why is this needed?
|
//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);
|
fprintf(stderr,"%s: extralen=%d\n",__func__,extralen);
|
||||||
|
|
||||||
*magicp = hush_smartmagic(symbol,supply,extraptr,extralen);
|
*magicp = hush_smartmagic(symbol,supply,extraptr,extralen);
|
||||||
//if(fDebug)
|
LogPrintf("%s: extralen=%d, supply=%lu\n",__func__,extralen, supply);
|
||||||
fprintf(stderr,"%s: extralen=%d, supply=%lu\n",__func__,extralen, supply);
|
|
||||||
|
|
||||||
return(hush_smartport(*magicp,extralen));
|
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;
|
int32_t numhalvings = 0, curEra = 0, sign = 1;
|
||||||
static uint64_t cached_subsidy; static int32_t cached_numhalvings; static int cached_era;
|
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;
|
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
|
// check for backwards compat, older chains with no explicit rewards had 0.0001 block reward
|
||||||
if ( ASSETCHAINS_ENDSUBSIDY[0] == 0 && ASSETCHAINS_REWARD[0] == 0 ) {
|
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;
|
subsidy = 10000;
|
||||||
} else if ( (ASSETCHAINS_ENDSUBSIDY[0] == 0 && ASSETCHAINS_REWARD[0] != 0) || ASSETCHAINS_ENDSUBSIDY[0] != 0 ) {
|
} 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
|
// 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
|
// The code below is not compatible with HUSH3 mainnet
|
||||||
if ( ASSETCHAINS_DECAY[curEra] == 0 ) {
|
if ( ASSETCHAINS_DECAY[curEra] == 0 ) {
|
||||||
subsidy >>= numhalvings;
|
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 ) {
|
} else if ( ASSETCHAINS_DECAY[curEra] == 100000000 && ASSETCHAINS_ENDSUBSIDY[curEra] != 0 ) {
|
||||||
if ( curEra == ASSETCHAINS_LASTERA )
|
if ( curEra == ASSETCHAINS_LASTERA )
|
||||||
{
|
{
|
||||||
@@ -1675,12 +1647,11 @@ uint64_t hush_sc_block_subsidy(int nHeight)
|
|||||||
}
|
}
|
||||||
denominator = ASSETCHAINS_ENDSUBSIDY[curEra] - nStart;
|
denominator = ASSETCHAINS_ENDSUBSIDY[curEra] - nStart;
|
||||||
numerator = denominator - ((ASSETCHAINS_ENDSUBSIDY[curEra] - nHeight) + ((nHeight - nStart) % ASSETCHAINS_HALVING[curEra]));
|
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 ) {
|
if( denominator ) {
|
||||||
subsidy = subsidy - sign * ((subsidyDifference * numerator) / denominator);
|
subsidy = subsidy - sign * ((subsidyDifference * numerator) / denominator);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,"%s: invalid denominator=%ld !\n", __func__, denominator);
|
LogPrintf("%s: invalid denominator=%ld !\n", __func__, denominator);
|
||||||
fprintf(stderr,"%s: defaulting to 0.0001 subsidy\n",__func__);
|
LogPrintf("%s: defaulting to 0.0001 subsidy\n",__func__);
|
||||||
subsidy = 10000;
|
subsidy = 10000;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1698,13 +1669,13 @@ uint64_t hush_sc_block_subsidy(int nHeight)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
uint32_t magicExtra = ASSETCHAINS_STAKED ? ASSETCHAINS_MAGIC : (ASSETCHAINS_MAGIC & 0xffffff);
|
||||||
if ( ASSETCHAINS_SUPPLY > 10000000000 ) // over 10 billion?
|
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 )
|
if ( nHeight <= ASSETCHAINS_SUPPLY/1000000000 )
|
||||||
{
|
{
|
||||||
subsidy += (uint64_t)1000000000 * COIN;
|
subsidy += (uint64_t)1000000000 * COIN;
|
||||||
@@ -1782,7 +1753,7 @@ void hush_args(char *argv0)
|
|||||||
IS_HUSH_NOTARY = 1;
|
IS_HUSH_NOTARY = 1;
|
||||||
HUSH_MININGTHREADS = 1;
|
HUSH_MININGTHREADS = 1;
|
||||||
mapArgs ["-genproclimit"] = itostr(HUSH_MININGTHREADS);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1815,7 +1786,7 @@ void hush_args(char *argv0)
|
|||||||
|
|
||||||
vector<string> more_nodes = mapMultiArgs["-addnode"];
|
vector<string> more_nodes = mapMultiArgs["-addnode"];
|
||||||
if (more_nodes.size() > 0) {
|
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
|
// Add default DRAGONX nodes after custom addnodes, if applicable
|
||||||
if(DRAGONX_nodes.size() > 0) {
|
if(DRAGONX_nodes.size() > 0) {
|
||||||
@@ -1857,19 +1828,19 @@ void hush_args(char *argv0)
|
|||||||
if ( i > 1 && ccEnablesHeight[i-2] == ecode )
|
if ( i > 1 && ccEnablesHeight[i-2] == ecode )
|
||||||
break;
|
break;
|
||||||
if ( ecode > 255 || ecode < 0 )
|
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 )
|
else if ( ht > 0 )
|
||||||
{
|
{
|
||||||
// update global map.
|
// update global map.
|
||||||
mapHeightEvalActivate[ecode] = ht;
|
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++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (HUSH_REWIND= GetArg("-rewind",0)) != 0 )
|
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());
|
HUSH_EARLYTXID = Parseuint256(GetArg("-earlytxid","0").c_str());
|
||||||
ASSETCHAINS_EARLYTXIDCONTRACT = GetArg("-ac_earlytxidcontract",0);
|
ASSETCHAINS_EARLYTXIDCONTRACT = GetArg("-ac_earlytxidcontract",0);
|
||||||
@@ -1887,7 +1858,7 @@ void hush_args(char *argv0)
|
|||||||
STAKING_MIN_DIFF = ASSETCHAINS_MINDIFF[i];
|
STAKING_MIN_DIFF = ASSETCHAINS_MINDIFF[i];
|
||||||
// only worth mentioning if it's not equihash
|
// only worth mentioning if it's not equihash
|
||||||
if (ASSETCHAINS_ALGO != ASSETCHAINS_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;
|
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]);
|
printf("equihash values N.%li and K.%li are not currently available\n", ASSETCHAINS_NK[0], ASSETCHAINS_NK[1]);
|
||||||
exit(0);
|
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)
|
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
|
// Set our symbol from -ac_name value
|
||||||
@@ -1916,14 +1887,14 @@ void hush_args(char *argv0)
|
|||||||
} else {
|
} else {
|
||||||
ASSETCHAINS_RANDOMX_VALIDATION = 1; // all other RandomX HACs: enforce from height 1
|
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);
|
ASSETCHAINS_LASTERA = GetArg("-ac_eras", 1);
|
||||||
if ( ASSETCHAINS_LASTERA < 1 || ASSETCHAINS_LASTERA > ASSETCHAINS_MAX_ERAS )
|
if ( ASSETCHAINS_LASTERA < 1 || ASSETCHAINS_LASTERA > ASSETCHAINS_MAX_ERAS )
|
||||||
{
|
{
|
||||||
ASSETCHAINS_LASTERA = 1;
|
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;
|
ASSETCHAINS_LASTERA -= 1;
|
||||||
if(fDebug)
|
if(fDebug)
|
||||||
@@ -1934,7 +1905,7 @@ void hush_args(char *argv0)
|
|||||||
ASSETCHAINS_TIMEUNLOCKTO = GetArg("-ac_timeunlockto", 0);
|
ASSETCHAINS_TIMEUNLOCKTO = GetArg("-ac_timeunlockto", 0);
|
||||||
if ( ASSETCHAINS_TIMEUNLOCKFROM > ASSETCHAINS_TIMEUNLOCKTO )
|
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_TIMELOCKGTE = _ASSETCHAINS_TIMELOCKOFF;
|
||||||
ASSETCHAINS_TIMEUNLOCKFROM = ASSETCHAINS_TIMEUNLOCKTO = 0;
|
ASSETCHAINS_TIMEUNLOCKFROM = ASSETCHAINS_TIMEUNLOCKTO = 0;
|
||||||
}
|
}
|
||||||
@@ -1953,7 +1924,7 @@ void hush_args(char *argv0)
|
|||||||
ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script","");
|
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) {
|
if(isdragonx) {
|
||||||
// DragonX chain parameters (previously set via wrapper script)
|
// 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
|
// -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 )
|
if ( ASSETCHAINS_DECAY[i] == 100000000 && ASSETCHAINS_ENDSUBSIDY == 0 )
|
||||||
{
|
{
|
||||||
ASSETCHAINS_DECAY[i] = 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 )
|
else if ( ASSETCHAINS_DECAY[i] > 100000000 )
|
||||||
{
|
{
|
||||||
ASSETCHAINS_DECAY[i] = 0;
|
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);
|
SplitStr(GetArg("-ac_stocks",""), ASSETCHAINS_STOCKS);
|
||||||
if ( ASSETCHAINS_STOCKS.size() > 0 )
|
if ( ASSETCHAINS_STOCKS.size() > 0 )
|
||||||
ASSETCHAINS_CBOPRET |= 8;
|
ASSETCHAINS_CBOPRET |= 8;
|
||||||
for (i=0; i<ASSETCHAINS_PRICES.size(); i++)
|
LogPrintf("%d -ac_prices\n",(int32_t)ASSETCHAINS_PRICES.size());
|
||||||
fprintf(stderr,"%s ",ASSETCHAINS_PRICES[i].c_str());
|
LogPrintf("%d -ac_stocks\n",(int32_t)ASSETCHAINS_STOCKS.size());
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
hexstr = GetArg("-ac_mineropret","");
|
hexstr = GetArg("-ac_mineropret","");
|
||||||
if ( hexstr.size() != 0 )
|
if ( hexstr.size() != 0 )
|
||||||
{
|
{
|
||||||
Mineropret.resize(hexstr.size()/2);
|
Mineropret.resize(hexstr.size()/2);
|
||||||
decode_hex(Mineropret.data(),hexstr.size()/2,(char *)hexstr.c_str());
|
decode_hex(Mineropret.data(),hexstr.size()/2,(char *)hexstr.c_str());
|
||||||
for (i=0; i<Mineropret.size(); i++)
|
LogPrintf(" Mineropret\n");
|
||||||
fprintf(stderr,"%02x",Mineropret[i]);
|
|
||||||
fprintf(stderr," Mineropret\n");
|
|
||||||
}
|
}
|
||||||
if ( ASSETCHAINS_COMMISSION != 0 && ASSETCHAINS_FOUNDERS_REWARD != 0 )
|
if ( ASSETCHAINS_COMMISSION != 0 && ASSETCHAINS_FOUNDERS_REWARD != 0 )
|
||||||
{
|
{
|
||||||
@@ -2034,10 +1999,9 @@ void hush_args(char *argv0)
|
|||||||
{
|
{
|
||||||
nonz++;
|
nonz++;
|
||||||
prevCCi = ccenables[i];
|
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 )
|
if ( nonz > 0 )
|
||||||
{
|
{
|
||||||
for (i=0; i<256; i++)
|
for (i=0; i<256; i++)
|
||||||
@@ -2137,9 +2101,9 @@ void hush_args(char *argv0)
|
|||||||
if ( ASSETCHAINS_FOUNDERS_REWARD == 0 )
|
if ( ASSETCHAINS_FOUNDERS_REWARD == 0 )
|
||||||
{
|
{
|
||||||
ASSETCHAINS_COMMISSION = 53846154; // maps to 35%
|
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 {
|
} 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 )
|
/*else if ( ASSETCHAINS_SELFIMPORT.size() == 0 )
|
||||||
{
|
{
|
||||||
@@ -2151,12 +2115,12 @@ void hush_args(char *argv0)
|
|||||||
if ( ASSETCHAINS_COMMISSION != 0 )
|
if ( ASSETCHAINS_COMMISSION != 0 )
|
||||||
{
|
{
|
||||||
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 )
|
if ( ASSETCHAINS_FOUNDERS != 0 )
|
||||||
{
|
{
|
||||||
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
|
// NOTE: Hush does not use this, we use -ac_script to implement our FR -- Duke
|
||||||
if ( ASSETCHAINS_FOUNDERS_REWARD != 0 )
|
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);
|
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());
|
decode_hex(&extraptr[extralen],ASSETCHAINS_SCRIPTPUB.size()/2,(char *)ASSETCHAINS_SCRIPTPUB.c_str());
|
||||||
extralen += ASSETCHAINS_SCRIPTPUB.size()/2;
|
extralen += ASSETCHAINS_SCRIPTPUB.size()/2;
|
||||||
//extralen += dragon_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str());
|
//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 )
|
if ( ASSETCHAINS_SELFIMPORT.size() > 0 )
|
||||||
{
|
{
|
||||||
memcpy(&extraptr[extralen],(char *)ASSETCHAINS_SELFIMPORT.c_str(),ASSETCHAINS_SELFIMPORT.size());
|
memcpy(&extraptr[extralen],(char *)ASSETCHAINS_SELFIMPORT.c_str(),ASSETCHAINS_SELFIMPORT.size());
|
||||||
for (i=0; i<ASSETCHAINS_SELFIMPORT.size(); i++)
|
LogPrintf(" selfimport\n");
|
||||||
fprintf(stderr,"%c",extraptr[extralen+i]);
|
|
||||||
fprintf(stderr," selfimport\n");
|
|
||||||
extralen += ASSETCHAINS_SELFIMPORT.size();
|
extralen += ASSETCHAINS_SELFIMPORT.size();
|
||||||
}
|
}
|
||||||
if ( ASSETCHAINS_BEAMPORT != 0 )
|
if ( ASSETCHAINS_BEAMPORT != 0 )
|
||||||
@@ -2250,7 +2212,7 @@ void hush_args(char *argv0)
|
|||||||
if ( ASSETCHAINS_MARMARA != 0 )
|
if ( ASSETCHAINS_MARMARA != 0 )
|
||||||
extraptr[extralen++] = ASSETCHAINS_MARMARA;
|
extraptr[extralen++] = ASSETCHAINS_MARMARA;
|
||||||
|
|
||||||
fprintf(stderr,"extralen.%d before disable bits\n",extralen);
|
LogPrintf("extralen.%d before disable bits\n",extralen);
|
||||||
|
|
||||||
if ( nonz > 0 ) {
|
if ( nonz > 0 ) {
|
||||||
memcpy(&extraptr[extralen],disablebits,sizeof(disablebits));
|
memcpy(&extraptr[extralen],disablebits,sizeof(disablebits));
|
||||||
@@ -2261,14 +2223,13 @@ void hush_args(char *argv0)
|
|||||||
for (i=0; i<ASSETCHAINS_CCLIB.size(); i++)
|
for (i=0; i<ASSETCHAINS_CCLIB.size(); i++)
|
||||||
{
|
{
|
||||||
extraptr[extralen++] = ASSETCHAINS_CCLIB[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 ) {
|
if ( ASSETCHAINS_BLOCKTIME != 60 ) {
|
||||||
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_BLOCKTIME),(void *)&ASSETCHAINS_BLOCKTIME);
|
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 )
|
if ( Mineropret.size() != 0 )
|
||||||
@@ -2299,7 +2260,7 @@ void hush_args(char *argv0)
|
|||||||
}
|
}
|
||||||
//hush_pricesinit();
|
//hush_pricesinit();
|
||||||
hush_cbopretupdate(1); // will set Mineropret
|
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 )
|
if ( ASSETCHAINS_NK[0] != 0 && ASSETCHAINS_NK[1] != 0 )
|
||||||
{
|
{
|
||||||
@@ -2355,13 +2316,12 @@ void hush_args(char *argv0)
|
|||||||
MAX_MONEY = HUSH_MAXNVALUE;
|
MAX_MONEY = HUSH_MAXNVALUE;
|
||||||
if(fDebug)
|
if(fDebug)
|
||||||
fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN);
|
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);
|
uint16_t tmpport = hush_port(SMART_CHAIN_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen);
|
||||||
if ( GetArg("-port",0) != 0 )
|
if ( GetArg("-port",0) != 0 )
|
||||||
{
|
{
|
||||||
ASSETCHAINS_P2PPORT = GetArg("-port",0);
|
ASSETCHAINS_P2PPORT = GetArg("-port",0);
|
||||||
if(ishush3) {
|
if(ishush3) {
|
||||||
fprintf(stderr,"set HUSH3 p2pport.%u\n",ASSETCHAINS_P2PPORT);
|
LogPrintf("set HUSH3 p2pport.%u\n",ASSETCHAINS_P2PPORT);
|
||||||
ASSETCHAINS_P2PPORT = 18030;
|
ASSETCHAINS_P2PPORT = 18030;
|
||||||
}
|
}
|
||||||
if(fDebug)
|
if(fDebug)
|
||||||
@@ -2377,7 +2337,6 @@ void hush_args(char *argv0)
|
|||||||
boost::this_thread::sleep(boost::posix_time::milliseconds(3000));
|
boost::this_thread::sleep(boost::posix_time::milliseconds(3000));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"Got datadir.(%s)\n",dirname);
|
|
||||||
if ( SMART_CHAIN_SYMBOL[0] != 0 )
|
if ( SMART_CHAIN_SYMBOL[0] != 0 )
|
||||||
{
|
{
|
||||||
int32_t hush_baseid(char *origbase);
|
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");
|
fprintf(stderr,"ac_cbmaturity must be >0, shutting down\n");
|
||||||
StartShutdown();
|
StartShutdown();
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"ASSETCHAINS_RPCPORT (%s) %u\n",SMART_CHAIN_SYMBOL,ASSETCHAINS_RPCPORT);
|
|
||||||
}
|
}
|
||||||
if ( ASSETCHAINS_RPCPORT == 0 )
|
if ( ASSETCHAINS_RPCPORT == 0 )
|
||||||
ASSETCHAINS_RPCPORT = ASSETCHAINS_P2PPORT + 1;
|
ASSETCHAINS_RPCPORT = ASSETCHAINS_P2PPORT + 1;
|
||||||
@@ -2411,10 +2369,10 @@ void hush_args(char *argv0)
|
|||||||
if ( HUSH_CCACTIVATE != 0 )
|
if ( HUSH_CCACTIVATE != 0 )
|
||||||
{
|
{
|
||||||
ASSETCHAINS_CC = 2;
|
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 ) {
|
} else if ( ccEnablesHeight[0] != 0 ) {
|
||||||
ASSETCHAINS_CC = 2;
|
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 {
|
} else {
|
||||||
@@ -2448,8 +2406,7 @@ void hush_args(char *argv0)
|
|||||||
_hush_userpass(username,password,fp);
|
_hush_userpass(username,password,fp);
|
||||||
sprintf(iter == 0 ? HUSHUSERPASS : BTCUSERPASS,"%s:%s",username,password);
|
sprintf(iter == 0 ? HUSHUSERPASS : BTCUSERPASS,"%s:%s",username,password);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
//printf("HUSH.(%s) -> userpass.(%s)\n",fname,HUSHUSERPASS);
|
}
|
||||||
} //else printf("couldnt open.(%s)\n",fname);
|
|
||||||
if ( IS_HUSH_NOTARY == 0 )
|
if ( IS_HUSH_NOTARY == 0 )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2458,7 +2415,6 @@ void hush_args(char *argv0)
|
|||||||
if ( SMART_CHAIN_SYMBOL[0] != 0 )
|
if ( SMART_CHAIN_SYMBOL[0] != 0 )
|
||||||
{
|
{
|
||||||
BITCOIND_RPCPORT = GetArg("-rpcport", ASSETCHAINS_RPCPORT);
|
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
|
// Set custom cc rulse for chains here
|
||||||
if ( strcmp("HUSH3",SMART_CHAIN_SYMBOL) == 0 ) {
|
if ( strcmp("HUSH3",SMART_CHAIN_SYMBOL) == 0 ) {
|
||||||
@@ -2514,7 +2470,7 @@ void hush_prefetch(FILE *fp)
|
|||||||
{
|
{
|
||||||
rewind(fp);
|
rewind(fp);
|
||||||
while ( fread(ignore,1,incr,fp) == incr ) // prefetch
|
while ( fread(ignore,1,incr,fp) == incr ) // prefetch
|
||||||
fprintf(stderr,".");
|
;
|
||||||
free(ignore);
|
free(ignore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
56
src/init.cpp
56
src/init.cpp
@@ -929,7 +929,7 @@ static void ZC_LoadParams(const CChainParams& chainparams)
|
|||||||
boost::system::error_code ec1, ec2;
|
boost::system::error_code ec1, ec2;
|
||||||
boost::uintmax_t spend_size = file_size(sapling_spend, ec1);
|
boost::uintmax_t spend_size = file_size(sapling_spend, ec1);
|
||||||
boost::uintmax_t output_size = file_size(sapling_output, ec2);
|
boost::uintmax_t output_size = file_size(sapling_output, ec2);
|
||||||
fprintf(stderr,"Sapling spend: %d bytes, output: %d bytes\n", (int)spend_size, (int)output_size);
|
LogPrintf("Sapling spend: %d bytes, output: %d bytes\n", (int)spend_size, (int)output_size);
|
||||||
|
|
||||||
// We could check sha hashes, but we mostly want to detect on-disk file corruption
|
// We could check sha hashes, but we mostly want to detect on-disk file corruption
|
||||||
// or people having a full harddrive. Full validation happens in librustzcash_init_zksnark_params
|
// or people having a full harddrive. Full validation happens in librustzcash_init_zksnark_params
|
||||||
@@ -982,7 +982,7 @@ static void ZC_LoadParams(const CChainParams& chainparams)
|
|||||||
|
|
||||||
bool AppInitServers(boost::thread_group& threadGroup)
|
bool AppInitServers(boost::thread_group& threadGroup)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%s: start\n",__func__);
|
LogPrintf("%s: start\n",__func__);
|
||||||
RPCServer::OnStopped(&OnRPCStopped);
|
RPCServer::OnStopped(&OnRPCStopped);
|
||||||
RPCServer::OnPreCommand(&OnRPCPreCommand);
|
RPCServer::OnPreCommand(&OnRPCPreCommand);
|
||||||
if (!InitHTTPServer())
|
if (!InitHTTPServer())
|
||||||
@@ -1191,7 +1191,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
// Fail early if user has set experimental options without the global flag
|
// Fail early if user has set experimental options without the global flag
|
||||||
if (!fExperimentalMode) {
|
if (!fExperimentalMode) {
|
||||||
if (mapArgs.count("-developerencryptwallet")) {
|
if (mapArgs.count("-developerencryptwallet")) {
|
||||||
fprintf(stderr,"%s wallet encryption error\n", __FUNCTION__);
|
LogPrintf("%s wallet encryption error\n", __FUNCTION__);
|
||||||
return InitError(_("Wallet encryption requires -experimentalfeatures."));
|
return InitError(_("Wallet encryption requires -experimentalfeatures."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1272,33 +1272,33 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
if (asmap_path.empty()) {
|
if (asmap_path.empty()) {
|
||||||
// Most binaries will have it in PWD
|
// Most binaries will have it in PWD
|
||||||
asmap_path = pwd / DEFAULT_ASMAP_FILENAME;
|
asmap_path = pwd / DEFAULT_ASMAP_FILENAME;
|
||||||
printf("%s: looking for asmap file at %s\n", __func__, asmap_path.c_str() );
|
LogPrint("net", "%s: looking for asmap file at %s\n", __func__, asmap_path.c_str() );
|
||||||
if(fs::exists(asmap_path)) {
|
if(fs::exists(asmap_path)) {
|
||||||
printf("%s: found asmap file at %s\n", __func__, asmap_path.c_str() );
|
LogPrint("net", "%s: found asmap file at %s\n", __func__, asmap_path.c_str() );
|
||||||
} else {
|
} else {
|
||||||
// Debian Packages
|
// Debian Packages
|
||||||
asmap_path = fs::path("/usr/share/hush") / DEFAULT_ASMAP_FILENAME;
|
asmap_path = fs::path("/usr/share/hush") / DEFAULT_ASMAP_FILENAME;
|
||||||
printf("%s: looking for asmap file at %s\n", __func__, asmap_path.c_str() );
|
LogPrint("net", "%s: looking for asmap file at %s\n", __func__, asmap_path.c_str() );
|
||||||
if(fs::exists(asmap_path)) {
|
if(fs::exists(asmap_path)) {
|
||||||
printf("%s: found asmap file at %s\n", __func__, asmap_path.c_str() );
|
LogPrint("net", "%s: found asmap file at %s\n", __func__, asmap_path.c_str() );
|
||||||
} else {
|
} else {
|
||||||
// Source code
|
// Source code
|
||||||
asmap_path = contrib / DEFAULT_ASMAP_FILENAME;
|
asmap_path = contrib / DEFAULT_ASMAP_FILENAME;
|
||||||
printf("%s: looking for asmap file at %s\n", __func__, asmap_path.c_str() );
|
LogPrint("net", "%s: looking for asmap file at %s\n", __func__, asmap_path.c_str() );
|
||||||
if(fs::exists(asmap_path)) {
|
if(fs::exists(asmap_path)) {
|
||||||
printf("%s: found asmap file at %s\n", __func__, asmap_path.c_str() );
|
LogPrint("net", "%s: found asmap file at %s\n", __func__, asmap_path.c_str() );
|
||||||
} else {
|
} else {
|
||||||
// Last Resort: Check the parent directory
|
// Last Resort: Check the parent directory
|
||||||
asmap_path = pwd / ".." / DEFAULT_ASMAP_FILENAME;
|
asmap_path = pwd / ".." / DEFAULT_ASMAP_FILENAME;
|
||||||
printf("%s: looking for asmap file at %s\n", __func__, asmap_path.c_str() );
|
LogPrint("net", "%s: looking for asmap file at %s\n", __func__, asmap_path.c_str() );
|
||||||
if(fs::exists(asmap_path)) {
|
if(fs::exists(asmap_path)) {
|
||||||
printf("%s: found asmap file at %s\n", __func__, asmap_path.c_str() );
|
LogPrint("net", "%s: found asmap file at %s\n", __func__, asmap_path.c_str() );
|
||||||
} else {
|
} else {
|
||||||
// Mac SD
|
// Mac SD
|
||||||
asmap_path = fs::path("/Applications/SilentDragon.app/Contents/MacOS/") / DEFAULT_ASMAP_FILENAME;
|
asmap_path = fs::path("/Applications/SilentDragon.app/Contents/MacOS/") / DEFAULT_ASMAP_FILENAME;
|
||||||
printf("%s: looking for asmap file at %s\n", __func__, asmap_path.c_str() );
|
LogPrint("net", "%s: looking for asmap file at %s\n", __func__, asmap_path.c_str() );
|
||||||
if(fs::exists(asmap_path)) {
|
if(fs::exists(asmap_path)) {
|
||||||
printf("%s: found asmap file at %s\n", __func__, asmap_path.c_str() );
|
LogPrint("net", "%s: found asmap file at %s\n", __func__, asmap_path.c_str() );
|
||||||
} else {
|
} else {
|
||||||
// Shit is fucked up, die an honorable death
|
// Shit is fucked up, die an honorable death
|
||||||
InitError(strprintf(_("Could not find any asmap file! Please report this bug to Hush Developers")));
|
InitError(strprintf(_("Could not find any asmap file! Please report this bug to Hush Developers")));
|
||||||
@@ -1312,7 +1312,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
if (!asmap_path.is_absolute()) {
|
if (!asmap_path.is_absolute()) {
|
||||||
asmap_path = GetDataDir() / asmap_path;
|
asmap_path = GetDataDir() / asmap_path;
|
||||||
}
|
}
|
||||||
printf("%s: looking for custom asmap file at %s\n", __func__, asmap_path.c_str() );
|
LogPrint("net", "%s: looking for custom asmap file at %s\n", __func__, asmap_path.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: verify asmap_path is not a directory
|
//TODO: verify asmap_path is not a directory
|
||||||
@@ -1326,7 +1326,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const uint256 asmap_version = SerializeHash(asmap);
|
const uint256 asmap_version = SerializeHash(asmap);
|
||||||
printf("%s: asmap version=%s with %lu mappings\n", __func__, asmap_version.ToString().c_str(), asmap.size());
|
LogPrint("net", "%s: asmap version=%s with %lu mappings\n", __func__, asmap_version.ToString().c_str(), asmap.size());
|
||||||
LogPrintf("Using asmap version %s for IP bucketing with %lu mappings\n", asmap_version.ToString(), asmap.size());
|
LogPrintf("Using asmap version %s for IP bucketing with %lu mappings\n", asmap_version.ToString(), asmap.size());
|
||||||
addrman.m_asmap = std::move(asmap); // //node.connman->SetAsmap(std::move(asmap));
|
addrman.m_asmap = std::move(asmap); // //node.connman->SetAsmap(std::move(asmap));
|
||||||
|
|
||||||
@@ -1351,7 +1351,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
nMaxConnections = GetArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS);
|
nMaxConnections = GetArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS);
|
||||||
nMaxConnections = std::max(std::min(nMaxConnections, (int)(FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS)), 0);
|
nMaxConnections = std::max(std::min(nMaxConnections, (int)(FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS)), 0);
|
||||||
int nFD = RaiseFileDescriptorLimit(nMaxConnections + MIN_CORE_FILEDESCRIPTORS);
|
int nFD = RaiseFileDescriptorLimit(nMaxConnections + MIN_CORE_FILEDESCRIPTORS);
|
||||||
fprintf(stderr,"nMaxConnections %d FD_SETSIZE.%d nBind.%d expr.%d \n",nMaxConnections,FD_SETSIZE,nBind,(int)(FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS));
|
LogPrintf("nMaxConnections %d FD_SETSIZE.%d nBind.%d expr.%d \n",nMaxConnections,FD_SETSIZE,nBind,(int)(FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS));
|
||||||
if (nFD < MIN_CORE_FILEDESCRIPTORS)
|
if (nFD < MIN_CORE_FILEDESCRIPTORS)
|
||||||
return InitError(_("Not enough file descriptors available."));
|
return InitError(_("Not enough file descriptors available."));
|
||||||
if (nFD - MIN_CORE_FILEDESCRIPTORS < nMaxConnections)
|
if (nFD - MIN_CORE_FILEDESCRIPTORS < nMaxConnections)
|
||||||
@@ -1401,7 +1401,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
}
|
}
|
||||||
if (find(categories.begin(), categories.end(), string("randomx")) != categories.end()) {
|
if (find(categories.begin(), categories.end(), string("randomx")) != categories.end()) {
|
||||||
fRandomXDebug = true;
|
fRandomXDebug = true;
|
||||||
fprintf(stderr,"%s: enabled randomx debug\n", __func__);
|
LogPrintf("%s: enabled randomx debug\n", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for -debugnet
|
// Check for -debugnet
|
||||||
@@ -1651,7 +1651,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
if (file) fclose(file);
|
if (file) fclose(file);
|
||||||
|
|
||||||
|
|
||||||
fprintf(stderr,"Attempting to obtain lock %s\n", pathLockFile.string().c_str());
|
LogPrintf("Attempting to obtain lock %s\n", pathLockFile.string().c_str());
|
||||||
try {
|
try {
|
||||||
static boost::interprocess::file_lock lock(pathLockFile.string().c_str());
|
static boost::interprocess::file_lock lock(pathLockFile.string().c_str());
|
||||||
if (!lock.try_lock())
|
if (!lock.try_lock())
|
||||||
@@ -2029,7 +2029,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
if ( checkval != fAddressIndex && fAddressIndex != 0 )
|
if ( checkval != fAddressIndex && fAddressIndex != 0 )
|
||||||
{
|
{
|
||||||
pblocktree->WriteFlag("addressindex", fAddressIndex);
|
pblocktree->WriteFlag("addressindex", fAddressIndex);
|
||||||
fprintf(stderr,"set addressindex, will reindex. could take a while.\n");
|
LogPrintf("set addressindex, will reindex. could take a while.\n");
|
||||||
fReindex = true;
|
fReindex = true;
|
||||||
}
|
}
|
||||||
fSpentIndex = GetBoolArg("-spentindex", DEFAULT_SPENTINDEX);
|
fSpentIndex = GetBoolArg("-spentindex", DEFAULT_SPENTINDEX);
|
||||||
@@ -2037,7 +2037,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
if ( checkval != fSpentIndex && fSpentIndex != 0 )
|
if ( checkval != fSpentIndex && fSpentIndex != 0 )
|
||||||
{
|
{
|
||||||
pblocktree->WriteFlag("spentindex", fSpentIndex);
|
pblocktree->WriteFlag("spentindex", fSpentIndex);
|
||||||
fprintf(stderr,"set spentindex, will reindex. could take a while.\n");
|
LogPrintf("set spentindex, will reindex. could take a while.\n");
|
||||||
fReindex = true;
|
fReindex = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2090,14 +2090,14 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
boost::filesystem::remove(GetDataDir() / "hushstate");
|
boost::filesystem::remove(GetDataDir() / "hushstate");
|
||||||
boost::filesystem::remove(GetDataDir() / "hushsignedmasks");
|
boost::filesystem::remove(GetDataDir() / "hushsignedmasks");
|
||||||
pblocktree->WriteReindexing(true);
|
pblocktree->WriteReindexing(true);
|
||||||
fprintf(stderr, "%s: Deleted hushstate and hushsignedmasks...\n", __FUNCTION__);
|
LogPrintf("%s: Deleted hushstate and hushsignedmasks...\n", __FUNCTION__);
|
||||||
|
|
||||||
//If we're reindexing in prune mode, wipe away unusable block files and all undo data files
|
//If we're reindexing in prune mode, wipe away unusable block files and all undo data files
|
||||||
if (fPruneMode)
|
if (fPruneMode)
|
||||||
CleanupBlockRevFiles();
|
CleanupBlockRevFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "%s: Loading block index...\n", __FUNCTION__);
|
LogPrintf("%s: Loading block index...\n", __FUNCTION__);
|
||||||
if (!LoadBlockIndex()) {
|
if (!LoadBlockIndex()) {
|
||||||
strLoadError = _("Error loading block database");
|
strLoadError = _("Error loading block database");
|
||||||
break;
|
break;
|
||||||
@@ -2121,7 +2121,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "zindex=%s in block index\n", fZindex ? "enabled" : "disabled");
|
LogPrintf("zindex=%s in block index\n", fZindex ? "enabled" : "disabled");
|
||||||
if (fZindex != GetBoolArg("-zindex", false)) {
|
if (fZindex != GetBoolArg("-zindex", false)) {
|
||||||
strLoadError = _("You need to rebuild the database using -reindex to change -zindex");
|
strLoadError = _("You need to rebuild the database using -reindex to change -zindex");
|
||||||
break;
|
break;
|
||||||
@@ -2176,7 +2176,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
if (!fLoaded) {
|
if (!fLoaded) {
|
||||||
// first suggest a reindex
|
// first suggest a reindex
|
||||||
if (!fReset) {
|
if (!fReset) {
|
||||||
fprintf(stderr,"%s: error in hd data\n", __FUNCTION__);
|
LogPrintf("%s: error in hd data\n", __FUNCTION__);
|
||||||
bool fRet = uiInterface.ThreadSafeMessageBox(
|
bool fRet = uiInterface.ThreadSafeMessageBox(
|
||||||
strLoadError + ".\n\n" + _("error in HDD data, might just need to update to latest, if that doesnt work, then you need to resync"),
|
strLoadError + ".\n\n" + _("error in HDD data, might just need to update to latest, if that doesnt work, then you need to resync"),
|
||||||
"", CClientUIInterface::MSG_ERROR | CClientUIInterface::BTN_ABORT);
|
"", CClientUIInterface::MSG_ERROR | CClientUIInterface::BTN_ABORT);
|
||||||
@@ -2382,7 +2382,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
|
|
||||||
int consolidationInterval = GetArg("-consolidationinterval", 25);
|
int consolidationInterval = GetArg("-consolidationinterval", 25);
|
||||||
if (consolidationInterval < 5) {
|
if (consolidationInterval < 5) {
|
||||||
fprintf(stderr,"%s: Invalid consolidation interval of %d < 5, setting to default of 25\n", __func__, consolidationInterval);
|
LogPrintf("%s: Invalid consolidation interval of %d < 5, setting to default of 25\n", __func__, consolidationInterval);
|
||||||
consolidationInterval = 25;
|
consolidationInterval = 25;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2407,7 +2407,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
if (pwalletMain->fSweepEnabled) {
|
if (pwalletMain->fSweepEnabled) {
|
||||||
int sweepInterval = GetArg("-zsweepinterval", 10);
|
int sweepInterval = GetArg("-zsweepinterval", 10);
|
||||||
if (sweepInterval < 5) {
|
if (sweepInterval < 5) {
|
||||||
fprintf(stderr,"%s: Invalid sweep interval of %d, setting to default of 10\n", __func__, sweepInterval);
|
LogPrintf("%s: Invalid sweep interval of %d, setting to default of 10\n", __func__, sweepInterval);
|
||||||
sweepInterval = 10;
|
sweepInterval = 10;
|
||||||
}
|
}
|
||||||
pwalletMain->sweepInterval = sweepInterval;
|
pwalletMain->sweepInterval = sweepInterval;
|
||||||
@@ -2726,7 +2726,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
// Advertise willingness to SERVE bulk block streams (full nodes only) when opted in.
|
// Advertise willingness to SERVE bulk block streams (full nodes only) when opted in.
|
||||||
if ( fBulkBlockSync )
|
if ( fBulkBlockSync )
|
||||||
nLocalServices |= NODE_BULKBLOCKS;
|
nLocalServices |= NODE_BULKBLOCKS;
|
||||||
fprintf(stderr,"nLocalServices %llx %d, %d\n",(long long)nLocalServices,GetBoolArg("-addressindex", DEFAULT_ADDRESSINDEX),GetBoolArg("-spentindex", DEFAULT_SPENTINDEX));
|
LogPrintf("nLocalServices %llx %d, %d\n",(long long)nLocalServices,GetBoolArg("-addressindex", DEFAULT_ADDRESSINDEX),GetBoolArg("-spentindex", DEFAULT_SPENTINDEX));
|
||||||
}
|
}
|
||||||
// ********************************************************* Step 10: import blocks
|
// ********************************************************* Step 10: import blocks
|
||||||
|
|
||||||
@@ -2742,7 +2742,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
if ( !ActivateBestChain(true,state))
|
if ( !ActivateBestChain(true,state))
|
||||||
strErrors << "Failed to connect best block";
|
strErrors << "Failed to connect best block";
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,"HUSH_REWIND < 0\n");
|
LogPrintf("HUSH_REWIND < 0\n");
|
||||||
}
|
}
|
||||||
std::vector<boost::filesystem::path> vImportFiles;
|
std::vector<boost::filesystem::path> vImportFiles;
|
||||||
if (mapArgs.count("-loadblock"))
|
if (mapArgs.count("-loadblock"))
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
std::unique_ptr<CBlockTemplate> pblocktemplate(new CBlockTemplate());
|
std::unique_ptr<CBlockTemplate> pblocktemplate(new CBlockTemplate());
|
||||||
if(!pblocktemplate.get())
|
if(!pblocktemplate.get())
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%s: pblocktemplate.get() failure\n", __func__);
|
LogPrintf("%s: pblocktemplate.get() failure\n", __func__);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
CBlock *pblock = &pblocktemplate->block; // pointer for convenience
|
CBlock *pblock = &pblocktemplate->block; // pointer for convenience
|
||||||
@@ -294,7 +294,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
|
|
||||||
if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight, nLockTimeCutoff) || IsExpiredTx(tx, nHeight))
|
if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight, nLockTimeCutoff) || IsExpiredTx(tx, nHeight))
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%s: coinbase.%d finaltx.%d expired.%d\n",__func__, tx.IsCoinBase(),IsFinalTx(tx, nHeight, nLockTimeCutoff),IsExpiredTx(tx, nHeight));
|
LogPrint("mempool", "%s: coinbase.%d finaltx.%d expired.%d\n",__func__, tx.IsCoinBase(),IsFinalTx(tx, nHeight, nLockTimeCutoff),IsExpiredTx(tx, nHeight));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
txvalue = tx.GetValueOut();
|
txvalue = tx.GetValueOut();
|
||||||
@@ -373,9 +373,8 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
{
|
{
|
||||||
// check a notary didnt sign twice (this would be an invalid notarization later on and cause problems)
|
// check a notary didnt sign twice (this would be an invalid notarization later on and cause problems)
|
||||||
std::set<int> checkdupes( TMP_NotarizationNotaries.begin(), TMP_NotarizationNotaries.end() );
|
std::set<int> checkdupes( TMP_NotarizationNotaries.begin(), TMP_NotarizationNotaries.end() );
|
||||||
if ( checkdupes.size() != TMP_NotarizationNotaries.size() )
|
if ( checkdupes.size() != TMP_NotarizationNotaries.size() )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: WTFBBQ! possible notarization is signed multiple times by same notary, passed as normal transaction.\n", __func__);
|
|
||||||
} else fNotarization = true;
|
} else fNotarization = true;
|
||||||
}
|
}
|
||||||
nTotalIn += tx.GetShieldedValueIn();
|
nTotalIn += tx.GetShieldedValueIn();
|
||||||
@@ -404,7 +403,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
Notarizations++;
|
Notarizations++;
|
||||||
if ( Notarizations > 1 )
|
if ( Notarizations > 1 )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: skipping notarization.%d\n",__func__, Notarizations);
|
LogPrint("mempool", "%s: skipping notarization.%d\n",__func__, Notarizations);
|
||||||
// Any attempted notarization needs to be in its own block!
|
// Any attempted notarization needs to be in its own block!
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -469,7 +468,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
|
|
||||||
if (nBlockSize + nTxSize >= nBlockMaxSize-512) // room for extra autotx
|
if (nBlockSize + nTxSize >= nBlockMaxSize-512) // room for extra autotx
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%s: nBlockSize %d + %d nTxSize >= %d nBlockMaxSize\n",__func__, (int32_t)nBlockSize,(int32_t)nTxSize,(int32_t)nBlockMaxSize);
|
LogPrint("mempool", "%s: nBlockSize %d + %d nTxSize >= %d nBlockMaxSize\n",__func__, (int32_t)nBlockSize,(int32_t)nTxSize,(int32_t)nBlockMaxSize);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -488,7 +487,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta);
|
mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta);
|
||||||
if (fSortedByFee && (dPriorityDelta <= 0) && (nFeeDelta <= 0) && (feeRate < ::minRelayTxFee) && (nBlockSize + nTxSize >= nBlockMinSize))
|
if (fSortedByFee && (dPriorityDelta <= 0) && (nFeeDelta <= 0) && (feeRate < ::minRelayTxFee) && (nBlockSize + nTxSize >= nBlockMinSize))
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%s: fee rate skip\n", __func__);
|
LogPrint("mempool", "%s: fee rate skip\n", __func__);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Prioritize by fee once past the priority size or we run out of high-priority transactions
|
// Prioritize by fee once past the priority size or we run out of high-priority transactions
|
||||||
@@ -526,7 +525,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
opcodetype op;
|
opcodetype op;
|
||||||
std::vector<uint8_t> opretData;
|
std::vector<uint8_t> opretData;
|
||||||
if (txout.scriptPubKey.GetOp(it, op, opretData)) {
|
if (txout.scriptPubKey.GetOp(it, op, opretData)) {
|
||||||
//std::cerr << HexStr(opretData.begin(), opretData.end()) << std::endl;
|
|
||||||
nTxOpretSize += opretData.size();
|
nTxOpretSize += opretData.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -537,7 +535,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
std::cerr << __func__ << ": " << tx.GetHash().ToString() << " nTxSize=" << nTxSize << " nTxOpretSize=" << nTxOpretSize << " feeRate=" << feeRate.ToString() << " opretMinFee=" << opretMinFee << " nTxFees=" << nTxFees <<" fSpamTx=" << fSpamTx << std::endl;
|
std::cerr << __func__ << ": " << tx.GetHash().ToString() << " nTxSize=" << nTxSize << " nTxOpretSize=" << nTxOpretSize << " feeRate=" << feeRate.ToString() << " opretMinFee=" << opretMinFee << " nTxFees=" << nTxFees <<" fSpamTx=" << fSpamTx << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// std::cerr << tx.GetHash().ToString() << " vecPriority.size() = " << vecPriority.size() << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nTxSigOps += GetP2SHSigOpCount(tx, view);
|
nTxSigOps += GetP2SHSigOpCount(tx, view);
|
||||||
@@ -552,7 +549,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
PrecomputedTransactionData txdata(tx);
|
PrecomputedTransactionData txdata(tx);
|
||||||
if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId))
|
if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId))
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%s: ContextualCheckInputs failure\n",__func__);
|
LogPrint("mempool", "%s: ContextualCheckInputs failure\n",__func__);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
UpdateCoins(tx, view, nHeight);
|
UpdateCoins(tx, view, nHeight);
|
||||||
@@ -646,7 +643,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
static bool didinit = false;
|
static bool didinit = false;
|
||||||
if ( !didinit && nHeight > HUSH_EARLYTXID_HEIGHT && HUSH_EARLYTXID != zeroid && hush_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());
|
LogPrintf("appended ccopreturn to assetchains_scriptpub.%s\n", assetchains_scriptpub.c_str());
|
||||||
didinit = true;
|
didinit = true;
|
||||||
}
|
}
|
||||||
//txNew.vout[1].scriptPubKey = CScript() << ParseHex();
|
//txNew.vout[1].scriptPubKey = CScript() << ParseHex();
|
||||||
@@ -666,7 +663,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
ptr[34] = OP_CHECKSIG;
|
ptr[34] = OP_CHECKSIG;
|
||||||
}
|
}
|
||||||
} else if ( (uint64_t)(txNew.vout[0].nValue) >= ASSETCHAINS_TIMELOCKGTE) {
|
} else if ( (uint64_t)(txNew.vout[0].nValue) >= ASSETCHAINS_TIMELOCKGTE) {
|
||||||
fprintf(stderr,"timelocked chains not supported in this code!\n");
|
LogPrintf("timelocked chains not supported in this code!\n");
|
||||||
LEAVE_CRITICAL_SECTION(cs_main);
|
LEAVE_CRITICAL_SECTION(cs_main);
|
||||||
LEAVE_CRITICAL_SECTION(mempool.cs);
|
LEAVE_CRITICAL_SECTION(mempool.cs);
|
||||||
return(0);
|
return(0);
|
||||||
@@ -679,7 +676,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
uint64_t totalsats = hush_notarypay(txNew, NotarizationNotaries, pblock->nTime, nHeight, script, scriptlen);
|
uint64_t totalsats = hush_notarypay(txNew, NotarizationNotaries, pblock->nTime, nHeight, script, scriptlen);
|
||||||
if ( totalsats == 0 )
|
if ( totalsats == 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Could not create notary payment, trying again.\n");
|
LogPrintf("Could not create notary payment, trying again.\n");
|
||||||
if ( !isStake )
|
if ( !isStake )
|
||||||
{
|
{
|
||||||
LEAVE_CRITICAL_SECTION(cs_main);
|
LEAVE_CRITICAL_SECTION(cs_main);
|
||||||
@@ -687,7 +684,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
}
|
}
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
} else fprintf(stderr, "vout 2 of notarization is not OP_RETURN scriptlen.%i\n", scriptlen);
|
} else LogPrintf("vout 2 of notarization is not OP_RETURN scriptlen.%i\n", scriptlen);
|
||||||
}
|
}
|
||||||
if ( ASSETCHAINS_CBOPRET != 0 )
|
if ( ASSETCHAINS_CBOPRET != 0 )
|
||||||
{
|
{
|
||||||
@@ -734,7 +731,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
LEAVE_CRITICAL_SECTION(cs_main);
|
LEAVE_CRITICAL_SECTION(cs_main);
|
||||||
LEAVE_CRITICAL_SECTION(mempool.cs);
|
LEAVE_CRITICAL_SECTION(mempool.cs);
|
||||||
}
|
}
|
||||||
fprintf(stderr,"%s: TestBlockValidity failed!\n", __func__);
|
LogPrintf("%s: TestBlockValidity failed!\n", __func__);
|
||||||
//throw std::runtime_error("CreateNewBlock(): TestBlockValidity failed"); // crashes the node, moved to GetBlockTemplate and issue return.
|
//throw std::runtime_error("CreateNewBlock(): TestBlockValidity failed"); // crashes the node, moved to GetBlockTemplate and issue return.
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
@@ -813,7 +810,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight,
|
|||||||
// scriptPubKey = CScript() << OP_DUP << OP_HASH160 << ToByteVector(keyID) << OP_EQUALVERIFY << OP_CHECKSIG;
|
// scriptPubKey = CScript() << OP_DUP << OP_HASH160 << ToByteVector(keyID) << OP_EQUALVERIFY << OP_CHECKSIG;
|
||||||
scriptPubKey = GetScriptForDestination(dest);
|
scriptPubKey = GetScriptForDestination(dest);
|
||||||
Getscriptaddress(destaddr,scriptPubKey);
|
Getscriptaddress(destaddr,scriptPubKey);
|
||||||
fprintf(stderr,"%s: wallet disabled with mineraddress=%s\n", __func__, destaddr);
|
LogPrintf("%s: wallet disabled with mineraddress=%s\n", __func__, destaddr);
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -853,16 +850,6 @@ static bool ProcessBlockFound(CBlock* pblock)
|
|||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
if (pblock->hashPrevBlock != chainActive.LastTip()->GetBlockHash())
|
if (pblock->hashPrevBlock != chainActive.LastTip()->GetBlockHash())
|
||||||
{
|
{
|
||||||
uint256 hash; int32_t i;
|
|
||||||
hash = pblock->hashPrevBlock;
|
|
||||||
for (i=31; i>=0; i--)
|
|
||||||
fprintf(stderr,"%02x",((uint8_t *)&hash)[i]);
|
|
||||||
fprintf(stderr," <- prev (stale)\n");
|
|
||||||
hash = chainActive.LastTip()->GetBlockHash();
|
|
||||||
for (i=31; i>=0; i--)
|
|
||||||
fprintf(stderr,"%02x",((uint8_t *)&hash)[i]);
|
|
||||||
fprintf(stderr," <- chainTip (stale)\n");
|
|
||||||
|
|
||||||
return error("HushMiner: generated block is stale");
|
return error("HushMiner: generated block is stale");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -954,7 +941,6 @@ CBlockIndex *get_chainactive(int32_t height)
|
|||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
return(chainActive[height]);
|
return(chainActive[height]);
|
||||||
}
|
}
|
||||||
// else fprintf(stderr,"get_chainactive height %d > active.%d\n",height,chainActive.Tip()->GetHeight());
|
|
||||||
}
|
}
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
@@ -1280,7 +1266,7 @@ void static RandomXMiner()
|
|||||||
|
|
||||||
// If we don't have a valid chain tip to work from, wait and try again.
|
// If we don't have a valid chain tip to work from, wait and try again.
|
||||||
if (pindexPrev == nullptr) {
|
if (pindexPrev == nullptr) {
|
||||||
fprintf(stderr,"%s: null pindexPrev, trying again...\n",__func__);
|
LogPrint("randomx", "%s: null pindexPrev, trying again...\n",__func__);
|
||||||
MilliSleep(1000);
|
MilliSleep(1000);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1341,7 +1327,7 @@ void static RandomXMiner()
|
|||||||
}
|
}
|
||||||
static uint32_t counter;
|
static uint32_t counter;
|
||||||
if ( counter++ < 10 )
|
if ( counter++ < 10 )
|
||||||
fprintf(stderr,"RandomXMiner: created illegal blockB, retry with counter=%u\n", counter);
|
LogPrint("randomx", "RandomXMiner: created illegal blockB, retry with counter=%u\n", counter);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1366,10 +1352,10 @@ void static RandomXMiner()
|
|||||||
{
|
{
|
||||||
static uint32_t counter;
|
static uint32_t counter;
|
||||||
if ( counter++ < 10 )
|
if ( counter++ < 10 )
|
||||||
fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",SMART_CHAIN_SYMBOL);
|
LogPrint("randomx", "skip generating %s on-demand block, no tx avail\n",SMART_CHAIN_SYMBOL);
|
||||||
sleep(10);
|
sleep(10);
|
||||||
continue;
|
continue;
|
||||||
} else fprintf(stderr,"%s vouts.%d mining.%d vs %d\n",SMART_CHAIN_SYMBOL,(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT);
|
} else LogPrint("randomx", "%s vouts.%d mining.%d vs %d\n",SMART_CHAIN_SYMBOL,(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT);
|
||||||
}
|
}
|
||||||
rxdebug("%s: incrementing extra nonce\n");
|
rxdebug("%s: incrementing extra nonce\n");
|
||||||
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
|
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
|
||||||
@@ -1388,7 +1374,7 @@ void static RandomXMiner()
|
|||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if ( gotinvalid != 0 ) {
|
if ( gotinvalid != 0 ) {
|
||||||
fprintf(stderr,"RandomXMiner: gotinvalid=%d\n",gotinvalid);
|
LogPrint("randomx", "RandomXMiner: gotinvalid=%d\n",gotinvalid);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
hush_longestchain();
|
hush_longestchain();
|
||||||
@@ -1402,7 +1388,6 @@ void static RandomXMiner()
|
|||||||
// Serialize block header without nSolution but with nNonce for deterministic RandomX input
|
// Serialize block header without nSolution but with nNonce for deterministic RandomX input
|
||||||
randomxInput << rxInput;
|
randomxInput << rxInput;
|
||||||
|
|
||||||
// std::cerr << "RandomXMiner: randomxInput=" << HexStr(randomxInput) << "\n";
|
|
||||||
rxdebug("%s: randomxKey=%s randomxInput=%s\n", randomxKey, HexStr(randomxInput).c_str());
|
rxdebug("%s: randomxKey=%s randomxInput=%s\n", randomxKey, HexStr(randomxInput).c_str());
|
||||||
|
|
||||||
rxdebug("%s: calculating randomx hash\n");
|
rxdebug("%s: calculating randomx hash\n");
|
||||||
@@ -1460,17 +1445,6 @@ void static RandomXMiner()
|
|||||||
SetSkipRandomXValidation(false);
|
SetSkipRandomXValidation(false);
|
||||||
if ( !fValid )
|
if ( !fValid )
|
||||||
{
|
{
|
||||||
h = UintToArith256(B.GetHash());
|
|
||||||
fprintf(stderr,"RandomXMiner: TestBlockValidity FAILED at ht.%d nNonce=%s hash=",
|
|
||||||
Mining_height, pblock->nNonce.ToString().c_str());
|
|
||||||
for (z=31; z>=0; z--)
|
|
||||||
fprintf(stderr,"%02x",((uint8_t *)&h)[z]);
|
|
||||||
fprintf(stderr," nSolution.size=%lu\n", B.nSolution.size());
|
|
||||||
// Dump nSolution hex for comparison with validator
|
|
||||||
fprintf(stderr,"RandomXMiner: nSolution=");
|
|
||||||
for (unsigned i = 0; i < B.nSolution.size(); i++)
|
|
||||||
fprintf(stderr,"%02x", B.nSolution[i]);
|
|
||||||
fprintf(stderr,"\n");
|
|
||||||
LogPrintf("RandomXMiner: TestBlockValidity FAILED at ht.%d, gotinvalid=1, state=%s\n",
|
LogPrintf("RandomXMiner: TestBlockValidity FAILED at ht.%d, gotinvalid=1, state=%s\n",
|
||||||
Mining_height, state.GetRejectReason());
|
Mining_height, state.GetRejectReason());
|
||||||
gotinvalid = 1;
|
gotinvalid = 1;
|
||||||
@@ -1527,13 +1501,13 @@ void static RandomXMiner()
|
|||||||
{
|
{
|
||||||
if ( Mining_height > ASSETCHAINS_MINHEIGHT )
|
if ( Mining_height > ASSETCHAINS_MINHEIGHT )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%s: no nodes, break\n", __func__);
|
LogPrint("randomx", "%s: no nodes, break\n", __func__);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((UintToArith256(pblock->nNonce) & 0xffff) == 0xffff)
|
if ((UintToArith256(pblock->nNonce) & 0xffff) == 0xffff)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%s: nonce & 0xffff == 0xffff, break\n", __func__);
|
LogPrint("randomx", "%s: nonce & 0xffff == 0xffff, break\n", __func__);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Update nNonce and nTime
|
// Update nNonce and nTime
|
||||||
@@ -1556,7 +1530,6 @@ void static RandomXMiner()
|
|||||||
LogPrintf("%s: destroyed vm via thread interrupt\n", __func__);
|
LogPrintf("%s: destroyed vm via thread interrupt\n", __func__);
|
||||||
} else {
|
} else {
|
||||||
LogPrintf("%s: WARNING myVM already null in thread interrupt handler, skipping destroy (would double-free)\n", __func__);
|
LogPrintf("%s: WARNING myVM already null in thread interrupt handler, skipping destroy (would double-free)\n", __func__);
|
||||||
fprintf(stderr, "%s: WARNING myVM already null in thread interrupt, would have double-freed!\n", __func__);
|
|
||||||
}
|
}
|
||||||
// Dataset and cache are owned by g_rxDatasetManager — do NOT release here
|
// Dataset and cache are owned by g_rxDatasetManager — do NOT release here
|
||||||
|
|
||||||
@@ -1565,7 +1538,7 @@ void static RandomXMiner()
|
|||||||
} catch (const std::runtime_error &e) {
|
} catch (const std::runtime_error &e) {
|
||||||
miningTimer.stop();
|
miningTimer.stop();
|
||||||
c.disconnect();
|
c.disconnect();
|
||||||
fprintf(stderr,"RandomXMiner: runtime error: %s\n", e.what());
|
LogPrintf("RandomXMiner: runtime error: %s\n", e.what());
|
||||||
|
|
||||||
if (myVM != nullptr) {
|
if (myVM != nullptr) {
|
||||||
randomx_destroy_vm(myVM);
|
randomx_destroy_vm(myVM);
|
||||||
@@ -1624,7 +1597,7 @@ void static BitcoinMiner()
|
|||||||
assert(solver == "tromp" || solver == "default");
|
assert(solver == "tromp" || solver == "default");
|
||||||
LogPrint("pow", "Using Equihash solver \"%s\" with n = %u, k = %u\n", solver, n, k);
|
LogPrint("pow", "Using Equihash solver \"%s\" with n = %u, k = %u\n", solver, n, k);
|
||||||
if ( SMART_CHAIN_SYMBOL[0] != 0 )
|
if ( SMART_CHAIN_SYMBOL[0] != 0 )
|
||||||
fprintf(stderr,"notaryid.%d Mining.%s with %s\n",notaryid,SMART_CHAIN_SYMBOL,solver.c_str());
|
LogPrintf("notaryid.%d Mining.%s with %s\n",notaryid,SMART_CHAIN_SYMBOL,solver.c_str());
|
||||||
std::mutex m_cs;
|
std::mutex m_cs;
|
||||||
bool cancelSolver = false;
|
bool cancelSolver = false;
|
||||||
boost::signals2::connection c = uiInterface.NotifyBlockTip.connect(
|
boost::signals2::connection c = uiInterface.NotifyBlockTip.connect(
|
||||||
@@ -1637,7 +1610,7 @@ void static BitcoinMiner()
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if ( SMART_CHAIN_SYMBOL[0] != 0 )
|
if ( SMART_CHAIN_SYMBOL[0] != 0 )
|
||||||
fprintf(stderr,"try %s Mining with %s\n",SMART_CHAIN_SYMBOL,solver.c_str());
|
LogPrintf("try %s Mining with %s\n",SMART_CHAIN_SYMBOL,solver.c_str());
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (chainparams.MiningRequiresPeers()) {
|
if (chainparams.MiningRequiresPeers()) {
|
||||||
@@ -1667,7 +1640,7 @@ void static BitcoinMiner()
|
|||||||
|
|
||||||
// If we don't have a valid chain tip to work from, wait and try again.
|
// If we don't have a valid chain tip to work from, wait and try again.
|
||||||
if (pindexPrev == nullptr) {
|
if (pindexPrev == nullptr) {
|
||||||
fprintf(stderr,"%s: null pindexPrev, trying again...\n",__func__);
|
LogPrint("pow", "%s: null pindexPrev, trying again...\n",__func__);
|
||||||
MilliSleep(1000);
|
MilliSleep(1000);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1699,7 +1672,7 @@ void static BitcoinMiner()
|
|||||||
}
|
}
|
||||||
static uint32_t counter;
|
static uint32_t counter;
|
||||||
if ( counter++ < 10 && ASSETCHAINS_STAKED == 0 )
|
if ( counter++ < 10 && ASSETCHAINS_STAKED == 0 )
|
||||||
fprintf(stderr,"created illegal blockB, retry\n");
|
LogPrint("pow", "created illegal blockB, retry\n");
|
||||||
sleep(1);
|
sleep(1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1723,10 +1696,10 @@ void static BitcoinMiner()
|
|||||||
{
|
{
|
||||||
static uint32_t counter;
|
static uint32_t counter;
|
||||||
if ( counter++ < 10 )
|
if ( counter++ < 10 )
|
||||||
fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",SMART_CHAIN_SYMBOL);
|
LogPrint("pow", "skip generating %s on-demand block, no tx avail\n",SMART_CHAIN_SYMBOL);
|
||||||
sleep(10);
|
sleep(10);
|
||||||
continue;
|
continue;
|
||||||
} else fprintf(stderr,"%s vouts.%d mining.%d vs %d\n",SMART_CHAIN_SYMBOL,(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT);
|
} else LogPrint("pow", "%s vouts.%d mining.%d vs %d\n",SMART_CHAIN_SYMBOL,(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
|
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
|
||||||
@@ -1806,7 +1779,7 @@ void static BitcoinMiner()
|
|||||||
sleep(1);
|
sleep(1);
|
||||||
if ( chainActive.LastTip()->GetHeight() >= Mining_height )
|
if ( chainActive.LastTip()->GetHeight() >= Mining_height )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"new block arrived\n");
|
LogPrint("pow", "new block arrived\n");
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1820,13 +1793,6 @@ void static BitcoinMiner()
|
|||||||
MilliSleep((rand() % (r * 1000)) + 1000);
|
MilliSleep((rand() % (r * 1000)) + 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
uint256 tmp = B.GetHash();
|
|
||||||
int32_t z; for (z=31; z>=0; z--)
|
|
||||||
fprintf(stderr,"%02x",((uint8_t *)&tmp)[z]);
|
|
||||||
fprintf(stderr," mined %s block %d!\n",SMART_CHAIN_SYMBOL,Mining_height);
|
|
||||||
}
|
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
|
|
||||||
//{ LOCK(cs_main);
|
//{ LOCK(cs_main);
|
||||||
@@ -1932,14 +1898,14 @@ void static BitcoinMiner()
|
|||||||
{
|
{
|
||||||
if ( SMART_CHAIN_SYMBOL[0] == 0 || Mining_height > ASSETCHAINS_MINHEIGHT )
|
if ( SMART_CHAIN_SYMBOL[0] == 0 || Mining_height > ASSETCHAINS_MINHEIGHT )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"no nodes, break\n");
|
LogPrint("pow", "no nodes, break\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((UintToArith256(pblock->nNonce) & 0xffff) == 0xffff)
|
if ((UintToArith256(pblock->nNonce) & 0xffff) == 0xffff)
|
||||||
{
|
{
|
||||||
//if ( 0 && SMART_CHAIN_SYMBOL[0] != 0 )
|
//if ( 0 && SMART_CHAIN_SYMBOL[0] != 0 )
|
||||||
fprintf(stderr,"0xffff, break\n");
|
LogPrint("pow", "0xffff, break\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 60)
|
if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 60)
|
||||||
@@ -2042,7 +2008,6 @@ void static BitcoinMiner()
|
|||||||
g_rxDatasetManager = new RandomXDatasetManager();
|
g_rxDatasetManager = new RandomXDatasetManager();
|
||||||
if (!g_rxDatasetManager->Init()) {
|
if (!g_rxDatasetManager->Init()) {
|
||||||
LogPrintf("%s: FATAL - Failed to initialize shared RandomX dataset manager\n", __func__);
|
LogPrintf("%s: FATAL - Failed to initialize shared RandomX dataset manager\n", __func__);
|
||||||
fprintf(stderr, "%s: FATAL - Failed to initialize shared RandomX dataset manager\n", __func__);
|
|
||||||
delete g_rxDatasetManager;
|
delete g_rxDatasetManager;
|
||||||
g_rxDatasetManager = nullptr;
|
g_rxDatasetManager = nullptr;
|
||||||
delete minerThreads;
|
delete minerThreads;
|
||||||
|
|||||||
17
src/net.cpp
17
src/net.cpp
@@ -614,7 +614,7 @@ void DumpBanlist()
|
|||||||
if (bandb.Write(banmap)) {
|
if (bandb.Write(banmap)) {
|
||||||
SetBannedSetDirty(false);
|
SetBannedSetDirty(false);
|
||||||
}
|
}
|
||||||
fprintf(stderr,"%s: Dumping banlist with %lu items\n", __func__, banmap.size());
|
LogPrint("net", "%s: Dumping banlist with %lu items\n", __func__, banmap.size());
|
||||||
|
|
||||||
LogPrint("net", "Flushed %d banned node ips/subnets to banlist.dat %dms\n",
|
LogPrint("net", "Flushed %d banned node ips/subnets to banlist.dat %dms\n",
|
||||||
banmap.size(), GetTimeMillis() - nStart);
|
banmap.size(), GetTimeMillis() - nStart);
|
||||||
@@ -642,7 +642,7 @@ bool CNode::IsBanned(CNetAddr ip)
|
|||||||
CBanEntry banEntry = (*it).second;
|
CBanEntry banEntry = (*it).second;
|
||||||
|
|
||||||
if(subNet.Match(ip) && GetTime() < banEntry.nBanUntil) {
|
if(subNet.Match(ip) && GetTime() < banEntry.nBanUntil) {
|
||||||
fprintf(stderr,"%s: found banned subnet %s\n", __func__, subNet.ToString().c_str());
|
LogPrint("net", "%s: found banned subnet %s\n", __func__, subNet.ToString().c_str());
|
||||||
fResult = true;
|
fResult = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -676,7 +676,7 @@ void CNode::Ban(const CSubNet& subNet, const BanReason &banReason, int64_t banti
|
|||||||
if (bantimeoffset > 0)
|
if (bantimeoffset > 0)
|
||||||
banEntry.nBanUntil = (sinceUnixEpoch ? 0 : GetTime() )+bantimeoffset;
|
banEntry.nBanUntil = (sinceUnixEpoch ? 0 : GetTime() )+bantimeoffset;
|
||||||
|
|
||||||
fprintf(stderr, "%s: banning %s until %ld with bantimeoffset=%ld sinceUnixEpoch=%d\n", __func__, subNet.ToString().c_str(), banEntry.nBanUntil, bantimeoffset, sinceUnixEpoch);
|
LogPrint("net", "%s: banning %s until %ld with bantimeoffset=%ld sinceUnixEpoch=%d\n", __func__, subNet.ToString().c_str(), banEntry.nBanUntil, bantimeoffset, sinceUnixEpoch);
|
||||||
{
|
{
|
||||||
LOCK(cs_setBanned);
|
LOCK(cs_setBanned);
|
||||||
if (setBanned[subNet].nBanUntil < banEntry.nBanUntil) {
|
if (setBanned[subNet].nBanUntil < banEntry.nBanUntil) {
|
||||||
@@ -690,13 +690,13 @@ void CNode::Ban(const CSubNet& subNet, const BanReason &banReason, int64_t banti
|
|||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
for (CNode* pnode : vNodes) {
|
for (CNode* pnode : vNodes) {
|
||||||
if (subNet.Match(static_cast<CNetAddr>(pnode->addr)))
|
if (subNet.Match(static_cast<CNetAddr>(pnode->addr)))
|
||||||
fprintf(stderr, "%s: disconnecting from banned node %s\n", __func__, pnode->addr.ToString().c_str() );
|
LogPrint("net", "%s: disconnecting from banned node %s\n", __func__, pnode->addr.ToString().c_str() );
|
||||||
pnode->fDisconnect = true;
|
pnode->fDisconnect = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(banReason == BanReasonManuallyAdded) {
|
if(banReason == BanReasonManuallyAdded) {
|
||||||
fprintf(stderr,"%s: dumping banlist after manual ban\n", __func__);
|
LogPrint("net", "%s: dumping banlist after manual ban\n", __func__);
|
||||||
DumpBanlist(); //store banlist to disk immediately if user requested ban
|
DumpBanlist(); //store banlist to disk immediately if user requested ban
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1851,7 +1851,6 @@ void ThreadOpenConnections()
|
|||||||
int randsleep = GetRandInt(FEELER_SLEEP_WINDOW * 1000);
|
int randsleep = GetRandInt(FEELER_SLEEP_WINDOW * 1000);
|
||||||
MilliSleep(randsleep);
|
MilliSleep(randsleep);
|
||||||
LogPrint("net", "Making feeler connection to %s\n", addrConnect.ToString().c_str());
|
LogPrint("net", "Making feeler connection to %s\n", addrConnect.ToString().c_str());
|
||||||
printf("%s: Making feeler connection to %s\n", __func__, addrConnect.ToString().c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//int failures = setConnected.size() >= std::min(nMaxConnections - 1, 2);
|
//int failures = setConnected.size() >= std::min(nMaxConnections - 1, 2);
|
||||||
@@ -2510,7 +2509,7 @@ void RelayTransaction(const CTransaction& tx, const CDataStream& ss)
|
|||||||
// If we have no nodes to relay to, there is nothing to do
|
// If we have no nodes to relay to, there is nothing to do
|
||||||
if(vNodes.size() == 0) {
|
if(vNodes.size() == 0) {
|
||||||
if (HUSH_TESTNODE==0) {
|
if (HUSH_TESTNODE==0) {
|
||||||
fprintf(stderr, "%s: No nodes to relay to!\n", __func__ );
|
LogPrint("net", "%s: No nodes to relay to!\n", __func__ );
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2522,10 +2521,10 @@ void RelayTransaction(const CTransaction& tx, const CDataStream& ss)
|
|||||||
|
|
||||||
vRelayNodes.resize(newSize);
|
vRelayNodes.resize(newSize);
|
||||||
if (HUSH_TESTNODE==1 && vNodes.size() == 0) {
|
if (HUSH_TESTNODE==1 && vNodes.size() == 0) {
|
||||||
fprintf(stderr, "%s: -testnode=1, no peers, not relaying\n", __func__ );
|
LogPrint("net", "%s: -testnode=1, no peers, not relaying\n", __func__ );
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "%s: Relaying %s to %lu of %lu peers\n", __func__, tx.GetHash().GetHex().c_str(), newSize, vNodes.size() );
|
LogPrint("net", "%s: Relaying %s to %lu of %lu peers\n", __func__, tx.GetHash().GetHex().c_str(), newSize, vNodes.size() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only relay to randomly chosen 50% of peers
|
// Only relay to randomly chosen 50% of peers
|
||||||
|
|||||||
39
src/pow.cpp
39
src/pow.cpp
@@ -113,13 +113,7 @@ arith_uint256 RT_CST_RST_outer(int32_t height,uint32_t nTime,arith_uint256 bnTar
|
|||||||
}
|
}
|
||||||
if ( bnTarget > mintarget )
|
if ( bnTarget > mintarget )
|
||||||
bnTarget = mintarget;
|
bnTarget = mintarget;
|
||||||
{
|
}
|
||||||
int32_t z;
|
|
||||||
for (z=31; z>=0; z--)
|
|
||||||
fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[z]);
|
|
||||||
}
|
|
||||||
fprintf(stderr," ht.%d initial W.%d outerK.%lld %d * %d * %d / %d\n",height,W,(long long)outerK,(nTime-ts[0]),(ts[0]-ts[W]),denominator,numerator);
|
|
||||||
} //else fprintf(stderr,"ht.%d no outer trigger %d >= %d\n",height,(ts[0] - ts[W]),(T * numerator)/denominator);
|
|
||||||
return(bnTarget);
|
return(bnTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,12 +140,6 @@ arith_uint256 RT_CST_RST_inner(int32_t height,uint32_t nTime,arith_uint256 bnTar
|
|||||||
bnTarget = RT_CST_RST_target(height,nTime,bnTarget,ts,ct,W);
|
bnTarget = RT_CST_RST_target(height,nTime,bnTarget,ts,ct,W);
|
||||||
if ( bnTarget == origtarget ) // force zawyflag to 1
|
if ( bnTarget == origtarget ) // force zawyflag to 1
|
||||||
bnTarget = mintarget;
|
bnTarget = mintarget;
|
||||||
{
|
|
||||||
int32_t z;
|
|
||||||
for (z=31; z>=0; z--)
|
|
||||||
fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[z]);
|
|
||||||
}
|
|
||||||
fprintf(stderr," height.%d O.%-2d, W.%-2d width.%-2d %4d vs %-4d, deficit %4d tip.%d\n",height,outeri,W,width,(ts[0] - ts[width]),expected,expected - (ts[0] - ts[width]),nTime-ts[0]);
|
|
||||||
}
|
}
|
||||||
return(bnTarget);
|
return(bnTarget);
|
||||||
}
|
}
|
||||||
@@ -211,23 +199,14 @@ arith_uint256 zawy_TSA_EMA(int32_t height,int32_t tipdiff,arith_uint256 prevTarg
|
|||||||
B = (bnTarget / arith_uint256(360000)) * arith_uint256(tipdiff * zawy_exponential_val360000(tipdiff/2));
|
B = (bnTarget / arith_uint256(360000)) * arith_uint256(tipdiff * zawy_exponential_val360000(tipdiff/2));
|
||||||
C = (bnTarget / arith_uint256(360000)) * arith_uint256(T * zawy_exponential_val360000(tipdiff/2));
|
C = (bnTarget / arith_uint256(360000)) * arith_uint256(T * zawy_exponential_val360000(tipdiff/2));
|
||||||
bnTarget = ((A + B - C) / arith_uint256(tipdiff)) * arith_uint256(K*T);
|
bnTarget = ((A + B - C) / arith_uint256(tipdiff)) * arith_uint256(K*T);
|
||||||
{
|
|
||||||
int32_t z;
|
|
||||||
for (z=31; z>=0; z--)
|
|
||||||
fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[z]);
|
|
||||||
}
|
|
||||||
fprintf(stderr," ht.%d TSA bnTarget tipdiff.%d\n",height,tipdiff);
|
|
||||||
return(bnTarget);
|
return(bnTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params)
|
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params)
|
||||||
{
|
{
|
||||||
if (pindexLast->GetHeight() == 340000) {
|
|
||||||
LogPrintf("%s: Using blocktime=%d\n",__func__,ASSETCHAINS_BLOCKTIME);
|
|
||||||
}
|
|
||||||
//if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH && ASSETCHAINS_STAKED == 0)
|
//if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH && ASSETCHAINS_STAKED == 0)
|
||||||
if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH && ASSETCHAINS_ALGO != ASSETCHAINS_RANDOMX) {
|
if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH && ASSETCHAINS_ALGO != ASSETCHAINS_RANDOMX) {
|
||||||
fprintf(stderr,"%s: using lwma for next work\n",__func__);
|
LogPrint("pow","%s: using lwma for next work\n",__func__);
|
||||||
return lwmaGetNextWorkRequired(pindexLast, pblock, params);
|
return lwmaGetNextWorkRequired(pindexLast, pblock, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,13 +288,11 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
|||||||
{
|
{
|
||||||
blocktime = pindexFirst->nTime;
|
blocktime = pindexFirst->nTime;
|
||||||
diff = (pblock->nTime - blocktime);
|
diff = (pblock->nTime - blocktime);
|
||||||
//fprintf(stderr,"%d ",diff);
|
|
||||||
if ( i < 6 )
|
if ( i < 6 )
|
||||||
{
|
{
|
||||||
diff -= (8+i)*ASSETCHAINS_BLOCKTIME;
|
diff -= (8+i)*ASSETCHAINS_BLOCKTIME;
|
||||||
if ( diff > mult )
|
if ( diff > mult )
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"i.%d diff.%d (%u - %u - %dx)\n",i,(int32_t)diff,pblock->nTime,pindexFirst->nTime,(8+i));
|
|
||||||
mult = diff;
|
mult = diff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -325,7 +302,6 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
|||||||
bnTot += bnTmp;
|
bnTot += bnTmp;
|
||||||
pindexFirst = pindexFirst->pprev;
|
pindexFirst = pindexFirst->pprev;
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"diffs %d\n",height);
|
|
||||||
// Check we have enough blocks
|
// Check we have enough blocks
|
||||||
if (pindexFirst == NULL)
|
if (pindexFirst == NULL)
|
||||||
return nProofOfWorkLimit;
|
return nProofOfWorkLimit;
|
||||||
@@ -422,15 +398,9 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
|||||||
if ( bnTarget < origtarget || bnTarget > easy )
|
if ( bnTarget < origtarget || bnTarget > easy )
|
||||||
{
|
{
|
||||||
bnTarget = easy;
|
bnTarget = easy;
|
||||||
fprintf(stderr,"cmp.%d mult.%d ht.%d -> easy target\n",mult>1,(int32_t)mult,height);
|
LogPrint("pow","cmp.%d mult.%d ht.%d -> easy target\n",mult>1,(int32_t)mult,height);
|
||||||
return(HUSH_MINDIFF_NBITS & (~3));
|
return(HUSH_MINDIFF_NBITS & (~3));
|
||||||
}
|
}
|
||||||
{
|
|
||||||
int32_t z;
|
|
||||||
for (z=31; z>=0; z--)
|
|
||||||
fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[z]);
|
|
||||||
}
|
|
||||||
fprintf(stderr," exp() to the rescue cmp.%d mult.%d for ht.%d\n",mult>1,(int32_t)mult,height);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nbits = bnTarget.GetCompact();
|
nbits = bnTarget.GetCompact();
|
||||||
@@ -527,8 +497,7 @@ unsigned int lwmaCalculateNextWorkRequired(const CBlockIndex* pindexLast, const
|
|||||||
bnLimit = UintToArith256(params.powAlternate);
|
bnLimit = UintToArith256(params.powAlternate);
|
||||||
|
|
||||||
unsigned int nProofOfWorkLimit = bnLimit.GetCompact();
|
unsigned int nProofOfWorkLimit = bnLimit.GetCompact();
|
||||||
|
|
||||||
//printf("PoWLimit: %u\n", nProofOfWorkLimit);
|
|
||||||
// Find the first block in the averaging interval as we total the linearly weighted average
|
// Find the first block in the averaging interval as we total the linearly weighted average
|
||||||
const CBlockIndex* pindexFirst = pindexLast;
|
const CBlockIndex* pindexFirst = pindexLast;
|
||||||
const CBlockIndex* pindexNext;
|
const CBlockIndex* pindexNext;
|
||||||
|
|||||||
@@ -363,7 +363,7 @@ UniValue setgenerate(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
|||||||
}
|
}
|
||||||
|
|
||||||
HUSH_MININGTHREADS = (int32_t)nGenProcLimit;
|
HUSH_MININGTHREADS = (int32_t)nGenProcLimit;
|
||||||
fprintf(stderr,"%s:HUSH_MININGTHREADS=%d\n", __FUNCTION__, HUSH_MININGTHREADS);
|
LogPrint("mining","%s:HUSH_MININGTHREADS=%d\n", __FUNCTION__, HUSH_MININGTHREADS);
|
||||||
|
|
||||||
mapArgs["-gen"] = (fGenerate ? "1" : "0");
|
mapArgs["-gen"] = (fGenerate ? "1" : "0");
|
||||||
mapArgs ["-genproclimit"] = itostr(HUSH_MININGTHREADS);
|
mapArgs ["-genproclimit"] = itostr(HUSH_MININGTHREADS);
|
||||||
@@ -847,7 +847,6 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp, const CPubKey& myp
|
|||||||
result.push_back(Pair("bits", strprintf("%08x", pblock->nBits)));
|
result.push_back(Pair("bits", strprintf("%08x", pblock->nBits)));
|
||||||
result.push_back(Pair("height", (int64_t)(pindexPrev->GetHeight()+1)));
|
result.push_back(Pair("height", (int64_t)(pindexPrev->GetHeight()+1)));
|
||||||
|
|
||||||
//fprintf(stderr,"return complete template\n");
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -898,7 +897,6 @@ UniValue submitblock(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
|||||||
);
|
);
|
||||||
|
|
||||||
CBlock block;
|
CBlock block;
|
||||||
//LogPrintStr("Hex block submission: " + params[0].get_str());
|
|
||||||
if (!DecodeHexBlk(block, params[0].get_str()))
|
if (!DecodeHexBlk(block, params[0].get_str()))
|
||||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block decode failed");
|
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block decode failed");
|
||||||
|
|
||||||
@@ -924,7 +922,6 @@ UniValue submitblock(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
|||||||
CValidationState state;
|
CValidationState state;
|
||||||
submitblock_StateCatcher sc(block.GetHash());
|
submitblock_StateCatcher sc(block.GetHash());
|
||||||
RegisterValidationInterface(&sc);
|
RegisterValidationInterface(&sc);
|
||||||
//printf("submitblock, height=%d, coinbase sequence: %d, scriptSig: %s\n", chainActive.LastTip()->GetHeight()+1, block.vtx[0].vin[0].nSequence, block.vtx[0].vin[0].scriptSig.ToString().c_str());
|
|
||||||
bool fAccepted = ProcessNewBlock(1,chainActive.LastTip()->GetHeight()+1,state, NULL, &block, true, NULL);
|
bool fAccepted = ProcessNewBlock(1,chainActive.LastTip()->GetHeight()+1,state, NULL, &block, true, NULL);
|
||||||
UnregisterValidationInterface(&sc);
|
UnregisterValidationInterface(&sc);
|
||||||
if (fBlockPresent)
|
if (fBlockPresent)
|
||||||
|
|||||||
@@ -1168,7 +1168,7 @@ UniValue signrawtransaction(const UniValue& params, bool fHelp, const CPubKey& m
|
|||||||
numiters++;
|
numiters++;
|
||||||
}
|
}
|
||||||
if ( numiters > 0 )
|
if ( numiters > 0 )
|
||||||
fprintf(stderr,"ASSETCHAINS_TXPOW.%d txpow.%d numiters.%d for signature\n",ASSETCHAINS_TXPOW,txpow,numiters);
|
LogPrintf("ASSETCHAINS_TXPOW.%d txpow.%d numiters.%d for signature\n",ASSETCHAINS_TXPOW,txpow,numiters);
|
||||||
bool fComplete = vErrors.empty();
|
bool fComplete = vErrors.empty();
|
||||||
|
|
||||||
UniValue result(UniValue::VOBJ);
|
UniValue result(UniValue::VOBJ);
|
||||||
|
|||||||
@@ -637,9 +637,6 @@ void CustomizeWork(const StratumClient& client, const StratumWork& current_work,
|
|||||||
nonce.insert(nonce.end(), extranonce2.begin(), extranonce2.end());
|
nonce.insert(nonce.end(), extranonce2.begin(), extranonce2.end());
|
||||||
|
|
||||||
// nonce = extranonce1 + extranonce2
|
// nonce = extranonce1 + extranonce2
|
||||||
// if (instance_of_cstratumparams.fstdErrDebugOutput) {
|
|
||||||
// std::cerr << __func__ << ": " << __FILE__ << "," << __LINE__ << " nonce = " << HexStr(nonce) << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (cb.vin.empty()) {
|
if (cb.vin.empty()) {
|
||||||
const std::string msg = strprintf("%s: first transaction is missing coinbase input; unable to customize work to miner", __func__);
|
const std::string msg = strprintf("%s: first transaction is missing coinbase input; unable to customize work to miner", __func__);
|
||||||
@@ -737,14 +734,11 @@ std::string GetWorkUnit(StratumClient& client)
|
|||||||
throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory");
|
throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (instance_of_cstratumparams.fstdErrDebugOutput) std::cerr << __func__ << ": " << __FILE__ << "," << __LINE__ << "hashMerkleRoot = " << new_work->block.hashMerkleRoot.ToString() << std::endl;
|
|
||||||
|
|
||||||
// So that block.GetHash() is correct
|
// So that block.GetHash() is correct
|
||||||
//new_work->block.hashMerkleRoot = BlockMerkleRoot(new_work->block);
|
//new_work->block.hashMerkleRoot = BlockMerkleRoot(new_work->block);
|
||||||
new_work->block.hashMerkleRoot = new_work->block.BuildMerkleTree();
|
new_work->block.hashMerkleRoot = new_work->block.BuildMerkleTree();
|
||||||
|
|
||||||
// NB! here we have merkle with scriptDummy script in coinbase, after CustomizeWork we should recalculate it (!)
|
// NB! here we have merkle with scriptDummy script in coinbase, after CustomizeWork we should recalculate it (!)
|
||||||
// if (instance_of_cstratumparams.fstdErrDebugOutput) std::cerr << __func__ << ": " << __FILE__ << "," << __LINE__ << "hashMerkleRoot = " << new_work->block.hashMerkleRoot.ToString() << std::endl;
|
|
||||||
|
|
||||||
job_id = new_work->block.GetHash();
|
job_id = new_work->block.GetHash();
|
||||||
//work_templates[job_id] = StratumWork(*new_work, new_work->block.vtx[0]->HasWitness());
|
//work_templates[job_id] = StratumWork(*new_work, new_work->block.vtx[0]->HasWitness());
|
||||||
@@ -851,12 +845,6 @@ std::string GetWorkUnit(StratumClient& client)
|
|||||||
CMutableTransaction cb, bf;
|
CMutableTransaction cb, bf;
|
||||||
std::vector<uint256> cb_branch;
|
std::vector<uint256> cb_branch;
|
||||||
|
|
||||||
// if (instance_of_cstratumparams.fstdErrDebugOutput)
|
|
||||||
// {
|
|
||||||
// std::cerr << __func__ << ": " << __FILE__ << "," << __LINE__ << " [1] cb = " << CTransaction(cb).ToString() << std::endl;
|
|
||||||
// std::cerr << __func__ << ": " << __FILE__ << "," << __LINE__ << " [1] current_work.GetBlock().vtx[0] = " << current_work.GetBlock().vtx[0].ToString() << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
{
|
{
|
||||||
std::vector<unsigned char> extranonce1 = client.ExtraNonce1(job_id);
|
std::vector<unsigned char> extranonce1 = client.ExtraNonce1(job_id);
|
||||||
|
|
||||||
@@ -873,12 +861,6 @@ std::string GetWorkUnit(StratumClient& client)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (instance_of_cstratumparams.fstdErrDebugOutput)
|
|
||||||
// {
|
|
||||||
// std::cerr << __func__ << ": " << __FILE__ << "," << __LINE__ << " [2] cb = " << CTransaction(cb).ToString() << std::endl;
|
|
||||||
// std::cerr << __func__ << ": " << __FILE__ << "," << __LINE__ << " [2] current_work.GetBlock().vtx[0] = " << current_work.GetBlock().vtx[0].ToString() << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
CBlockHeader blkhdr;
|
CBlockHeader blkhdr;
|
||||||
// Setup native proof-of-work
|
// Setup native proof-of-work
|
||||||
|
|
||||||
@@ -992,14 +974,6 @@ bool SubmitBlock(StratumClient& client, const uint256& job_id, const StratumWork
|
|||||||
blkhdr.hashMerkleRoot = current_work.GetBlock().hashMerkleRoot;
|
blkhdr.hashMerkleRoot = current_work.GetBlock().hashMerkleRoot;
|
||||||
blkhdr.nNonce = (uint256) nonce;
|
blkhdr.nNonce = (uint256) nonce;
|
||||||
|
|
||||||
// example how to display constructed block
|
|
||||||
// if (instance_of_cstratumparams.fstdErrDebugOutput) {
|
|
||||||
// CBlockIndex index {blkhdr};
|
|
||||||
// index.SetHeight(current_work.nHeight);
|
|
||||||
// std::cerr << __func__ << ": " << __FILE__ << "," << __LINE__ << " blkhdr.hashPrevBlock = " << blkhdr.hashPrevBlock.GetHex() << std::endl;
|
|
||||||
// std::cerr << __func__ << ": " << __FILE__ << "," << __LINE__ << " blkhdr = " << blockToJSON(blkhdr, &index).write() << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// block is constructed, now it's time to VerifyEH
|
// block is constructed, now it's time to VerifyEH
|
||||||
|
|
||||||
if (instance_of_cstratumparams.fCheckEquihashSolution && !CheckEquihashSolution(&blkhdr, Params()))
|
if (instance_of_cstratumparams.fCheckEquihashSolution && !CheckEquihashSolution(&blkhdr, Params()))
|
||||||
@@ -1018,7 +992,6 @@ bool SubmitBlock(StratumClient& client, const uint256& job_id, const StratumWork
|
|||||||
uint8_t pubkey33[33]; int32_t height = current_work.nHeight;
|
uint8_t pubkey33[33]; int32_t height = current_work.nHeight;
|
||||||
res = CheckProofOfWork(blkhdr, pubkey33, height, Params().GetConsensus());
|
res = CheckProofOfWork(blkhdr, pubkey33, height, Params().GetConsensus());
|
||||||
}
|
}
|
||||||
// if (instance_of_cstratumparams.fstdErrDebugOutput) std::cerr << DateTimeStrPrecise() << "res[1] = " << res << std::endl;
|
|
||||||
|
|
||||||
uint256 hash = blkhdr.GetHash();
|
uint256 hash = blkhdr.GetHash();
|
||||||
|
|
||||||
@@ -1061,27 +1034,8 @@ bool SubmitBlock(StratumClient& client, const uint256& job_id, const StratumWork
|
|||||||
shares_accepted_since_last = counter_TotalShares - counter_prev;
|
shares_accepted_since_last = counter_TotalShares - counter_prev;
|
||||||
start = finish;
|
start = finish;
|
||||||
counter_prev = counter_TotalShares;
|
counter_prev = counter_TotalShares;
|
||||||
// std::cerr << strprintf("%f ms - %" PRIu64 "", elapsed.count(), shares_accepted_since_last) << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fDisplayDiffHUSH = true; // otherwise it will display ccminer diff
|
|
||||||
|
|
||||||
std::cerr << DateTimeStrPrecise() <<
|
|
||||||
strprintf("%saccepted: %" PRIu64 "/%" PRIu64 "%s ", ColorTypeNames[cl_WHT], counter_TotalBlocks, counter_TotalShares, ColorTypeNames[cl_N] );
|
|
||||||
if (fDisplayDiffHUSH) {
|
|
||||||
/* hushd diff display */
|
|
||||||
std::cerr << strprintf("%slocal %g%s ", "\x1B[90m", hush_local_diff, ColorTypeNames[cl_N]) <<
|
|
||||||
strprintf("%s(diff %g, target %g) %s ", ColorTypeNames[cl_WHT], hush_real_diff, hush_target_diff, ColorTypeNames[cl_N]);
|
|
||||||
} else { /* ccminer diff display */
|
|
||||||
std::cerr << strprintf("%slocal %.3f%s ", "\x1B[90m", ccminer_local_diff, ColorTypeNames[cl_N]) <<
|
|
||||||
strprintf("%s(diff %.3f, target %.3f) %s", ColorTypeNames[cl_WHT], ccminer_real_diff, ccminer_target_diff, ColorTypeNames[cl_N]); // ccminer diff
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cerr << "" <<
|
|
||||||
strprintf("%f ms ", elapsed.count()) << // 1 share took elapsed ms
|
|
||||||
strprintf("%s%s%s ", ColorTypeNames[cl_LGR], (res ? "yay!!!": "yes!"), ColorTypeNames[cl_N]) <<
|
|
||||||
std::endl;
|
|
||||||
|
|
||||||
// (diff %g, target %g), %
|
// (diff %g, target %g), %
|
||||||
if (res) {
|
if (res) {
|
||||||
|
|
||||||
@@ -1097,7 +1051,6 @@ bool SubmitBlock(StratumClient& client, const uint256& job_id, const StratumWork
|
|||||||
block.nVersion = version;
|
block.nVersion = version;
|
||||||
// block.hashMerkleRoot = BlockMerkleRoot(block);
|
// block.hashMerkleRoot = BlockMerkleRoot(block);
|
||||||
block.hashMerkleRoot = block.BuildMerkleTree();
|
block.hashMerkleRoot = block.BuildMerkleTree();
|
||||||
//if (instance_of_cstratumparams.fstdErrDebugOutput) std::cerr << "hashMerkleRoot = " << block.hashMerkleRoot.GetHex() << std::endl;
|
|
||||||
|
|
||||||
block.nTime = nTime;
|
block.nTime = nTime;
|
||||||
// block.nNonce = nNonce;
|
// block.nNonce = nNonce;
|
||||||
@@ -1106,22 +1059,12 @@ bool SubmitBlock(StratumClient& client, const uint256& job_id, const StratumWork
|
|||||||
block.nNonce = (uint256) nonce;
|
block.nNonce = (uint256) nonce;
|
||||||
block.nSolution = std::vector<unsigned char>(sol.begin() + 3, sol.end());
|
block.nSolution = std::vector<unsigned char>(sol.begin() + 3, sol.end());
|
||||||
|
|
||||||
// example how to pre-check the equihash solution
|
|
||||||
// if(instance_of_cstratumparams.fstdErrDebugOutput) {
|
|
||||||
// CBlockIndex index {blkhdr};
|
|
||||||
// index.SetHeight(-1);
|
|
||||||
// std::cerr << "block = " << blockToJSON(block, &index, true).write(1) << std::endl;
|
|
||||||
// std::cerr << "CheckEquihashSolution = " << CheckEquihashSolution(&block, Params()) << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// std::shared_ptr<const CBlock> pblock = std::make_shared<const CBlock>(block);
|
// std::shared_ptr<const CBlock> pblock = std::make_shared<const CBlock>(block);
|
||||||
// res = ProcessNewBlock(Params(), pblock, true, NULL);
|
// res = ProcessNewBlock(Params(), pblock, true, NULL);
|
||||||
|
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
res = ProcessNewBlock(0,0,state, NULL, &block, true /* forceProcessing */ , NULL);
|
res = ProcessNewBlock(0,0,state, NULL, &block, true /* forceProcessing */ , NULL);
|
||||||
|
|
||||||
//if (instance_of_cstratumparams.fstdErrDebugOutput) std::cerr << DateTimeStrPrecise() << "res[2] = " << res << std::endl;
|
|
||||||
|
|
||||||
// we haven't PreciousBlock, so we can't prioritize the block this way for now
|
// we haven't PreciousBlock, so we can't prioritize the block this way for now
|
||||||
/*
|
/*
|
||||||
if (res) {
|
if (res) {
|
||||||
@@ -1207,14 +1150,6 @@ UniValue stratum_mining_subscribe(StratumClient& client, const UniValue& params)
|
|||||||
* sExtraNonce1 for a given client based on m_secret.
|
* sExtraNonce1 for a given client based on m_secret.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// if (instance_of_cstratumparams.fstdErrDebugOutput && vExtraNonce1.size() > 3) {
|
|
||||||
// std::cerr << __func__ << ": " << __FILE__ << "," << __LINE__ << " " << strprintf("client.m_supports_extranonce = %d, [%d, %d, %d, %d], %s", client.m_supports_extranonce, vExtraNonce1[0], vExtraNonce1[1], vExtraNonce1[2], vExtraNonce1[3], sExtraNonce1) << std::endl;
|
|
||||||
// // recalc from client.m_secret example
|
|
||||||
// uint256 sha256;
|
|
||||||
// CSHA256().Write(client.m_secret.begin(), 32).Finalize(sha256.begin());
|
|
||||||
// std::cerr << __func__ << ": " << __FILE__ << "," << __LINE__ << " " << HexStr(std::vector<unsigned char>(sha256.begin(), sha256.begin() + 4)) << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
ret.push_back(NullUniValue);
|
ret.push_back(NullUniValue);
|
||||||
ret.push_back(sExtraNonce1);
|
ret.push_back(sExtraNonce1);
|
||||||
|
|
||||||
@@ -1340,10 +1275,8 @@ UniValue stratum_mining_submit(StratumClient& client, const UniValue& params)
|
|||||||
bool fEWBFJobIDFixNeeded = false;
|
bool fEWBFJobIDFixNeeded = false;
|
||||||
uint256 ret;
|
uint256 ret;
|
||||||
if (params[1].isStr()) {
|
if (params[1].isStr()) {
|
||||||
//std::cerr << "\"" << params[1].get_str() << "\"" << std::endl;
|
|
||||||
const std::string job_id_str = params[1].get_str();
|
const std::string job_id_str = params[1].get_str();
|
||||||
const std::string hexDigits = "0123456789abcdef";
|
const std::string hexDigits = "0123456789abcdef";
|
||||||
// std::cerr << strprintf("\"%s\" (%d)", job_id_str, job_id_str.length()) << std::endl;
|
|
||||||
if (job_id_str.length() == 63) {
|
if (job_id_str.length() == 63) {
|
||||||
fEWBFJobIDFixNeeded = true;
|
fEWBFJobIDFixNeeded = true;
|
||||||
for(const auto& hexDigit : hexDigits) {
|
for(const auto& hexDigit : hexDigits) {
|
||||||
@@ -1816,7 +1749,7 @@ void SendKeepAlivePackets()
|
|||||||
if ( (client.m_last_tip && client.m_last_tip->GetHeight() == chainActive.Tip()->GetHeight()) || (!client.m_last_tip) )
|
if ( (client.m_last_tip && client.m_last_tip->GetHeight() == chainActive.Tip()->GetHeight()) || (!client.m_last_tip) )
|
||||||
{
|
{
|
||||||
LOCK(cs_stratum);
|
LOCK(cs_stratum);
|
||||||
std::cerr << DateTimeStrPrecise() << "\033[31m" << client.m_from.ToString() << "\033[0m seems stucked (ccminer issue), need to emulate new block incoming to unstuck!" << std::endl;
|
LogPrint("stratum", "%s seems stucked (ccminer issue), need to emulate new block incoming to unstuck!\n", client.m_from.ToString());
|
||||||
mempool.AddTransactionsUpdated(1);
|
mempool.AddTransactionsUpdated(1);
|
||||||
client.m_last_tip = (client.m_last_tip ? nullptr : chainActive.Tip());
|
client.m_last_tip = (client.m_last_tip ? nullptr : chainActive.Tip());
|
||||||
client.m_nextid++;
|
client.m_nextid++;
|
||||||
@@ -1836,7 +1769,7 @@ bool InitStratumServer()
|
|||||||
|
|
||||||
int stratumPort = BaseParams().StratumPort();
|
int stratumPort = BaseParams().StratumPort();
|
||||||
int defaultPort = GetArg("-stratumport", stratumPort);
|
int defaultPort = GetArg("-stratumport", stratumPort);
|
||||||
fprintf(stderr,"%s: Starting built-in stratum server on port %d\n",__func__, defaultPort );
|
LogPrintf("%s: Starting built-in stratum server on port %d\n",__func__, defaultPort );
|
||||||
|
|
||||||
|
|
||||||
if (!InitStratumAllowList(stratum_allow_subnets)) {
|
if (!InitStratumAllowList(stratum_allow_subnets)) {
|
||||||
@@ -1959,7 +1892,7 @@ UniValue rpc_stratum_updatework(const UniValue& params, bool fHelp, const CPubKe
|
|||||||
|
|
||||||
// Ignore clients that aren't authorized yet.
|
// Ignore clients that aren't authorized yet.
|
||||||
if (!client.m_authorized && client.m_aux_addr.empty()) {
|
if (!client.m_authorized && client.m_aux_addr.empty()) {
|
||||||
fprintf(stderr,"%s: Ignoring unauthorized client\n", __func__);
|
LogPrint("stratum", "%s: Ignoring unauthorized client\n", __func__);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
16
src/txdb.cpp
16
src/txdb.cpp
@@ -472,7 +472,6 @@ bool CBlockTreeDB::Snapshot2(std::map <std::string, CAmount> &addressAmounts, Un
|
|||||||
iter->GetKey(keyObj);
|
iter->GetKey(keyObj);
|
||||||
char chType = keyObj.first;
|
char chType = keyObj.first;
|
||||||
CAddressIndexIteratorKey indexKey = keyObj.second;
|
CAddressIndexIteratorKey indexKey = keyObj.second;
|
||||||
//fprintf(stderr, "chType=%d\n", chType);
|
|
||||||
if (chType == DB_ADDRESSUNSPENTINDEX)
|
if (chType == DB_ADDRESSUNSPENTINDEX)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@@ -485,7 +484,7 @@ bool CBlockTreeDB::Snapshot2(std::map <std::string, CAmount> &addressAmounts, Un
|
|||||||
std::map <std::string, int>::iterator ignored = ignoredMap.find(address);
|
std::map <std::string, int>::iterator ignored = ignoredMap.find(address);
|
||||||
if (ignored != ignoredMap.end())
|
if (ignored != ignoredMap.end())
|
||||||
{
|
{
|
||||||
fprintf(stderr,"ignoring %s\n", address.c_str());
|
LogPrint("coindb", "ignoring %s\n", address.c_str());
|
||||||
ignoredAddresses++;
|
ignoredAddresses++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -493,17 +492,14 @@ bool CBlockTreeDB::Snapshot2(std::map <std::string, CAmount> &addressAmounts, Un
|
|||||||
if ( pos == addressAmounts.end() )
|
if ( pos == addressAmounts.end() )
|
||||||
{
|
{
|
||||||
// insert new address + utxo amount
|
// insert new address + utxo amount
|
||||||
//fprintf(stderr, "inserting new address %s with amount %li\n", address.c_str(), nValue);
|
|
||||||
addressAmounts[address] = nValue;
|
addressAmounts[address] = nValue;
|
||||||
totalAddresses++;
|
totalAddresses++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// update unspent tally for this address
|
// update unspent tally for this address
|
||||||
//fprintf(stderr, "updating address %s with new utxo amount %li\n", address.c_str(), nValue);
|
|
||||||
addressAmounts[address] += nValue;
|
addressAmounts[address] += nValue;
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"{\"%s\", %.8f},\n",address.c_str(),(double)nValue/COIN);
|
|
||||||
// total += nValue;
|
// total += nValue;
|
||||||
utxos++;
|
utxos++;
|
||||||
total += nValue;
|
total += nValue;
|
||||||
@@ -527,8 +523,7 @@ bool CBlockTreeDB::Snapshot2(std::map <std::string, CAmount> &addressAmounts, Un
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//fprintf(stderr, "total=%f, totalAddresses=%li, utxos=%li, ignored=%li\n", (double) total / COIN, totalAddresses, utxos, ignoredAddresses);
|
|
||||||
|
|
||||||
// this is for the snapshot RPC, you can skip this by passing a 0 as the last argument.
|
// this is for the snapshot RPC, you can skip this by passing a 0 as the last argument.
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
@@ -681,23 +676,18 @@ bool CBlockTreeDB::LoadBlockIndexGuts()
|
|||||||
boost::scoped_ptr<CDBIterator> pcursor(NewIterator());
|
boost::scoped_ptr<CDBIterator> pcursor(NewIterator());
|
||||||
|
|
||||||
pcursor->Seek(make_pair(DB_BLOCK_INDEX, uint256()));
|
pcursor->Seek(make_pair(DB_BLOCK_INDEX, uint256()));
|
||||||
//fprintf(stderr,"%s: Seeked cursor to block index\n",__FUNCTION__);
|
|
||||||
|
|
||||||
// Load mapBlockIndex
|
// Load mapBlockIndex
|
||||||
while (pcursor->Valid()) {
|
while (pcursor->Valid()) {
|
||||||
//fprintf(stderr,"%s: Valid cursor\n",__FUNCTION__);
|
|
||||||
boost::this_thread::interruption_point();
|
boost::this_thread::interruption_point();
|
||||||
std::pair<char, uint256> key;
|
std::pair<char, uint256> key;
|
||||||
if (pcursor->GetKey(key) && key.first == DB_BLOCK_INDEX) {
|
if (pcursor->GetKey(key) && key.first == DB_BLOCK_INDEX) {
|
||||||
//fprintf(stderr,"%s: Found DB_BLOCK_INDEX\n",__FUNCTION__);
|
|
||||||
CDiskBlockIndex diskindex;
|
CDiskBlockIndex diskindex;
|
||||||
if (pcursor->GetValue(diskindex)) {
|
if (pcursor->GetValue(diskindex)) {
|
||||||
// Construct block index object
|
// Construct block index object
|
||||||
//fprintf(stderr,"%s: Creating CBlockIndex...\n",__FUNCTION__);
|
|
||||||
CBlockIndex* pindexNew = InsertBlockIndex(diskindex.GetBlockHash());
|
CBlockIndex* pindexNew = InsertBlockIndex(diskindex.GetBlockHash());
|
||||||
pindexNew->pprev = InsertBlockIndex(diskindex.hashPrev);
|
pindexNew->pprev = InsertBlockIndex(diskindex.hashPrev);
|
||||||
pindexNew->SetHeight(diskindex.GetHeight());
|
pindexNew->SetHeight(diskindex.GetHeight());
|
||||||
//fprintf(stderr,"%s: Setting CBlockIndex height...\n",__FUNCTION__);
|
|
||||||
pindexNew->nFile = diskindex.nFile;
|
pindexNew->nFile = diskindex.nFile;
|
||||||
pindexNew->nDataPos = diskindex.nDataPos;
|
pindexNew->nDataPos = diskindex.nDataPos;
|
||||||
pindexNew->nUndoPos = diskindex.nUndoPos;
|
pindexNew->nUndoPos = diskindex.nUndoPos;
|
||||||
@@ -715,7 +705,6 @@ bool CBlockTreeDB::LoadBlockIndexGuts()
|
|||||||
pindexNew->nTx = diskindex.nTx;
|
pindexNew->nTx = diskindex.nTx;
|
||||||
pindexNew->nSproutValue = diskindex.nSproutValue;
|
pindexNew->nSproutValue = diskindex.nSproutValue;
|
||||||
pindexNew->nSaplingValue = diskindex.nSaplingValue;
|
pindexNew->nSaplingValue = diskindex.nSaplingValue;
|
||||||
//fprintf(stderr,"%s: Setting CBlockIndex details...\n",__FUNCTION__);
|
|
||||||
pindexNew->segid = diskindex.segid;
|
pindexNew->segid = diskindex.segid;
|
||||||
pindexNew->nNotaryPay = diskindex.nNotaryPay;
|
pindexNew->nNotaryPay = diskindex.nNotaryPay;
|
||||||
pindexNew->nPayments = diskindex.nPayments;
|
pindexNew->nPayments = diskindex.nPayments;
|
||||||
@@ -731,7 +720,6 @@ bool CBlockTreeDB::LoadBlockIndexGuts()
|
|||||||
pindexNew->nFullyShieldedPayments = diskindex.nFullyShieldedPayments;
|
pindexNew->nFullyShieldedPayments = diskindex.nFullyShieldedPayments;
|
||||||
pindexNew->nNotarizations = diskindex.nNotarizations;
|
pindexNew->nNotarizations = diskindex.nNotarizations;
|
||||||
|
|
||||||
//fprintf(stderr,"loadguts ht.%d\n",pindexNew->GetHeight());
|
|
||||||
// Consistency checks
|
// Consistency checks
|
||||||
/*
|
/*
|
||||||
CBlockHeader header;
|
CBlockHeader header;
|
||||||
|
|||||||
@@ -1231,7 +1231,6 @@ UniValue nspv_listtransactions(const UniValue& params, bool fHelp, const CPubKey
|
|||||||
CCflag = atoi((char *)params[1].get_str().c_str());
|
CCflag = atoi((char *)params[1].get_str().c_str());
|
||||||
if ( params.size() == 3 )
|
if ( params.size() == 3 )
|
||||||
skipcount = atoi((char *)params[2].get_str().c_str());
|
skipcount = atoi((char *)params[2].get_str().c_str());
|
||||||
//fprintf(stderr,"call txids cc.%d skip.%d\n",CCflag,skipcount);
|
|
||||||
return(NSPV_addresstxids((char *)params[0].get_str().c_str(),CCflag,skipcount,0));
|
return(NSPV_addresstxids((char *)params[0].get_str().c_str(),CCflag,skipcount,0));
|
||||||
}
|
}
|
||||||
else throw runtime_error("nspv_listtransactions [address [isCC [skipcount]]]\n");
|
else throw runtime_error("nspv_listtransactions [address [isCC [skipcount]]]\n");
|
||||||
@@ -1294,7 +1293,6 @@ UniValue nspv_spend(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
|||||||
if ( NSPV_address.size() == 0 )
|
if ( NSPV_address.size() == 0 )
|
||||||
throw runtime_error("to nspv_send you need an active nspv_login\n");
|
throw runtime_error("to nspv_send you need an active nspv_login\n");
|
||||||
satoshis = atof(params[1].get_str().c_str())*COIN + 0.0000000049;
|
satoshis = atof(params[1].get_str().c_str())*COIN + 0.0000000049;
|
||||||
//fprintf(stderr,"satoshis.%lld from %.8f\n",(long long)satoshis,atof(params[1].get_str().c_str()));
|
|
||||||
if ( satoshis < 1000 )
|
if ( satoshis < 1000 )
|
||||||
throw runtime_error("amount too small\n");
|
throw runtime_error("amount too small\n");
|
||||||
return(NSPV_spend((char *)NSPV_address.c_str(),(char *)params[0].get_str().c_str(),satoshis));
|
return(NSPV_spend((char *)NSPV_address.c_str(),(char *)params[0].get_str().c_str(),satoshis));
|
||||||
|
|||||||
@@ -496,7 +496,6 @@ static void SendMoney(const CTxDestination &address, CAmount nValue, bool fSubtr
|
|||||||
// Check amount
|
// Check amount
|
||||||
if (nValue <= 0)
|
if (nValue <= 0)
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid amount");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid amount");
|
||||||
//fprintf(stderr,"nValue %.8f vs curBalance %.8f\n",(double)nValue/COIN,(double)curBalance/COIN);
|
|
||||||
if (nValue > curBalance)
|
if (nValue > curBalance)
|
||||||
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds");
|
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds");
|
||||||
|
|
||||||
@@ -518,9 +517,7 @@ static void SendMoney(const CTxDestination &address, CAmount nValue, bool fSubtr
|
|||||||
for (i=0; i<opretlen; i++)
|
for (i=0; i<opretlen; i++)
|
||||||
{
|
{
|
||||||
opretpubkey[i] = opretbuf[i];
|
opretpubkey[i] = opretbuf[i];
|
||||||
//printf("%02x",ptr[i]);
|
|
||||||
}
|
}
|
||||||
//printf(" opretbuf[%d]\n",opretlen);
|
|
||||||
CRecipient opret = { opretpubkey, opretValue, false };
|
CRecipient opret = { opretpubkey, opretValue, false };
|
||||||
vecSend.push_back(opret);
|
vecSend.push_back(opret);
|
||||||
}
|
}
|
||||||
@@ -665,7 +662,6 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
|||||||
if ( (n= (int32_t)params.size()) >= 3 )
|
if ( (n= (int32_t)params.size()) >= 3 )
|
||||||
{
|
{
|
||||||
flags = atoi(params[2].get_str().c_str());
|
flags = atoi(params[2].get_str().c_str());
|
||||||
//printf("flags.%d (%s) n.%d\n",flags,params[2].get_str().c_str(),n);
|
|
||||||
} else flags = 0;
|
} else flags = 0;
|
||||||
if ( n >= 4 )
|
if ( n >= 4 )
|
||||||
privkey = hush_kvprivkey(&pubkey,(char *)(n >= 4 ? params[3].get_str().c_str() : "password"));
|
privkey = hush_kvprivkey(&pubkey,(char *)(n >= 4 ? params[3].get_str().c_str() : "password"));
|
||||||
@@ -704,14 +700,11 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
|||||||
if ( hush_kvsigverify(keyvalue,keylen+refvaluesize,refpubkey,sig) < 0 )
|
if ( hush_kvsigverify(keyvalue,keylen+refvaluesize,refpubkey,sig) < 0 )
|
||||||
{
|
{
|
||||||
ret.push_back(Pair("error",(char *)"error verifying sig, passphrase is probably wrong"));
|
ret.push_back(Pair("error",(char *)"error verifying sig, passphrase is probably wrong"));
|
||||||
printf("VERIFY ERROR\n");
|
LogPrintf("VERIFY ERROR\n");
|
||||||
return ret;
|
return ret;
|
||||||
} // else printf("verified immediately\n");
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//for (i=0; i<32; i++)
|
|
||||||
// printf("%02x",((uint8_t *)&sig)[i]);
|
|
||||||
//printf(" sig for keylen.%d + valuesize.%d\n",keylen,refvaluesize);
|
|
||||||
ret.push_back(Pair("coin",(char *)(SMART_CHAIN_SYMBOL[0] == 0 ? "HUSH3" : SMART_CHAIN_SYMBOL)));
|
ret.push_back(Pair("coin",(char *)(SMART_CHAIN_SYMBOL[0] == 0 ? "HUSH3" : SMART_CHAIN_SYMBOL)));
|
||||||
height = chainActive.LastTip()->GetHeight();
|
height = chainActive.LastTip()->GetHeight();
|
||||||
if ( memcmp(&zeroes,&refpubkey,sizeof(refpubkey)) != 0 )
|
if ( memcmp(&zeroes,&refpubkey,sizeof(refpubkey)) != 0 )
|
||||||
@@ -749,9 +742,6 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
|||||||
}
|
}
|
||||||
if ( (opretlen= hush_opreturnscript(opretbuf,'K',keyvalue,coresize)) == 40 )
|
if ( (opretlen= hush_opreturnscript(opretbuf,'K',keyvalue,coresize)) == 40 )
|
||||||
opretlen++;
|
opretlen++;
|
||||||
//for (i=0; i<opretlen; i++)
|
|
||||||
// printf("%02x",opretbuf[i]);
|
|
||||||
//printf(" opretbuf keylen.%d valuesize.%d height.%d (%02x %02x %02x)\n",*(uint16_t *)&keyvalue[0],*(uint16_t *)&keyvalue[2],*(uint32_t *)&keyvalue[4],keyvalue[8],keyvalue[9],keyvalue[10]);
|
|
||||||
EnsureWalletIsUnlocked();
|
EnsureWalletIsUnlocked();
|
||||||
fee = hush_kvfee(flags,opretlen,keylen);
|
fee = hush_kvfee(flags,opretlen,keylen);
|
||||||
ret.push_back(Pair("fee",(double)fee/COIN));
|
ret.push_back(Pair("fee",(double)fee/COIN));
|
||||||
@@ -1823,7 +1813,6 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
|
|||||||
BOOST_FOREACH(const COutputEntry& r, listReceived)
|
BOOST_FOREACH(const COutputEntry& r, listReceived)
|
||||||
{
|
{
|
||||||
string account;
|
string account;
|
||||||
//fprintf(stderr,"recv iter %s\n",wtx.GetHash().GetHex().c_str());
|
|
||||||
if (pwalletMain->mapAddressBook.count(r.destination))
|
if (pwalletMain->mapAddressBook.count(r.destination))
|
||||||
account = pwalletMain->mapAddressBook[r.destination].name;
|
account = pwalletMain->mapAddressBook[r.destination].name;
|
||||||
if (fAllAccounts || (account == strAccount))
|
if (fAllAccounts || (account == strAccount))
|
||||||
@@ -1972,9 +1961,8 @@ UniValue listtransactions(const UniValue& params, bool fHelp, const CPubKey& myp
|
|||||||
CWalletTx *const pwtx = (*it).second.first;
|
CWalletTx *const pwtx = (*it).second.first;
|
||||||
if (pwtx != 0)
|
if (pwtx != 0)
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"pwtx iter.%d %s\n",(int32_t)pwtx->nOrderPos,pwtx->GetHash().GetHex().c_str());
|
|
||||||
ListTransactions(*pwtx, strAccount, 0, true, ret, filter);
|
ListTransactions(*pwtx, strAccount, 0, true, ret, filter);
|
||||||
} //else fprintf(stderr,"null pwtx\n");
|
}
|
||||||
CAccountingEntry *const pacentry = (*it).second.second;
|
CAccountingEntry *const pacentry = (*it).second.second;
|
||||||
if (pacentry != 0)
|
if (pacentry != 0)
|
||||||
AcentryToJSON(*pacentry, strAccount, ret);
|
AcentryToJSON(*pacentry, strAccount, ret);
|
||||||
@@ -2959,7 +2947,6 @@ UniValue listunspent(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
|||||||
BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock());
|
BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock());
|
||||||
CBlockIndex *tipindex,*pindex = it->second;
|
CBlockIndex *tipindex,*pindex = it->second;
|
||||||
uint32_t locktime;
|
uint32_t locktime;
|
||||||
//fprintf(stderr,"nValue %.8f pindex.%p tipindex.%p locktime.%u txheight.%d pindexht.%d\n",(double)nValue/COIN,pindex,chainActive.LastTip(),locktime,txheight,pindex->GetHeight());
|
|
||||||
}
|
}
|
||||||
else if ( chainActive.LastTip() != 0 )
|
else if ( chainActive.LastTip() != 0 )
|
||||||
txheight = (chainActive.LastTip()->GetHeight() - out.nDepth - 1);
|
txheight = (chainActive.LastTip()->GetHeight() - out.nDepth - 1);
|
||||||
@@ -4675,7 +4662,6 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp, const CPubK
|
|||||||
obj.push_back(Pair("outindex", (int)entry.op.n));
|
obj.push_back(Pair("outindex", (int)entry.op.n));
|
||||||
obj.push_back(Pair("rawconfirmations", entry.confirmations));
|
obj.push_back(Pair("rawconfirmations", entry.confirmations));
|
||||||
auto wtx = pwalletMain->mapWallet.at(entry.op.hash); //.ToString());
|
auto wtx = pwalletMain->mapWallet.at(entry.op.hash); //.ToString());
|
||||||
//fprintf(stderr,"%s: txid=%s not found in wallet!\n", __func__, entry.op.hash.ToString().c_str());
|
|
||||||
obj.push_back(Pair("time", wtx.GetTxTime()));
|
obj.push_back(Pair("time", wtx.GetTxTime()));
|
||||||
|
|
||||||
obj.push_back(Pair("confirmations", dpowconfs));
|
obj.push_back(Pair("confirmations", dpowconfs));
|
||||||
@@ -5245,7 +5231,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
|||||||
// select a random address with enough confirmed balance
|
// select a random address with enough confirmed balance
|
||||||
auto nPotentials = vPotentialAddresses.size();
|
auto nPotentials = vPotentialAddresses.size();
|
||||||
if (nPotentials > 0) {
|
if (nPotentials > 0) {
|
||||||
fprintf(stderr,"%s: Selecting one of %lu potential source zaddrs\n", __func__, nPotentials);
|
LogPrintf("%s: Selecting one of %lu potential source zaddrs\n", __func__, nPotentials);
|
||||||
fromaddress = vPotentialAddresses[ GetRandInt(nPotentials) ];
|
fromaddress = vPotentialAddresses[ GetRandInt(nPotentials) ];
|
||||||
} else {
|
} else {
|
||||||
// Automagic zaddr source selection failed, exit honorably
|
// Automagic zaddr source selection failed, exit honorably
|
||||||
@@ -5407,7 +5393,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
|||||||
unsigned int MIN_ZOUTS=GetArg("-sietch-min-zouts", DEFAULT_MIN_ZOUTS);
|
unsigned int MIN_ZOUTS=GetArg("-sietch-min-zouts", DEFAULT_MIN_ZOUTS);
|
||||||
|
|
||||||
if((MIN_ZOUTS<3) || (MIN_ZOUTS>MAX_ZOUTS)) {
|
if((MIN_ZOUTS<3) || (MIN_ZOUTS>MAX_ZOUTS)) {
|
||||||
fprintf(stderr,"%s: Sietch min zouts must be >= 3 and <= %d, setting to default value of %d\n", __FUNCTION__, MAX_ZOUTS, DEFAULT_MIN_ZOUTS );
|
LogPrintf("%s: Sietch min zouts must be >= 3 and <= %d, setting to default value of %d\n", __FUNCTION__, MAX_ZOUTS, DEFAULT_MIN_ZOUTS );
|
||||||
MIN_ZOUTS=DEFAULT_MIN_ZOUTS;
|
MIN_ZOUTS=DEFAULT_MIN_ZOUTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6025,8 +6011,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp
|
|||||||
CAmount nValue = out.tx->vout[out.i].nValue;
|
CAmount nValue = out.tx->vout[out.i].nValue;
|
||||||
|
|
||||||
if (maximum_utxo_size != 0) {
|
if (maximum_utxo_size != 0) {
|
||||||
//fprintf(stderr, "utxo txid.%s vout.%i nValue.%li scriptpubkeylength.%i\n",out.tx->GetHash().ToString().c_str(),out.i,nValue,out.tx->vout[out.i].scriptPubKey.size());
|
if (nValue > maximum_utxo_size)
|
||||||
if (nValue > maximum_utxo_size)
|
|
||||||
continue;
|
continue;
|
||||||
if (nValue == 10000 && out.tx->vout[out.i].scriptPubKey.size() == 35)
|
if (nValue == 10000 && out.tx->vout[out.i].scriptPubKey.size() == 35)
|
||||||
continue;
|
continue;
|
||||||
@@ -6087,7 +6072,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp
|
|||||||
size_t numUtxos = utxoInputs.size();
|
size_t numUtxos = utxoInputs.size();
|
||||||
size_t numNotes = saplingNoteInputs.size();
|
size_t numNotes = saplingNoteInputs.size();
|
||||||
|
|
||||||
//fprintf(stderr, "num utxos.%li\n", numUtxos);
|
|
||||||
if (numUtxos < 2 && numNotes == 0) {
|
if (numUtxos < 2 && numNotes == 0) {
|
||||||
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Could not find any funds to merge.");
|
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Could not find any funds to merge.");
|
||||||
}
|
}
|
||||||
@@ -6248,7 +6232,6 @@ int32_t hush_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33, void *pT
|
|||||||
script = (uint8_t *)&out.tx->vout[out.i].scriptPubKey[0];
|
script = (uint8_t *)&out.tx->vout[out.i].scriptPubKey[0];
|
||||||
if ( out.tx->vout[out.i].scriptPubKey.size() != 35 || script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(notarypub33,script+1,33) != 0 )
|
if ( out.tx->vout[out.i].scriptPubKey.size() != 35 || script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(notarypub33,script+1,33) != 0 )
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"scriptsize.%d [0] %02x\n",(int32_t)out.tx->vout[out.i].scriptPubKey.size(),script[0]);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
utxovalue = (uint64_t)nValue;
|
utxovalue = (uint64_t)nValue;
|
||||||
@@ -6256,7 +6239,6 @@ int32_t hush_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33, void *pT
|
|||||||
utxotxid = out.tx->GetHash();
|
utxotxid = out.tx->GetHash();
|
||||||
utxovout = out.i;
|
utxovout = out.i;
|
||||||
best_scriptPubKey = out.tx->vout[out.i].scriptPubKey;
|
best_scriptPubKey = out.tx->vout[out.i].scriptPubKey;
|
||||||
//fprintf(stderr,"check %s/v%d %llu\n",(char *)utxotxid.GetHex().c_str(),utxovout,(long long)utxovalue);
|
|
||||||
|
|
||||||
txNew.vin.resize(1);
|
txNew.vin.resize(1);
|
||||||
txNew.vout.resize((pTr!=0)+1);
|
txNew.vout.resize((pTr!=0)+1);
|
||||||
@@ -6277,15 +6259,14 @@ int32_t hush_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33, void *pT
|
|||||||
CTransaction txNewConst(txNew);
|
CTransaction txNewConst(txNew);
|
||||||
signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, utxovalue, SIGHASH_ALL), best_scriptPubKey, sigdata, consensusBranchId);
|
signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, utxovalue, SIGHASH_ALL), best_scriptPubKey, sigdata, consensusBranchId);
|
||||||
if (!signSuccess)
|
if (!signSuccess)
|
||||||
fprintf(stderr,"notaryvin failed to create signature\n");
|
LogPrintf("notaryvin failed to create signature\n");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UpdateTransaction(txNew,0,sigdata);
|
UpdateTransaction(txNew,0,sigdata);
|
||||||
ptr = (uint8_t *)&sigdata.scriptSig[0];
|
ptr = (uint8_t *)&sigdata.scriptSig[0];
|
||||||
siglen = sigdata.scriptSig.size();
|
siglen = sigdata.scriptSig.size();
|
||||||
for (i=0; i<siglen; i++)
|
for (i=0; i<siglen; i++)
|
||||||
utxosig[i] = ptr[i];//, fprintf(stderr,"%02x",ptr[i]);
|
utxosig[i] = ptr[i];
|
||||||
//fprintf(stderr," siglen.%d notaryvin %s/v%d\n",siglen,utxotxid.GetHex().c_str(),utxovout);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1160,9 +1160,6 @@ int64_t CWallet::NullifierCount()
|
|||||||
{
|
{
|
||||||
LOCK(cs_wallet);
|
LOCK(cs_wallet);
|
||||||
if(fZdebug) {
|
if(fZdebug) {
|
||||||
//fprintf(stderr,"%s:mapTxSaplingNullifers.size=%d\n",__FUNCTION__,(int)mapTxSaplingNullifiers.size() );
|
|
||||||
//fprintf(stderr,"%s:mempool.getNullifiers.size=%d\n",__FUNCTION__,(int)mempool.getNullifiers().size() );
|
|
||||||
//fprintf(stderr,"%s:cacheSaplingNullifiers.size=%d\n",__FUNCTION__,(int)pcoinsTip->getNullifiers().size() );
|
|
||||||
}
|
}
|
||||||
return pcoinsTip->getNullifiers().size();
|
return pcoinsTip->getNullifiers().size();
|
||||||
}
|
}
|
||||||
@@ -1709,7 +1706,6 @@ CWallet::TxItems CWallet::OrderedTxItems(std::list<CAccountingEntry>& acentries,
|
|||||||
{
|
{
|
||||||
CWalletTx* wtx = &((*it).second);
|
CWalletTx* wtx = &((*it).second);
|
||||||
txOrdered.insert(make_pair(wtx->nOrderPos, TxPair(wtx, (CAccountingEntry*)0)));
|
txOrdered.insert(make_pair(wtx->nOrderPos, TxPair(wtx, (CAccountingEntry*)0)));
|
||||||
//fprintf(stderr,"ordered iter.%d %s\n",(int32_t)wtx->nOrderPos,wtx->GetHash().GetHex().c_str());
|
|
||||||
}
|
}
|
||||||
acentries.clear();
|
acentries.clear();
|
||||||
walletdb.ListAccountCreditDebit(strAccount, acentries);
|
walletdb.ListAccountCreditDebit(strAccount, acentries);
|
||||||
@@ -2016,9 +2012,9 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
|
|||||||
vAllowListAddress = mapMultiArgs["-allowlistaddress"];
|
vAllowListAddress = mapMultiArgs["-allowlistaddress"];
|
||||||
if ( !vAllowListAddress.empty() )
|
if ( !vAllowListAddress.empty() )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Activated Wallet Filter \n Notary Address: %s \n Adding allowlist address's:\n", NotaryAddress.c_str());
|
LogPrintf("Activated Wallet Filter \n Notary Address: %s \n Adding allowlist address's:\n", NotaryAddress.c_str());
|
||||||
for ( auto wladdr : vAllowListAddress )
|
for ( auto wladdr : vAllowListAddress )
|
||||||
fprintf(stderr, " %s\n", wladdr.c_str());
|
LogPrintf(" %s\n", wladdr.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fExisted || IsMine(tx) || IsFromMe(tx) || saplingNoteData.size() > 0) {
|
if (fExisted || IsMine(tx) || IsFromMe(tx) || saplingNoteData.size() > 0) {
|
||||||
@@ -2036,7 +2032,6 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
|
|||||||
{
|
{
|
||||||
if ( CBitcoinAddress(address).ToString() == wladdr )
|
if ( CBitcoinAddress(address).ToString() == wladdr )
|
||||||
{
|
{
|
||||||
//fprintf(stderr, "We received from allowlisted address.%s\n", wladdr.c_str());
|
|
||||||
numvinIsAllowList++;
|
numvinIsAllowList++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2044,7 +2039,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
|
|||||||
}
|
}
|
||||||
// Now we know if it was a tx sent to us, by either a allowlisted address, or ourself.
|
// Now we know if it was a tx sent to us, by either a allowlisted address, or ourself.
|
||||||
if ( numvinIsOurs != 0 )
|
if ( numvinIsOurs != 0 )
|
||||||
fprintf(stderr, "We sent from address: %s vins: %d\n",NotaryAddress.c_str(),numvinIsOurs);
|
LogPrintf("We sent from address: %s vins: %d\n",NotaryAddress.c_str(),numvinIsOurs);
|
||||||
if ( numvinIsOurs == 0 && numvinIsAllowList == 0 )
|
if ( numvinIsOurs == 0 && numvinIsAllowList == 0 )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -3047,14 +3042,12 @@ void CWalletTx::GetAmounts(list<COutputEntry>& listReceived,
|
|||||||
{
|
{
|
||||||
if ( oneshot++ > 1 )
|
if ( oneshot++ > 1 )
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"skip change vout\n");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!(fIsMine & filter))
|
else if (!(fIsMine & filter))
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"skip filtered vout %d %d\n",(int32_t)fIsMine,(int32_t)filter);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// In either case, we need to get the destination address
|
// In either case, we need to get the destination address
|
||||||
@@ -3575,7 +3568,6 @@ void CWallet::ReacceptWalletTransactions()
|
|||||||
bool invalid = state.IsInvalid(nDoS);
|
bool invalid = state.IsInvalid(nDoS);
|
||||||
|
|
||||||
// log rejection and deletion
|
// log rejection and deletion
|
||||||
//printf("ERROR reaccepting wallet transaction %s to mempool, reason: %s, DoS: %d\n", wtx.GetHash().ToString().c_str(), state.GetRejectReason().c_str(), nDoS);
|
|
||||||
|
|
||||||
if (!wtx.IsCoinBase() && invalid && nDoS > 0 && state.GetRejectReason() != "tx-overwinter-expired")
|
if (!wtx.IsCoinBase() && invalid && nDoS > 0 && state.GetRejectReason() != "tx-overwinter-expired")
|
||||||
{
|
{
|
||||||
@@ -3593,11 +3585,8 @@ void CWallet::ReacceptWalletTransactions()
|
|||||||
bool CWalletTx::RelayWalletTransaction()
|
bool CWalletTx::RelayWalletTransaction()
|
||||||
{
|
{
|
||||||
int64_t nNow = GetTime();
|
int64_t nNow = GetTime();
|
||||||
//if(fZdebug)
|
|
||||||
// LogPrintf("%s: now=%li\n",__func__,nNow);
|
|
||||||
if ( pwallet == 0 )
|
if ( pwallet == 0 )
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"unexpected null pwallet in RelayWalletTransaction\n");
|
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
assert(pwallet->GetBroadcastTransactions());
|
assert(pwallet->GetBroadcastTransactions());
|
||||||
@@ -3835,7 +3824,7 @@ std::vector<uint256> CWallet::ResendWalletTransactionsBefore(int64_t nTime)
|
|||||||
// Do not relay expired transactions, to avoid other nodes banning us
|
// Do not relay expired transactions, to avoid other nodes banning us
|
||||||
// Current code will not ban nodes relaying expired txs but older nodes will
|
// Current code will not ban nodes relaying expired txs but older nodes will
|
||||||
if (wtx.nExpiryHeight > 0 && wtx.nExpiryHeight < chainActive.LastTip()->GetHeight()) {
|
if (wtx.nExpiryHeight > 0 && wtx.nExpiryHeight < chainActive.LastTip()->GetHeight()) {
|
||||||
fprintf(stderr,"%s: ignoring expired tx %s with expiry %d at height %d\n", __func__, wtx.GetHash().ToString().c_str(), wtx.nExpiryHeight, chainActive.LastTip()->GetHeight() );
|
LogPrintf("%s: ignoring expired tx %s with expiry %d at height %d\n", __func__, wtx.GetHash().ToString().c_str(), wtx.nExpiryHeight, chainActive.LastTip()->GetHeight() );
|
||||||
// TODO: expired detection doesn't seem to work right
|
// TODO: expired detection doesn't seem to work right
|
||||||
// append to list of txs to delete
|
// append to list of txs to delete
|
||||||
// vwtxh.push_back(wtx.GetHash());
|
// vwtxh.push_back(wtx.GetHash());
|
||||||
@@ -4156,7 +4145,6 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int
|
|||||||
nTotalLower += n;
|
nTotalLower += n;
|
||||||
if ( nTotalLower > 4*nTargetValue + CENT )
|
if ( nTotalLower > 4*nTargetValue + CENT )
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"why bother with all the utxo if we have double what is needed?\n");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (n < coinLowestLarger.first)
|
} else if (n < coinLowestLarger.first)
|
||||||
@@ -4498,7 +4486,6 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
|
|||||||
//reflecting an assumption the user would accept a bit more delay for
|
//reflecting an assumption the user would accept a bit more delay for
|
||||||
//a chance at a free transaction.
|
//a chance at a free transaction.
|
||||||
//But mempool inputs might still be in the mempool, so their age stays 0
|
//But mempool inputs might still be in the mempool, so their age stays 0
|
||||||
//fprintf(stderr,"nCredit %.8f interest %.8f\n",(double)nCredit/COIN,(double)pcoin.first->vout[pcoin.second].interest/COIN);
|
|
||||||
int age = pcoin.first->GetDepthInMainChain();
|
int age = pcoin.first->GetDepthInMainChain();
|
||||||
if (age != 0)
|
if (age != 0)
|
||||||
age += 1;
|
age += 1;
|
||||||
@@ -4542,7 +4529,6 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"use notary pubkey\n");
|
|
||||||
scriptChange = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG;
|
scriptChange = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4739,7 +4725,6 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey)
|
|||||||
// Broadcast
|
// Broadcast
|
||||||
if (!wtxNew.AcceptToMemoryPool(false))
|
if (!wtxNew.AcceptToMemoryPool(false))
|
||||||
{
|
{
|
||||||
fprintf(stderr,"commit failed\n");
|
|
||||||
// This must not fail. The transaction has already been signed and recorded.
|
// This must not fail. The transaction has already been signed and recorded.
|
||||||
LogPrintf("CommitTransaction(): Error: Transaction not valid\n");
|
LogPrintf("CommitTransaction(): Error: Transaction not valid\n");
|
||||||
return false;
|
return false;
|
||||||
@@ -4789,7 +4774,7 @@ DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
|
|||||||
fFirstRunRet = false;
|
fFirstRunRet = false;
|
||||||
if ( 0 ) // doesnt help
|
if ( 0 ) // doesnt help
|
||||||
{
|
{
|
||||||
fprintf(stderr,"loading wallet %s %u\n",strWalletFile.c_str(),(uint32_t)time(NULL));
|
LogPrintf("loading wallet %s %u\n",strWalletFile.c_str(),(uint32_t)time(NULL));
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
if ( (fp= fopen(strWalletFile.c_str(),"rb")) != 0 )
|
if ( (fp= fopen(strWalletFile.c_str(),"rb")) != 0 )
|
||||||
{
|
{
|
||||||
@@ -4797,9 +4782,7 @@ DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"prefetched wallet %s %u\n",strWalletFile.c_str(),(uint32_t)time(NULL));
|
|
||||||
DBErrors nLoadWalletRet = CWalletDB(strWalletFile,"cr+").LoadWallet(this);
|
DBErrors nLoadWalletRet = CWalletDB(strWalletFile,"cr+").LoadWallet(this);
|
||||||
//fprintf(stderr,"loaded wallet %s %u\n",strWalletFile.c_str(),(uint32_t)time(NULL));
|
|
||||||
if (nLoadWalletRet == DB_NEED_REWRITE)
|
if (nLoadWalletRet == DB_NEED_REWRITE)
|
||||||
{
|
{
|
||||||
if (CDB::Rewrite(strWalletFile, "\x04pool"))
|
if (CDB::Rewrite(strWalletFile, "\x04pool"))
|
||||||
@@ -4984,7 +4967,6 @@ void CWallet::ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool)
|
|||||||
if (!HaveKey(keypool.vchPubKey.GetID()))
|
if (!HaveKey(keypool.vchPubKey.GetID()))
|
||||||
throw runtime_error("ReserveKeyFromKeyPool(): unknown key in key pool");
|
throw runtime_error("ReserveKeyFromKeyPool(): unknown key in key pool");
|
||||||
assert(keypool.vchPubKey.IsValid());
|
assert(keypool.vchPubKey.IsValid());
|
||||||
//LogPrintf("keypool reserve %d\n", nIndex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5006,7 +4988,6 @@ void CWallet::ReturnKey(int64_t nIndex)
|
|||||||
LOCK(cs_wallet);
|
LOCK(cs_wallet);
|
||||||
setKeyPool.insert(nIndex);
|
setKeyPool.insert(nIndex);
|
||||||
}
|
}
|
||||||
//LogPrintf("keypool return %d\n", nIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CWallet::GetKeyFromPool(CPubKey& result)
|
bool CWallet::GetKeyFromPool(CPubKey& result)
|
||||||
@@ -5293,14 +5274,14 @@ void CWallet::LockNote(const SaplingOutPoint& output)
|
|||||||
{
|
{
|
||||||
AssertLockHeld(cs_wallet);
|
AssertLockHeld(cs_wallet);
|
||||||
setLockedSaplingNotes.insert(output);
|
setLockedSaplingNotes.insert(output);
|
||||||
fprintf(stderr,"%s: locking note %s...\n", __func__, output.hash.ToString().substr(0,8).c_str() );
|
LogPrintf("%s: locking note %s...\n", __func__, output.hash.ToString().substr(0,8).c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWallet::UnlockNote(const SaplingOutPoint& output)
|
void CWallet::UnlockNote(const SaplingOutPoint& output)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_wallet);
|
AssertLockHeld(cs_wallet);
|
||||||
setLockedSaplingNotes.erase(output);
|
setLockedSaplingNotes.erase(output);
|
||||||
fprintf(stderr,"%s: unlocking note %s...\n", __func__, output.hash.ToString().substr(0,8).c_str() );
|
LogPrintf("%s: unlocking note %s...\n", __func__, output.hash.ToString().substr(0,8).c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWallet::UnlockAllSaplingNotes()
|
void CWallet::UnlockAllSaplingNotes()
|
||||||
@@ -5540,7 +5521,6 @@ int CMerkleTx::GetBlocksToMaturity() const
|
|||||||
int32_t depth = GetDepthInMainChain();
|
int32_t depth = GetDepthInMainChain();
|
||||||
int32_t ut = UnlockTime(0);
|
int32_t ut = UnlockTime(0);
|
||||||
int32_t toMaturity = (ut - chainActive.Height()) < 0 ? 0 : ut - chainActive.Height();
|
int32_t toMaturity = (ut - chainActive.Height()) < 0 ? 0 : ut - chainActive.Height();
|
||||||
//printf("depth.%i, unlockTime.%i, toMaturity.%i\n", depth, ut, toMaturity);
|
|
||||||
ut = (COINBASE_MATURITY - depth) < 0 ? 0 : COINBASE_MATURITY - depth;
|
ut = (COINBASE_MATURITY - depth) < 0 ? 0 : COINBASE_MATURITY - depth;
|
||||||
return(ut < toMaturity ? toMaturity : ut);
|
return(ut < toMaturity ? toMaturity : ut);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user