Compare commits

...

4 Commits

Author SHA1 Message Date
Duke
1c45a71b05 Remove dead code 2023-09-03 08:52:28 -04:00
Duke
e2521ac2fa Remove unused sproutfunds argument 2023-09-03 08:48:06 -04:00
Duke
bd38a12512 Remove useless sprout key from coinsupply RPC 2023-09-03 08:40:06 -04:00
Duke
bacc08e817 Remove sprout data from valuePools
This codebase does not support sprout, the data will always be zero/empty
and is essentially useless cruft, so we delete it.
2023-09-03 08:37:19 -04:00
3 changed files with 13 additions and 25 deletions

View File

@ -1786,13 +1786,13 @@ int32_t hush_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
int32_t hush_scpublic(uint32_t tiptime) int32_t hush_scpublic(uint32_t tiptime)
{ {
// HUSH does not support public blockchains, go use something else if you want no privacy // HUSH does not support surveillance coins, go use something else if you want no privacy
return 0; return 0;
} }
int64_t hush_newcoins(int64_t *zfundsp,int64_t *sproutfundsp,int32_t nHeight,CBlock *pblock) int64_t hush_newcoins(int64_t *zfundsp,int32_t nHeight,CBlock *pblock)
{ {
CTxDestination address; int32_t i,j,m,n,vout; uint8_t *script; uint256 txid,hashBlock; int64_t zfunds=0,vinsum=0,voutsum=0,sproutfunds=0; CTxDestination address; int32_t i,j,m,n,vout; uint8_t *script; uint256 txid,hashBlock; int64_t zfunds=0,vinsum=0,voutsum=0;
n = pblock->vtx.size(); n = pblock->vtx.size();
for (i=0; i<n; i++) for (i=0; i<n; i++)
{ {
@ -1832,19 +1832,16 @@ int64_t hush_newcoins(int64_t *zfundsp,int64_t *sproutfundsp,int32_t nHeight,CBl
zfunds -= tx.valueBalance; zfunds -= tx.valueBalance;
} }
*zfundsp = zfunds; *zfundsp = zfunds;
*sproutfundsp = sproutfunds;
if ( SMART_CHAIN_SYMBOL[0] == 0 && (voutsum-vinsum) == 100003*SATOSHIDEN ) // 15 times
return(3 * SATOSHIDEN);
//if ( voutsum-vinsum+zfunds > 100000*SATOSHIDEN || voutsum-vinsum+zfunds < 0 ) //if ( voutsum-vinsum+zfunds > 100000*SATOSHIDEN || voutsum-vinsum+zfunds < 0 )
//. fprintf(stderr,"ht.%d vins %.8f, vouts %.8f -> %.8f zfunds %.8f\n",nHeight,dstr(vinsum),dstr(voutsum),dstr(voutsum)-dstr(vinsum),dstr(zfunds)); //. fprintf(stderr,"ht.%d vins %.8f, vouts %.8f -> %.8f zfunds %.8f\n",nHeight,dstr(vinsum),dstr(voutsum),dstr(voutsum)-dstr(vinsum),dstr(zfunds));
return(voutsum - vinsum); return(voutsum - vinsum);
} }
int64_t hush_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height) int64_t hush_coinsupply(int64_t *zfundsp,int32_t height)
{ {
CBlockIndex *pindex; CBlock block; int64_t zfunds=0,sproutfunds=0,supply = 0; CBlockIndex *pindex; CBlock block; int64_t zfunds=0,supply = 0;
//fprintf(stderr,"coinsupply %d\n",height); //fprintf(stderr,"coinsupply %d\n",height);
*zfundsp = *sproutfundsp = 0; *zfundsp = 0;
if ( (pindex= hush_chainactive(height)) != 0 ) if ( (pindex= hush_chainactive(height)) != 0 )
{ {
while ( pindex != 0 && pindex->GetHeight() > 0 ) while ( pindex != 0 && pindex->GetHeight() > 0 )
@ -1852,7 +1849,7 @@ int64_t hush_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height)
if ( pindex->newcoins == 0 && pindex->zfunds == 0 ) if ( pindex->newcoins == 0 && pindex->zfunds == 0 )
{ {
if ( hush_blockload(block,pindex) == 0 ) { if ( hush_blockload(block,pindex) == 0 ) {
pindex->newcoins = hush_newcoins(&pindex->zfunds,&pindex->sproutfunds,pindex->GetHeight(),&block); pindex->newcoins = hush_newcoins(&pindex->zfunds,pindex->GetHeight(),&block);
} else { } else {
fprintf(stderr,"error loading block.%d\n",pindex->GetHeight()); fprintf(stderr,"error loading block.%d\n",pindex->GetHeight());
return(0); return(0);
@ -1860,13 +1857,11 @@ int64_t hush_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height)
} }
supply += pindex->newcoins; supply += pindex->newcoins;
zfunds += pindex->zfunds; zfunds += pindex->zfunds;
sproutfunds += pindex->sproutfunds;
//printf("start ht.%d new %.8f -> supply %.8f zfunds %.8f -> %.8f\n",pindex->GetHeight(),dstr(pindex->newcoins),dstr(supply),dstr(pindex->zfunds),dstr(zfunds)); //printf("start ht.%d new %.8f -> supply %.8f zfunds %.8f -> %.8f\n",pindex->GetHeight(),dstr(pindex->newcoins),dstr(supply),dstr(pindex->zfunds),dstr(zfunds));
pindex = pindex->pprev; pindex = pindex->pprev;
} }
} }
*zfundsp = zfunds; *zfundsp = zfunds;
*sproutfundsp = sproutfunds;
return(supply); return(supply);
} }

