Merge pull request #57 from StakedChain/periodic_founders

Periodic founders and fix getnotarysendmany
This commit is contained in:
blackjok3rtt
2018-12-06 00:31:36 +08:00
committed by GitHub
5 changed files with 33 additions and 12 deletions

View File

@@ -1112,6 +1112,7 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_
commission must be in coinbase.vout[1] and must be >= 10000 sats
PoS stake must be without txfee and in the last tx in the block at vout[0]
*/
extern int32_t ASSETCHAINS_FOUNDERS_PERIOD;
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams);
@@ -1123,11 +1124,14 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height)
{
nSubsidy = GetBlockSubsidy(height,Params().GetConsensus());
//fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION));
return((nSubsidy * ASSETCHAINS_COMMISSION) / COIN);
n = pblock->vtx[0].vout.size();
for (j=0; j<n; j++)
if ( j != 1 )
total += pblock->vtx[0].vout[j].nValue;
commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN);
if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 )
{
if ( height % ASSETCHAINS_FOUNDERS_PERIOD == 0 )
commission = commission * ASSETCHAINS_FOUNDERS_PERIOD;
else
commission = 0;
}
}
else
{
@@ -1141,7 +1145,10 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height)
total += pblock->vtx[i].vout[j].nValue;
}
}
commission = ((total * ASSETCHAINS_COMMISSION) / COIN);
}
if ( commission < 10000 )
commission = 0;
return(commission);
}
@@ -1541,7 +1548,7 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height)
{
fprintf(stderr,"ERROR: chain not fully loaded or invalid PoS block %s - no past block found\n",blkHash.ToString().c_str());
}
else
else
#ifndef KOMODO_ZCASH
if (!GetTransaction(txid, tx, Params().GetConsensus(), blkHash, true))
#else
@@ -1574,7 +1581,7 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height)
{
BlockMap::const_iterator it = mapBlockIndex.find(blkHash);
if ((it == mapBlockIndex.end()) ||
!(pastBlockIndex = it->second) ||
!(pastBlockIndex = it->second) ||
(height - pastBlockIndex->GetHeight()) < VERUS_MIN_STAKEAGE)
{
fprintf(stderr,"ERROR: invalid PoS block %s - stake source too new or not found\n",blkHash.ToString().c_str());
@@ -1665,9 +1672,7 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height)
{
checktoshis = komodo_commission(pblock,height);
//fprintf(stderr,"height.%d commission %.8f\n",height,(double)checktoshis/COIN);
/*if ( checktoshis > 10000 && pblock->vtx[0].vout.size() != 2 ) jl777: not sure why this was here
return(-1);
else*/ if ( checktoshis != 0 )
if ( checktoshis != 0 )
{
script = (uint8_t *)&pblock->vtx[0].vout[1].scriptPubKey[0];
scriptlen = (int32_t)pblock->vtx[0].vout[1].scriptPubKey.size();

View File

@@ -44,7 +44,7 @@ struct komodo_state KOMODO_STATES[34];
#define _COINBASE_MATURITY 100
int COINBASE_MATURITY = _COINBASE_MATURITY;//100;
int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI;
int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS_PERIOD;
int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1;
std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,WHITELIST_ADDRESS;
uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_FOUNDERS,NUM_NOTARIES;

View File

@@ -1772,6 +1772,7 @@ void komodo_args(char *argv0)
ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0);
ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey","");
ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script","");
ASSETCHAINS_FOUNDERS_PERIOD = GetArg("-ac_period",0);
if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 )
ASSETCHAINS_STAKED = 100;

View File

@@ -36,6 +36,8 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "sendtoaddress", 1 },
{ "sendtoaddress", 4 },
{ "settxfee", 0 },
{ "getnotarysendmany", 0 },
{ "getnotarysendmany", 1 },
{ "getreceivedbyaddress", 1 },
{ "getreceivedbyaccount", 1 },
{ "listreceivedbyaddress", 0 },

View File

@@ -119,6 +119,19 @@ UniValue getiguanajson(const UniValue& params, bool fHelp)
UniValue getnotarysendmany(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() > 1)
throw runtime_error(
"getnotarysendmany\n"
"Returns a sendmany JSON array with all current notaries Raddress's.\n"
"\nExamples:\n"
+ HelpExampleCli("getnotarysendmany", "10")
+ HelpExampleRpc("getnotarysendmany", "10")
);
int amount = 0;
if ( params.size() == 1 ) {
amount = params[0].get_int();
}
int era = getera(time(NULL));
UniValue ret(UniValue::VOBJ);
@@ -127,7 +140,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp)
char Raddress[18]; uint8_t pubkey33[33];
decode_hex(pubkey33,33,(char *)notaries_STAKED[era][i][1]);
pubkey2addr((char *)Raddress,(uint8_t *)pubkey33);
ret.push_back(Pair(Raddress,(int)10));
ret.push_back(Pair(Raddress,amount));
}
return ret;
}