@@ -269,6 +269,37 @@ static RPCHelpMan getbestchainlock()
269269 };
270270}
271271
272+ static RPCHelpMan getrawbestchainlock ()
273+ {
274+ return RPCHelpMan{" getrawbestchainlock" ,
275+ " \n Returns the raw best ChainLock. Throws an error if there is no known ChainLock yet." ,
276+ {},
277+ RPCResult{
278+ RPCResult::Type::STR, " data" , " The serialized, hex-encoded data for best ChainLock"
279+ },
280+ RPCExamples{
281+ HelpExampleCli (" getrawbestchainlock" , " " )
282+ + HelpExampleRpc (" getrawbestchainlock" , " " )
283+ },
284+ [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
285+ {
286+ UniValue result (UniValue::VOBJ);
287+
288+ const NodeContext& node = EnsureAnyNodeContext (request.context );
289+
290+ LLMQContext& llmq_ctx = EnsureLLMQContext (node);
291+ llmq::CChainLockSig clsig = llmq_ctx.clhandler ->GetBestChainLock ();
292+ if (clsig.IsNull ()) {
293+ throw JSONRPCError (RPC_MISC_ERROR, " Unable to find any ChainLock" );
294+ }
295+ CDataStream ssTx (SER_NETWORK, PROTOCOL_VERSION);
296+ ssTx << clsig;
297+ return HexStr (ssTx);
298+
299+ },
300+ };
301+ }
302+
272303void RPCNotifyBlockChange (const CBlockIndex* pindex)
273304{
274305 if (pindex) {
@@ -2671,6 +2702,7 @@ static const CRPCCommand commands[] =
26712702 { " blockchain" , &getblockstats, },
26722703 { " blockchain" , &getbestblockhash, },
26732704 { " blockchain" , &getbestchainlock, },
2705+ { " blockchain" , &getrawbestchainlock, },
26742706 { " blockchain" , &getblockcount, },
26752707 { " blockchain" , &getblock, },
26762708 { " blockchain" , &getblockfrompeer, },
0 commit comments