View File

@ -324,7 +324,6 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx
result.push_back(Pair("blocktype", "mined")); result.push_back(Pair("blocktype", "mined"));
UniValue valuePools(UniValue::VARR); UniValue valuePools(UniValue::VARR);
valuePools.push_back(ValuePoolDesc("sprout", blockindex->nChainSproutValue, blockindex->nSproutValue));
valuePools.push_back(ValuePoolDesc("sapling", blockindex->nChainSaplingValue, blockindex->nSaplingValue)); valuePools.push_back(ValuePoolDesc("sapling", blockindex->nChainSaplingValue, blockindex->nSaplingValue));
result.push_back(Pair("valuePools", valuePools)); result.push_back(Pair("valuePools", valuePools));
@ -1310,14 +1309,10 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp, const CPubKey& my
obj.push_back(Pair("chainwork", chainActive.LastTip()->chainPower.chainWork.GetHex())); obj.push_back(Pair("chainwork", chainActive.LastTip()->chainPower.chainWork.GetHex()));
obj.push_back(Pair("pruned", fPruneMode)); obj.push_back(Pair("pruned", fPruneMode));
//SproutMerkleTree tree;
//pcoinsTip->GetSproutAnchorAt(pcoinsTip->GetBestAnchor(SPROUT), tree);
//obj.push_back(Pair("commitments", static_cast<uint64_t>(tree.size())));
obj.push_back(Pair("commitments", 0)); obj.push_back(Pair("commitments", 0));
CBlockIndex* tip = chainActive.LastTip(); CBlockIndex* tip = chainActive.LastTip();
UniValue valuePools(UniValue::VARR); UniValue valuePools(UniValue::VARR);
valuePools.push_back(ValuePoolDesc("sprout", tip->nChainSproutValue, boost::none));
valuePools.push_back(ValuePoolDesc("sapling", tip->nChainSaplingValue, boost::none)); valuePools.push_back(ValuePoolDesc("sapling", tip->nChainSaplingValue, boost::none));
obj.push_back(Pair("valuePools", valuePools)); obj.push_back(Pair("valuePools", valuePools));

View File

