@@ -387,7 +387,7 @@ const CScript &CCoinsViewCache::GetSpendFor(const CTxIn& input) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
//uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime);
|
//uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime);
|
||||||
uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue);
|
uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue,int32_t tipheight);
|
||||||
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
||||||
|
|
||||||
CAmount CCoinsViewCache::GetValueIn(int32_t nHeight,int64_t *interestp,const CTransaction& tx,uint32_t tiptime) const
|
CAmount CCoinsViewCache::GetValueIn(int32_t nHeight,int64_t *interestp,const CTransaction& tx,uint32_t tiptime) const
|
||||||
@@ -407,7 +407,7 @@ CAmount CCoinsViewCache::GetValueIn(int32_t nHeight,int64_t *interestp,const CTr
|
|||||||
if ( value >= 10*COIN )
|
if ( value >= 10*COIN )
|
||||||
{
|
{
|
||||||
int64_t interest; int32_t txheight; uint32_t locktime;
|
int64_t interest; int32_t txheight; uint32_t locktime;
|
||||||
interest = komodo_accrued_interest(&txheight,&locktime,tx.vin[i].prevout.hash,tx.vin[i].prevout.n,0,value);
|
interest = komodo_accrued_interest(&txheight,&locktime,tx.vin[i].prevout.hash,tx.vin[i].prevout.n,0,value,(int32_t)nHeight);
|
||||||
//printf("nResult %.8f += val %.8f interest %.8f ht.%d lock.%u tip.%u\n",(double)nResult/COIN,(double)value/COIN,(double)interest/COIN,txheight,locktime,tiptime);
|
//printf("nResult %.8f += val %.8f interest %.8f ht.%d lock.%u tip.%u\n",(double)nResult/COIN,(double)value/COIN,(double)interest/COIN,txheight,locktime,tiptime);
|
||||||
//fprintf(stderr,"nResult %.8f += val %.8f interest %.8f ht.%d lock.%u tip.%u\n",(double)nResult/COIN,(double)value/COIN,(double)interest/COIN,txheight,locktime,tiptime);
|
//fprintf(stderr,"nResult %.8f += val %.8f interest %.8f ht.%d lock.%u tip.%u\n",(double)nResult/COIN,(double)value/COIN,(double)interest/COIN,txheight,locktime,tiptime);
|
||||||
nResult += interest;
|
nResult += interest;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ using namespace std;
|
|||||||
|
|
||||||
#include "komodo_interest.h"
|
#include "komodo_interest.h"
|
||||||
|
|
||||||
uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue)
|
uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue,int32_t tipheight)
|
||||||
{
|
{
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,9 @@
|
|||||||
|
|
||||||
#include "komodo_defs.h"
|
#include "komodo_defs.h"
|
||||||
|
|
||||||
|
int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp);
|
||||||
|
int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp);
|
||||||
|
|
||||||
//#define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"curl",(char *)"http://127.0.0.1:7776",0,0,(char *)(cmdstr))
|
//#define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"curl",(char *)"http://127.0.0.1:7776",0,0,(char *)(cmdstr))
|
||||||
|
|
||||||
struct MemoryStruct { char *memory; size_t size; };
|
struct MemoryStruct { char *memory; size_t size; };
|
||||||
@@ -700,13 +703,36 @@ uint32_t komodo_heightstamp(int32_t height)
|
|||||||
|
|
||||||
void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height)
|
void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height)
|
||||||
{
|
{
|
||||||
CBlock block;
|
CBlock block; int32_t num,i; uint8_t pubkeys[64][33];
|
||||||
//komodo_init(height);
|
//komodo_init(height);
|
||||||
memset(pubkey33,0,33);
|
memset(pubkey33,0,33);
|
||||||
if ( pindex != 0 )
|
if ( pindex != 0 )
|
||||||
{
|
{
|
||||||
|
if ( pindex->pubkey33[0] == 2 || pindex->pubkey33[0] == 3 )
|
||||||
|
{
|
||||||
|
memcpy(pubkey33,pindex->pubkey33,33);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ( komodo_blockload(block,pindex) == 0 )
|
if ( komodo_blockload(block,pindex) == 0 )
|
||||||
|
{
|
||||||
komodo_block2pubkey33(pubkey33,block);
|
komodo_block2pubkey33(pubkey33,block);
|
||||||
|
if ( (pubkey33[0] == 2 || pubkey33[0] == 3) )
|
||||||
|
{
|
||||||
|
memcpy(pindex->pubkey33,pubkey33,33);
|
||||||
|
if ( (num= komodo_notaries(pubkeys,(int32_t)pindex->nHeight,(uint32_t)pindex->nTime)) > 0 )
|
||||||
|
{
|
||||||
|
pindex->notaryid = -1;
|
||||||
|
for (i=0; i<num; i++)
|
||||||
|
{
|
||||||
|
if ( memcmp(pubkeys[i],pubkey33,33) == 0 )
|
||||||
|
{
|
||||||
|
pindex->notaryid = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else pindex->notaryid = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -722,20 +748,21 @@ void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height)
|
|||||||
komodo_connectblock(pindex,block);
|
komodo_connectblock(pindex,block);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp);
|
|
||||||
int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp);
|
|
||||||
|
|
||||||
int8_t komodo_minerid(int32_t height,uint8_t *pubkey33)
|
int8_t komodo_minerid(int32_t height,uint8_t *pubkey33)
|
||||||
{
|
{
|
||||||
int32_t num,i,numnotaries; CBlockIndex *pindex; uint32_t timestamp=0; uint8_t _pubkey33[33],pubkeys[64][33];
|
int32_t num,i,numnotaries; CBlockIndex *pindex; uint32_t timestamp=0; uint8_t _pubkey33[33],pubkeys[64][33];
|
||||||
if ( pubkey33 == 0 && (pindex= chainActive[height]) != 0 )
|
if ( (pindex= chainActive[height]) != 0 )
|
||||||
{
|
{
|
||||||
timestamp = pindex->GetBlockTime();
|
if ( (pindex->pubkey33[0] == 2 || pindex->pubkey33[0] == 3) )
|
||||||
if ( pubkey33 == 0 )
|
|
||||||
{
|
{
|
||||||
pubkey33 = _pubkey33;
|
if ( pubkey33 != 0 )
|
||||||
komodo_index2pubkey33(pubkey33,pindex,height);
|
memcpy(pubkey33,pindex->pubkey33,33);
|
||||||
|
return(pindex->notaryid);
|
||||||
}
|
}
|
||||||
|
if ( pubkey33 != 0 )
|
||||||
|
komodo_index2pubkey33(pubkey33,pindex,height);
|
||||||
|
timestamp = pindex->GetBlockTime();
|
||||||
if ( (num= komodo_notaries(pubkeys,height,timestamp)) > 0 )
|
if ( (num= komodo_notaries(pubkeys,height,timestamp)) > 0 )
|
||||||
{
|
{
|
||||||
for (i=0; i<num; i++)
|
for (i=0; i<num; i++)
|
||||||
@@ -754,15 +781,22 @@ int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,int32_t *non
|
|||||||
{
|
{
|
||||||
if ( (pindex= komodo_chainactive(height-i)) != 0 )
|
if ( (pindex= komodo_chainactive(height-i)) != 0 )
|
||||||
{
|
{
|
||||||
komodo_index2pubkey33(pubkey33,pindex,height-i);
|
if ( pindex->notaryid >= 0 && (pindex->pubkey33[0] == 2 || pindex->pubkey33[0] == 3) )
|
||||||
//for (j=0; j<33; j++)
|
|
||||||
// pubkeys[i][j] = pubkey33[j];
|
|
||||||
memcpy(pubkeys[i],pubkey33,33);
|
|
||||||
if ( (mids[i]= komodo_minerid(height-i,pubkey33)) >= 0 )
|
|
||||||
{
|
{
|
||||||
//mids[i] = *(int32_t *)pubkey33;
|
memcpy(pubkeys[i],pindex->pubkey33,33);
|
||||||
|
mids[i] = pindex->notaryid;
|
||||||
(*nonzpkeysp)++;
|
(*nonzpkeysp)++;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
komodo_index2pubkey33(pubkey33,pindex,height-i);
|
||||||
|
memcpy(pubkeys[i],pubkey33,33);
|
||||||
|
if ( (mids[i]= komodo_minerid(height-i,pubkey33)) >= 0 )
|
||||||
|
{
|
||||||
|
//mids[i] = *(int32_t *)pubkey33;
|
||||||
|
(*nonzpkeysp)++;
|
||||||
|
}
|
||||||
|
}
|
||||||
if ( mids[0] >= 0 && i > 0 && mids[i] == mids[0] )
|
if ( mids[0] >= 0 && i > 0 && mids[i] == mids[0] )
|
||||||
duplicate++;
|
duplicate++;
|
||||||
}
|
}
|
||||||
@@ -772,23 +806,24 @@ int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,int32_t *non
|
|||||||
else return(0);
|
else return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t komodo_minerids(uint8_t *minerids,int32_t height,int32_t width)
|
int32_t komodo_minerids(uint8_t *minerids,int32_t height,int32_t width) // deprecate
|
||||||
{
|
{
|
||||||
int32_t i,n=0;
|
/*int32_t i,n=0;
|
||||||
for (i=0; i<width; i++,n++)
|
for (i=0; i<width; i++,n++)
|
||||||
{
|
{
|
||||||
if ( height-i <= 0 )
|
if ( height-i <= 0 )
|
||||||
break;
|
break;
|
||||||
minerids[i] = komodo_minerid(height - i,0);
|
minerids[i] = komodo_minerid(height - i,0);
|
||||||
}
|
}
|
||||||
return(n);
|
return(n);*/
|
||||||
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33],uint32_t timestamp)
|
int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33],uint32_t timestamp)
|
||||||
{
|
{
|
||||||
int32_t i,notaryid=0,minerid,limit,nid; uint8_t _pubkey33[33];
|
int32_t i,notaryid=0,minerid,limit,nid; //uint8_t _pubkey33[33];
|
||||||
if ( height >= 225000 )
|
if ( height >= 225000 )
|
||||||
komodo_chosennotary(¬aryid,height,_pubkey33,timestamp);
|
komodo_chosennotary(¬aryid,height,pubkey33,timestamp);
|
||||||
if ( height >= 34000 && notaryid >= 0 )
|
if ( height >= 34000 && notaryid >= 0 )
|
||||||
{
|
{
|
||||||
if ( height < 79693 )
|
if ( height < 79693 )
|
||||||
@@ -798,8 +833,8 @@ int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33],uint32_t timestamp
|
|||||||
else limit = 66;
|
else limit = 66;
|
||||||
for (i=1; i<limit; i++)
|
for (i=1; i<limit; i++)
|
||||||
{
|
{
|
||||||
komodo_chosennotary(&nid,height-i,_pubkey33,timestamp);
|
komodo_chosennotary(&nid,height-i,pubkey33,timestamp);
|
||||||
if ( nid == notaryid ) //komodo_minerid(height-i,_pubkey33)
|
if ( nid == notaryid )
|
||||||
{
|
{
|
||||||
if ( (0) && notaryid > 0 )
|
if ( (0) && notaryid > 0 )
|
||||||
fprintf(stderr,"ht.%d notaryid.%d already mined -i.%d nid.%d\n",height,notaryid,i,nid);
|
fprintf(stderr,"ht.%d notaryid.%d already mined -i.%d nid.%d\n",height,notaryid,i,nid);
|
||||||
@@ -869,12 +904,13 @@ uint32_t komodo_interest_args(uint32_t *txheighttimep,int32_t *txheightp,uint32_
|
|||||||
uint32_t locktime = 0;
|
uint32_t locktime = 0;
|
||||||
if ( n < tx.vout.size() )
|
if ( n < tx.vout.size() )
|
||||||
{
|
{
|
||||||
if ( (pindex= mapBlockIndex[hashBlock]) != 0 && (tipindex= chainActive.Tip()) != 0 )
|
if ( (pindex= mapBlockIndex[hashBlock]) != 0 )
|
||||||
{
|
{
|
||||||
*valuep = tx.vout[n].nValue;
|
*valuep = tx.vout[n].nValue;
|
||||||
*txheightp = pindex->nHeight;
|
*txheightp = pindex->nHeight;
|
||||||
*txheighttimep = pindex->nTime;
|
*txheighttimep = pindex->nTime;
|
||||||
*tiptimep = tipindex->nTime;
|
if ( *tiptimep == 0 && (tipindex= chainActive.Tip()) != 0 )
|
||||||
|
*tiptimep = (uint32_t)tipindex->nTime;
|
||||||
locktime = tx.nLockTime;
|
locktime = tx.nLockTime;
|
||||||
//fprintf(stderr,"tx locktime.%u %.8f height.%d | tiptime.%u\n",locktime,(double)*valuep/COIN,*txheightp,*tiptimep);
|
//fprintf(stderr,"tx locktime.%u %.8f height.%d | tiptime.%u\n",locktime,(double)*valuep/COIN,*txheightp,*tiptimep);
|
||||||
}
|
}
|
||||||
@@ -883,9 +919,13 @@ uint32_t komodo_interest_args(uint32_t *txheighttimep,int32_t *txheightp,uint32_
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime);
|
uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime);
|
||||||
uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue)
|
|
||||||
|
uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue,int32_t tipheight)
|
||||||
{
|
{
|
||||||
uint64_t value; uint32_t tiptime,txheighttimep;
|
uint64_t value; uint32_t tiptime=0,txheighttimep; CBlockIndex *pindex;
|
||||||
|
if ( (pindex= chainActive[tipheight]) != 0 )
|
||||||
|
tiptime = (uint32_t)pindex->nTime;
|
||||||
|
else fprintf(stderr,"cant find height[%d]\n",tipheight);
|
||||||
if ( (*locktimep= komodo_interest_args(&txheighttimep,txheightp,&tiptime,&value,hash,n)) != 0 )
|
if ( (*locktimep= komodo_interest_args(&txheighttimep,txheightp,&tiptime,&value,hash,n)) != 0 )
|
||||||
{
|
{
|
||||||
if ( (checkvalue == 0 || value == checkvalue) && (checkheight == 0 || *txheightp == checkheight) )
|
if ( (checkvalue == 0 || value == checkvalue) && (checkheight == 0 || *txheightp == checkheight) )
|
||||||
|
|||||||
@@ -339,7 +339,6 @@ int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,
|
|||||||
{
|
{
|
||||||
// -1 if not notary, 0 if notary, 1 if special notary
|
// -1 if not notary, 0 if notary, 1 if special notary
|
||||||
struct knotary_entry *kp; int32_t numnotaries=0,htind,modval = -1;
|
struct knotary_entry *kp; int32_t numnotaries=0,htind,modval = -1;
|
||||||
komodo_init(0);
|
|
||||||
*notaryidp = -1;
|
*notaryidp = -1;
|
||||||
if ( height < 0 )//|| height >= KOMODO_MAXBLOCKS )
|
if ( height < 0 )//|| height >= KOMODO_MAXBLOCKS )
|
||||||
{
|
{
|
||||||
@@ -356,6 +355,8 @@ int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,
|
|||||||
}
|
}
|
||||||
if ( height >= 250000 )
|
if ( height >= 250000 )
|
||||||
return(-1);
|
return(-1);
|
||||||
|
if ( Pubkeys == 0 )
|
||||||
|
komodo_init(0);
|
||||||
htind = height / KOMODO_ELECTION_GAP;
|
htind = height / KOMODO_ELECTION_GAP;
|
||||||
if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP )
|
if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP )
|
||||||
htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1;
|
htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1;
|
||||||
|
|||||||
16
src/main.cpp
16
src/main.cpp
@@ -751,7 +751,7 @@ bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime)
|
|||||||
}
|
}
|
||||||
else if (!txin.IsFinal())
|
else if (!txin.IsFinal())
|
||||||
{
|
{
|
||||||
printf("non-final txin seq.%x locktime.%u vs nTime.%u\n",txin.nSequence,(uint32_t)tx.nLockTime,(uint32_t)nBlockTime);
|
//printf("non-final txin seq.%x locktime.%u vs nTime.%u\n",txin.nSequence,(uint32_t)tx.nLockTime,(uint32_t)nBlockTime);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1345,7 +1345,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
|||||||
// are the joinsplit's requirements met?
|
// are the joinsplit's requirements met?
|
||||||
if (!view.HaveJoinSplitRequirements(tx))
|
if (!view.HaveJoinSplitRequirements(tx))
|
||||||
{
|
{
|
||||||
fprintf(stderr,"accept failure.2\n");
|
//fprintf(stderr,"accept failure.2\n");
|
||||||
return state.Invalid(error("AcceptToMemoryPool: joinsplit requirements not met"),REJECT_DUPLICATE, "bad-txns-joinsplit-requirements-not-met");
|
return state.Invalid(error("AcceptToMemoryPool: joinsplit requirements not met"),REJECT_DUPLICATE, "bad-txns-joinsplit-requirements-not-met");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1455,7 +1455,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
|||||||
PrecomputedTransactionData txdata(tx);
|
PrecomputedTransactionData txdata(tx);
|
||||||
if (!ContextualCheckInputs(tx, state, view, true, STANDARD_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId))
|
if (!ContextualCheckInputs(tx, state, view, true, STANDARD_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId))
|
||||||
{
|
{
|
||||||
fprintf(stderr,"accept failure.9\n");
|
//fprintf(stderr,"accept failure.9\n");
|
||||||
return error("AcceptToMemoryPool: ConnectInputs failed %s", hash.ToString());
|
return error("AcceptToMemoryPool: ConnectInputs failed %s", hash.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1986,14 +1986,14 @@ bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoins
|
|||||||
// Check for negative or overflow input values
|
// Check for negative or overflow input values
|
||||||
nValueIn += coins->vout[prevout.n].nValue;
|
nValueIn += coins->vout[prevout.n].nValue;
|
||||||
#ifdef KOMODO_ENABLE_INTEREST
|
#ifdef KOMODO_ENABLE_INTEREST
|
||||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && chainActive.Tip() != 0 && chainActive.Tip()->nHeight >= 60000 )
|
if ( ASSETCHAINS_SYMBOL[0] == 0 && nSpendHeight > 60000 )//chainActive.Tip() != 0 && chainActive.Tip()->nHeight >= 60000 )
|
||||||
{
|
{
|
||||||
if ( coins->vout[prevout.n].nValue >= 10*COIN )
|
if ( coins->vout[prevout.n].nValue >= 10*COIN )
|
||||||
{
|
{
|
||||||
int64_t interest; int32_t txheight; uint32_t locktime;
|
int64_t interest; int32_t txheight; uint32_t locktime;
|
||||||
if ( (interest= komodo_accrued_interest(&txheight,&locktime,prevout.hash,prevout.n,0,coins->vout[prevout.n].nValue)) != 0 )
|
if ( (interest= komodo_accrued_interest(&txheight,&locktime,prevout.hash,prevout.n,0,coins->vout[prevout.n].nValue,(int32_t)nSpendHeight-1)) != 0 )
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"checkResult %.8f += val %.8f interest %.8f ht.%d lock.%u tip.%u\n",(double)nValueIn/COIN,(double)coins->vout[prevout.n].nValue/COIN,(double)interest/COIN,txheight,locktime,chainActive.Tip()->nTime);
|
//fprintf(stderr,"checkResult %.8f += val %.8f interest %.8f ht.%d lock.%u tip.%u\n",(double)nValueIn/COIN,(double)coins->vout[prevout.n].nValue/COIN,(double)interest/COIN,txheight,locktime,chainActive.Tip()->nTime);
|
||||||
nValueIn += interest;
|
nValueIn += interest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2011,9 +2011,11 @@ bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoins
|
|||||||
REJECT_INVALID, "bad-txns-inputvalues-outofrange");
|
REJECT_INVALID, "bad-txns-inputvalues-outofrange");
|
||||||
|
|
||||||
if (nValueIn < tx.GetValueOut())
|
if (nValueIn < tx.GetValueOut())
|
||||||
|
{
|
||||||
|
fprintf(stderr,"spentheight.%d valuein %s vs %s error\n",nSpendHeight,FormatMoney(nValueIn).c_str(), FormatMoney(tx.GetValueOut()).c_str());
|
||||||
return state.DoS(100, error("CheckInputs(): %s value in (%s) < value out (%s) diff %.8f",
|
return state.DoS(100, error("CheckInputs(): %s value in (%s) < value out (%s) diff %.8f",
|
||||||
tx.GetHash().ToString(), FormatMoney(nValueIn), FormatMoney(tx.GetValueOut()),((double)nValueIn - tx.GetValueOut())/COIN),REJECT_INVALID, "bad-txns-in-belowout");
|
tx.GetHash().ToString(), FormatMoney(nValueIn), FormatMoney(tx.GetValueOut()),((double)nValueIn - tx.GetValueOut())/COIN),REJECT_INVALID, "bad-txns-in-belowout");
|
||||||
|
}
|
||||||
// Tally transaction fees
|
// Tally transaction fees
|
||||||
CAmount nTxFee = nValueIn - tx.GetValueOut();
|
CAmount nTxFee = nValueIn - tx.GetValueOut();
|
||||||
if (nTxFee < 0)
|
if (nTxFee < 0)
|
||||||
|
|||||||
@@ -112,7 +112,6 @@ extern std::string NOTARY_PUBKEY;
|
|||||||
extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33];
|
extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33];
|
||||||
uint32_t Mining_start,Mining_height;
|
uint32_t Mining_start,Mining_height;
|
||||||
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
|
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
|
||||||
int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33],uint32_t timestamp);
|
|
||||||
int32_t komodo_pax_opreturn(int32_t height,uint8_t *opret,int32_t maxsize);
|
int32_t komodo_pax_opreturn(int32_t height,uint8_t *opret,int32_t maxsize);
|
||||||
uint64_t komodo_paxtotal();
|
uint64_t komodo_paxtotal();
|
||||||
int32_t komodo_baseid(char *origbase);
|
int32_t komodo_baseid(char *origbase);
|
||||||
@@ -524,7 +523,6 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int&
|
|||||||
//
|
//
|
||||||
// Internal miner
|
// Internal miner
|
||||||
//
|
//
|
||||||
int8_t komodo_minerid(int32_t height,uint8_t *pubkey33);
|
|
||||||
|
|
||||||
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey)
|
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey)
|
||||||
{
|
{
|
||||||
@@ -549,12 +547,6 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey)
|
|||||||
script[34] = OP_CHECKSIG;
|
script[34] = OP_CHECKSIG;
|
||||||
//scriptPubKey = CScript() << ToByteVector(pubkey) << OP_CHECKSIG;
|
//scriptPubKey = CScript() << ToByteVector(pubkey) << OP_CHECKSIG;
|
||||||
}
|
}
|
||||||
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
|
|
||||||
{
|
|
||||||
for (i=0; i<65; i++)
|
|
||||||
fprintf(stderr,"%d ",komodo_minerid(chainActive.Tip()->nHeight-i,0));
|
|
||||||
fprintf(stderr," minerids.special %d from ht.%d\n",komodo_is_special(chainActive.Tip()->nHeight+1,NOTARY_PUBKEY33,chainActive.Tip()->GetBlockTime()),chainActive.Tip()->nHeight);
|
|
||||||
}
|
|
||||||
return CreateNewBlock(scriptPubKey);
|
return CreateNewBlock(scriptPubKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -762,7 +754,7 @@ void static BitcoinMiner()
|
|||||||
savebits = pblock->nBits;
|
savebits = pblock->nBits;
|
||||||
arith_uint256 hashTarget = arith_uint256().SetCompact(pblock->nBits);
|
arith_uint256 hashTarget = arith_uint256().SetCompact(pblock->nBits);
|
||||||
roundrobin_delay = ROUNDROBIN_DELAY;
|
roundrobin_delay = ROUNDROBIN_DELAY;
|
||||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && notaryid >= 0 )//komodo_is_special(pindexPrev->nHeight+1,NOTARY_PUBKEY33) > 0 )
|
if ( ASSETCHAINS_SYMBOL[0] == 0 && notaryid >= 0 )
|
||||||
{
|
{
|
||||||
j = 65;
|
j = 65;
|
||||||
if ( (Mining_height >= 235300 && Mining_height < 236000) || (Mining_height % KOMODO_ELECTION_GAP) > 64 || (Mining_height % KOMODO_ELECTION_GAP) == 0 )
|
if ( (Mining_height >= 235300 && Mining_height < 236000) || (Mining_height % KOMODO_ELECTION_GAP) > 64 || (Mining_height % KOMODO_ELECTION_GAP) == 0 )
|
||||||
@@ -783,12 +775,6 @@ void static BitcoinMiner()
|
|||||||
break;
|
break;
|
||||||
if ( externalflag == 0 && i != 66 )
|
if ( externalflag == 0 && i != 66 )
|
||||||
printf("VIOLATION at %d\n",i);
|
printf("VIOLATION at %d\n",i);
|
||||||
for (i=0; i<66; i++)
|
|
||||||
{ break;
|
|
||||||
for (j=0; j<33; j++)
|
|
||||||
printf("%02x",pubkeys[i][j]);
|
|
||||||
printf(" p%d -> %d\n",i,komodo_minerid(pindexPrev->nHeight-i,pubkeys[i]));
|
|
||||||
}
|
|
||||||
for (j=gpucount=0; j<65; j++)
|
for (j=gpucount=0; j<65; j++)
|
||||||
{
|
{
|
||||||
if ( mids[j] >= 0 || notaryid == 34 )
|
if ( mids[j] >= 0 || notaryid == 34 )
|
||||||
|
|||||||
@@ -120,7 +120,6 @@ int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,
|
|||||||
int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33],uint32_t timestamp);
|
int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33],uint32_t timestamp);
|
||||||
int32_t komodo_currentheight();
|
int32_t komodo_currentheight();
|
||||||
CBlockIndex *komodo_chainactive(int32_t height);
|
CBlockIndex *komodo_chainactive(int32_t height);
|
||||||
//int8_t komodo_minerid(int32_t height,uint8_t *pubkey33);
|
|
||||||
void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height);
|
void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height);
|
||||||
extern int32_t KOMODO_CHOSEN_ONE;
|
extern int32_t KOMODO_CHOSEN_ONE;
|
||||||
extern char ASSETCHAINS_SYMBOL[];
|
extern char ASSETCHAINS_SYMBOL[];
|
||||||
@@ -169,7 +168,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
|
|||||||
// Check proof of work matches claimed amount
|
// Check proof of work matches claimed amount
|
||||||
if ( UintToArith256(hash) > bnTarget )
|
if ( UintToArith256(hash) > bnTarget )
|
||||||
{
|
{
|
||||||
if ( (height < 235300 || height >= 236000) && KOMODO_LOADINGBLOCKS == 0 && height > 188000 )
|
if ( 0 && (height < 235300 || height >= 236000) && KOMODO_LOADINGBLOCKS == 0 && height > 188000 )
|
||||||
//&& )//186269, 182507&& komodo_chainactive(height) != 0 && nonzpkeys > 0
|
//&& )//186269, 182507&& komodo_chainactive(height) != 0 && nonzpkeys > 0
|
||||||
{
|
{
|
||||||
for (i=31; i>=0; i--)
|
for (i=31; i>=0; i--)
|
||||||
|
|||||||
@@ -636,7 +636,7 @@ UniValue minerids(const UniValue& params, bool fHelp)
|
|||||||
if ( pblockindex != 0 )
|
if ( pblockindex != 0 )
|
||||||
timestamp = pblockindex->GetBlockTime();
|
timestamp = pblockindex->GetBlockTime();
|
||||||
}
|
}
|
||||||
if ( (n= komodo_minerids(minerids,height,(int32_t)(sizeof(minerids)/sizeof(*minerids)))) > 0 )
|
if ( 0 && (n= komodo_minerids(minerids,height,(int32_t)(sizeof(minerids)/sizeof(*minerids)))) > 0 )
|
||||||
{
|
{
|
||||||
memset(tally,0,sizeof(tally));
|
memset(tally,0,sizeof(tally));
|
||||||
numnotaries = komodo_notaries(pubkeys,height,timestamp);
|
numnotaries = komodo_notaries(pubkeys,height,timestamp);
|
||||||
@@ -843,7 +843,7 @@ UniValue paxprices(const UniValue& params, bool fHelp)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue);
|
uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue,int32_t tipheight);
|
||||||
|
|
||||||
UniValue gettxout(const UniValue& params, bool fHelp)
|
UniValue gettxout(const UniValue& params, bool fHelp)
|
||||||
{
|
{
|
||||||
@@ -916,7 +916,7 @@ UniValue gettxout(const UniValue& params, bool fHelp)
|
|||||||
else ret.push_back(Pair("confirmations", pindex->nHeight - coins.nHeight + 1));
|
else ret.push_back(Pair("confirmations", pindex->nHeight - coins.nHeight + 1));
|
||||||
ret.push_back(Pair("value", ValueFromAmount(coins.vout[n].nValue)));
|
ret.push_back(Pair("value", ValueFromAmount(coins.vout[n].nValue)));
|
||||||
uint64_t interest; int32_t txheight; uint32_t locktime;
|
uint64_t interest; int32_t txheight; uint32_t locktime;
|
||||||
if ( (interest= komodo_accrued_interest(&txheight,&locktime,hash,n,coins.nHeight,coins.vout[n].nValue)) != 0 )
|
if ( (interest= komodo_accrued_interest(&txheight,&locktime,hash,n,coins.nHeight,coins.vout[n].nValue,(int32_t)pindex->nHeight)) != 0 )
|
||||||
ret.push_back(Pair("interest", ValueFromAmount(interest)));
|
ret.push_back(Pair("interest", ValueFromAmount(interest)));
|
||||||
UniValue o(UniValue::VOBJ);
|
UniValue o(UniValue::VOBJ);
|
||||||
ScriptPubKeyToJSON(coins.vout[n].scriptPubKey, o, true);
|
ScriptPubKeyToJSON(coins.vout[n].scriptPubKey, o, true);
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ void EnsureWalletIsUnlocked()
|
|||||||
throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first.");
|
throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first.");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue);
|
uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue,int32_t tipheight);
|
||||||
uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime);
|
uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime);
|
||||||
|
|
||||||
void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry)
|
void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry)
|
||||||
@@ -2675,9 +2675,9 @@ UniValue listunspent(const UniValue& params, bool fHelp)
|
|||||||
BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock());
|
BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock());
|
||||||
CBlockIndex *tipindex,*pindex = it->second;
|
CBlockIndex *tipindex,*pindex = it->second;
|
||||||
uint64_t interest; uint32_t locktime; int32_t txheight;
|
uint64_t interest; uint32_t locktime; int32_t txheight;
|
||||||
komodo_accrued_interest(&txheight,&locktime,out.tx->GetHash(),out.i,0,nValue);
|
|
||||||
if ( pindex != 0 && (tipindex= chainActive.Tip()) != 0 )
|
if ( pindex != 0 && (tipindex= chainActive.Tip()) != 0 )
|
||||||
{
|
{
|
||||||
|
komodo_accrued_interest(&txheight,&locktime,out.tx->GetHash(),out.i,0,nValue,(int32_t)tipindex->nHeight);
|
||||||
interest = komodo_interest(txheight,nValue,out.tx->nLockTime,tipindex->nTime);
|
interest = komodo_interest(txheight,nValue,out.tx->nLockTime,tipindex->nTime);
|
||||||
entry.push_back(Pair("interest",ValueFromAmount(interest)));
|
entry.push_back(Pair("interest",ValueFromAmount(interest)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2247,7 +2247,7 @@ CAmount CWallet::GetImmatureWatchOnlyBalance() const
|
|||||||
* populate vCoins with vector of available COutputs.
|
* populate vCoins with vector of available COutputs.
|
||||||
*/
|
*/
|
||||||
uint64_t komodo_interestnew(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime);
|
uint64_t komodo_interestnew(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime);
|
||||||
uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue);
|
uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue,int32_t tipheight);
|
||||||
|
|
||||||
void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const CCoinControl *coinControl, bool fIncludeZeroValue, bool fIncludeCoinBase) const
|
void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const CCoinControl *coinControl, bool fIncludeZeroValue, bool fIncludeCoinBase) const
|
||||||
{
|
{
|
||||||
@@ -2291,9 +2291,9 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const
|
|||||||
{
|
{
|
||||||
if ( pcoin->vout[i].nValue >= 10*COIN )
|
if ( pcoin->vout[i].nValue >= 10*COIN )
|
||||||
{
|
{
|
||||||
komodo_accrued_interest(&txheight,&locktime,wtxid,i,0,pcoin->vout[i].nValue);
|
|
||||||
if ( (tipindex= chainActive.Tip()) != 0 )
|
if ( (tipindex= chainActive.Tip()) != 0 )
|
||||||
{
|
{
|
||||||
|
komodo_accrued_interest(&txheight,&locktime,wtxid,i,0,pcoin->vout[i].nValue,(int32_t)tipindex->nHeight);
|
||||||
interest = komodo_interestnew(txheight,pcoin->vout[i].nValue,locktime,tipindex->nTime);
|
interest = komodo_interestnew(txheight,pcoin->vout[i].nValue,locktime,tipindex->nTime);
|
||||||
} else interest = 0;
|
} else interest = 0;
|
||||||
//interest = komodo_interestnew(chainActive.Tip()->nHeight+1,pcoin->vout[i].nValue,pcoin->nLockTime,chainActive.Tip()->nTime);
|
//interest = komodo_interestnew(chainActive.Tip()->nHeight+1,pcoin->vout[i].nValue,pcoin->nLockTime,chainActive.Tip()->nTime);
|
||||||
|
|||||||
Reference in New Issue
Block a user