diff --git a/rpc/interface/src/route/bin.rs b/rpc/interface/src/route/bin.rs index 1e3b202..12c4e57 100644 --- a/rpc/interface/src/route/bin.rs +++ b/rpc/interface/src/route/bin.rs @@ -71,12 +71,13 @@ macro_rules! generate_endpoints_inner { ($variant:ident, $handler:ident, $request:expr_2021) => { paste::paste! { { - // INVARIANT: - // The handler functions in `cuprated` depend on this line existing, - // the functions themselves do not check if they are being called - // from an (un)restricted context. + // Check if restricted. // - // This line must be here or all methods will be allowed to be called freely. + // INVARIANT: + // The RPC handler functions in `cuprated` depend on this line existing, + // the functions themselves do not check if they are being called + // from an (un)restricted context. This line must be here or all + // methods will be allowed to be called freely. if [<$variant Request>]::IS_RESTRICTED && $handler.is_restricted() { // TODO: mimic `monerod` behavior. return Err(StatusCode::FORBIDDEN); diff --git a/rpc/interface/src/route/json_rpc.rs b/rpc/interface/src/route/json_rpc.rs index 1ef5722..9d814c2 100644 --- a/rpc/interface/src/route/json_rpc.rs +++ b/rpc/interface/src/route/json_rpc.rs @@ -39,21 +39,16 @@ pub(crate) async fn json_rpc( // the requested method is only for non-restricted RPC. // // INVARIANT: - // The handler functions in `cuprated` depend on this line existing, + // The RPC handler functions in `cuprated` depend on this line existing, // the functions themselves do not check if they are being called - // from an (un)restricted context. - // - // This line must be here or all methods will be allowed to be called freely. + // from an (un)restricted context. This line must be here or all + // methods will be allowed to be called freely. if request.body.is_restricted() && handler.is_restricted() { - let error_object = ErrorObject { - code: ErrorCode::ServerError(-1 /* TODO */), - message: Cow::Borrowed("Restricted. TODO: mimic monerod message"), - data: None, - }; - - let response = Response::err(id, error_object); - - return Ok(Json(response)); + // The error when a restricted JSON-RPC method is called as per: + // + // - + // - + return Ok(Json(Response::method_not_found(id))); } // Send request. diff --git a/rpc/interface/src/route/other.rs b/rpc/interface/src/route/other.rs index 2b7c14b..3a804a6 100644 --- a/rpc/interface/src/route/other.rs +++ b/rpc/interface/src/route/other.rs @@ -77,11 +77,10 @@ macro_rules! generate_endpoints_inner { // Check if restricted. // // INVARIANT: - // The handler functions in `cuprated` depend on this line existing, + // The RPC handler functions in `cuprated` depend on this line existing, // the functions themselves do not check if they are being called - // from an (un)restricted context. - // - // This line must be here or all methods will be allowed to be called freely. + // from an (un)restricted context. This line must be here or all + // methods will be allowed to be called freely. if [<$variant Request>]::IS_RESTRICTED && $handler.is_restricted() { // TODO: mimic `monerod` behavior. return Err(StatusCode::FORBIDDEN);