diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 80e0257fa..efe09d1b6 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -351,13 +351,14 @@ static UniValue getblocktemplate(const JSONRPCRequest& request) " \"value\" (string) A way the block template may be changed, e.g. 'time', 'transactions', 'prevblock'\n" " ,...\n" " ],\n" - " \"noncerange\" : \"00000000ffffffff\",(string) A range of valid nonces\n" + " \"noncerange\" : \"00000000ffffffff\", (string) A range of valid nonces\n" " \"sigoplimit\" : n, (numeric) limit of sigops in blocks\n" " \"sizelimit\" : n, (numeric) limit of block size\n" " \"weightlimit\" : n, (numeric) limit of block weight\n" " \"curtime\" : ttt, (numeric) current timestamp in seconds since epoch (Jan 1 1970 GMT)\n" " \"bits\" : \"xxxxxxxx\", (string) compressed target of next block\n" " \"height\" : n (numeric) The height of the next block\n" + " \"claimtrie\" : \"00000000ffffffff\", (string) The root hash of the claim trie in hex\n" "}\n" "\nExamples:\n" @@ -432,15 +433,17 @@ static UniValue getblocktemplate(const JSONRPCRequest& request) if (strMode != "template") throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); - if(!g_connman) - throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); + if (Params().NetworkIDString() != "lbrycrdreg") // who should own this constant? + { + if (!g_connman) + throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); - if (g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL) == 0) - throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "LBRYcrd is not connected!"); - - if (IsInitialBlockDownload()) - throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "LBRYcrd is downloading blocks..."); + if (g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL) == 0) + throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "LBRYcrd is not connected!"); + if (IsInitialBlockDownload()) + throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "LBRYcrd is downloading blocks..."); + } static unsigned int nTransactionsUpdatedLast; if (!lpval.isNull()) @@ -652,6 +655,7 @@ static UniValue getblocktemplate(const JSONRPCRequest& request) result.pushKV("mintime", (int64_t)pindexPrev->GetMedianTimePast()+1); result.pushKV("mutable", aMutable); result.pushKV("noncerange", "00000000ffffffff"); + int64_t nSigOpLimit = MAX_BLOCK_SIGOPS_COST; int64_t nSizeLimit = MAX_BLOCK_SERIALIZED_SIZE; if (fPreSegWit) { @@ -667,7 +671,8 @@ static UniValue getblocktemplate(const JSONRPCRequest& request) } result.pushKV("curtime", pblock->GetBlockTime()); result.pushKV("bits", strprintf("%08x", pblock->nBits)); - result.pushKV("height", (int64_t)(pindexPrev->nHeight+1)); + result.pushKV("height", (int64_t)(pindexPrev->nHeight)+1); + result.pushKV("claimtrie", pblock->hashClaimTrie.GetHex()); if (!pblocktemplate->vchCoinbaseCommitment.empty() && fSupportsSegwit) { result.pushKV("default_witness_commitment", HexStr(pblocktemplate->vchCoinbaseCommitment.begin(), pblocktemplate->vchCoinbaseCommitment.end())); diff --git a/src/test/claimtriebranching_tests.cpp b/src/test/claimtriebranching_tests.cpp index b7be352c5..f3111ed8c 100644 --- a/src/test/claimtriebranching_tests.cpp +++ b/src/test/claimtriebranching_tests.cpp @@ -3947,9 +3947,13 @@ BOOST_AUTO_TEST_CASE(claim_rpcs_rollback3_test) rpcfn_type getclaimsforname = tableRPC["getclaimsforname"]->actor; rpcfn_type getvalueforname = tableRPC["getvalueforname"]->actor; + rpcfn_type getblocktemplate = tableRPC["getblocktemplate"]->actor; JSONRPCRequest req; req.params = UniValue(UniValue::VARR); + UniValue templateResults = getblocktemplate(req); + BOOST_CHECK_EQUAL(templateResults["claimtrie"].get_str(), chainActive.Tip()->hashClaimTrie.GetHex()); + req.params.push_back(UniValue(sName1)); req.params.push_back(blockHash.GetHex()); @@ -3959,6 +3963,7 @@ BOOST_AUTO_TEST_CASE(claim_rpcs_rollback3_test) UniValue valueResults = getvalueforname(req); BOOST_CHECK_EQUAL(valueResults["value"].get_str(), HexStr(sValue1)); BOOST_CHECK_EQUAL(valueResults["amount"].get_int(), 3); + } BOOST_AUTO_TEST_SUITE_END()