function getrawtransaction($tx_id, $verbose = 1) { // The JSON-RPC request starts with a method name $request_array["method"] = "getrawtransaction"; // For getrawtransaction a txid is required $request_array["params"][0] = $tx_id; $request_array["params"][1] = $verbose; // Send the request to the wallet $info = wallet_fetch($request_array); // This function returns a string containing the block // hash value for the specified block in the chain return $info; }
if ($request[0] == "keypoolrefill") { bcapi_error(4, "Method Not Permitted: keypoolrefill"); } if ($request[0] == "getpeerinfo") { bcapi_error(5, "Method Not Permitted: getpeerinfo"); } if ($request[0] == "listreceivedbyaddress") { bcapi_error(7, "Method Not Permitted: listreceivedbyaddress"); } // Check to stop remote users from killing the daemon via API if ($request[0] == "stop") { bcapi_error(6, "Method Not Permitted: stop"); } // The first word of the request is passed to the daemon as a // JSON-RPC method $query["method"] = $request[0]; // The data is fetched from the wallet $result = wallet_fetch($query); // The wallet fetch routine has removed the JSON formatting for // internal use. The JSON format is re-applied for the the feed print_r(json_encode($result)); // That's it. exit; // this function is here to generate repetitive error messages function bcapi_error($code, $message) { $error["code"] = $code; $error["message"] = $message; print_r(json_encode($error)); exit; }