Skip to content

Commit

Permalink
Merge #732: Give more descriptive error for non-WSH(OP_TRUE) block ge…
Browse files Browse the repository at this point in the history
…neration

3a2888c 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
  • Loading branch information
stevenroose committed Oct 14, 2019
2 parents b0f4cb3 + 3a2888c commit 073cb3c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 073cb3c

Please sign in to comment.