Staking improvement
This commit is contained in:
@@ -1266,14 +1266,14 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height)
|
|||||||
int32_t txn_count;
|
int32_t txn_count;
|
||||||
uint32_t voutNum;
|
uint32_t voutNum;
|
||||||
bool isPOS = false;
|
bool isPOS = false;
|
||||||
CTxDestination voutaddress, destaddress;
|
CTxDestination voutaddress, destaddress, cbaddress;
|
||||||
arith_uint256 target, hash;
|
arith_uint256 target, hash;
|
||||||
CTransaction tx;
|
CTransaction tx;
|
||||||
|
|
||||||
if (!pblock->IsVerusPOSBlock())
|
if (!pblock->IsVerusPOSBlock())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
char voutaddr[64],destaddr[64];
|
char voutaddr[64], destaddr[64], cbaddr[64];
|
||||||
|
|
||||||
target.SetCompact(pblock->GetVerusPOSTarget());
|
target.SetCompact(pblock->GetVerusPOSTarget());
|
||||||
txn_count = pblock->vtx.size();
|
txn_count = pblock->vtx.size();
|
||||||
@@ -1324,17 +1324,19 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height)
|
|||||||
fprintf(stderr,"ERROR: invalid PoS block %s - invalid diff target\n",blkHash.ToString().c_str());
|
fprintf(stderr,"ERROR: invalid PoS block %s - invalid diff target\n",blkHash.ToString().c_str());
|
||||||
}
|
}
|
||||||
else if ( ExtractDestination(pblock->vtx[txn_count-1].vout[0].scriptPubKey, voutaddress) &&
|
else if ( ExtractDestination(pblock->vtx[txn_count-1].vout[0].scriptPubKey, voutaddress) &&
|
||||||
ExtractDestination(tx.vout[voutNum].scriptPubKey, destaddress) )
|
ExtractDestination(tx.vout[voutNum].scriptPubKey, destaddress) &&
|
||||||
|
ExtractDestination(tx.vout[voutNum].scriptPubKey, cbaddress) )
|
||||||
{
|
{
|
||||||
strcpy(voutaddr, CBitcoinAddress(voutaddress).ToString().c_str());
|
strcpy(voutaddr, CBitcoinAddress(voutaddress).ToString().c_str());
|
||||||
strcpy(destaddr, CBitcoinAddress(destaddress).ToString().c_str());
|
strcpy(destaddr, CBitcoinAddress(destaddress).ToString().c_str());
|
||||||
if ( strcmp(destaddr,voutaddr) == 0 )
|
strcpy(cbaddr, CBitcoinAddress(cbaddress).ToString().c_str());
|
||||||
|
if ( !strcmp(destaddr,voutaddr) && strcmp(destaddr,cb) )
|
||||||
{
|
{
|
||||||
isPOS = true;
|
isPOS = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr,"ERROR: invalid PoS block %s - invalid stake destination\n",blkHash.ToString().c_str());
|
fprintf(stderr,"ERROR: invalid PoS block %s - invalid stake or coinbase destination\n",blkHash.ToString().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -463,6 +463,10 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, bool isStake)
|
|||||||
siglen = verus_staked(key, txStaked, nBitsPOS, posHash, utxosig);
|
siglen = verus_staked(key, txStaked, nBitsPOS, posHash, utxosig);
|
||||||
blocktime = GetAdjustedTime();
|
blocktime = GetAdjustedTime();
|
||||||
pblock->SetVerusPOSTarget(nBitsPOS);
|
pblock->SetVerusPOSTarget(nBitsPOS);
|
||||||
|
|
||||||
|
// change the scriptPubKeyIn to the same output script exactly as the staking transaction
|
||||||
|
if (siglen > 0)
|
||||||
|
scriptPubKeyIn = CScript(txStaked.vout[0].scriptPubKey);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user