/*
 * Copyright 2012 Tamas Blummer tamas@bitsofproof.com
 *
 * 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 com.bitsofproof.supernode.api;

import java.util.List;

/**
 * This is the API extensions to the bitsofproof supernode should build on
 */
public interface BCSAPI
{
	public long getHeartbeat (long mine);

	/**
	 * get a block for the hash
	 * 
	 * @param hash
	 * @return block or null if hash is unknown
	 */
	public Block getBlock (String hash);

	/**
	 * get the transaction identified by the hash on the trunk
	 * 
	 * @param hash
	 * @return transaction or null if no transaction with that hash on the trunk
	 */
	public Transaction getTransaction (String hash);

	/**
	 * get the hash of the highest block on the trunk
	 * 
	 * @return
	 */
	public String getTrunk ();

	/**
	 * get predecessor of a block identified by the hash
	 * 
	 * @param hash
	 * @return a block or null if the hash is invalid. It returns zero hash for genesis
	 */
	public String getPreviousBlockHash (String hash);

	/**
	 * get transaction outputs that could be spent by the adresses
	 * 
	 * @param address
	 * @return list of outputs, eventually empty
	 */
	public List<TransactionOutput> getBalance (List<String> address);

	/**
	 * send a signed transaction
	 * 
	 * @param transaction
	 * @throws ValidationException
	 *             - if the transaction is invalid for numerous reasons
	 */
	public void sendTransaction (Transaction transaction) throws ValidationException;

	/**
	 * get list of outputs an address ever received
	 * 
	 * @param address
	 * @return list of outputs, eventually empty
	 */
	public List<TransactionOutput> getReceivedTransactions (List<String> address);

	/**
	 * get list of spends for a set of adresses
	 * 
	 * @param address
	 * @return list of spends, eventually empty
	 */
	public List<TransactionInput> getSpentTransactions (List<String> address);
}

@@ -1602,32 +1602,233 @@
  @param address%0A
+%09 * @param asOf%0A%09 *            - The balance will be computed using outputs included into blocks mined not later than asOf. -1 means until most recent known block. Unix%0A%09 *            style timestamp.%0A
 %09 * @return list
@@ -1918,32 +1918,43 @@
 %3CString%3E address
+, long asOf
 );%0A%0A%09/**%0A%09 * sen
@@ -2264,32 +2264,133 @@
  @param address%0A
+%09 * @param after%0A%09 *            - result includes output in blocks mined after this. Unix timestamp.%0A
 %09 * @return list
@@ -2501,16 +2501,28 @@
  address
+, long after
 );%0A%0A%09/**
@@ -2587,24 +2587,125 @@
 ram address%0A
+%09 * @param after%0A%09 *            - result includes output in blocks mined after this. Unix timestamp.%0A
 %09 * @return 
@@ -2815,13 +2815,25 @@
  address
+, long after
 );%0A%7D%0A

add asof and after parameters to API