| 1117 | } |
| 1118 | |
| 1119 | bool ProcessBlockFound(CBlock* pblock, CWallet& wallet) |
| 1120 | { |
| 1121 | // Found a solution (stake) |
| 1122 | { |
| 1123 | LOCK(cs_main); |
| 1124 | if (pblock->hashPrevBlock != chainActive.Tip()->GetBlockHash()) |
| 1125 | return error("LUXMiner : generated block is stale"); |
| 1126 | |
| 1127 | for(const CTxIn& vin : pblock->vtx[1].vin) { |
| 1128 | if (wallet.IsSpent(vin.prevout.hash, vin.prevout.n)) { |
| 1129 | return error("LUXMiner : Gen block stake is invalid - UTXO spent"); |
| 1130 | } |
| 1131 | } |
| 1132 | } |
| 1133 | |
| 1134 | CAmount generated = GetProofOfStakeReward(0, chainActive.Height()+1); |
| 1135 | generated -= GetMasternodePosReward(chainActive.Height()+1, generated); |
| 1136 | LogPrintf("generated %s\n", FormatMoney(generated)); |
| 1137 | |
| 1138 | // Process this block the same as if we had received it from another node |
| 1139 | const CChainParams& chainParams = Params(); |
| 1140 | CValidationState state; |
| 1141 | if (!ProcessNewBlock(state, chainParams, NULL, pblock)) { |
| 1142 | return error("LUXMiner : ProcessNewBlock, block not accepted"); |
| 1143 | } |
| 1144 | |
| 1145 | { |
| 1146 | LOCK(stake->stakeMiner.lock); |
| 1147 | stake->stakeMiner.nBlocksAccepted++; |
| 1148 | } |
| 1149 | |
| 1150 | return true; |
| 1151 | } |
no test coverage detected