mirror of
https://git.hush.is/hush/hush3.git
synced 2025-07-18 00:03:31 -04:00
Compare commits
No commits in common. "1c45a71b05abea9f5a984316941b9420d44a7344" and "a90f03ce6dd3347689229fa4bff1116e838f309e" have entirely different histories.
1c45a71b05
...
a90f03ce6d
@ -1786,13 +1786,13 @@ int32_t hush_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
|
||||
|
||||
int32_t hush_scpublic(uint32_t tiptime)
|
||||
{
|
||||
// HUSH does not support surveillance coins, go use something else if you want no privacy
|
||||
// HUSH does not support public blockchains, go use something else if you want no privacy
|
||||
return 0;
|
||||
}
|
||||
|
||||
int64_t hush_newcoins(int64_t *zfundsp,int32_t nHeight,CBlock *pblock)
|
||||
int64_t hush_newcoins(int64_t *zfundsp,int64_t *sproutfundsp,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;
|
||||
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;
|
||||
n = pblock->vtx.size();
|
||||
for (i=0; i<n; i++)
|
||||
{
|
||||
@ -1832,16 +1832,19 @@ int64_t hush_newcoins(int64_t *zfundsp,int32_t nHeight,CBlock *pblock)
|
||||
zfunds -= tx.valueBalance;
|
||||
}
|
||||
*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 )
|
||||
//. 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);
|
||||
}
|
||||
|
||||
int64_t hush_coinsupply(int64_t *zfundsp,int32_t height)
|
||||
int64_t hush_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height)
|
||||
{
|
||||
CBlockIndex *pindex; CBlock block; int64_t zfunds=0,supply = 0;
|
||||
CBlockIndex *pindex; CBlock block; int64_t zfunds=0,sproutfunds=0,supply = 0;
|
||||
//fprintf(stderr,"coinsupply %d\n",height);
|
||||
*zfundsp = 0;
|
||||
*zfundsp = *sproutfundsp = 0;
|
||||
if ( (pindex= hush_chainactive(height)) != 0 )
|
||||
{
|
||||
while ( pindex != 0 && pindex->GetHeight() > 0 )
|
||||
@ -1849,7 +1852,7 @@ int64_t hush_coinsupply(int64_t *zfundsp,int32_t height)
|
||||
if ( pindex->newcoins == 0 && pindex->zfunds == 0 )
|
||||
{
|
||||
if ( hush_blockload(block,pindex) == 0 ) {
|
||||
pindex->newcoins = hush_newcoins(&pindex->zfunds,pindex->GetHeight(),&block);
|
||||
pindex->newcoins = hush_newcoins(&pindex->zfunds,&pindex->sproutfunds,pindex->GetHeight(),&block);
|
||||
} else {
|
||||
fprintf(stderr,"error loading block.%d\n",pindex->GetHeight());
|
||||
return(0);
|
||||
@ -1857,11 +1860,13 @@ int64_t hush_coinsupply(int64_t *zfundsp,int32_t height)
|
||||
}
|
||||
supply += pindex->newcoins;
|
||||
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));
|
||||
pindex = pindex->pprev;
|
||||
}
|
||||
}
|
||||
*zfundsp = zfunds;
|
||||
*sproutfundsp = sproutfunds;
|
||||
return(supply);
|
||||
}
|
||||
|
||||
|
@ -324,6 +324,7 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx
|
||||
result.push_back(Pair("blocktype", "mined"));
|
||||
|
||||
UniValue valuePools(UniValue::VARR);
|
||||
valuePools.push_back(ValuePoolDesc("sprout", blockindex->nChainSproutValue, blockindex->nSproutValue));
|
||||
valuePools.push_back(ValuePoolDesc("sapling", blockindex->nChainSaplingValue, blockindex->nSaplingValue));
|
||||
result.push_back(Pair("valuePools", valuePools));
|
||||
|
||||
@ -1309,10 +1310,14 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp, const CPubKey& my
|
||||
obj.push_back(Pair("chainwork", chainActive.LastTip()->chainPower.chainWork.GetHex()));
|
||||
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));
|
||||
|
||||
CBlockIndex* tip = chainActive.LastTip();
|
||||
UniValue valuePools(UniValue::VARR);
|
||||
valuePools.push_back(ValuePoolDesc("sprout", tip->nChainSproutValue, boost::none));
|
||||
valuePools.push_back(ValuePoolDesc("sapling", tip->nChainSaplingValue, boost::none));
|
||||
obj.push_back(Pair("valuePools", valuePools));
|
||||
|
||||
|
@ -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 char SMART_CHAIN_SYMBOL[HUSH_SMART_CHAIN_MAXLEN];
|
||||
uint32_t hush_segid32(char *coinaddr);
|
||||
int64_t hush_coinsupply(int64_t *zfundsp,int32_t height);
|
||||
int64_t hush_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height);
|
||||
int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *hushnotarized_heightp);
|
||||
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);
|
||||
@ -416,7 +416,7 @@ public:
|
||||
|
||||
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,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,sf1,sf3,sf12,sproutfunds,zfunds,supply1,supply3,supply12,supply = 0; UniValue result(UniValue::VOBJ);
|
||||
if (fHelp || params.size() > 1)
|
||||
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"
|
||||
@ -429,6 +429,7 @@ UniValue coinsupply(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
" \"height\" : 420, (integer) The height of this coin supply data\n"
|
||||
" \"supply\" : \"555.0\", (float) The transparent coin supply\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"
|
||||
"}\n"
|
||||
"\nExamples:\n"
|
||||
@ -441,22 +442,23 @@ UniValue coinsupply(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
currentHeight = chainActive.Height();
|
||||
|
||||
if (height >= 0 && height <= currentHeight) {
|
||||
if ( (supply= hush_coinsupply(&zfunds,height)) > 0 )
|
||||
if ( (supply= hush_coinsupply(&zfunds,&sproutfunds,height)) > 0 )
|
||||
{
|
||||
result.push_back(Pair("result", "success"));
|
||||
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("supply", ValueFromAmount(supply)));
|
||||
result.push_back(Pair("zfunds", ValueFromAmount(zfunds)));
|
||||
result.push_back(Pair("sprout", ValueFromAmount(sproutfunds)));
|
||||
result.push_back(Pair("total", ValueFromAmount(zfunds + supply)));
|
||||
if ( ASSETCHAINS_BLOCKTIME > 0 )
|
||||
{
|
||||
blocks_per_year = 24*3600*365 / ASSETCHAINS_BLOCKTIME;
|
||||
if ( height > blocks_per_year )
|
||||
{
|
||||
supply1 = hush_coinsupply(&zf1,height - blocks_per_year/12);
|
||||
supply3 = hush_coinsupply(&zf3,height - blocks_per_year/4);
|
||||
supply12 = hush_coinsupply(&zf12,height - blocks_per_year);
|
||||
supply1 = hush_coinsupply(&zf1,&sf1,height - blocks_per_year/12);
|
||||
supply3 = hush_coinsupply(&zf3,&sf3,height - blocks_per_year/4);
|
||||
supply12 = hush_coinsupply(&zf12,&sf12,height - blocks_per_year);
|
||||
if ( supply1 != 0 && supply3 != 0 && supply12 != 0 )
|
||||
{
|
||||
result.push_back(Pair("lastmonth", ValueFromAmount(supply1+zf1)));
|
||||
|
Loading…
x
Reference in New Issue
Block a user