@@ -590,6 +590,48 @@ static bool rest_chaininfo(const std::any& context, HTTPRequest* req, const std:
590
590
}
591
591
}
592
592
593
+
594
+ RPCHelpMan getdeploymentinfo ();
595
+
596
+ static bool rest_deploymentinfo (const std::any& context, HTTPRequest* req, const std::string& str_uri_part)
597
+ {
598
+ if (!CheckWarmup (req)) return false ;
599
+
600
+ std::string hash_str;
601
+ const RESTResponseFormat rf = ParseDataFormat (hash_str, str_uri_part);
602
+
603
+ switch (rf) {
604
+ case RESTResponseFormat::JSON: {
605
+ JSONRPCRequest jsonRequest;
606
+ jsonRequest.context = context;
607
+ jsonRequest.params = UniValue (UniValue::VARR);
608
+
609
+ if (!hash_str.empty ()) {
610
+ uint256 hash;
611
+ if (!ParseHashStr (hash_str, hash)) {
612
+ return RESTERR (req, HTTP_BAD_REQUEST, " Invalid hash: " + hash_str);
613
+ }
614
+
615
+ const ChainstateManager* chainman = GetChainman (context, req);
616
+ if (!chainman) return false ;
617
+ if (!WITH_LOCK (::cs_main, return chainman->m_blockman .LookupBlockIndex (ParseHashV (hash_str, " blockhash" )))) {
618
+ return RESTERR (req, HTTP_BAD_REQUEST, " Block not found" );
619
+ }
620
+
621
+ jsonRequest.params .pushKV (" blockhash" , hash_str);
622
+ }
623
+
624
+ req->WriteHeader (" Content-Type" , " application/json" );
625
+ req->WriteReply (HTTP_OK, getdeploymentinfo ().HandleRequest (jsonRequest).write () + " \n " );
626
+ return true ;
627
+ }
628
+ default : {
629
+ return RESTERR (req, HTTP_NOT_FOUND, " output format not found (available: json)" );
630
+ }
631
+ }
632
+
633
+ }
634
+
593
635
static bool rest_mempool (const std::any& context, HTTPRequest* req, const std::string& str_uri_part)
594
636
{
595
637
if (!CheckWarmup (req))
@@ -935,6 +977,8 @@ static const struct {
935
977
{" /rest/mempool/" , rest_mempool},
936
978
{" /rest/headers/" , rest_headers},
937
979
{" /rest/getutxos" , rest_getutxos},
980
+ {" /rest/deploymentinfo/" , rest_deploymentinfo},
981
+ {" /rest/deploymentinfo" , rest_deploymentinfo},
938
982
{" /rest/blockhashbyheight/" , rest_blockhash_by_height},
939
983
};
940
984
0 commit comments