Merge pull request #27 from StakedChain/streamer_recv
merge streamer branch into copy of master to check conflicts
This commit is contained in:
@@ -1105,25 +1105,33 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_
|
|||||||
commission must be in coinbase.vout[1] and must be >= 10000 sats
|
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]
|
PoS stake must be without txfee and in the last tx in the block at vout[0]
|
||||||
*/
|
*/
|
||||||
|
extern int32_t ASSETCHAINS_STREAM;
|
||||||
|
|
||||||
uint64_t komodo_commission(const CBlock *pblock)
|
uint64_t komodo_commission(const CBlock *pblock)
|
||||||
{
|
{
|
||||||
int32_t i,j,n=0,txn_count; uint64_t commission,total = 0;
|
int32_t i,j,n=0,txn_count; uint64_t commission,total = 0;
|
||||||
txn_count = pblock->vtx.size();
|
if ( ASSETCHAINS_STREAM == 0 )
|
||||||
for (i=0; i<txn_count; i++)
|
|
||||||
{
|
{
|
||||||
n = pblock->vtx[i].vout.size();
|
txn_count = pblock->vtx.size();
|
||||||
for (j=0; j<n; j++)
|
for (i=0; i<txn_count; i++)
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"(%d %.8f).%d ",i,dstr(block.vtx[i].vout[j].nValue),j);
|
n = pblock->vtx[i].vout.size();
|
||||||
if ( i != 0 || j != 1 )
|
for (j=0; j<n; j++)
|
||||||
total += pblock->vtx[i].vout[j].nValue;
|
{
|
||||||
}
|
//fprintf(stderr,"(%d %.8f).%d ",i,dstr(block.vtx[i].vout[j].nValue),j);
|
||||||
|
if ( i != 0 || j != 1 )
|
||||||
|
total += pblock->vtx[i].vout[j].nValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//fprintf(stderr,"txn.%d n.%d commission total %.8f -> %.8f\n",txn_count,n,dstr(total),dstr((total * ASSETCHAINS_COMMISSION) / COIN));
|
||||||
|
commission = ((total * ASSETCHAINS_COMMISSION) / COIN);
|
||||||
|
if ( commission < 10000 )
|
||||||
|
commission = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
commission = 10000;
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"txn.%d n.%d commission total %.8f -> %.8f\n",txn_count,n,dstr(total),dstr((total * ASSETCHAINS_COMMISSION) / COIN));
|
|
||||||
commission = ((total * ASSETCHAINS_COMMISSION) / COIN);
|
|
||||||
if ( commission < 10000 )
|
|
||||||
commission = 0;
|
|
||||||
return(commission);
|
return(commission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1464,7 +1472,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_
|
|||||||
int64_t komodo_checkcommission(CBlock *pblock,int32_t height)
|
int64_t komodo_checkcommission(CBlock *pblock,int32_t height)
|
||||||
{
|
{
|
||||||
int64_t checktoshis=0; uint8_t *script;
|
int64_t checktoshis=0; uint8_t *script;
|
||||||
if ( ASSETCHAINS_COMMISSION != 0 )
|
if ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0)
|
||||||
{
|
{
|
||||||
checktoshis = komodo_commission(pblock);
|
checktoshis = komodo_commission(pblock);
|
||||||
if ( checktoshis > 10000 && pblock->vtx[0].vout.size() != 2 )
|
if ( checktoshis > 10000 && pblock->vtx[0].vout.size() != 2 )
|
||||||
@@ -1570,14 +1578,33 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
|
|||||||
if ( height == 1 )
|
if ( height == 1 )
|
||||||
{
|
{
|
||||||
script = (uint8_t *)pblock->vtx[0].vout[0].scriptPubKey.data();
|
script = (uint8_t *)pblock->vtx[0].vout[0].scriptPubKey.data();
|
||||||
if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 )
|
if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) {
|
||||||
return(-1);
|
return(-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( komodo_checkcommission(pblock,height) < 0 )
|
if ( komodo_checkcommission(pblock,height) < 0 )
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
if ( ASSETCHAINS_STREAM != 0 && height > 128 )
|
||||||
|
{
|
||||||
|
int lasttx = ( pblock->vtx.size() -1 );
|
||||||
|
printf("ABOUT TO CHECK LAST TX: %d\n",lasttx);
|
||||||
|
if ( lasttx == 0 )
|
||||||
|
return(-1);
|
||||||
|
uint256 hash; CTransaction tx;
|
||||||
|
if (GetTransaction(pblock->vtx[lasttx].vin[0].prevout.hash,tx,hash,false))
|
||||||
|
{
|
||||||
|
printf("CHECKING THE script pubkey\n");
|
||||||
|
script = (uint8_t *)tx.vout[pblock->vtx[lasttx].vin[0].prevout.n].scriptPubKey.data();
|
||||||
|
if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) {
|
||||||
|
printf("THE PUBKEY IS WRONG!\n");
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
printf("THE PUBKEY IS RIGHT! \n");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"komodo_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed);
|
//fprintf(stderr,"komodo_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed);
|
||||||
if ( failed != 0 && possible == 0 && notaryid < 0 )
|
if ( failed != 0 && possible == 0 && notaryid < 0 )
|
||||||
|
|||||||
@@ -744,7 +744,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
checktoshis = 0;
|
checktoshis = 0;
|
||||||
if ( ASSETCHAINS_COMMISSION != 0 && height > 1 )
|
if ( (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0) && height > 1 )
|
||||||
{
|
{
|
||||||
if ( (checktoshis= komodo_checkcommission((CBlock *)&block,height)) < 0 )
|
if ( (checktoshis= komodo_checkcommission((CBlock *)&block,height)) < 0 )
|
||||||
{
|
{
|
||||||
@@ -1518,4 +1518,3 @@ void komodo_passport_iteration()
|
|||||||
printf("READY for %s RPC calls at %u! done PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,(uint32_t)time(NULL),ASSETCHAINS_SYMBOL,refid);
|
printf("READY for %s RPC calls at %u! done PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,(uint32_t)time(NULL),ASSETCHAINS_SYMBOL,refid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ struct komodo_state KOMODO_STATES[34];
|
|||||||
#define _COINBASE_MATURITY 100
|
#define _COINBASE_MATURITY 100
|
||||||
int COINBASE_MATURITY = _COINBASE_MATURITY;//100;
|
int COINBASE_MATURITY = _COINBASE_MATURITY;//100;
|
||||||
|
|
||||||
int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1;
|
int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1;
|
||||||
int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1;
|
int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1;
|
||||||
std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY;
|
std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY;
|
||||||
uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE;
|
uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE;
|
||||||
|
|||||||
@@ -1561,6 +1561,11 @@ void komodo_args(char *argv0)
|
|||||||
ASSETCHAINS_DECAY = GetArg("-ac_decay",0);
|
ASSETCHAINS_DECAY = GetArg("-ac_decay",0);
|
||||||
ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0);
|
ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0);
|
||||||
ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey","");
|
ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey","");
|
||||||
|
ASSETCHAINS_STREAM = GetArg("-ac_stream",0);
|
||||||
|
if ( ASSETCHAINS_STREAM != 0 && ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_PRIVATE != 0 )) {
|
||||||
|
printf("ASSETCHAINS_STREAM cannot be used with:\n ASSETCHAINS_COMMISSION \n ASSETCHAINS_ENDSUBSIDY\n ASSETCHAINS_REWARD\n ASSETCHAINS_HALVING\n ASSETCHAINS_DECAY\n ASSETCHAINS_PRIVATE\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 )
|
if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 )
|
||||||
ASSETCHAINS_STAKED = 100;
|
ASSETCHAINS_STAKED = 100;
|
||||||
if ( ASSETCHAINS_STAKED != 0 && ASSETCHAINS_PRIVATE != 0 )
|
if ( ASSETCHAINS_STAKED != 0 && ASSETCHAINS_PRIVATE != 0 )
|
||||||
@@ -1589,8 +1594,15 @@ void komodo_args(char *argv0)
|
|||||||
{
|
{
|
||||||
ASSETCHAINS_COMMISSION = 0;
|
ASSETCHAINS_COMMISSION = 0;
|
||||||
printf("ASSETCHAINS_COMMISSION needs an ASETCHAINS_OVERRIDE_PUBKEY and cant be more than 100000000 (100%%)\n");
|
printf("ASSETCHAINS_COMMISSION needs an ASETCHAINS_OVERRIDE_PUBKEY and cant be more than 100000000 (100%%)\n");
|
||||||
}
|
} else if ( ASSETCHAINS_STREAM != 0) {
|
||||||
if ( ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 )
|
ASSETCHAINS_STREAM = 0;
|
||||||
|
printf("ASSETCHAINS_STREAM needs ASSETCHAINS_OVERRIDE_PUBKEY! This parameter has been ignored! \n");
|
||||||
|
}
|
||||||
|
if ( ASSETCHAINS_STREAM != 0 && ASSETCHAINS_SUPPLY == 10 ) {
|
||||||
|
ASSETCHAINS_SUPPLY = 1000000;
|
||||||
|
printf("ASSETCHAINS_STREAM is set with no supply, setting supply at 1,000,000 coins. \n");
|
||||||
|
}
|
||||||
|
if ( ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_STREAM != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"end.%llu blocks, reward %.8f halving.%llu blocks, decay.%llu perc %.4f%% ac_pub=[%02x...]\n",(long long)ASSETCHAINS_ENDSUBSIDY,dstr(ASSETCHAINS_REWARD),(long long)ASSETCHAINS_HALVING,(long long)ASSETCHAINS_DECAY,dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0]);
|
fprintf(stderr,"end.%llu blocks, reward %.8f halving.%llu blocks, decay.%llu perc %.4f%% ac_pub=[%02x...]\n",(long long)ASSETCHAINS_ENDSUBSIDY,dstr(ASSETCHAINS_REWARD),(long long)ASSETCHAINS_HALVING,(long long)ASSETCHAINS_DECAY,dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0]);
|
||||||
extraptr = extrabuf;
|
extraptr = extrabuf;
|
||||||
|
|||||||
25
src/main.cpp
25
src/main.cpp
@@ -1866,6 +1866,7 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW)
|
|||||||
//uint64_t komodo_moneysupply(int32_t height);
|
//uint64_t komodo_moneysupply(int32_t height);
|
||||||
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
||||||
extern uint32_t ASSETCHAINS_MAGIC;
|
extern uint32_t ASSETCHAINS_MAGIC;
|
||||||
|
extern int32_t ASSETCHAINS_STREAM;
|
||||||
extern uint64_t ASSETCHAINS_STAKED,ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_LINEAR,ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY;
|
extern uint64_t ASSETCHAINS_STAKED,ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_LINEAR,ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY;
|
||||||
extern uint8_t ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE;
|
extern uint8_t ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE;
|
||||||
|
|
||||||
@@ -1894,8 +1895,13 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
|
|||||||
else if ( ASSETCHAINS_ENDSUBSIDY == 0 || nHeight < ASSETCHAINS_ENDSUBSIDY )
|
else if ( ASSETCHAINS_ENDSUBSIDY == 0 || nHeight < ASSETCHAINS_ENDSUBSIDY )
|
||||||
{
|
{
|
||||||
if ( ASSETCHAINS_REWARD == 0 )
|
if ( ASSETCHAINS_REWARD == 0 )
|
||||||
return(10000);
|
{
|
||||||
else if ( ASSETCHAINS_ENDSUBSIDY != 0 && nHeight >= ASSETCHAINS_ENDSUBSIDY )
|
if ( ASSETCHAINS_STREAM != 0 && nHeight > 128 )
|
||||||
|
return(0);
|
||||||
|
else
|
||||||
|
return(10000);
|
||||||
|
}
|
||||||
|
else if ( ASSETCHAINS_ENDSUBSIDY != 0 && nHeight >= ASSETCHAINS_ENDSUBSIDY )
|
||||||
return(0);
|
return(0);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2961,6 +2967,19 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||||||
if (!view.HaveJoinSplitRequirements(tx))
|
if (!view.HaveJoinSplitRequirements(tx))
|
||||||
return state.DoS(100, error("ConnectBlock(): JoinSplit requirements not met"),
|
return state.DoS(100, error("ConnectBlock(): JoinSplit requirements not met"),
|
||||||
REJECT_INVALID, "bad-txns-joinsplit-requirements-not-met");
|
REJECT_INVALID, "bad-txns-joinsplit-requirements-not-met");
|
||||||
|
|
||||||
|
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||||
|
{
|
||||||
|
if ( ASSETCHAINS_STREAM != 0 )
|
||||||
|
{
|
||||||
|
if ( block.vtx.size() == 1 && block.vtx[0].vout.size() == 2 && pindex->nHeight > ASSETCHAINS_MINHEIGHT)
|
||||||
|
{
|
||||||
|
return state.DoS(100, error("ConnectBlock(): There are no TX in this block, it is invalid!"),
|
||||||
|
REJECT_INVALID, "bad-block-no-transactions");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (fAddressIndex || fSpentIndex)
|
if (fAddressIndex || fSpentIndex)
|
||||||
{
|
{
|
||||||
for (size_t j = 0; j < tx.vin.size(); j++) {
|
for (size_t j = 0; j < tx.vin.size(); j++) {
|
||||||
@@ -3110,7 +3129,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||||||
LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime1 - nTimeStart), 0.001 * (nTime1 - nTimeStart) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime1 - nTimeStart) / (nInputs-1), nTimeConnect * 0.000001);
|
LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime1 - nTimeStart), 0.001 * (nTime1 - nTimeStart) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime1 - nTimeStart) / (nInputs-1), nTimeConnect * 0.000001);
|
||||||
|
|
||||||
CAmount blockReward = nFees + GetBlockSubsidy(pindex->nHeight, chainparams.GetConsensus()) + sum;
|
CAmount blockReward = nFees + GetBlockSubsidy(pindex->nHeight, chainparams.GetConsensus()) + sum;
|
||||||
if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 )
|
if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0) )
|
||||||
{
|
{
|
||||||
uint64_t checktoshis;
|
uint64_t checktoshis;
|
||||||
if ( (checktoshis= komodo_commission((CBlock *)&block)) != 0 )
|
if ( (checktoshis= komodo_commission((CBlock *)&block)) != 0 )
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams,
|
|||||||
|
|
||||||
#include "komodo_defs.h"
|
#include "komodo_defs.h"
|
||||||
|
|
||||||
extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE;
|
extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE;
|
||||||
extern uint64_t ASSETCHAINS_REWARD,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED;
|
extern uint64_t ASSETCHAINS_REWARD,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED;
|
||||||
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
||||||
extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY;
|
extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY;
|
||||||
@@ -428,7 +428,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount)
|
|||||||
txNew.vin[0].scriptSig = CScript() << nHeight << OP_0;
|
txNew.vin[0].scriptSig = CScript() << nHeight << OP_0;
|
||||||
|
|
||||||
pblock->vtx[0] = txNew;
|
pblock->vtx[0] = txNew;
|
||||||
if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block)) != 0 )
|
if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0) && (commission= komodo_commission((CBlock*)&pblocktemplate->block)) != 0 )
|
||||||
{
|
{
|
||||||
int32_t i; uint8_t *ptr;
|
int32_t i; uint8_t *ptr;
|
||||||
txNew.vout.resize(2);
|
txNew.vout.resize(2);
|
||||||
@@ -439,7 +439,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount)
|
|||||||
for (i=0; i<33; i++)
|
for (i=0; i<33; i++)
|
||||||
ptr[i+1] = ASSETCHAINS_OVERRIDE_PUBKEY33[i];
|
ptr[i+1] = ASSETCHAINS_OVERRIDE_PUBKEY33[i];
|
||||||
ptr[34] = OP_CHECKSIG;
|
ptr[34] = OP_CHECKSIG;
|
||||||
//printf("autocreate commision vout\n");
|
//printf("autocreate commission vout\n");
|
||||||
pblock->vtx[0] = txNew;
|
pblock->vtx[0] = txNew;
|
||||||
}
|
}
|
||||||
pblocktemplate->vTxFees[0] = -nFees;
|
pblocktemplate->vTxFees[0] = -nFees;
|
||||||
@@ -493,6 +493,26 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount)
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ( ASSETCHAINS_STREAM != 0 && ASSETCHAINS_SYMBOL[0] != 0 && nHeight > 128 )
|
||||||
|
{
|
||||||
|
CMutableTransaction txStream = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1);
|
||||||
|
if ( komodo_notaryvin(txStream,ASSETCHAINS_OVERRIDE_PUBKEY33) > 0 )
|
||||||
|
{
|
||||||
|
CAmount txfees = 10000;
|
||||||
|
pblock->vtx.push_back(txStream);
|
||||||
|
pblocktemplate->vTxFees.push_back(txfees);
|
||||||
|
pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txStream));
|
||||||
|
nFees += txfees;
|
||||||
|
pblocktemplate->vTxFees[0] = -nFees;
|
||||||
|
//*(uint64_t *)(&pblock->vtx[0].vout[0].nValue) += txfees;
|
||||||
|
//fprintf(stderr,"added notaryvin\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr,"error adding streamer vin, the chain broke! \n");
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
else if ( ASSETCHAINS_CC == 0 && pindexPrev != 0 && ASSETCHAINS_STAKED == 0 && (ASSETCHAINS_SYMBOL[0] != 0 || IS_KOMODO_NOTARY == 0 || My_notaryid < 0) )
|
else if ( ASSETCHAINS_CC == 0 && pindexPrev != 0 && ASSETCHAINS_STAKED == 0 && (ASSETCHAINS_SYMBOL[0] != 0 || IS_KOMODO_NOTARY == 0 || My_notaryid < 0) )
|
||||||
{
|
{
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
@@ -610,12 +630,18 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,in
|
|||||||
{
|
{
|
||||||
scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG;
|
scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG;
|
||||||
}
|
}
|
||||||
|
else if ( ASSETCHAINS_STREAM != 0 )
|
||||||
|
{
|
||||||
|
if ( nHeight < 128 )
|
||||||
|
scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG;
|
||||||
|
else
|
||||||
|
scriptPubKey = CScript() << ParseHex(CRYPTO777_PUBSECPSTR) << OP_CHECKSIG;
|
||||||
|
}
|
||||||
else if ( USE_EXTERNAL_PUBKEY != 0 )
|
else if ( USE_EXTERNAL_PUBKEY != 0 )
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"use notary pubkey\n");
|
//fprintf(stderr,"use notary pubkey\n");
|
||||||
scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG;
|
scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (!reservekey.GetReservedKey(pubkey))
|
if (!reservekey.GetReservedKey(pubkey))
|
||||||
{
|
{
|
||||||
@@ -840,14 +866,19 @@ void static BitcoinMiner()
|
|||||||
{
|
{
|
||||||
if ( ASSETCHAINS_REWARD == 0 )
|
if ( ASSETCHAINS_REWARD == 0 )
|
||||||
{
|
{
|
||||||
if ( pblock->vtx.size() == 1 && pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT )
|
int minvoutsize = 1;
|
||||||
|
int minvtxsize = 1;
|
||||||
|
if ( ASSETCHAINS_STREAM != 0 )
|
||||||
|
minvoutsize = 2;
|
||||||
|
minvtxsize = 2;
|
||||||
|
if ( pblock->vtx.size() == minvtxsize && pblock->vtx[0].vout.size() == minvoutsize && Mining_height > ASSETCHAINS_MINHEIGHT )
|
||||||
{
|
{
|
||||||
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",ASSETCHAINS_SYMBOL);
|
fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL);
|
||||||
sleep(10);
|
sleep(10);
|
||||||
continue;
|
continue;
|
||||||
} else fprintf(stderr,"%s vouts.%d mining.%d vs %d\n",ASSETCHAINS_SYMBOL,(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT);
|
} else fprintf(stderr,"%s tx.%d vouts.%d mining.%d vs %d\n",ASSETCHAINS_SYMBOL,(int32_t)pblock->vtx.size(),(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
|
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
|
||||||
@@ -926,13 +957,13 @@ void static BitcoinMiner()
|
|||||||
}
|
}
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if ( KOMODO_INSYNC == 0 )
|
/*if ( KOMODO_INSYNC == 0 && Mining_height > ASSETCHAINS_MINHEIGHT )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Mining when blockchain might not be in sync longest.%d vs %d\n",KOMODO_LONGESTCHAIN,Mining_height);
|
fprintf(stderr,"Mining when blockchain might not be in sync longest.%d vs %d\n",KOMODO_LONGESTCHAIN,Mining_height);
|
||||||
if ( KOMODO_LONGESTCHAIN != 0 && Mining_height >= KOMODO_LONGESTCHAIN )
|
if ( KOMODO_LONGESTCHAIN != 0 && Mining_height >= KOMODO_LONGESTCHAIN )
|
||||||
KOMODO_INSYNC = 1;
|
KOMODO_INSYNC = 1;
|
||||||
sleep(3);
|
sleep(3);
|
||||||
}
|
} */
|
||||||
// Hash state
|
// Hash state
|
||||||
KOMODO_CHOSEN_ONE = 0;
|
KOMODO_CHOSEN_ONE = 0;
|
||||||
crypto_generichash_blake2b_state state;
|
crypto_generichash_blake2b_state state;
|
||||||
|
|||||||
48
src/pow.cpp
48
src/pow.cpp
@@ -20,31 +20,39 @@
|
|||||||
#include "librustzcash.h"
|
#include "librustzcash.h"
|
||||||
#endif // ENABLE_RUST
|
#endif // ENABLE_RUST
|
||||||
uint32_t komodo_chainactive_timestamp();
|
uint32_t komodo_chainactive_timestamp();
|
||||||
|
extern int32_t ASSETCHAINS_STREAM;
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact();
|
if ( ASSETCHAINS_STREAM == 0)
|
||||||
// Genesis block
|
{
|
||||||
if (pindexLast == NULL )
|
unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact();
|
||||||
return nProofOfWorkLimit;
|
// Genesis block
|
||||||
|
if (pindexLast == NULL )
|
||||||
|
return nProofOfWorkLimit;
|
||||||
|
|
||||||
// Find the first block in the averaging interval
|
// Find the first block in the averaging interval
|
||||||
const CBlockIndex* pindexFirst = pindexLast;
|
const CBlockIndex* pindexFirst = pindexLast;
|
||||||
arith_uint256 bnTot {0};
|
arith_uint256 bnTot {0};
|
||||||
for (int i = 0; pindexFirst && i < params.nPowAveragingWindow; i++) {
|
for (int i = 0; pindexFirst && i < params.nPowAveragingWindow; i++) {
|
||||||
arith_uint256 bnTmp;
|
arith_uint256 bnTmp;
|
||||||
bnTmp.SetCompact(pindexFirst->nBits);
|
bnTmp.SetCompact(pindexFirst->nBits);
|
||||||
bnTot += bnTmp;
|
bnTot += bnTmp;
|
||||||
pindexFirst = pindexFirst->pprev;
|
pindexFirst = pindexFirst->pprev;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check we have enough blocks
|
||||||
|
if (pindexFirst == NULL)
|
||||||
|
return nProofOfWorkLimit;
|
||||||
|
|
||||||
|
arith_uint256 bnAvg {bnTot / params.nPowAveragingWindow};
|
||||||
|
|
||||||
|
return CalculateNextWorkRequired(bnAvg, pindexLast->GetMedianTimePast(), pindexFirst->GetMedianTimePast(), params);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 537857807;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check we have enough blocks
|
|
||||||
if (pindexFirst == NULL)
|
|
||||||
return nProofOfWorkLimit;
|
|
||||||
|
|
||||||
arith_uint256 bnAvg {bnTot / params.nPowAveragingWindow};
|
|
||||||
|
|
||||||
return CalculateNextWorkRequired(bnAvg, pindexLast->GetMedianTimePast(), pindexFirst->GetMedianTimePast(), params);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int CalculateNextWorkRequired(arith_uint256 bnAvg,
|
unsigned int CalculateNextWorkRequired(arith_uint256 bnAvg,
|
||||||
|
|||||||
@@ -257,6 +257,218 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char hexval(unsigned char c)
|
||||||
|
{
|
||||||
|
if ('0' <= c && c <= '9')
|
||||||
|
return c - '0';
|
||||||
|
else if ('a' <= c && c <= 'f')
|
||||||
|
return c - 'a' + 10;
|
||||||
|
else if ('A' <= c && c <= 'F')
|
||||||
|
return c - 'A' + 10;
|
||||||
|
else abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
void hex2ascii(const string& in, string& out)
|
||||||
|
{
|
||||||
|
out.clear();
|
||||||
|
out.reserve(in.length() / 2);
|
||||||
|
for (string::const_iterator p = in.begin(); p != in.end(); p++)
|
||||||
|
{
|
||||||
|
unsigned char c = hexval(*p);
|
||||||
|
p++;
|
||||||
|
if (p == in.end()) break; // incomplete last digit - should report error
|
||||||
|
c = (c << 4) + hexval(*p); // + takes precedence over <<
|
||||||
|
out.push_back(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UniValue getdatafromblock(const UniValue& params, bool fHelp)
|
||||||
|
{
|
||||||
|
if (fHelp || params.size() < 1 || params.size() > 2)
|
||||||
|
throw runtime_error(
|
||||||
|
"getdatafromblock \"hash|height\" true/false\n"
|
||||||
|
"\nReturns all the data sent via streamer in block if there was any data in it.\n"
|
||||||
|
"\nArguments:\n"
|
||||||
|
"1. \"hash|height\" (string, required) The block hash or height\n"
|
||||||
|
"2. \"true/false\" (bool, optional) if false do not return the actual data. Default true.\n"
|
||||||
|
"\nResult (for verbose = true):\n"
|
||||||
|
"{\n"
|
||||||
|
" \"streamid\" : \"string\", (string) the name of the stream.\n"
|
||||||
|
" \"firsttxid\" : \"hash\", (string) the first transaction of the stream.\n"
|
||||||
|
" \"firstblockheight\" : \"n\", (numeric) the block the stream starts in.\n"
|
||||||
|
" \"firstdeqid\" : n, (numeric) The sequence id of the first data chunk in this block\n"
|
||||||
|
" \"lastseqid\" : n, (numeric) The sequence id of the last data chunk in this block\n"
|
||||||
|
" \"data\" : \"xxxx\", (string) A hex string containing all the data chunks in this block.\n"
|
||||||
|
"}\n"
|
||||||
|
"\nResult (for verbose=false):\n"
|
||||||
|
" \"streamid\" : \"string\", (string) the name of the stream.\n"
|
||||||
|
" \"firsttxid\" : \"hash\", (string) the first transaction of the stream.\n"
|
||||||
|
" \"firstblockheight\" : \"n\", (numeric) the block the stream starts in.\n"
|
||||||
|
" \"firstdeqid\" : n, (numeric) The sequence id of the first data chunk in this block\n"
|
||||||
|
" \"lastseqid\" : n, (numeric) The sequence id of the last data chunk in this block\n"
|
||||||
|
+ HelpExampleCli("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09 false\"")
|
||||||
|
+ HelpExampleRpc("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
|
||||||
|
+ HelpExampleCli("getblock", "12800")
|
||||||
|
+ HelpExampleRpc("getblock", "12800 false")
|
||||||
|
);
|
||||||
|
|
||||||
|
LOCK(cs_main);
|
||||||
|
|
||||||
|
std::string strHash = params[0].get_str();
|
||||||
|
bool fVerbose = true;
|
||||||
|
if (params.size() > 1) {
|
||||||
|
std::string verboseflag = params[1].get_str();
|
||||||
|
if ( verboseflag == "false" )
|
||||||
|
fVerbose = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If height is supplied, find the hash
|
||||||
|
if (strHash.size() < (2 * sizeof(uint256))) {
|
||||||
|
// std::stoi allows characters, whereas we want to be strict
|
||||||
|
regex r("[[:digit:]]+");
|
||||||
|
if (!regex_match(strHash, r)) {
|
||||||
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid block height parameter");
|
||||||
|
}
|
||||||
|
|
||||||
|
int nHeight = -1;
|
||||||
|
try {
|
||||||
|
nHeight = std::stoi(strHash);
|
||||||
|
}
|
||||||
|
catch (const std::exception &e) {
|
||||||
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid block height parameter");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nHeight < 0 || nHeight > chainActive.Height()) {
|
||||||
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range");
|
||||||
|
}
|
||||||
|
strHash = chainActive[nHeight]->GetBlockHash().GetHex();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint256 hash(uint256S(strHash));
|
||||||
|
|
||||||
|
if (mapBlockIndex.count(hash) == 0)
|
||||||
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
|
||||||
|
|
||||||
|
CBlock block;
|
||||||
|
CBlockIndex* pblockindex = mapBlockIndex[hash];
|
||||||
|
|
||||||
|
if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0)
|
||||||
|
throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)");
|
||||||
|
|
||||||
|
if(!ReadBlockFromDisk(block, pblockindex,1))
|
||||||
|
throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk");
|
||||||
|
|
||||||
|
UniValue result(UniValue::VOBJ);
|
||||||
|
int firstseqid = 0;
|
||||||
|
int lastseqid = 0;
|
||||||
|
int i = 0;
|
||||||
|
int did1 = 0;
|
||||||
|
int skippedtxs = 0;
|
||||||
|
int failed = 0;
|
||||||
|
int getfirstblock = 0;
|
||||||
|
static std::string streamid,firsttxid;
|
||||||
|
static int firsttxnHeight;
|
||||||
|
std::string blockdata;
|
||||||
|
fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size());
|
||||||
|
// Iif block tx size is > 2 then we can do this
|
||||||
|
if ( block.vtx.size() > 2 )
|
||||||
|
{
|
||||||
|
BOOST_FOREACH(const CTransaction&tx, block.vtx)
|
||||||
|
{
|
||||||
|
// ignore first and last TX and any TX that does not have 3 vouts.
|
||||||
|
if ( (i == 0) || (i == (block.vtx.size() -1)) || (tx.vout.size() != 3) )
|
||||||
|
{
|
||||||
|
fprintf(stderr, "skipped tx number: %d\n",i);
|
||||||
|
skippedtxs = skippedtxs + 1;
|
||||||
|
} else {
|
||||||
|
std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end());
|
||||||
|
// scriptPubKey is longer than 81, should mean its an OP_RETURN, maybe also check vout == 0 ?
|
||||||
|
if ( opretstr.size() > 81 ) {
|
||||||
|
std::string idstr = opretstr.substr (8,64); // stream ID or txid
|
||||||
|
std::string seqidstr = opretstr.substr (72,8); // sequence ID
|
||||||
|
std::string data = opretstr.substr (80); // data chunk
|
||||||
|
unsigned int seqid;
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << std::hex << seqidstr;
|
||||||
|
ss >> seqid;
|
||||||
|
if ( seqid == 1 ) {
|
||||||
|
streamid = idstr;
|
||||||
|
getfirstblock = 1;
|
||||||
|
} else if ( seqid == 2 ) {
|
||||||
|
firsttxid = idstr;
|
||||||
|
} else if (firsttxid.empty()) {
|
||||||
|
firsttxid.append(idstr);
|
||||||
|
} else if ( firsttxid != idstr ) {
|
||||||
|
printf("firsttxid.%s idstr.%s change firsttxid and wipe streamid?\n",firsttxid.c_str(),idstr.c_str());
|
||||||
|
firsttxid.clear();
|
||||||
|
firsttxid.append(idstr);
|
||||||
|
streamid.clear();
|
||||||
|
firsttxnHeight = 0;
|
||||||
|
}
|
||||||
|
if ( seqid == (lastseqid + 1) || did1 == 0 ) {
|
||||||
|
blockdata.append(data);
|
||||||
|
} else {
|
||||||
|
result.push_back(Pair("error","chunck out of order or missing in this block!"));
|
||||||
|
result.push_back(Pair("lastvalidseqid", (int)lastseqid));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ( did1 == 0 ) {
|
||||||
|
firstseqid = seqid;
|
||||||
|
did1 = 1;
|
||||||
|
}
|
||||||
|
lastseqid = seqid;
|
||||||
|
} else {
|
||||||
|
skippedtxs = skippedtxs + 1;
|
||||||
|
fprintf(stderr, "skipped tx number: %d\n",i);
|
||||||
|
}
|
||||||
|
// function here to extract seqid from first and last TX
|
||||||
|
// we an push the data or not depending on input from RPC.
|
||||||
|
}
|
||||||
|
i = i + 1;
|
||||||
|
}
|
||||||
|
if (streamid.empty() || getfirstblock == 1) {
|
||||||
|
if ( lastseqid == 1) {
|
||||||
|
firsttxid = block.vtx[1].GetHash().GetHex();
|
||||||
|
}
|
||||||
|
uint256 hash; CTransaction firsttx;
|
||||||
|
uint256 firsttxid_256(uint256S(firsttxid));
|
||||||
|
if (GetTransaction(firsttxid_256,firsttx,hash,false)) {
|
||||||
|
if ( streamid.empty() ) {
|
||||||
|
std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end());
|
||||||
|
streamid.append(firststreamid.substr (8,64));
|
||||||
|
}
|
||||||
|
printf("first stream id changed to: %s\n", streamid.c_str());
|
||||||
|
BlockMap::iterator mi = mapBlockIndex.find(hash);
|
||||||
|
if (mi != mapBlockIndex.end() && (*mi).second) {
|
||||||
|
CBlockIndex* pindex = (*mi).second;
|
||||||
|
printf("found block height: %d\n",pindex->nHeight);
|
||||||
|
if (chainActive.Contains(pindex)) {
|
||||||
|
firsttxnHeight = pindex->nHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( failed == 1 || skippedtxs == i ) {
|
||||||
|
result.push_back(Pair("error","there is no data in this block."));
|
||||||
|
} else {
|
||||||
|
std::string decodedstreamid;
|
||||||
|
hex2ascii(streamid, decodedstreamid);
|
||||||
|
result.push_back(Pair("streamid", decodedstreamid.c_str()));
|
||||||
|
result.push_back(Pair("firsttxid", firsttxid));
|
||||||
|
result.push_back(Pair("firstblockheight", (int)firsttxnHeight));
|
||||||
|
result.push_back(Pair("firstseqid", (int)firstseqid));
|
||||||
|
result.push_back(Pair("lastseqid", (int)lastseqid));
|
||||||
|
if (fVerbose == true) {
|
||||||
|
result.push_back(Pair("data", blockdata));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false)
|
UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false)
|
||||||
{
|
{
|
||||||
UniValue result(UniValue::VOBJ);
|
UniValue result(UniValue::VOBJ);
|
||||||
|
|||||||
@@ -264,6 +264,7 @@ static const CRPCCommand vRPCCommands[] =
|
|||||||
{ "control", "getinfo", &getinfo, true }, /* uses wallet if enabled */
|
{ "control", "getinfo", &getinfo, true }, /* uses wallet if enabled */
|
||||||
{ "control", "help", &help, true },
|
{ "control", "help", &help, true },
|
||||||
{ "control", "stop", &stop, true },
|
{ "control", "stop", &stop, true },
|
||||||
|
{ "control", "setpubkey", &setpubkey, true },
|
||||||
|
|
||||||
/* P2P networking */
|
/* P2P networking */
|
||||||
{ "network", "getnetworkinfo", &getnetworkinfo, true },
|
{ "network", "getnetworkinfo", &getnetworkinfo, true },
|
||||||
@@ -285,6 +286,7 @@ static const CRPCCommand vRPCCommands[] =
|
|||||||
{ "blockchain", "getbestblockhash", &getbestblockhash, true },
|
{ "blockchain", "getbestblockhash", &getbestblockhash, true },
|
||||||
{ "blockchain", "getblockcount", &getblockcount, true },
|
{ "blockchain", "getblockcount", &getblockcount, true },
|
||||||
{ "blockchain", "getblock", &getblock, true },
|
{ "blockchain", "getblock", &getblock, true },
|
||||||
|
{ "blockchain", "getdatafromblock", &getdatafromblock, true },
|
||||||
{ "blockchain", "getblockdeltas", &getblockdeltas, false },
|
{ "blockchain", "getblockdeltas", &getblockdeltas, false },
|
||||||
{ "blockchain", "getblockhashes", &getblockhashes, true },
|
{ "blockchain", "getblockhashes", &getblockhashes, true },
|
||||||
{ "blockchain", "getblockhash", &getblockhash, true },
|
{ "blockchain", "getblockhash", &getblockhash, true },
|
||||||
|
|||||||
@@ -364,6 +364,7 @@ extern UniValue getblockdeltas(const UniValue& params, bool fHelp);
|
|||||||
extern UniValue getblockhash(const UniValue& params, bool fHelp);
|
extern UniValue getblockhash(const UniValue& params, bool fHelp);
|
||||||
extern UniValue getblockheader(const UniValue& params, bool fHelp);
|
extern UniValue getblockheader(const UniValue& params, bool fHelp);
|
||||||
extern UniValue getblock(const UniValue& params, bool fHelp);
|
extern UniValue getblock(const UniValue& params, bool fHelp);
|
||||||
|
extern UniValue getdatafromblock(const UniValue& params, bool fHelp);
|
||||||
extern UniValue gettxoutsetinfo(const UniValue& params, bool fHelp);
|
extern UniValue gettxoutsetinfo(const UniValue& params, bool fHelp);
|
||||||
extern UniValue gettxout(const UniValue& params, bool fHelp);
|
extern UniValue gettxout(const UniValue& params, bool fHelp);
|
||||||
extern UniValue verifychain(const UniValue& params, bool fHelp);
|
extern UniValue verifychain(const UniValue& params, bool fHelp);
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ using namespace std;
|
|||||||
using namespace libzcash;
|
using namespace libzcash;
|
||||||
|
|
||||||
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
||||||
|
extern std::string ASSETCHAINS_OVERRIDE_PUBKEY;
|
||||||
|
extern int32_t ASSETCHAINS_STREAM;
|
||||||
extern UniValue TxJoinSplitToJSON(const CTransaction& tx);
|
extern UniValue TxJoinSplitToJSON(const CTransaction& tx);
|
||||||
extern uint8_t ASSETCHAINS_PRIVATE;
|
extern uint8_t ASSETCHAINS_PRIVATE;
|
||||||
uint32_t komodo_segid32(char *coinaddr);
|
uint32_t komodo_segid32(char *coinaddr);
|
||||||
@@ -4606,8 +4608,8 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33)
|
|||||||
// ((uint8_t *)&revtxid)[i] = ((uint8_t *)&utxotxid)[31 - i];
|
// ((uint8_t *)&revtxid)[i] = ((uint8_t *)&utxotxid)[31 - i];
|
||||||
txNew.vin[0].prevout.hash = utxotxid; //revtxid;
|
txNew.vin[0].prevout.hash = utxotxid; //revtxid;
|
||||||
txNew.vin[0].prevout.n = utxovout;
|
txNew.vin[0].prevout.n = utxovout;
|
||||||
txNew.vout[0].scriptPubKey = CScript() << ParseHex(CRYPTO777_PUBSECPSTR) << OP_CHECKSIG;
|
|
||||||
txNew.vout[0].nValue = utxovalue - txfee;
|
txNew.vout[0].nValue = utxovalue - txfee;
|
||||||
|
txNew.vout[0].scriptPubKey = CScript() << ParseHex(CRYPTO777_PUBSECPSTR) << OP_CHECKSIG;
|
||||||
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user