From 3a2888ccad96530f853fdb0e90e508edf7eb159c Mon Sep 17 00:00:00 2001 From: Gregory Sanders Date: Mon, 7 Oct 2019 13:19:30 -0400 Subject: [PATCH] Give more descriptive error for non-WSH(OP_TRUE) block generation --- src/rpc/mining.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 1bd87f368a..ee02afde82 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -142,11 +142,13 @@ UniValue generateBlocks(std::shared_ptr 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(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 shared_pblock = std::make_shared(*pblock);