Merge #732: Give more descriptive error for non-WSH(OP_TRUE) block generation

3a2888cca Give more descriptive error for non-WSH(OP_TRUE) block generation (Gregory Sanders)

Pull request description:

  If someone transitions to a different block type, including something else op_true-ey but not exactly, `generatetoaddress` and ilk will complain without much recourse.

Tree-SHA512: 720e6888eb3985ad3619d2570b4c22985365a63d72d4a0d9b7d75d2091f6839db034d1b192a177901f0dfbb0d97cef330183438b02c6a11b64d33fe480023d88
This commit is contained in:
Steven Roose 2019-10-14 13:38:19 +01:00
commit 073cb3cb94
No known key found for this signature in database
GPG key ID: 2F2A88D7F8D68E87

View file

@ -142,11 +142,13 @@ UniValue generateBlocks(std::shared_ptr<CReserveScript> coinbaseScript, int nGen
}
}
// Fill out block witness if dynamic federation is enabled
// since we are assuming WSH(OP_TRUE)
if (!pblock->m_dynafed_params.IsNull()) {
CScript op_true(OP_TRUE);
// Handle OP_TRUE m_signblockscript case
CScript op_true(OP_TRUE);
if (pblock->m_dynafed_params.m_current.m_signblockscript ==
GetScriptForDestination(WitnessV0ScriptHash(op_true))) {
pblock->m_signblock_witness.stack.push_back(std::vector<unsigned char>(op_true.begin(), op_true.end()));
} else if (!pblock->m_dynafed_params.IsNull()) {
throw JSONRPCError(RPC_MISC_ERROR, "Unable to fill out dynamic federation signblockscript witness, are you sure it's WSH(OP_TRUE)?");
}
std::shared_ptr<const CBlock> shared_pblock = std::make_shared<const CBlock>(*pblock);