diff --git a/src/rpc/quorums.cpp b/src/rpc/quorums.cpp index 37059788f1fbf..a631d8c79b41a 100644 --- a/src/rpc/quorums.cpp +++ b/src/rpc/quorums.cpp @@ -1004,7 +1004,8 @@ static void submitchainlock_help(const JSONRPCRequest& request) {"signature", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The signature of the ChainLock."}, {"blockHeight", RPCArg::Type::NUM, RPCArg::Optional::NO, "The height of the ChainLock."}, }, - RPCResults{}, + RPCResult{ + RPCResult::Type::NUM, "", "The height of the current best ChainLock"}, RPCExamples{""}, }.Check(request); } @@ -1019,6 +1020,9 @@ static UniValue submitchainlock(const JSONRPCRequest& request) if (nBlockHeight <= 0) { throw JSONRPCError(RPC_INVALID_PARAMETER, "invalid block height"); } + const LLMQContext& llmq_ctx = EnsureLLMQContext(EnsureAnyNodeContext(request.context)); + const int32_t bestCLHeight = llmq_ctx.clhandler->GetBestChainLock().getHeight(); + if (nBlockHeight <= bestCLHeight) return bestCLHeight; CBLSSignature sig; if (!sig.SetHexStr(request.params[1].get_str(), false) && !sig.SetHexStr(request.params[1].get_str(), true)) { @@ -1026,14 +1030,13 @@ static UniValue submitchainlock(const JSONRPCRequest& request) } - const LLMQContext& llmq_ctx = EnsureLLMQContext(EnsureAnyNodeContext(request.context)); auto clsig = llmq::CChainLockSig(nBlockHeight, nBlockHash, sig); if (!llmq_ctx.clhandler->VerifyChainLock(clsig)) { throw JSONRPCError(RPC_INVALID_PARAMETER, "invalid signature"); } llmq_ctx.clhandler->ProcessNewChainLock(-1, clsig, ::SerializeHash(clsig)); - return true; + return llmq_ctx.clhandler->GetBestChainLock().getHeight(); } diff --git a/test/functional/feature_llmq_chainlocks.py b/test/functional/feature_llmq_chainlocks.py index af8e67407de42..b65900964f49b 100755 --- a/test/functional/feature_llmq_chainlocks.py +++ b/test/functional/feature_llmq_chainlocks.py @@ -119,7 +119,10 @@ def run_test(self): assert best_0['height'] != best_1['height'] assert best_0['signature'] != best_1['signature'] assert_equal(best_0['known_block'], True) - self.nodes[0].submitchainlock(best_1['blockhash'], best_1['signature'], best_1['height']) + node_height = self.nodes[1].submitchainlock(best_0['blockhash'], best_0['signature'], best_0['height']) + rpc_height = self.nodes[0].submitchainlock(best_1['blockhash'], best_1['signature'], best_1['height']) + assert_equal(best_1['height'], node_height) + assert_equal(best_1['height'], rpc_height) best_0 = self.nodes[0].getbestchainlock() assert_equal(best_0['blockhash'], best_1['blockhash']) assert_equal(best_0['height'], best_1['height'])