@@ -620,6 +620,48 @@ static bool rest_chaininfo(const CoreContext& context, HTTPRequest* req, const s
620620 }
621621}
622622
623+
624+ RPCHelpMan getdeploymentinfo ();
625+
626+ static bool rest_deploymentinfo (const CoreContext& context, HTTPRequest* req, const std::string& str_uri_part)
627+ {
628+ if (!CheckWarmup (req)) return false ;
629+
630+ std::string hash_str;
631+ const RESTResponseFormat rf = ParseDataFormat (hash_str, str_uri_part);
632+
633+ switch (rf) {
634+ case RESTResponseFormat::JSON: {
635+ JSONRPCRequest jsonRequest;
636+ jsonRequest.context = context;
637+ jsonRequest.params = UniValue (UniValue::VARR);
638+
639+ if (!hash_str.empty ()) {
640+ uint256 hash;
641+ if (!ParseHashStr (hash_str, hash)) {
642+ return RESTERR (req, HTTP_BAD_REQUEST, " Invalid hash: " + hash_str);
643+ }
644+
645+ const ChainstateManager* chainman = GetChainman (context, req);
646+ if (!chainman) return false ;
647+ if (!WITH_LOCK (::cs_main, return chainman->m_blockman .LookupBlockIndex (ParseHashV (hash_str, " blockhash" )))) {
648+ return RESTERR (req, HTTP_BAD_REQUEST, " Block not found" );
649+ }
650+
651+ jsonRequest.params .pushKV (" blockhash" , hash_str);
652+ }
653+
654+ req->WriteHeader (" Content-Type" , " application/json" );
655+ req->WriteReply (HTTP_OK, getdeploymentinfo ().HandleRequest (jsonRequest).write () + " \n " );
656+ return true ;
657+ }
658+ default : {
659+ return RESTERR (req, HTTP_NOT_FOUND, " output format not found (available: json)" );
660+ }
661+ }
662+
663+ }
664+
623665static bool rest_mempool_info (const CoreContext& context, HTTPRequest* req, const std::string& strURIPart)
624666{
625667 if (!CheckWarmup (req))
@@ -986,6 +1028,8 @@ static const struct {
9861028 {" /rest/mempool/contents" , rest_mempool_contents},
9871029 {" /rest/headers/" , rest_headers},
9881030 {" /rest/getutxos" , rest_getutxos},
1031+ {" /rest/deploymentinfo/" , rest_deploymentinfo},
1032+ {" /rest/deploymentinfo" , rest_deploymentinfo},
9891033 {" /rest/blockhashbyheight/" , rest_blockhash_by_height},
9901034};
9911035
0 commit comments