Skip to content

Commit

Permalink
Merge pull request bitcoin#337 from qtumproject/earlz/fix-evm-coinbase
Browse files Browse the repository at this point in the history
Fix inconsistent EVM coinbase between staking and validation
  • Loading branch information
qtum-neil authored Sep 8, 2017
2 parents 0542018 + 63211ca commit 5e090b5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ void ThreadStakeMiner(CWallet *pwallet)
SetThreadPriority(THREAD_PRIORITY_ABOVE_NORMAL);
// Create a block that's properly populated with transactions
std::unique_ptr<CBlockTemplate> pblocktemplatefilled(
BlockAssembler(Params()).CreateNewBlock(reservekey.reserveScript, true, &nTotalFees,
BlockAssembler(Params()).CreateNewBlock(pblock->vtx[1]->vout[1].scriptPubKey, true, &nTotalFees,
i, FutureDrift(GetAdjustedTime()) - STAKE_TIME_BUFFER));
if (!pblocktemplatefilled.get())
return;
Expand Down
27 changes: 17 additions & 10 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2260,20 +2260,27 @@ dev::eth::EnvInfo ByteCodeExec::BuildEVMEnvironment(){
}
env.setLastHashes(std::move(lh));
env.setGasLimit(blockGasLimit);
env.setAuthor(EthAddrFromScript(block.vtx.at(0)->vout.at(0).scriptPubKey));
if(block.IsProofOfStake()){
env.setAuthor(EthAddrFromScript(block.vtx[1]->vout[1].scriptPubKey));
}else {
env.setAuthor(EthAddrFromScript(block.vtx[0]->vout[0].scriptPubKey));
}
return env;
}

dev::Address ByteCodeExec::EthAddrFromScript(const CScript& scriptIn){
CTxDestination resDest;
if(!ExtractDestination(scriptIn, resDest)){
return dev::Address();
dev::Address ByteCodeExec::EthAddrFromScript(const CScript& script){
CTxDestination addressBit;
txnouttype txType=TX_NONSTANDARD;
if(ExtractDestination(script, addressBit, &txType)){
if ((txType == TX_PUBKEY || txType == TX_PUBKEYHASH) &&
addressBit.type() == typeid(CKeyID)){
CKeyID addressKey(boost::get<CKeyID>(addressBit));
std::vector<unsigned char> addr(addressKey.begin(), addressKey.end());
return dev::Address(addr);
}
}
CKeyID resPH(boost::get<CKeyID>(resDest));

std::vector<unsigned char> addr(resPH.begin(), resPH.end());

return dev::Address(addr);
//if not standard or not a pubkey or pubkeyhash output, then return 0
return dev::Address();
}

bool QtumTxConverter::extractionQtumTransactions(ExtractQtumTX& qtumtx){
Expand Down

0 comments on commit 5e090b5

Please sign in to comment.