diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 7fdbc63b6..82ea1f722 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1266,14 +1266,14 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) int32_t txn_count; uint32_t voutNum; bool isPOS = false; - CTxDestination voutaddress, destaddress; + CTxDestination voutaddress, destaddress, cbaddress; arith_uint256 target, hash; CTransaction tx; if (!pblock->IsVerusPOSBlock()) return false; - char voutaddr[64],destaddr[64]; + char voutaddr[64], destaddr[64], cbaddr[64]; target.SetCompact(pblock->GetVerusPOSTarget()); 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()); } 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(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; } 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()); } } } diff --git a/src/miner.cpp b/src/miner.cpp index a1419ed96..72c184e57 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -463,6 +463,10 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, bool isStake) siglen = verus_staked(key, txStaked, nBitsPOS, posHash, utxosig); blocktime = GetAdjustedTime(); 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 {