| 168 | } |
| 169 | |
| 170 | static UniValue generateBlocks(ChainstateManager& chainman, const CTxMemPool& mempool, const CScript& coinbase_script, int nGenerate, uint64_t nMaxTries) |
| 171 | { |
| 172 | int nHeightEnd = 0; |
| 173 | int nHeight = 0; |
| 174 | |
| 175 | { // Don't keep cs_main locked |
| 176 | LOCK(cs_main); |
| 177 | nHeight = chainman.ActiveChain().Height(); |
| 178 | nHeightEnd = nHeight+nGenerate; |
| 179 | } |
| 180 | unsigned int nExtraNonce = 0; |
| 181 | UniValue blockHashes(UniValue::VARR); |
| 182 | while (nHeight < nHeightEnd && !ShutdownRequested()) |
| 183 | { |
| 184 | std::unique_ptr<CBlockTemplate> pblocktemplate(BlockAssembler(chainman.ActiveChainstate(), mempool, Params()).CreateNewBlock(coinbase_script)); |
| 185 | if (!pblocktemplate.get()) |
| 186 | throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block"); |
| 187 | CBlock *pblock = &pblocktemplate->block; |
| 188 | |
| 189 | uint256 block_hash; |
| 190 | if (!GenerateBlock(chainman, *pblock, nMaxTries, nExtraNonce, block_hash)) { |
| 191 | break; |
| 192 | } |
| 193 | |
| 194 | if (!block_hash.IsNull()) { |
| 195 | ++nHeight; |
| 196 | blockHashes.push_back(block_hash.GetHex()); |
| 197 | } |
| 198 | } |
| 199 | return blockHashes; |
| 200 | } |
| 201 | |
| 202 | static bool getScriptFromDescriptor(const std::string& descriptor, CScript& script, std::string& error) |
| 203 | { |
no test coverage detected