@ -65,7 +65,7 @@ int32_t hush_whoami(char *pubkeystr,int32_t height,uint32_t timestamp);
extern int32_t HUSH_LASTMINED,HUSH_LONGESTCHAIN,IS_HUSH_NOTARY,HUSH_INSYNC; extern int32_t HUSH_LASTMINED,HUSH_LONGESTCHAIN,IS_HUSH_NOTARY,HUSH_INSYNC;
extern char SMART_CHAIN_SYMBOL[HUSH_SMART_CHAIN_MAXLEN]; extern char SMART_CHAIN_SYMBOL[HUSH_SMART_CHAIN_MAXLEN];
uint32_t hush_segid32(char *coinaddr); uint32_t hush_segid32(char *coinaddr);
int64_t hush_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height); int64_t hush_coinsupply(int64_t *zfundsp,int32_t height);
int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *hushnotarized_heightp); int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *hushnotarized_heightp);
uint64_t hush_notarypayamount(int32_t nHeight, int64_t notarycount); uint64_t hush_notarypayamount(int32_t nHeight, int64_t notarycount);
int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp);
@ -416,7 +416,7 @@ public:
UniValue coinsupply(const UniValue& params, bool fHelp, const CPubKey& mypk) UniValue coinsupply(const UniValue& params, bool fHelp, const CPubKey& mypk)
{ {
int32_t height = 0; int32_t currentHeight; int64_t blocks_per_year,zf1,zf3,zf12,sf1,sf3,sf12,sproutfunds,zfunds,supply1,supply3,supply12,supply = 0; UniValue result(UniValue::VOBJ); int32_t height = 0; int32_t currentHeight; int64_t blocks_per_year,zf1,zf3,zf12,zfunds,supply1,supply3,supply12,supply = 0; UniValue result(UniValue::VOBJ);
if (fHelp || params.size() > 1) if (fHelp || params.size() > 1)
throw runtime_error("coinsupply <height>\n" throw runtime_error("coinsupply <height>\n"
"\nReturn coin supply information at a given block height. If no height is given, the current height is used.\n" "\nReturn coin supply information at a given block height. If no height is given, the current height is used.\n"
@ -429,7 +429,6 @@ UniValue coinsupply(const UniValue& params, bool fHelp, const CPubKey& mypk)
" \"height\" : 420, (integer) The height of this coin supply data\n" " \"height\" : 420, (integer) The height of this coin supply data\n"
" \"supply\" : \"555.0\", (float) The transparent coin supply\n" " \"supply\" : \"555.0\", (float) The transparent coin supply\n"
" \"zfunds\" : \"0.55555\", (float) The shielded coin supply (in zaddrs)\n" " \"zfunds\" : \"0.55555\", (float) The shielded coin supply (in zaddrs)\n"
" \"sprout\" : \"0.000\", (float) The sprout coin supply (in zcaddrs)\n"
" \"total\" : \"555.55555\", (float) The total coin supply, i.e. sum of supply + zfunds\n" " \"total\" : \"555.55555\", (float) The total coin supply, i.e. sum of supply + zfunds\n"
"}\n" "}\n"
"\nExamples:\n" "\nExamples:\n"
@ -442,23 +441,22 @@ UniValue coinsupply(const UniValue& params, bool fHelp, const CPubKey& mypk)
currentHeight = chainActive.Height(); currentHeight = chainActive.Height();
if (height >= 0 && height <= currentHeight) { if (height >= 0 && height <= currentHeight) {
if ( (supply= hush_coinsupply(&zfunds,&sproutfunds,height)) > 0 ) if ( (supply= hush_coinsupply(&zfunds,height)) > 0 )
{ {
result.push_back(Pair("result", "success")); result.push_back(Pair("result", "success"));
result.push_back(Pair("coin", SMART_CHAIN_SYMBOL[0] == 0 ? "HUSH" : SMART_CHAIN_SYMBOL)); result.push_back(Pair("coin", SMART_CHAIN_SYMBOL[0] == 0 ? "HUSH" : SMART_CHAIN_SYMBOL));
result.push_back(Pair("height", (int)height)); result.push_back(Pair("height", (int)height));
result.push_back(Pair("supply", ValueFromAmount(supply))); result.push_back(Pair("supply", ValueFromAmount(supply)));
result.push_back(Pair("zfunds", ValueFromAmount(zfunds))); result.push_back(Pair("zfunds", ValueFromAmount(zfunds)));
result.push_back(Pair("sprout", ValueFromAmount(sproutfunds)));
result.push_back(Pair("total", ValueFromAmount(zfunds + supply))); result.push_back(Pair("total", ValueFromAmount(zfunds + supply)));
if ( ASSETCHAINS_BLOCKTIME > 0 ) if ( ASSETCHAINS_BLOCKTIME > 0 )
{ {
blocks_per_year = 24*3600*365 / ASSETCHAINS_BLOCKTIME; blocks_per_year = 24*3600*365 / ASSETCHAINS_BLOCKTIME;
if ( height > blocks_per_year ) if ( height > blocks_per_year )
{ {
supply1 = hush_coinsupply(&zf1,&sf1,height - blocks_per_year/12); supply1 = hush_coinsupply(&zf1,height - blocks_per_year/12);
supply3 = hush_coinsupply(&zf3,&sf3,height - blocks_per_year/4); supply3 = hush_coinsupply(&zf3,height - blocks_per_year/4);
supply12 = hush_coinsupply(&zf12,&sf12,height - blocks_per_year); supply12 = hush_coinsupply(&zf12,height - blocks_per_year);
if ( supply1 != 0 && supply3 != 0 && supply12 != 0 ) if ( supply1 != 0 && supply3 != 0 && supply12 != 0 )
{ {
result.push_back(Pair("lastmonth", ValueFromAmount(supply1+zf1))); result.push_back(Pair("lastmonth", ValueFromAmount(supply1+zf1)));