Test
This commit is contained in:
@@ -557,11 +557,11 @@ uint64_t komodo_seed(int32_t height)
|
|||||||
return(seed);
|
return(seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t komodo_txtime(uint64_t *valuep,uint256 hash,int32_t n)
|
uint32_t komodo_txtime(uint64_t *valuep,uint256 hash,int32_t n,char *address)
|
||||||
{
|
{
|
||||||
CTransaction tx;
|
CTxDestination address; CTransaction tx; uint256 hashBlock;
|
||||||
uint256 hashBlock;
|
|
||||||
*valuep = 0;
|
*valuep = 0;
|
||||||
|
address[0] = 0;
|
||||||
if (!GetTransaction(hash, tx,
|
if (!GetTransaction(hash, tx,
|
||||||
#ifndef KOMODO_ZCASH
|
#ifndef KOMODO_ZCASH
|
||||||
Params().GetConsensus(),
|
Params().GetConsensus(),
|
||||||
@@ -573,7 +573,11 @@ uint32_t komodo_txtime(uint64_t *valuep,uint256 hash,int32_t n)
|
|||||||
}
|
}
|
||||||
//fprintf(stderr,"%s/v%d locktime.%u\n",hash.ToString().c_str(),n,(uint32_t)tx.nLockTime);
|
//fprintf(stderr,"%s/v%d locktime.%u\n",hash.ToString().c_str(),n,(uint32_t)tx.nLockTime);
|
||||||
if ( n < tx.vout.size() )
|
if ( n < tx.vout.size() )
|
||||||
|
{
|
||||||
*valuep = tx.vout[n].nValue;
|
*valuep = tx.vout[n].nValue;
|
||||||
|
if (ExtractDestination(tx.scriptPubKey, address))
|
||||||
|
strcpy(address,CBitcoinAddress(address).ToString().c_str());
|
||||||
|
}
|
||||||
return(tx.nLockTime);
|
return(tx.nLockTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -670,11 +670,11 @@ uint64_t komodo_commission(const CBlock &block)
|
|||||||
return((total * ASSETCHAINS_COMMISSION) / COIN);
|
return((total * ASSETCHAINS_COMMISSION) / COIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t komodo_stake(arith_uint256 bnTarget,int32_t nHeight,uint256 txid,int32_t vout,uint32_t blocktime,uint32_t prevtime)
|
uint32_t komodo_stake(arith_uint256 bnTarget,int32_t nHeight,uint256 txid,int32_t vout,uint32_t blocktime,uint32_t prevtime,char *destaddr)
|
||||||
{
|
{
|
||||||
CBlockIndex *pindex; arith_uint256 hashval; uint256 hash; int32_t minage,i,iter=0; uint32_t txtime,winner = 0; uint64_t diff,value,coinage,supply = ASSETCHAINS_SUPPLY + nHeight*ASSETCHAINS_REWARD/SATOSHIDEN;
|
CBlockIndex *pindex; char address[64]; arith_uint256 hashval; uint256 hash; int32_t minage,i,iter=0; uint32_t txtime,winner = 0; uint64_t diff,value,coinage,supply = ASSETCHAINS_SUPPLY + nHeight*ASSETCHAINS_REWARD/SATOSHIDEN;
|
||||||
txtime = komodo_txtime(&value,txid,vout);
|
txtime = komodo_txtime(&value,txid,vout,address);
|
||||||
//fprintf(stderr,"%s/v%d %.8f txtime.%u\n",txid.ToString().c_str(),vout,dstr(value),txtime);
|
fprintf(stderr,"(%s) vs. (%s) %s/v%d %.8f txtime.%u\n",address,destaddr,txid.ToString().c_str(),vout,dstr(value),txtime);
|
||||||
if ( value == 0 )
|
if ( value == 0 )
|
||||||
return(0);
|
return(0);
|
||||||
if ( txtime == 0 )
|
if ( txtime == 0 )
|
||||||
@@ -799,7 +799,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim
|
|||||||
prevtime = (uint32_t)previndex->nTime;
|
prevtime = (uint32_t)previndex->nTime;
|
||||||
}
|
}
|
||||||
bnTarget.SetCompact(block.nBits, &fNegative, &fOverflow);
|
bnTarget.SetCompact(block.nBits, &fNegative, &fOverflow);
|
||||||
eligible = komodo_stake(bnTarget,height,block.vtx[txn_count-1].vin[0].prevout.hash,block.vtx[txn_count-1].vin[0].prevout.n,block.nTime,prevtime);
|
eligible = komodo_stake(bnTarget,height,block.vtx[txn_count-1].vin[0].prevout.hash,block.vtx[txn_count-1].vin[0].prevout.n,block.nTime,prevtime,"");
|
||||||
if ( eligible == 0 || eligible > block.nTime )
|
if ( eligible == 0 || eligible > block.nTime )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"eligible.%u vs blocktime.%u, lag.%d\n",eligible,(uint32_t)block.nTime,(int32_t)(eligible - block.nTime));
|
fprintf(stderr,"eligible.%u vs blocktime.%u, lag.%d\n",eligible,(uint32_t)block.nTime,(int32_t)(eligible - block.nTime));
|
||||||
|
|||||||
@@ -4490,7 +4490,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt
|
|||||||
CBlockIndex *tipindex;
|
CBlockIndex *tipindex;
|
||||||
if ( (tipindex= chainActive.Tip()) != 0 )
|
if ( (tipindex= chainActive.Tip()) != 0 )
|
||||||
{
|
{
|
||||||
eligible = komodo_stake(bnTarget,(uint32_t)tipindex->nHeight+1,out.tx->GetHash(),out.i,*blocktimep,(uint32_t)tipindex->nTime);
|
eligible = komodo_stake(bnTarget,(uint32_t)tipindex->nHeight+1,out.tx->GetHash(),out.i,*blocktimep,(uint32_t)tipindex->nTime,CBitcoinAddress(address).ToString().c_str());
|
||||||
if ( eligible > 0 )
|
if ( eligible > 0 )
|
||||||
{
|
{
|
||||||
if ( earliest == 0 || eligible < earliest || (eligible == earliest && (*utxovaluep == 0 || nValue < *utxovaluep)) )
|
if ( earliest == 0 || eligible < earliest || (eligible == earliest && (*utxovaluep == 0 || nValue < *utxovaluep)) )
|
||||||
|
|||||||
Reference in New Issue
Block a user