Browse Source

add ac_founders and ac_perc to getblocksubsidy

pull/28/head
blackjok3r 5 years ago
parent
commit
1c4c00ff8b
  1. 4
      src/komodo_bitcoind.h
  2. 30
      src/rpc/mining.cpp

4
src/komodo_bitcoind.h

@ -1224,7 +1224,6 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height)
return(0);
int32_t i,j,n=0,txn_count; int64_t nSubsidy; uint64_t commission,total = 0;
txn_count = pblock->vtx.size();
if ( ASSETCHAINS_FOUNDERS != 0 )
{
nSubsidy = GetBlockSubsidy(height,Params().GetConsensus());
@ -1242,8 +1241,9 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height)
else commission = 0;
}
}
else
else if ( pblock != 0 )
{
txn_count = pblock->vtx.size();
for (i=0; i<txn_count; i++)
{
n = pblock->vtx[i].vout.size();

30
src/rpc/mining.cpp

@ -49,8 +49,10 @@
using namespace std;
#include "komodo_defs.h"
extern int32_t ASSETCHAINS_FOUNDERS;
extern int32_t ASSETCHAINS_FOUNDERS;
uint64_t komodo_commission(const CBlock *pblock,int32_t height);
int32_t komodo_blockload(CBlock& block,CBlockIndex *pindex);
arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc);
/**
@ -1009,6 +1011,7 @@ UniValue getblocksubsidy(const UniValue& params, bool fHelp)
"\nResult:\n"
"{\n"
" \"miner\" : x.xxx (numeric) The mining reward amount in KMD.\n"
" \"ac_pubkey\" : x.xxx (numeric) The mining reward amount in KMD.\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getblocksubsidy", "1000")
@ -1019,11 +1022,32 @@ UniValue getblocksubsidy(const UniValue& params, bool fHelp)
int nHeight = (params.size()==1) ? params[0].get_int() : chainActive.Height();
if (nHeight < 0)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range");
CAmount nFoundersReward = 0;
CAmount nReward = GetBlockSubsidy(nHeight, Params().GetConsensus());
UniValue result(UniValue::VOBJ);
result.push_back(Pair("miner", ValueFromAmount(nReward)));
//result.push_back(Pair("founders", ValueFromAmount(nFoundersReward)));
if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 || ASSETCHAINS_SCRIPTPUB.size() > 1 )
{
if ( ASSETCHAINS_FOUNDERS == 0 && ASSETCHAINS_COMMISSION != 0 )
{
// ac comission chains need the block to exist to calulate the reward.
if ( nHeight <= chainActive.Height() )
{
CBlockIndex* pblockIndex = chainActive[nHeight];
CBlock block;
if ( komodo_blockload(block, pblockIndex) == 0 )
nFoundersReward = komodo_commission(&block, nHeight);
}
}
else if ( ASSETCHAINS_FOUNDERS != 0 )
{
// Assetchains founders chains have a fixed reward so can be calculated at any given height.
nFoundersReward = komodo_commission(0, nHeight);
}
result.push_back(Pair("ac_pubkey", ValueFromAmount(nFoundersReward)));
}
return result;
}

Loading…
Cancel
Save