diff --git a/chronik/chronik-http/src/electrum.rs b/chronik/chronik-http/src/electrum.rs --- a/chronik/chronik-http/src/electrum.rs +++ b/chronik/chronik-http/src/electrum.rs @@ -52,6 +52,8 @@ struct ChronikElectrumRPCServerEndpoint {} +struct ChronikElectrumRPCBlockchainEndpoint {} + impl ChronikElectrumServer { /// Binds the Chronik server on the given hosts pub fn setup(params: ChronikElectrumServerParams) -> Result<Self> { @@ -68,12 +70,15 @@ // The behavior is to bind the endpoint name to its method name like so: // endpoint.method as the name of the RPC let server_endpoint = Arc::new(ChronikElectrumRPCServerEndpoint {}); + let blockchain_endpoint = + Arc::new(ChronikElectrumRPCBlockchainEndpoint {}); + let endpoints = (server_endpoint, blockchain_endpoint); let servers = self .hosts .into_iter() - .zip(std::iter::repeat(server_endpoint)) - .map(|(host, server_endpoint)| { + .zip(std::iter::repeat(endpoints)) + .map(|(host, endpoints)| { Box::pin(async move { // Don't use the karyon Endpoint parsing as it doesn't // appear to support IPv6. @@ -87,8 +92,10 @@ .map_err(|err| { FailedBindingAddress(host, err.to_string()) })?; + let server = builder - .service(server_endpoint) + .service(endpoints.0) + .service(endpoints.1) .build() .await .map_err(|err| ServingFailed(err.to_string()))?; @@ -127,3 +134,24 @@ Ok(Value::Null) } } + +impl RPCService for ChronikElectrumRPCBlockchainEndpoint { + fn name(&self) -> String { + "blockchain".to_string() + } + + fn get_method(&self, name: &str) -> Option<RPCMethod<'_>> { + match name { + "transaction.get" => Some(Box::new(move |params: Value| { + Box::pin(self.transaction_get(params)) + })), + _ => None, + } + } +} + +impl ChronikElectrumRPCBlockchainEndpoint { + async fn transaction_get(&self, _params: Value) -> Result<Value, RPCError> { + Ok(Value::Null) + } +}