/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.drausin.bitflow.bitcoin.api;

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.drausin.bitflow.bitcoin.api.requests.BitcoinNodeRequest;
import org.drausin.bitflow.bitcoin.api.responses.BlockHeaderResponse;
import org.drausin.bitflow.bitcoin.api.responses.BlockchainInfoResponse;
import org.drausin.bitflow.bitcoin.api.responses.StopResponse;

/**
 * BitcoinNode service for interacting with the underlying (external) bitcoind server.
 *
 * @author dwulsin
 */
@Path("/")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public interface BitcoinNodeService {

    /**
     * Gets current information about the blockchain.
     *
     * @param request the request associated with the bitcoind RPC {@code getblockchaininfo} method
     * @return the RPC response in {@link BlockchainInfoResponse}
     *
     * @see {@link org.drausin.bitflow.bitcoin.api.requests.BitcoinNodeRequestFactory}
     */
    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    BlockchainInfoResponse getBlockchainInfo(BitcoinNodeRequest request);

    /**
     * Gets the block header for a given block hash.
     *
     * @param request the request associated with the bitcoind RPC {@code getblock} method
     * @return the RPC response in {@link BlockchainInfoResponse}
     *
     * @see {@link org.drausin.bitflow.bitcoin.api.requests.BitcoinNodeRequestFactory}
     */
    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    BlockHeaderResponse getBlockHeader(BitcoinNodeRequest request);

    /**
     * Stops the bitcoind server gracefully.
     *
     * @param request the request associated with the bitcoind RPC {@code stop} method
     * @return the RPC response in {@link org.drausin.bitflow.bitcoin.api.responses.StopResponse}
     *
     * @see {@link org.drausin.bitflow.bitcoin.api.requests.BitcoinNodeRequestFactory}
     */
    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    StopResponse stop(BitcoinNodeRequest request);
}

@@ -809,16 +809,90 @@
 equest;%0A
+import org.drausin.bitflow.bitcoin.api.responses.BlockHeaderHashResponse;%0A
 import o
@@ -1560,39 +1560,32 @@
 inInfoResponse%7D%0A
-     *%0A
      * @see %7B@li
@@ -1657,111 +1657,57 @@
 tory
-%7D%0A     */%0A    @POST%0A    @Consumes(MediaType.APPLICATION_JSON)%0A    @Produces(MediaType.APPLICATION_JSON)
+#createBlockchainInfoRequest()%7D%0A     */%0A    @POST
 %0A   
@@ -1995,39 +1995,32 @@
 inInfoResponse%7D%0A
-     *%0A
      * @see %7B@li
@@ -2092,111 +2092,466 @@
 tory
-%7D%0A     */%0A    @POST%0A    @Consumes(MediaType.APPLICATION_JSON)%0A    @Produces(MediaType.APPLICATION_JSON)
+#%0A     * createBlockHeaderRequest(Sha256Hash)%7D%0A     */%0A    @POST%0A    BlockHeaderResponse getBlockHeader(BitcoinNodeRequest request);%0A%0A    /**%0A     * Gets the block header hash for the block at a given height.%0A     *%0A     * @param request the request associated with the bitcoind RPC %7B@code getblockhash%7D method%0A     * @see %7B@link org.drausin.bitflow.bitcoin.api.requests.BitcoinNodeRequestFactory#%0A     * createBlockHeaderHashRequest(long)%7D%0A     */%0A    @POST
 %0A   
@@ -2554,32 +2554,36 @@
 %0A    BlockHeader
+Hash
 Response getBloc
@@ -2581,32 +2581,36 @@
 e getBlockHeader
+Hash
 (BitcoinNodeRequ
@@ -2869,23 +2869,16 @@
 sponse%7D%0A
-     *%0A
      * @
@@ -2958,111 +2958,47 @@
 tory
-%7D%0A     */%0A    @POST%0A    @Consumes(MediaType.APPLICATION_JSON)%0A    @Produces(MediaType.APPLICATION_JSON)
+#createStopRequest()%7D%0A     */%0A    @POST
 %0A   

add getBlockHeaderHash method to BitcoinNode