diff --git a/ethereumj-core-android/build.gradle b/ethereumj-core-android/build.gradle index f72df6ec..89be26e8 100644 --- a/ethereumj-core-android/build.gradle +++ b/ethereumj-core-android/build.gradle @@ -67,4 +67,5 @@ dependencies { compile "javax.persistence:persistence-api:1.0.2" compile group: "com.thetransactioncompany", name: "jsonrpc2-server", version: "1.11" + compile group: "com.thetransactioncompany", name: "jsonrpc2-client", version: "1.15" } diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/EthereumManager.java b/ethereumj-core-android/src/main/java/org/ethereum/android/EthereumManager.java index 96c4e954..a0d7daa2 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/EthereumManager.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/EthereumManager.java @@ -35,7 +35,8 @@ public class EthereumManager { .ethereumModule(new EthereumModule(context)) .build().ethereum(); - jsonRpcServer = new JsonRpcServer(ethereum); + //TODO: add here switch between full and light version + jsonRpcServer = new org.ethereum.android.jsonrpc.light.JsonRpcServer(ethereum); } public void start() { diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/JsonRpcServer.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/JsonRpcServer.java index a0ca7d75..4edf9057 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/JsonRpcServer.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/JsonRpcServer.java @@ -1,226 +1,8 @@ package org.ethereum.android.jsonrpc; -import io.netty.bootstrap.ServerBootstrap; -import io.netty.channel.Channel; -import io.netty.channel.ChannelOption; -import io.netty.channel.EventLoopGroup; -import io.netty.channel.nio.NioEventLoopGroup; -import io.netty.channel.socket.nio.NioServerSocketChannel; -import io.netty.channel.ChannelInitializer; -import io.netty.channel.ChannelPipeline; -import io.netty.channel.socket.SocketChannel; -import io.netty.handler.codec.http.HttpServerCodec; -import io.netty.buffer.Unpooled; -import io.netty.channel.ChannelFutureListener; -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.http.DefaultFullHttpResponse; -import io.netty.handler.codec.http.FullHttpResponse; -import io.netty.handler.codec.http.HttpRequest; -import io.netty.handler.codec.http.multipart.HttpPostStandardRequestDecoder; -import io.netty.handler.codec.http.multipart.DefaultHttpDataFactory; -import io.netty.handler.codec.http.HttpObject; -import io.netty.channel.SimpleChannelInboundHandler; -import io.netty.handler.codec.http.HttpMethod; -import io.netty.handler.codec.http.HttpContent; -import io.netty.handler.codec.http.LastHttpContent; -import io.netty.buffer.ByteBuf; -import io.netty.util.CharsetUtil; -import io.netty.handler.codec.http.HttpVersion; -import io.netty.handler.codec.http.HttpResponseStatus; -import io.netty.channel.ChannelFuture; -import org.ethereum.android.jsonrpc.filter.FilterManager; import org.ethereum.facade.Ethereum; -import com.thetransactioncompany.jsonrpc2.*; -import com.thetransactioncompany.jsonrpc2.server.*; -import io.netty.handler.codec.http.HttpHeaders; -import static io.netty.handler.codec.http.HttpHeaders.Names.*; -import org.ethereum.android.jsonrpc.method.*; - -import java.net.InetAddress; - - -public final class JsonRpcServer { - - static final int PORT = 8545; - - private Ethereum ethereum; - private Dispatcher dispatcher; - - public JsonRpcServer(Ethereum ethereum) { - this.ethereum = ethereum; - - this.dispatcher = new Dispatcher(); - - this.dispatcher.register(new web3_clientVersion(this.ethereum)); - this.dispatcher.register(new web3_sha3(this.ethereum)); - - this.dispatcher.register(new net_version(this.ethereum)); - this.dispatcher.register(new net_listening(this.ethereum)); - this.dispatcher.register(new net_peerCount(this.ethereum)); - - this.dispatcher.register(new eth_protocolVersion(this.ethereum)); - this.dispatcher.register(new eth_coinbase(this.ethereum)); - this.dispatcher.register(new eth_mining(this.ethereum)); - this.dispatcher.register(new eth_hashrate(this.ethereum)); - this.dispatcher.register(new eth_gasPrice(this.ethereum)); - this.dispatcher.register(new eth_accounts(this.ethereum)); - this.dispatcher.register(new eth_blockNumber(this.ethereum)); - this.dispatcher.register(new eth_getBalance(this.ethereum)); - this.dispatcher.register(new eth_getStorageAt(this.ethereum)); - this.dispatcher.register(new eth_getTransactionCount(this.ethereum)); - this.dispatcher.register(new eth_getBlockTransactionCountByHash(this.ethereum)); - this.dispatcher.register(new eth_getBlockTransactionCountByNumber(this.ethereum)); - this.dispatcher.register(new eth_getUncleCountByBlockHash(this.ethereum)); - this.dispatcher.register(new eth_getUncleCountByBlockNumber(this.ethereum)); - this.dispatcher.register(new eth_getCode(this.ethereum)); - this.dispatcher.register(new eth_sign(this.ethereum)); - this.dispatcher.register(new eth_sendTransaction(this.ethereum)); - this.dispatcher.register(new eth_call(this.ethereum)); - this.dispatcher.register(new eth_estimateGas(this.ethereum)); - this.dispatcher.register(new eth_getBlockByHash(this.ethereum)); - this.dispatcher.register(new eth_getBlockByNumber(this.ethereum)); - this.dispatcher.register(new eth_getTransactionByHash(this.ethereum)); - this.dispatcher.register(new eth_getTransactionByBlockHashAndIndex(this.ethereum)); - this.dispatcher.register(new eth_getTransactionByBlockNumberAndIndex(this.ethereum)); - this.dispatcher.register(new eth_getUncleByBlockHashAndIndex(this.ethereum)); - this.dispatcher.register(new eth_getUncleByBlockNumberAndIndex(this.ethereum)); - this.dispatcher.register(new eth_getCompilers(this.ethereum)); - this.dispatcher.register(new eth_compileSolidity(this.ethereum)); - this.dispatcher.register(new eth_compileLLL(this.ethereum)); - this.dispatcher.register(new eth_compileSerpent(this.ethereum)); - this.dispatcher.register(new eth_newFilter(this.ethereum)); - this.dispatcher.register(new eth_newBlockFilter(this.ethereum)); - this.dispatcher.register(new eth_newPendingTransactionFilter(this.ethereum)); - this.dispatcher.register(new eth_uninstallFilter(this.ethereum)); - this.dispatcher.register(new eth_getFilterChanges(this.ethereum)); - this.dispatcher.register(new eth_getFilterLogs(this.ethereum)); - this.dispatcher.register(new eth_getLogs(this.ethereum)); - this.dispatcher.register(new eth_getWork(this.ethereum)); - this.dispatcher.register(new eth_submitWork(this.ethereum)); - - this.dispatcher.register(new db_putString(this.ethereum)); - this.dispatcher.register(new db_getString(this.ethereum)); - this.dispatcher.register(new db_putHex(this.ethereum)); - this.dispatcher.register(new db_getHex(this.ethereum)); - - this.dispatcher.register(new shh_version(this.ethereum)); - this.dispatcher.register(new shh_post(this.ethereum)); - this.dispatcher.register(new shh_newIdentity(this.ethereum)); - this.dispatcher.register(new shh_hasIdentity(this.ethereum)); - this.dispatcher.register(new shh_newGroup(this.ethereum)); - this.dispatcher.register(new shh_addToGroup(this.ethereum)); - this.dispatcher.register(new shh_newFilter(this.ethereum)); - this.dispatcher.register(new shh_uninstallFilter(this.ethereum)); - this.dispatcher.register(new shh_getFilterChanges(this.ethereum)); - this.dispatcher.register(new shh_getMessages(this.ethereum)); - - ethereum.addListener(FilterManager.getInstance()); - org.ethereum.android.jsonrpc.whisper.FilterManager.getInstance(); - } - - public void start() throws Exception { - EventLoopGroup bossGroup = new NioEventLoopGroup(1); - EventLoopGroup workerGroup = new NioEventLoopGroup(); - try { - ServerBootstrap b = new ServerBootstrap(); - b.option(ChannelOption.SO_BACKLOG, 1024); - b.localAddress(InetAddress.getLocalHost(), PORT); -// b.localAddress(PORT); - b.group(bossGroup, workerGroup) - .channel(NioServerSocketChannel.class) - .childHandler(new JsonRpcServerInitializer()); - - Channel ch = b.bind().sync().channel(); - - ch.closeFuture().sync(); - } finally { - bossGroup.shutdownGracefully(); - workerGroup.shutdownGracefully(); - } - } - - class JsonRpcServerInitializer extends ChannelInitializer { - @Override - public void initChannel(SocketChannel ch) { - ChannelPipeline p = ch.pipeline(); - p.addLast(new HttpServerCodec()); - p.addLast(new JsonRpcServerHandler()); - } - } - - class JsonRpcServerHandler extends SimpleChannelInboundHandler { - - private HttpRequest request; - private final StringBuilder responseContent = new StringBuilder(); - private HttpPostStandardRequestDecoder decoder; - private String postData; - - @Override - public void channelInactive(ChannelHandlerContext ctx) throws Exception { - if (decoder != null) { - decoder.destroy(); - } - } - @Override - public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception { - if (msg instanceof HttpRequest) { - HttpRequest req = this.request = (HttpRequest) msg; - if (!req.getUri().equals("/") || !request.getMethod().equals(HttpMethod.POST)) { - responseContent.append("Hi, how are you?!!"); - return; - } else { - decoder = new HttpPostStandardRequestDecoder(new DefaultHttpDataFactory(false), req); - postData = ""; - } - } - - if (decoder != null) { - if (msg instanceof HttpContent) { - HttpContent chunk = (HttpContent) msg; - decoder.offer(chunk); - postData += chunk.content().toString(0, chunk.content().capacity(), CharsetUtil.UTF_8); - - if (chunk instanceof LastHttpContent) { - JSONRPC2Request req = JSONRPC2Request.parse(postData); - JSONRPC2Response resp = dispatcher.process(req, null); - responseContent.append(resp); - writeResponse(ctx); - request = null; - decoder.destroy(); - decoder = null; - } - } - } else { - writeResponse(ctx); - } - } - - private void writeResponse(ChannelHandlerContext ctx) { - ByteBuf buf = Unpooled.copiedBuffer(responseContent.toString(), CharsetUtil.UTF_8); - responseContent.setLength(0); - - boolean close = HttpHeaders.Values.CLOSE.equalsIgnoreCase(request.headers().get(CONNECTION)) - || request.getProtocolVersion().equals(HttpVersion.HTTP_1_0) - && !HttpHeaders.Values.KEEP_ALIVE.equalsIgnoreCase(request.headers().get(CONNECTION)); - FullHttpResponse response = new DefaultFullHttpResponse( - HttpVersion.HTTP_1_1, HttpResponseStatus.OK, buf); - response.headers().set(CONTENT_TYPE, "text/plain; charset=UTF-8"); - - if (!close) { - response.headers().set(CONTENT_LENGTH, buf.readableBytes()); - } - - ChannelFuture future = ctx.writeAndFlush(response); - if (close) { - future.addListener(ChannelFutureListener.CLOSE); - } - } - - @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { - cause.printStackTrace(); - ctx.close(); - } - } +public abstract class JsonRpcServer { + public JsonRpcServer(Ethereum ethereum) {}; + public abstract void start() throws Exception; } \ No newline at end of file diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/JsonRpcServer.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/JsonRpcServer.java new file mode 100644 index 00000000..49d9b839 --- /dev/null +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/JsonRpcServer.java @@ -0,0 +1,226 @@ +package org.ethereum.android.jsonrpc.full; + +import io.netty.bootstrap.ServerBootstrap; +import io.netty.channel.Channel; +import io.netty.channel.ChannelOption; +import io.netty.channel.EventLoopGroup; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.nio.NioServerSocketChannel; +import io.netty.channel.ChannelInitializer; +import io.netty.channel.ChannelPipeline; +import io.netty.channel.socket.SocketChannel; +import io.netty.handler.codec.http.HttpServerCodec; +import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelFutureListener; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.http.DefaultFullHttpResponse; +import io.netty.handler.codec.http.FullHttpResponse; +import io.netty.handler.codec.http.HttpRequest; +import io.netty.handler.codec.http.multipart.HttpPostStandardRequestDecoder; +import io.netty.handler.codec.http.multipart.DefaultHttpDataFactory; +import io.netty.handler.codec.http.HttpObject; +import io.netty.channel.SimpleChannelInboundHandler; +import io.netty.handler.codec.http.HttpMethod; +import io.netty.handler.codec.http.HttpContent; +import io.netty.handler.codec.http.LastHttpContent; +import io.netty.buffer.ByteBuf; +import io.netty.util.CharsetUtil; +import io.netty.handler.codec.http.HttpVersion; +import io.netty.handler.codec.http.HttpResponseStatus; +import io.netty.channel.ChannelFuture; +import org.ethereum.android.jsonrpc.full.filter.FilterManager; +import org.ethereum.facade.Ethereum; +import com.thetransactioncompany.jsonrpc2.*; +import com.thetransactioncompany.jsonrpc2.server.*; +import io.netty.handler.codec.http.HttpHeaders; +import static io.netty.handler.codec.http.HttpHeaders.Names.*; +import org.ethereum.android.jsonrpc.full.method.*; + +import java.net.InetAddress; + + +public final class JsonRpcServer extends org.ethereum.android.jsonrpc.JsonRpcServer{ + + static final int PORT = 8545; + + private Ethereum ethereum; + private Dispatcher dispatcher; + + public JsonRpcServer(Ethereum ethereum) { + super(ethereum); + this.ethereum = ethereum; + + this.dispatcher = new Dispatcher(); + + this.dispatcher.register(new web3_clientVersion(this.ethereum)); + this.dispatcher.register(new web3_sha3(this.ethereum)); + + this.dispatcher.register(new net_version(this.ethereum)); + this.dispatcher.register(new net_listening(this.ethereum)); + this.dispatcher.register(new net_peerCount(this.ethereum)); + + this.dispatcher.register(new eth_protocolVersion(this.ethereum)); + this.dispatcher.register(new eth_coinbase(this.ethereum)); + this.dispatcher.register(new eth_mining(this.ethereum)); + this.dispatcher.register(new eth_hashrate(this.ethereum)); + this.dispatcher.register(new eth_gasPrice(this.ethereum)); + this.dispatcher.register(new eth_accounts(this.ethereum)); + this.dispatcher.register(new eth_blockNumber(this.ethereum)); + this.dispatcher.register(new eth_getBalance(this.ethereum)); + this.dispatcher.register(new eth_getStorageAt(this.ethereum)); + this.dispatcher.register(new eth_getTransactionCount(this.ethereum)); + this.dispatcher.register(new eth_getBlockTransactionCountByHash(this.ethereum)); + this.dispatcher.register(new eth_getBlockTransactionCountByNumber(this.ethereum)); + this.dispatcher.register(new eth_getUncleCountByBlockHash(this.ethereum)); + this.dispatcher.register(new eth_getUncleCountByBlockNumber(this.ethereum)); + this.dispatcher.register(new eth_getCode(this.ethereum)); + this.dispatcher.register(new eth_sign(this.ethereum)); + this.dispatcher.register(new eth_sendTransaction(this.ethereum)); + this.dispatcher.register(new eth_call(this.ethereum)); + this.dispatcher.register(new eth_estimateGas(this.ethereum)); + this.dispatcher.register(new eth_getBlockByHash(this.ethereum)); + this.dispatcher.register(new eth_getBlockByNumber(this.ethereum)); + this.dispatcher.register(new eth_getTransactionByHash(this.ethereum)); + this.dispatcher.register(new eth_getTransactionByBlockHashAndIndex(this.ethereum)); + this.dispatcher.register(new eth_getTransactionByBlockNumberAndIndex(this.ethereum)); + this.dispatcher.register(new eth_getUncleByBlockHashAndIndex(this.ethereum)); + this.dispatcher.register(new eth_getUncleByBlockNumberAndIndex(this.ethereum)); + this.dispatcher.register(new eth_getCompilers(this.ethereum)); + this.dispatcher.register(new eth_compileSolidity(this.ethereum)); + this.dispatcher.register(new eth_compileLLL(this.ethereum)); + this.dispatcher.register(new eth_compileSerpent(this.ethereum)); + this.dispatcher.register(new eth_newFilter(this.ethereum)); + this.dispatcher.register(new eth_newBlockFilter(this.ethereum)); + this.dispatcher.register(new eth_newPendingTransactionFilter(this.ethereum)); + this.dispatcher.register(new eth_uninstallFilter(this.ethereum)); + this.dispatcher.register(new eth_getFilterChanges(this.ethereum)); + this.dispatcher.register(new eth_getFilterLogs(this.ethereum)); + this.dispatcher.register(new eth_getLogs(this.ethereum)); + this.dispatcher.register(new eth_getWork(this.ethereum)); + this.dispatcher.register(new eth_submitWork(this.ethereum)); + + this.dispatcher.register(new db_putString(this.ethereum)); + this.dispatcher.register(new db_getString(this.ethereum)); + this.dispatcher.register(new db_putHex(this.ethereum)); + this.dispatcher.register(new db_getHex(this.ethereum)); + + this.dispatcher.register(new shh_version(this.ethereum)); + this.dispatcher.register(new shh_post(this.ethereum)); + this.dispatcher.register(new shh_newIdentity(this.ethereum)); + this.dispatcher.register(new shh_hasIdentity(this.ethereum)); + this.dispatcher.register(new shh_newGroup(this.ethereum)); + this.dispatcher.register(new shh_addToGroup(this.ethereum)); + this.dispatcher.register(new shh_newFilter(this.ethereum)); + this.dispatcher.register(new shh_uninstallFilter(this.ethereum)); + this.dispatcher.register(new shh_getFilterChanges(this.ethereum)); + this.dispatcher.register(new shh_getMessages(this.ethereum)); + + ethereum.addListener(FilterManager.getInstance()); + org.ethereum.android.jsonrpc.full.whisper.FilterManager.getInstance(); + } + + public void start() throws Exception { + EventLoopGroup bossGroup = new NioEventLoopGroup(1); + EventLoopGroup workerGroup = new NioEventLoopGroup(); + try { + ServerBootstrap b = new ServerBootstrap(); + b.option(ChannelOption.SO_BACKLOG, 1024); + b.localAddress(InetAddress.getLocalHost(), PORT); +// b.localAddress(PORT); + b.group(bossGroup, workerGroup) + .channel(NioServerSocketChannel.class) + .childHandler(new JsonRpcServerInitializer()); + + Channel ch = b.bind().sync().channel(); + + ch.closeFuture().sync(); + } finally { + bossGroup.shutdownGracefully(); + workerGroup.shutdownGracefully(); + } + } + + class JsonRpcServerInitializer extends ChannelInitializer { + @Override + public void initChannel(SocketChannel ch) { + ChannelPipeline p = ch.pipeline(); + p.addLast(new HttpServerCodec()); + p.addLast(new JsonRpcServerHandler()); + } + } + + class JsonRpcServerHandler extends SimpleChannelInboundHandler { + + private HttpRequest request; + private final StringBuilder responseContent = new StringBuilder(); + private HttpPostStandardRequestDecoder decoder; + private String postData; + + @Override + public void channelInactive(ChannelHandlerContext ctx) throws Exception { + if (decoder != null) { + decoder.destroy(); + } + } + @Override + public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception { + if (msg instanceof HttpRequest) { + HttpRequest req = this.request = (HttpRequest) msg; + if (!req.getUri().equals("/") || !request.getMethod().equals(HttpMethod.POST)) { + responseContent.append("Hi, how are you?!!"); + return; + } else { + decoder = new HttpPostStandardRequestDecoder(new DefaultHttpDataFactory(false), req); + postData = ""; + } + } + + if (decoder != null) { + if (msg instanceof HttpContent) { + HttpContent chunk = (HttpContent) msg; + decoder.offer(chunk); + postData += chunk.content().toString(0, chunk.content().capacity(), CharsetUtil.UTF_8); + + if (chunk instanceof LastHttpContent) { + JSONRPC2Request req = JSONRPC2Request.parse(postData); + JSONRPC2Response resp = dispatcher.process(req, null); + responseContent.append(resp); + writeResponse(ctx); + request = null; + decoder.destroy(); + decoder = null; + } + } + } else { + writeResponse(ctx); + } + } + + private void writeResponse(ChannelHandlerContext ctx) { + ByteBuf buf = Unpooled.copiedBuffer(responseContent.toString(), CharsetUtil.UTF_8); + responseContent.setLength(0); + + boolean close = HttpHeaders.Values.CLOSE.equalsIgnoreCase(request.headers().get(CONNECTION)) + || request.getProtocolVersion().equals(HttpVersion.HTTP_1_0) + && !HttpHeaders.Values.KEEP_ALIVE.equalsIgnoreCase(request.headers().get(CONNECTION)); + FullHttpResponse response = new DefaultFullHttpResponse( + HttpVersion.HTTP_1_1, HttpResponseStatus.OK, buf); + response.headers().set(CONTENT_TYPE, "text/plain; charset=UTF-8"); + + if (!close) { + response.headers().set(CONTENT_LENGTH, buf.readableBytes()); + } + + ChannelFuture future = ctx.writeAndFlush(response); + if (close) { + future.addListener(ChannelFutureListener.CLOSE); + } + } + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { + cause.printStackTrace(); + ctx.close(); + } + } +} \ No newline at end of file diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/JsonRpcServerMethod.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/JsonRpcServerMethod.java similarity index 97% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/JsonRpcServerMethod.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/JsonRpcServerMethod.java index c078f183..55e12d82 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/JsonRpcServerMethod.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/JsonRpcServerMethod.java @@ -1,4 +1,4 @@ -package org.ethereum.android.jsonrpc; +package org.ethereum.android.jsonrpc.full; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; @@ -8,7 +8,7 @@ import net.minidev.json.JSONObject; import org.ethereum.android.db.BlockTransactionVO; import org.ethereum.android.db.OrmLiteBlockStoreDatabase; -import org.ethereum.android.jsonrpc.JsonRpcServer; +import org.ethereum.android.jsonrpc.full.JsonRpcServer; import org.ethereum.core.Account; import org.ethereum.core.AccountState; import org.ethereum.core.Block; @@ -91,7 +91,7 @@ public abstract class JsonRpcServerMethod implements RequestHandler { throw new Exception(""); } - byte[] from = ((Account) ethereum.getWallet().getAccountCollection().toArray()[1]).getEcKey().getAddress(); + byte[] from = getCoinBase(); if (obj.containsKey("from") && !((String)obj.get("from")).equals("")) { from = jsToAddress((String) obj.get("from")); } @@ -271,4 +271,8 @@ public abstract class JsonRpcServerMethod implements RequestHandler { return res; } + + protected byte[] getCoinBase() { + return ((Account) ethereum.getWallet().getAccountCollection().toArray()[0]).getEcKey().getAddress(); + } } \ No newline at end of file diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/filter/FilterBase.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/filter/FilterBase.java similarity index 92% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/filter/FilterBase.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/filter/FilterBase.java index 3f3d83fb..b0f7d1e4 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/filter/FilterBase.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/filter/FilterBase.java @@ -1,4 +1,4 @@ -package org.ethereum.android.jsonrpc.filter; +package org.ethereum.android.jsonrpc.full.filter; import net.minidev.json.JSONArray; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/filter/FilterBlock.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/filter/FilterBlock.java similarity index 94% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/filter/FilterBlock.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/filter/FilterBlock.java index dab9cdba..53931f15 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/filter/FilterBlock.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/filter/FilterBlock.java @@ -1,4 +1,4 @@ -package org.ethereum.android.jsonrpc.filter; +package org.ethereum.android.jsonrpc.full.filter; import net.minidev.json.JSONArray; import org.ethereum.core.Block; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/filter/FilterLog.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/filter/FilterLog.java similarity index 99% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/filter/FilterLog.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/filter/FilterLog.java index 8bd2e37a..8eecfbb8 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/filter/FilterLog.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/filter/FilterLog.java @@ -1,4 +1,4 @@ -package org.ethereum.android.jsonrpc.filter; +package org.ethereum.android.jsonrpc.full.filter; import net.minidev.json.JSONArray; import net.minidev.json.JSONObject; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/filter/FilterManager.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/filter/FilterManager.java similarity index 98% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/filter/FilterManager.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/filter/FilterManager.java index 0887a991..50688414 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/filter/FilterManager.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/filter/FilterManager.java @@ -1,4 +1,4 @@ -package org.ethereum.android.jsonrpc.filter; +package org.ethereum.android.jsonrpc.full.filter; import net.minidev.json.JSONArray; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/filter/FilterTransaction.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/filter/FilterTransaction.java similarity index 94% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/filter/FilterTransaction.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/filter/FilterTransaction.java index ec2ce3aa..68908ce5 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/filter/FilterTransaction.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/filter/FilterTransaction.java @@ -1,4 +1,4 @@ -package org.ethereum.android.jsonrpc.filter; +package org.ethereum.android.jsonrpc.full.filter; import net.minidev.json.JSONArray; import org.ethereum.core.Transaction; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/db_getHex.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/db_getHex.java similarity index 81% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/db_getHex.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/db_getHex.java index fd924ce6..2b5e59ee 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/db_getHex.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/db_getHex.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; /* diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/db_getString.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/db_getString.java similarity index 81% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/db_getString.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/db_getString.java index 9d68fef5..8fd4873f 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/db_getString.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/db_getString.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; /* diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/db_putHex.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/db_putHex.java similarity index 81% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/db_putHex.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/db_putHex.java index db36d9ca..bb3d5c8a 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/db_putHex.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/db_putHex.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; /* diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/db_putString.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/db_putString.java similarity index 81% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/db_putString.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/db_putString.java index d542f6c6..3eccc1d1 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/db_putString.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/db_putString.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; /* diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_accounts.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_accounts.java similarity index 88% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_accounts.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_accounts.java index c6676f25..f1f49029 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_accounts.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_accounts.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; import org.ethereum.core.*; import org.spongycastle.util.encoders.Hex; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_blockNumber.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_blockNumber.java similarity index 83% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_blockNumber.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_blockNumber.java index 46bb6010..b2143871 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_blockNumber.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_blockNumber.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; public class eth_blockNumber extends JsonRpcServerMethod { diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_call.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_call.java similarity index 94% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_call.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_call.java index c13c9c45..13949fb3 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_call.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_call.java @@ -1,9 +1,9 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; import net.minidev.json.JSONObject; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.core.Transaction; import org.ethereum.facade.Ethereum; import org.ethereum.vm.Program; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_coinbase.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_coinbase.java similarity index 70% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_coinbase.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_coinbase.java index 0b0d013e..b90a1598 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_coinbase.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_coinbase.java @@ -1,27 +1,26 @@ -package org.ethereum.android.jsonrpc.method; - -import com.thetransactioncompany.jsonrpc2.*; -import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; -import org.ethereum.facade.Ethereum; -import org.ethereum.core.*; -import org.spongycastle.util.encoders.Hex; - -/* -TODO: -core not handle mining so coinbase not present in it. Right now returned second address from Wallet. Must be changed in app where implemented mining -*/ -public class eth_coinbase extends JsonRpcServerMethod { - - public eth_coinbase (Ethereum ethereum) { - super(ethereum); - } - - protected JSONRPC2Response worker(JSONRPC2Request req, MessageContext ctx) { - - Wallet w = ethereum.getWallet(); - String tmp = "0x" + Hex.toHexString(((Account) w.getAccountCollection().toArray()[1]).getEcKey().getAddress()); - JSONRPC2Response res = new JSONRPC2Response(tmp, req.getID()); - return res; - - } +package org.ethereum.android.jsonrpc.full.method; + +import com.thetransactioncompany.jsonrpc2.*; +import com.thetransactioncompany.jsonrpc2.server.*; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; +import org.ethereum.facade.Ethereum; +import org.ethereum.core.*; +import org.spongycastle.util.encoders.Hex; + +/* +TODO: -core not handle mining so coinbase not present in it. Right now returned second address from Wallet. Must be changed in app where implemented mining +*/ +public class eth_coinbase extends JsonRpcServerMethod { + + public eth_coinbase (Ethereum ethereum) { + super(ethereum); + } + + protected JSONRPC2Response worker(JSONRPC2Request req, MessageContext ctx) { + + String tmp = "0x" + getCoinBase(); + JSONRPC2Response res = new JSONRPC2Response(tmp, req.getID()); + return res; + + } } \ No newline at end of file diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_compileLLL.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_compileLLL.java similarity index 88% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_compileLLL.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_compileLLL.java index 1bc571c7..f6948772 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_compileLLL.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_compileLLL.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.core.AccountState; import org.ethereum.facade.Ethereum; import org.spongycastle.util.encoders.Hex; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_compileSerpent.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_compileSerpent.java similarity index 94% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_compileSerpent.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_compileSerpent.java index defb80b8..ead56a34 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_compileSerpent.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_compileSerpent.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.core.AccountState; import org.ethereum.facade.Ethereum; import org.ethereum.serpent.SerpentCompiler; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_compileSolidity.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_compileSolidity.java similarity index 81% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_compileSolidity.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_compileSolidity.java index 8d44c298..5b0dd54d 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_compileSolidity.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_compileSolidity.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.core.AccountState; import org.ethereum.facade.Ethereum; import org.spongycastle.util.encoders.Hex; @@ -10,7 +10,7 @@ import java.math.BigInteger; import java.util.List; /* -ATODO: -core not have solidity compiler. Need try to use cpp solidity compiler using JNI +TODO: -core not have Solidity compiler */ public class eth_compileSolidity extends JsonRpcServerMethod { diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_estimateGas.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_estimateGas.java similarity index 94% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_estimateGas.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_estimateGas.java index c21bcdf8..eb870aa7 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_estimateGas.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_estimateGas.java @@ -1,9 +1,9 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; import net.minidev.json.JSONObject; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.core.Transaction; import org.ethereum.facade.Ethereum; import org.ethereum.vm.Program; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_gasPrice.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_gasPrice.java similarity index 83% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_gasPrice.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_gasPrice.java index c1dd481e..4a71eced 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_gasPrice.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_gasPrice.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; import static org.ethereum.core.Denomination.SZABO; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getBalance.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getBalance.java similarity index 93% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getBalance.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getBalance.java index e084122d..70b27e72 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getBalance.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getBalance.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.core.AccountState; import org.ethereum.facade.Ethereum; import org.spongycastle.util.encoders.Hex; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getBlockByHash.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getBlockByHash.java similarity index 90% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getBlockByHash.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getBlockByHash.java index b5a0636f..7690dcea 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getBlockByHash.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getBlockByHash.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.core.AccountState; import org.ethereum.core.Block; import org.ethereum.facade.Ethereum; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getBlockByNumber.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getBlockByNumber.java similarity index 92% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getBlockByNumber.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getBlockByNumber.java index e7ac5763..c94bbec6 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getBlockByNumber.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getBlockByNumber.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.core.AccountState; import org.ethereum.core.Block; import org.ethereum.facade.Ethereum; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getBlockTransactionCountByHash.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getBlockTransactionCountByHash.java similarity index 89% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getBlockTransactionCountByHash.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getBlockTransactionCountByHash.java index a29dbcdd..ab475349 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getBlockTransactionCountByHash.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getBlockTransactionCountByHash.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; import org.spongycastle.util.encoders.Hex; import java.util.List; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getBlockTransactionCountByNumber.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getBlockTransactionCountByNumber.java similarity index 92% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getBlockTransactionCountByNumber.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getBlockTransactionCountByNumber.java index 30817e0e..74360bd1 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getBlockTransactionCountByNumber.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getBlockTransactionCountByNumber.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; import java.util.List; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getCode.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getCode.java similarity index 92% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getCode.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getCode.java index 8635e532..ad59691f 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getCode.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getCode.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; import org.spongycastle.util.encoders.Hex; import java.util.List; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getCompilers.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getCompilers.java similarity index 85% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getCompilers.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getCompilers.java index d6c72224..053db8c9 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getCompilers.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getCompilers.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; import java.util.ArrayList; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getFilterChanges.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getFilterChanges.java similarity index 73% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getFilterChanges.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getFilterChanges.java index 3a60af7c..d9b5eb56 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getFilterChanges.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getFilterChanges.java @@ -1,12 +1,12 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; import net.minidev.json.JSONObject; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; -import org.ethereum.android.jsonrpc.filter.FilterBase; -import org.ethereum.android.jsonrpc.filter.FilterLog; -import org.ethereum.android.jsonrpc.filter.FilterManager; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.filter.FilterBase; +import org.ethereum.android.jsonrpc.full.filter.FilterLog; +import org.ethereum.android.jsonrpc.full.filter.FilterManager; import org.ethereum.facade.Ethereum; import java.util.List; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getFilterLogs.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getFilterLogs.java similarity index 73% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getFilterLogs.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getFilterLogs.java index 204330ca..d10f04bf 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getFilterLogs.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getFilterLogs.java @@ -1,12 +1,12 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; import net.minidev.json.JSONObject; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; -import org.ethereum.android.jsonrpc.filter.FilterBase; -import org.ethereum.android.jsonrpc.filter.FilterLog; -import org.ethereum.android.jsonrpc.filter.FilterManager; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.filter.FilterBase; +import org.ethereum.android.jsonrpc.full.filter.FilterLog; +import org.ethereum.android.jsonrpc.full.filter.FilterManager; import org.ethereum.facade.Ethereum; import java.util.List; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getLogs.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getLogs.java similarity index 77% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getLogs.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getLogs.java index 2b129f0d..22931c20 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getLogs.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getLogs.java @@ -1,11 +1,11 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; import net.minidev.json.JSONObject; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; -import org.ethereum.android.jsonrpc.filter.FilterLog; -import org.ethereum.android.jsonrpc.filter.FilterManager; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.filter.FilterLog; +import org.ethereum.android.jsonrpc.full.filter.FilterManager; import org.ethereum.facade.Ethereum; import java.util.List; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getStorageAt.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getStorageAt.java similarity index 89% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getStorageAt.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getStorageAt.java index 8130dd97..476939de 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getStorageAt.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getStorageAt.java @@ -1,9 +1,9 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServer; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServer; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; import org.ethereum.vm.DataWord; import org.spongycastle.util.encoders.Hex; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getTransactionByBlockHashAndIndex.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getTransactionByBlockHashAndIndex.java similarity index 93% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getTransactionByBlockHashAndIndex.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getTransactionByBlockHashAndIndex.java index 57663606..838f8ed7 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getTransactionByBlockHashAndIndex.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getTransactionByBlockHashAndIndex.java @@ -1,11 +1,11 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; import net.minidev.json.JSONObject; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.core.AccountState; import org.ethereum.core.Block; import org.ethereum.facade.Ethereum; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getTransactionByBlockNumberAndIndex.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getTransactionByBlockNumberAndIndex.java similarity index 94% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getTransactionByBlockNumberAndIndex.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getTransactionByBlockNumberAndIndex.java index f7672211..adacd3a8 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getTransactionByBlockNumberAndIndex.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getTransactionByBlockNumberAndIndex.java @@ -1,11 +1,11 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; import net.minidev.json.JSONObject; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.core.AccountState; import org.ethereum.core.Block; import org.ethereum.core.Transaction; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getTransactionByHash.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getTransactionByHash.java similarity index 90% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getTransactionByHash.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getTransactionByHash.java index 14b9d495..268fbc3c 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getTransactionByHash.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getTransactionByHash.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.core.TransactionReceipt; import org.ethereum.facade.Ethereum; import java.util.List; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getTransactionCount.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getTransactionCount.java similarity index 92% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getTransactionCount.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getTransactionCount.java index c86e6cc9..7dc5ffb7 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getTransactionCount.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getTransactionCount.java @@ -1,9 +1,9 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServer; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServer; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.core.AccountState; import org.ethereum.core.Transaction; import org.ethereum.facade.Ethereum; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getUncleByBlockHashAndIndex.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getUncleByBlockHashAndIndex.java similarity index 92% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getUncleByBlockHashAndIndex.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getUncleByBlockHashAndIndex.java index 0ddb0ba6..4c1169fb 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getUncleByBlockHashAndIndex.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getUncleByBlockHashAndIndex.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.core.Block; import org.ethereum.crypto.HashUtil; import org.ethereum.facade.Ethereum; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getUncleByBlockNumberAndIndex.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getUncleByBlockNumberAndIndex.java similarity index 93% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getUncleByBlockNumberAndIndex.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getUncleByBlockNumberAndIndex.java index cc72ea61..61049181 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getUncleByBlockNumberAndIndex.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getUncleByBlockNumberAndIndex.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.core.Block; import org.ethereum.crypto.HashUtil; import org.ethereum.facade.Ethereum; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getUncleCountByBlockHash.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getUncleCountByBlockHash.java similarity index 89% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getUncleCountByBlockHash.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getUncleCountByBlockHash.java index 894e3154..1445caea 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getUncleCountByBlockHash.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getUncleCountByBlockHash.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; import org.spongycastle.util.encoders.Hex; import java.util.List; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getUncleCountByBlockNumber.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getUncleCountByBlockNumber.java similarity index 91% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getUncleCountByBlockNumber.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getUncleCountByBlockNumber.java index 00419773..4c58b97a 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getUncleCountByBlockNumber.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getUncleCountByBlockNumber.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; import java.util.List; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getWork.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getWork.java similarity index 82% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getWork.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getWork.java index 8cd6d778..840cfd46 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_getWork.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_getWork.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; /* diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_hashrate.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_hashrate.java similarity index 83% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_hashrate.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_hashrate.java index 48e3f704..f16010d2 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_hashrate.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_hashrate.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; /* diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_mining.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_mining.java similarity index 82% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_mining.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_mining.java index ea09cb39..29b960db 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_mining.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_mining.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; /* diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_newBlockFilter.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_newBlockFilter.java similarity index 71% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_newBlockFilter.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_newBlockFilter.java index 14d982f0..3ed271c5 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_newBlockFilter.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_newBlockFilter.java @@ -1,10 +1,10 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; -import org.ethereum.android.jsonrpc.filter.FilterBlock; -import org.ethereum.android.jsonrpc.filter.FilterManager; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.filter.FilterBlock; +import org.ethereum.android.jsonrpc.full.filter.FilterManager; import org.ethereum.facade.Ethereum; public class eth_newBlockFilter extends JsonRpcServerMethod { diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_newFilter.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_newFilter.java similarity index 79% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_newFilter.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_newFilter.java index 7fa16046..710e7d6b 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_newFilter.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_newFilter.java @@ -1,11 +1,11 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; import net.minidev.json.JSONObject; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; -import org.ethereum.android.jsonrpc.filter.FilterLog; -import org.ethereum.android.jsonrpc.filter.FilterManager; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.filter.FilterLog; +import org.ethereum.android.jsonrpc.full.filter.FilterManager; import org.ethereum.facade.Ethereum; import java.util.List; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_newPendingTransactionFilter.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_newPendingTransactionFilter.java similarity index 67% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_newPendingTransactionFilter.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_newPendingTransactionFilter.java index 1e7dc844..47bf9446 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_newPendingTransactionFilter.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_newPendingTransactionFilter.java @@ -1,11 +1,11 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; -import org.ethereum.android.jsonrpc.filter.FilterBlock; -import org.ethereum.android.jsonrpc.filter.FilterManager; -import org.ethereum.android.jsonrpc.filter.FilterTransaction; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.filter.FilterBlock; +import org.ethereum.android.jsonrpc.full.filter.FilterManager; +import org.ethereum.android.jsonrpc.full.filter.FilterTransaction; import org.ethereum.facade.Ethereum; public class eth_newPendingTransactionFilter extends JsonRpcServerMethod { diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_protocolVersion.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_protocolVersion.java similarity index 83% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_protocolVersion.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_protocolVersion.java index 19a5d9e5..9b48a1cb 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_protocolVersion.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_protocolVersion.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; import org.ethereum.net.eth.EthHandler; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_sendTransaction.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_sendTransaction.java similarity index 93% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_sendTransaction.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_sendTransaction.java index 3423cc7e..3d96ad85 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_sendTransaction.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_sendTransaction.java @@ -1,9 +1,9 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; import net.minidev.json.JSONObject; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.core.Account; import org.ethereum.core.Transaction; import org.ethereum.facade.Ethereum; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_sign.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_sign.java similarity index 83% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_sign.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_sign.java index c554745a..df6a84dc 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_sign.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_sign.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.core.Account; import org.ethereum.crypto.ECKey; import org.ethereum.facade.Ethereum; @@ -26,25 +26,24 @@ public class eth_sign extends JsonRpcServerMethod { } else { byte[] address = jsToAddress((String) params.get(0)); byte[] data = jsToAddress((String) params.get(1)); - String out = null; + byte[] sigData = null; for (Account ac : ethereum.getWallet().getAccountCollection()) { if (Arrays.equals(ac.getAddress(), address)) { ECKey.ECDSASignature sig = ac.getEcKey().doSign(data); - byte[] sigData = new byte[65]; + sigData = new byte[65]; sigData[0] = sig.v; System.arraycopy(bigIntegerToBytes(sig.r, 32), 0, sigData, 1, 32); System.arraycopy(bigIntegerToBytes(sig.s, 32), 0, sigData, 33, 32); - out = Hex.toHexString(sigData); break; } } - if (out == null) { + if (sigData == null) { return new JSONRPC2Response(JSONRPC2Error.INTERNAL_ERROR, req.getID()); } - String tmp = "0x" + out; + String tmp = "0x" + Hex.toHexString(sigData); JSONRPC2Response res = new JSONRPC2Response(tmp, req.getID()); return res; } diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_submitWork.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_submitWork.java similarity index 84% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_submitWork.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_submitWork.java index d00b000c..68d773bc 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_submitWork.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_submitWork.java @@ -1,9 +1,9 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; -import org.ethereum.android.jsonrpc.filter.FilterManager; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.filter.FilterManager; import org.ethereum.facade.Ethereum; import java.util.List; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_uninstallFilter.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_uninstallFilter.java similarity index 73% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_uninstallFilter.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_uninstallFilter.java index 7e8db421..b0af2205 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/eth_uninstallFilter.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/eth_uninstallFilter.java @@ -1,12 +1,12 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; import net.minidev.json.JSONObject; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; -import org.ethereum.android.jsonrpc.filter.FilterBase; -import org.ethereum.android.jsonrpc.filter.FilterLog; -import org.ethereum.android.jsonrpc.filter.FilterManager; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.filter.FilterBase; +import org.ethereum.android.jsonrpc.full.filter.FilterLog; +import org.ethereum.android.jsonrpc.full.filter.FilterManager; import org.ethereum.facade.Ethereum; import java.util.List; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/net_listening.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/net_listening.java similarity index 80% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/net_listening.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/net_listening.java index 337ffb87..74cab164 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/net_listening.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/net_listening.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; public class net_listening extends JsonRpcServerMethod { diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/net_peerCount.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/net_peerCount.java similarity index 87% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/net_peerCount.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/net_peerCount.java index b5cb30c1..9d1023c4 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/net_peerCount.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/net_peerCount.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; import org.ethereum.net.peerdiscovery.PeerInfo; import java.util.Set; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/net_version.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/net_version.java similarity index 82% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/net_version.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/net_version.java index 8ef96720..1785716e 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/net_version.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/net_version.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; /* diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_addToGroup.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_addToGroup.java similarity index 88% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_addToGroup.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_addToGroup.java index 86c49a8e..18307491 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_addToGroup.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_addToGroup.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; import java.util.List; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_getFilterChanges.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_getFilterChanges.java similarity index 81% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_getFilterChanges.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_getFilterChanges.java index dd068c82..bf7e0ea1 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_getFilterChanges.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_getFilterChanges.java @@ -1,9 +1,9 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; -import org.ethereum.android.jsonrpc.whisper.FilterManager; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.whisper.FilterManager; import org.ethereum.facade.Ethereum; import java.util.List; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_getMessages.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_getMessages.java similarity index 81% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_getMessages.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_getMessages.java index 7607973d..99cd7f7a 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_getMessages.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_getMessages.java @@ -1,9 +1,9 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; -import org.ethereum.android.jsonrpc.whisper.FilterManager; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.whisper.FilterManager; import org.ethereum.facade.Ethereum; import java.util.List; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_hasIdentity.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_hasIdentity.java similarity index 88% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_hasIdentity.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_hasIdentity.java index f1eede34..b65392ce 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_hasIdentity.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_hasIdentity.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; import java.util.List; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_newFilter.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_newFilter.java similarity index 79% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_newFilter.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_newFilter.java index 8d38fbcf..68187031 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_newFilter.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_newFilter.java @@ -1,13 +1,13 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; import net.minidev.json.JSONObject; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; -import org.ethereum.android.jsonrpc.whisper.Filter; -import org.ethereum.android.jsonrpc.whisper.FilterManager; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.whisper.Filter; +import org.ethereum.android.jsonrpc.full.whisper.FilterManager; import org.ethereum.facade.Ethereum; import java.util.List; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_newGroup.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_newGroup.java similarity index 83% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_newGroup.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_newGroup.java index 636c214e..2de1a4cc 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_newGroup.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_newGroup.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; /* diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_newIdentity.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_newIdentity.java similarity index 82% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_newIdentity.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_newIdentity.java index 87c23e27..a598baf0 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_newIdentity.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_newIdentity.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; /* diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_post.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_post.java similarity index 93% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_post.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_post.java index 69b69ef1..b8d7beff 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_post.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_post.java @@ -1,4 +1,4 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; @@ -6,7 +6,7 @@ import com.thetransactioncompany.jsonrpc2.server.*; import net.minidev.json.JSONArray; import net.minidev.json.JSONObject; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; import org.spongycastle.util.encoders.Hex; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_uninstallFilter.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_uninstallFilter.java similarity index 81% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_uninstallFilter.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_uninstallFilter.java index 38f3f54b..d267dcff 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_uninstallFilter.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_uninstallFilter.java @@ -1,9 +1,9 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; -import org.ethereum.android.jsonrpc.whisper.FilterManager; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.whisper.FilterManager; import org.ethereum.facade.Ethereum; import java.util.List; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_version.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_version.java similarity index 82% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_version.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_version.java index 12aba25f..0c25bef2 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/shh_version.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/shh_version.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.facade.Ethereum; import org.ethereum.net.shh.ShhHandler; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/web3_clientVersion.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/web3_clientVersion.java similarity index 85% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/web3_clientVersion.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/web3_clientVersion.java index 529dcc0f..2b586ed5 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/web3_clientVersion.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/web3_clientVersion.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.config.SystemProperties; import org.ethereum.facade.Ethereum; import org.ethereum.util.Utils; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/web3_sha3.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/web3_sha3.java similarity index 88% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/web3_sha3.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/web3_sha3.java index 8ac1ba21..39cd354d 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/method/web3_sha3.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/method/web3_sha3.java @@ -1,8 +1,8 @@ -package org.ethereum.android.jsonrpc.method; +package org.ethereum.android.jsonrpc.full.method; import com.thetransactioncompany.jsonrpc2.*; import com.thetransactioncompany.jsonrpc2.server.*; -import org.ethereum.android.jsonrpc.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod; import org.ethereum.crypto.SHA3Helper; import org.ethereum.facade.Ethereum; import org.spongycastle.util.encoders.Hex; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/whisper/Filter.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/whisper/Filter.java similarity index 97% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/whisper/Filter.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/whisper/Filter.java index be0d2999..193a3054 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/whisper/Filter.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/whisper/Filter.java @@ -1,4 +1,4 @@ -package org.ethereum.android.jsonrpc.whisper; +package org.ethereum.android.jsonrpc.full.whisper; import net.minidev.json.JSONArray; import net.minidev.json.JSONObject; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/whisper/FilterManager.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/whisper/FilterManager.java similarity index 97% rename from ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/whisper/FilterManager.java rename to ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/whisper/FilterManager.java index 9089f508..62e95503 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/whisper/FilterManager.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/full/whisper/FilterManager.java @@ -1,4 +1,4 @@ -package org.ethereum.android.jsonrpc.whisper; +package org.ethereum.android.jsonrpc.full.whisper; import net.minidev.json.JSONArray; diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/JsonRpcServer.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/JsonRpcServer.java new file mode 100644 index 00000000..a6d633af --- /dev/null +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/JsonRpcServer.java @@ -0,0 +1,181 @@ +package org.ethereum.android.jsonrpc.light; + +import io.netty.bootstrap.ServerBootstrap; +import io.netty.channel.Channel; +import io.netty.channel.ChannelOption; +import io.netty.channel.EventLoopGroup; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.nio.NioServerSocketChannel; +import io.netty.channel.ChannelInitializer; +import io.netty.channel.ChannelPipeline; +import io.netty.channel.socket.SocketChannel; +import io.netty.handler.codec.http.HttpServerCodec; +import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelFutureListener; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.http.DefaultFullHttpResponse; +import io.netty.handler.codec.http.FullHttpResponse; +import io.netty.handler.codec.http.HttpRequest; +import io.netty.handler.codec.http.multipart.HttpPostStandardRequestDecoder; +import io.netty.handler.codec.http.multipart.DefaultHttpDataFactory; +import io.netty.handler.codec.http.HttpObject; +import io.netty.channel.SimpleChannelInboundHandler; +import io.netty.handler.codec.http.HttpMethod; +import io.netty.handler.codec.http.HttpContent; +import io.netty.handler.codec.http.LastHttpContent; +import io.netty.buffer.ByteBuf; +import io.netty.util.CharsetUtil; +import io.netty.handler.codec.http.HttpVersion; +import io.netty.handler.codec.http.HttpResponseStatus; +import io.netty.channel.ChannelFuture; +import org.ethereum.android.jsonrpc.light.whisper.FilterManager; +import org.ethereum.facade.Ethereum; +import com.thetransactioncompany.jsonrpc2.*; +import com.thetransactioncompany.jsonrpc2.server.*; +import io.netty.handler.codec.http.HttpHeaders; +import static io.netty.handler.codec.http.HttpHeaders.Names.*; +import org.ethereum.android.jsonrpc.light.method.*; + +import java.net.InetAddress; + + +public final class JsonRpcServer extends org.ethereum.android.jsonrpc.JsonRpcServer{ + + static public final int PORT = 8545; + static public final String RemoteServer = "http://192.168.1.30:8545/"; + + private Ethereum ethereum; + private Dispatcher dispatcher; + + public JsonRpcServer(Ethereum ethereum) { + super(ethereum); + this.ethereum = ethereum; + + this.dispatcher = new Dispatcher(); + + this.dispatcher.register(new eth_coinbase(this.ethereum)); + this.dispatcher.register(new eth_accounts(this.ethereum)); + this.dispatcher.register(new eth_sign(this.ethereum)); + this.dispatcher.register(new eth_sendTransaction(this.ethereum)); + + this.dispatcher.register(new shh_version(this.ethereum)); + this.dispatcher.register(new shh_post(this.ethereum)); + this.dispatcher.register(new shh_newIdentity(this.ethereum)); + this.dispatcher.register(new shh_hasIdentity(this.ethereum)); + this.dispatcher.register(new shh_newGroup(this.ethereum)); + this.dispatcher.register(new shh_addToGroup(this.ethereum)); + this.dispatcher.register(new shh_newFilter(this.ethereum)); + this.dispatcher.register(new shh_uninstallFilter(this.ethereum)); + this.dispatcher.register(new shh_getFilterChanges(this.ethereum)); + this.dispatcher.register(new shh_getMessages(this.ethereum)); + + this.dispatcher.register(new proxy(this.ethereum)); + + FilterManager.getInstance(); + } + + public void start() throws Exception { + EventLoopGroup bossGroup = new NioEventLoopGroup(1); + EventLoopGroup workerGroup = new NioEventLoopGroup(); + try { + ServerBootstrap b = new ServerBootstrap(); + b.option(ChannelOption.SO_BACKLOG, 1024); +// b.localAddress(InetAddress.getLocalHost(), PORT); + b.localAddress(PORT); + b.group(bossGroup, workerGroup) + .channel(NioServerSocketChannel.class) + .childHandler(new JsonRpcServerInitializer()); + + Channel ch = b.bind().sync().channel(); + + ch.closeFuture().sync(); + } finally { + bossGroup.shutdownGracefully(); + workerGroup.shutdownGracefully(); + } + } + + class JsonRpcServerInitializer extends ChannelInitializer { + @Override + public void initChannel(SocketChannel ch) { + ChannelPipeline p = ch.pipeline(); + p.addLast(new HttpServerCodec()); + p.addLast(new JsonRpcServerHandler()); + } + } + + class JsonRpcServerHandler extends SimpleChannelInboundHandler { + + private HttpRequest request; + private final StringBuilder responseContent = new StringBuilder(); + private HttpPostStandardRequestDecoder decoder; + private String postData; + + @Override + public void channelInactive(ChannelHandlerContext ctx) throws Exception { + if (decoder != null) { + decoder.destroy(); + } + } + @Override + public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception { + if (msg instanceof HttpRequest) { + HttpRequest req = this.request = (HttpRequest) msg; + if (!req.getUri().equals("/") || !request.getMethod().equals(HttpMethod.POST)) { + responseContent.append("Hi, how are you?!!"); + return; + } else { + decoder = new HttpPostStandardRequestDecoder(new DefaultHttpDataFactory(false), req); + postData = ""; + } + } + + if (decoder != null) { + if (msg instanceof HttpContent) { + HttpContent chunk = (HttpContent) msg; + decoder.offer(chunk); + postData += chunk.content().toString(0, chunk.content().capacity(), CharsetUtil.UTF_8); + + if (chunk instanceof LastHttpContent) { + JSONRPC2Request req = JSONRPC2Request.parse(postData); + JSONRPC2Response resp = dispatcher.process(req, null); + responseContent.append(resp); + writeResponse(ctx); + request = null; + decoder.destroy(); + decoder = null; + } + } + } else { + writeResponse(ctx); + } + } + + private void writeResponse(ChannelHandlerContext ctx) { + ByteBuf buf = Unpooled.copiedBuffer(responseContent.toString(), CharsetUtil.UTF_8); + responseContent.setLength(0); + + boolean close = HttpHeaders.Values.CLOSE.equalsIgnoreCase(request.headers().get(CONNECTION)) + || request.getProtocolVersion().equals(HttpVersion.HTTP_1_0) + && !HttpHeaders.Values.KEEP_ALIVE.equalsIgnoreCase(request.headers().get(CONNECTION)); + FullHttpResponse response = new DefaultFullHttpResponse( + HttpVersion.HTTP_1_1, HttpResponseStatus.OK, buf); + response.headers().set(CONTENT_TYPE, "text/plain; charset=UTF-8"); + + if (!close) { + response.headers().set(CONTENT_LENGTH, buf.readableBytes()); + } + + ChannelFuture future = ctx.writeAndFlush(response); + if (close) { + future.addListener(ChannelFutureListener.CLOSE); + } + } + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { + cause.printStackTrace(); + ctx.close(); + } + } +} \ No newline at end of file diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/JsonRpcServerMethod.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/JsonRpcServerMethod.java new file mode 100644 index 00000000..c2e33148 --- /dev/null +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/JsonRpcServerMethod.java @@ -0,0 +1,207 @@ +package org.ethereum.android.jsonrpc.light; + +import com.thetransactioncompany.jsonrpc2.*; +import com.thetransactioncompany.jsonrpc2.client.JSONRPC2Session; +import com.thetransactioncompany.jsonrpc2.server.*; +import net.minidev.json.JSONObject; +import org.ethereum.core.Account; +import org.ethereum.core.Transaction; +import org.ethereum.facade.Ethereum; +import org.spongycastle.util.encoders.Hex; +import java.math.BigInteger; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; + +import static org.ethereum.core.Denomination.SZABO; + +public abstract class JsonRpcServerMethod implements RequestHandler { + + private String name = ""; + protected Ethereum ethereum; + private JSONRPC2Session jpSession; + + public JsonRpcServerMethod(Ethereum ethereum) { + this.ethereum = ethereum; + name = this.getClass().getSimpleName(); + } + + public String[] handledRequests() { + return new String[]{name}; + } + + public JSONRPC2Response process(JSONRPC2Request req, MessageContext ctx) { + if (req.getMethod().equals(name)) { + return worker(req, ctx); + } else { + return new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND, req.getID()); + } + } + + protected abstract JSONRPC2Response worker(JSONRPC2Request req, MessageContext ctx); + + protected long getBlockNumber(String height) { + long blockNumber = 0; + switch (height) { + case "earliest": + blockNumber = 0; + break; + case "latest": + blockNumber = -1; + break; + case "pending": + blockNumber = -2; + break; + default: + blockNumber = jsToLong(height); + } + if (blockNumber >= 0) + blockNumber = -1; + return blockNumber; + } + + protected byte[] jsToAddress(String data) { + return Hex.decode(data.substring(2)); + } + + protected int jsToInt(String data) { + return Integer.parseInt(data.substring(2), 16); + } + + protected long jsToLong(String data) { + return Long.parseLong(data.substring(2), 16); + } + + protected BigInteger jsToBigInteger(String data) { + return new BigInteger(data.substring(2), 16); + } + + protected Transaction jsToTransaction(JSONObject obj) throws Exception { + if ((!obj.containsKey("to") || ((String)obj.get("to")).equals("")) && (!obj.containsKey("data") || ((String)obj.get("data")).equals(""))) { + throw new Exception(""); + } + + byte[] from = getCoinBase(); + if (obj.containsKey("from") && !((String)obj.get("from")).equals("")) { + from = jsToAddress((String) obj.get("from")); + } + Account acc = null; + for (Account ac : ethereum.getWallet().getAccountCollection()) { + if (Arrays.equals(ac.getAddress(), from)) { + acc = ac; + break; + } + } + if (acc == null) { + throw new Exception(""); + } + + byte[] senderPrivKey = acc.getEcKey().getPrivKeyBytes(); + + // default - from ethereumj-studio + byte[] to = null; + if (obj.containsKey("to") && !((String)obj.get("to")).equals("")) { + to = jsToAddress((String) obj.get("to")); + } + + // default - from ethereumj-studio + BigInteger gasPrice = SZABO.value().multiply(BigInteger.TEN); + if (obj.containsKey("gasPrice") && !((String)obj.get("gasPrice")).equals("")) { + gasPrice = jsToBigInteger((String) obj.get("gasPrice")); + } + + // default - from cpp-ethereum + BigInteger gas = getBalance(from).divide(gasPrice); + BigInteger gasBBRemaining = getLatestBlockGasRemaining(); + if (gasBBRemaining.compareTo(gas) < 0) + gas = gasBBRemaining; + if (obj.containsKey("gas") && !((String)obj.get("gas")).equals("")) { + gas = jsToBigInteger((String) obj.get("gas")); + } + + // default - from ethereumj-studio + BigInteger value = new BigInteger("1000"); + if (obj.containsKey("value") && !((String)obj.get("value")).equals("")) { + value = jsToBigInteger((String) obj.get("value")); + } + + // default - from ethereumj-studio + BigInteger nonce = getTransactionCount(from); + if (obj.containsKey("nonce") && !((String)obj.get("nonce")).equals("")) { + nonce = jsToBigInteger((String) obj.get("nonce")); + } + + // default - from ethereumj-studio + byte[] data = new byte[]{}; + if (obj.containsKey("data") && !((String)obj.get("data")).equals("")) { + data = jsToAddress((String) obj.get("data")); + } + + Transaction tx = ethereum.createTransaction(nonce, gasPrice, gas, to, value, data); + + tx.sign(senderPrivKey); + + return tx; + } + + + protected JSONRPC2Response getRemoteData(JSONRPC2Request req) { + if (jpSession == null) { + try { + jpSession = new JSONRPC2Session(new URL(JsonRpcServer.RemoteServer)); + } catch (Exception e) { + return null; + } + } + try { + return jpSession.send(req); + } catch (Exception e) { + return null; + } + } + + protected byte[] getCoinBase() { + return ((Account) ethereum.getWallet().getAccountCollection().toArray()[0]).getEcKey().getAddress(); + } + + protected BigInteger getBalance(byte[] account) { + ArrayList params = new ArrayList(); + params.add("0x" + Hex.toHexString(account)); + params.add("latest"); + JSONRPC2Request req = new JSONRPC2Request("eth_getBalance", params, 1000); + JSONRPC2Response res = getRemoteData(req); + if (res == null || !res.indicatesSuccess()) { + return BigInteger.ZERO; + } else { + return jsToBigInteger(res.getResult().toString()); + } + } + + protected BigInteger getLatestBlockGasRemaining() { + ArrayList params = new ArrayList(); + params.add("latest"); + params.add(false); + JSONRPC2Request req = new JSONRPC2Request("eth_getBlockByNumber", params, 1000); + JSONRPC2Response res = getRemoteData(req); + if (res == null || !res.indicatesSuccess()) { + return BigInteger.ZERO; + } else { + JSONObject block = (JSONObject)res.getResult(); + return jsToBigInteger((String)block.get("gasLimit")).add(jsToBigInteger((String)block.get("gasUsed")).negate()); + } + } + + protected BigInteger getTransactionCount(byte[] account) { + ArrayList params = new ArrayList(); + params.add("0x" + Hex.toHexString(account)); + params.add("latest"); + JSONRPC2Request req = new JSONRPC2Request("eth_getTransactionCount", params, 1000); + JSONRPC2Response res = getRemoteData(req); + if (res == null || !res.indicatesSuccess()) { + return BigInteger.ZERO; + } else { + return jsToBigInteger(res.getResult().toString()); + } + } + +} \ No newline at end of file diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/eth_accounts.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/eth_accounts.java new file mode 100644 index 00000000..345dab53 --- /dev/null +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/eth_accounts.java @@ -0,0 +1,29 @@ +package org.ethereum.android.jsonrpc.light.method; + +import com.thetransactioncompany.jsonrpc2.*; +import com.thetransactioncompany.jsonrpc2.server.*; +import org.ethereum.android.jsonrpc.light.JsonRpcServerMethod; +import org.ethereum.facade.Ethereum; +import org.ethereum.core.*; +import org.spongycastle.util.encoders.Hex; +import java.util.ArrayList; +import java.util.Collection; + +public class eth_accounts extends JsonRpcServerMethod { + + public eth_accounts (Ethereum ethereum) { + super(ethereum); + } + + protected JSONRPC2Response worker(JSONRPC2Request req, MessageContext ctx) { + + Collection accounts = ethereum.getWallet().getAccountCollection(); + ArrayList tmp = new ArrayList(); + for (Account ac : accounts) { + tmp.add("0x" + Hex.toHexString(ac.getEcKey().getAddress())); + } + JSONRPC2Response res = new JSONRPC2Response(tmp, req.getID()); + return res; + + } +} \ No newline at end of file diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/eth_coinbase.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/eth_coinbase.java new file mode 100644 index 00000000..d9f96a07 --- /dev/null +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/eth_coinbase.java @@ -0,0 +1,23 @@ +package org.ethereum.android.jsonrpc.light.method; + +import com.thetransactioncompany.jsonrpc2.*; +import com.thetransactioncompany.jsonrpc2.server.*; +import org.ethereum.android.jsonrpc.light.JsonRpcServerMethod; +import org.ethereum.facade.Ethereum; +import org.ethereum.core.*; +import org.spongycastle.util.encoders.Hex; + +public class eth_coinbase extends JsonRpcServerMethod { + + public eth_coinbase (Ethereum ethereum) { + super(ethereum); + } + + protected JSONRPC2Response worker(JSONRPC2Request req, MessageContext ctx) { + + String tmp = "0x" + getCoinBase(); + JSONRPC2Response res = new JSONRPC2Response(tmp, req.getID()); + return res; + + } +} \ No newline at end of file diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/eth_sendTransaction.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/eth_sendTransaction.java new file mode 100644 index 00000000..ed32fa94 --- /dev/null +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/eth_sendTransaction.java @@ -0,0 +1,53 @@ +package org.ethereum.android.jsonrpc.light.method; + +import com.thetransactioncompany.jsonrpc2.*; +import com.thetransactioncompany.jsonrpc2.server.*; +import net.minidev.json.JSONObject; +import org.ethereum.android.jsonrpc.light.JsonRpcServerMethod; +import org.ethereum.core.Account; +import org.ethereum.core.Transaction; +import org.ethereum.facade.Ethereum; +import org.spongycastle.util.encoders.Hex; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.TimeUnit; +import static org.ethereum.core.Denomination.SZABO; +import static org.ethereum.config.SystemProperties.CONFIG; + + +public class eth_sendTransaction extends JsonRpcServerMethod { + + public eth_sendTransaction (Ethereum ethereum) { + super(ethereum); + } + + protected JSONRPC2Response worker(JSONRPC2Request req, MessageContext ctx) { + + List params = req.getPositionalParams(); + if (params.size() != 1) { + return new JSONRPC2Response(JSONRPC2Error.INVALID_PARAMS, req.getID()); + } else { + JSONObject obj = (JSONObject)params.get(0); + Transaction tx; + try { + tx = jsToTransaction(obj); + } catch (Exception e) { + return new JSONRPC2Response(JSONRPC2Error.INVALID_PARAMS, req.getID()); + } + + ArrayList rparams = new ArrayList(); + params.add("0x" + Hex.toHexString(tx.getEncoded())); + JSONRPC2Request rreq = new JSONRPC2Request("eth_sendRawTransaction", rparams, req.getID()); + JSONRPC2Response rres = getRemoteData(rreq); + if (rres == null) { + return new JSONRPC2Response(JSONRPC2Error.INTERNAL_ERROR, req.getID()); + } + + JSONRPC2Response res = new JSONRPC2Response(rres.getResult(), req.getID()); + return res; + } + + } +} \ No newline at end of file diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/eth_sign.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/eth_sign.java new file mode 100644 index 00000000..84016f8a --- /dev/null +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/eth_sign.java @@ -0,0 +1,52 @@ +package org.ethereum.android.jsonrpc.light.method; + +import com.thetransactioncompany.jsonrpc2.*; +import com.thetransactioncompany.jsonrpc2.server.*; +import org.ethereum.android.jsonrpc.light.JsonRpcServerMethod; +import org.ethereum.core.Account; +import org.ethereum.crypto.ECKey; +import org.ethereum.facade.Ethereum; +import org.spongycastle.util.encoders.Hex; +import java.util.Arrays; +import java.util.List; +import static org.ethereum.util.ByteUtil.bigIntegerToBytes; + + +public class eth_sign extends JsonRpcServerMethod { + + public eth_sign (Ethereum ethereum) { + super(ethereum); + } + + protected JSONRPC2Response worker(JSONRPC2Request req, MessageContext ctx) { + + List params = req.getPositionalParams(); + if (params.size() != 2) { + return new JSONRPC2Response(JSONRPC2Error.INVALID_PARAMS, req.getID()); + } else { + byte[] address = jsToAddress((String) params.get(0)); + byte[] data = jsToAddress((String) params.get(1)); + byte[] sigData = null; + + for (Account ac : ethereum.getWallet().getAccountCollection()) { + if (Arrays.equals(ac.getAddress(), address)) { + ECKey.ECDSASignature sig = ac.getEcKey().doSign(data); + sigData = new byte[65]; + sigData[0] = sig.v; + System.arraycopy(bigIntegerToBytes(sig.r, 32), 0, sigData, 1, 32); + System.arraycopy(bigIntegerToBytes(sig.s, 32), 0, sigData, 33, 32); + break; + } + } + + if (sigData == null) { + return new JSONRPC2Response(JSONRPC2Error.INTERNAL_ERROR, req.getID()); + } + + String tmp = "0x" + Hex.toHexString(sigData); + JSONRPC2Response res = new JSONRPC2Response(tmp, req.getID()); + return res; + } + + } +} \ No newline at end of file diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/proxy.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/proxy.java new file mode 100644 index 00000000..c2504ad0 --- /dev/null +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/proxy.java @@ -0,0 +1,90 @@ +package org.ethereum.android.jsonrpc.light.method; + +import com.thetransactioncompany.jsonrpc2.*; +import com.thetransactioncompany.jsonrpc2.server.*; +import org.ethereum.android.jsonrpc.light.JsonRpcServerMethod; +import org.ethereum.facade.Ethereum; + +import java.util.ArrayList; + +public class proxy extends JsonRpcServerMethod { + + ArrayList proxyMethods; + ArrayList deprecatedMethods; + + public proxy (Ethereum ethereum) + { + super(ethereum); + proxyMethods = new ArrayList<>(); + proxyMethods.add("web3_clientVersion"); + proxyMethods.add("web3_sha3"); + proxyMethods.add("net_version"); + proxyMethods.add("net_listening"); + proxyMethods.add("net_peerCount"); + proxyMethods.add("eth_protocolVersion"); + proxyMethods.add("eth_gasPrice"); + proxyMethods.add("eth_blockNumber"); + proxyMethods.add("eth_getBalance"); + proxyMethods.add("eth_getStorageAt"); + proxyMethods.add("eth_getTransactionCount"); + proxyMethods.add("eth_getBlockTransactionCountByHash"); + proxyMethods.add("eth_getBlockTransactionCountByNumber"); + proxyMethods.add("eth_getUncleCountByBlockHash"); + proxyMethods.add("eth_getUncleCountByBlockNumber"); + proxyMethods.add("eth_getCode"); + proxyMethods.add("eth_getBlockByHash"); + proxyMethods.add("eth_getBlockByNumber"); + proxyMethods.add("eth_getTransactionByHash"); + proxyMethods.add("eth_getTransactionByBlockHashAndIndex"); + proxyMethods.add("eth_getTransactionByBlockNumberAndIndex"); + proxyMethods.add("eth_getUncleByBlockHashAndIndex"); + proxyMethods.add("eth_getUncleByBlockNumberAndIndex"); + proxyMethods.add("eth_getCompilers"); + proxyMethods.add("eth_compileSolidity"); + proxyMethods.add("eth_compileLLL"); + proxyMethods.add("eth_compileSerpent"); + proxyMethods.add("eth_newFilter"); + proxyMethods.add("eth_newBlockFilter"); + proxyMethods.add("eth_newPendingTransactionFilter"); + proxyMethods.add("eth_uninstallFilter"); + proxyMethods.add("eth_getFilterChanges"); + proxyMethods.add("eth_getFilterLogs"); + proxyMethods.add("eth_getLogs"); + + //TODO: issue methods - they generate transaction but must call them in blockchain. + proxyMethods.add("eth_call"); + proxyMethods.add("eth_estimateGas"); + + + deprecatedMethods = new ArrayList<>(); + //db - deprecated in specification + deprecatedMethods.add("db_getHex"); + deprecatedMethods.add("db_getString"); + deprecatedMethods.add("db_putHex"); + deprecatedMethods.add("db_putString"); + //mining - deprecated because will be mess over global. + deprecatedMethods.add("eth_getWork"); + deprecatedMethods.add("eth_hashrate"); + deprecatedMethods.add("eth_mining"); + deprecatedMethods.add("eth_submitWork"); + } + + @Override + public JSONRPC2Response process(JSONRPC2Request req, MessageContext ctx) { + if (proxyMethods.contains(req.getMethod())) { + return worker(req, ctx); + } else if (deprecatedMethods.contains(req.getMethod())) { + return new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND, req.getID()); + } else { + return new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND, req.getID()); + } + } + + protected JSONRPC2Response worker(JSONRPC2Request req, MessageContext ctx) { + JSONRPC2Response res = getRemoteData(req); + if (res == null) { + return new JSONRPC2Response(JSONRPC2Error.INTERNAL_ERROR, req.getID()); + } + return res; + } +} \ No newline at end of file diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_addToGroup.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_addToGroup.java new file mode 100644 index 00000000..09386f5d --- /dev/null +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_addToGroup.java @@ -0,0 +1,32 @@ +package org.ethereum.android.jsonrpc.light.method; + +import com.thetransactioncompany.jsonrpc2.*; +import com.thetransactioncompany.jsonrpc2.server.*; +import org.ethereum.android.jsonrpc.light.JsonRpcServerMethod; +import org.ethereum.facade.Ethereum; + +import java.util.List; + +/* +TODO: not present clear specification for this method, also cpp and go version not provide it. +*/ +public class shh_addToGroup extends JsonRpcServerMethod { + + public shh_addToGroup(Ethereum ethereum) { + super(ethereum); + } + + protected JSONRPC2Response worker(JSONRPC2Request req, MessageContext ctx) { + + List params = req.getPositionalParams(); + if (params.size() != 1) { + return new JSONRPC2Response(JSONRPC2Error.INVALID_PARAMS, req.getID()); + } else { + byte[] identity = jsToAddress((String)params.get(0)); + + JSONRPC2Response res = new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND, req.getID()); + return res; + } + + } +} \ No newline at end of file diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_getFilterChanges.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_getFilterChanges.java new file mode 100644 index 00000000..cd7ac1f2 --- /dev/null +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_getFilterChanges.java @@ -0,0 +1,29 @@ +package org.ethereum.android.jsonrpc.light.method; + +import com.thetransactioncompany.jsonrpc2.*; +import com.thetransactioncompany.jsonrpc2.server.*; +import org.ethereum.android.jsonrpc.light.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.light.whisper.FilterManager; +import org.ethereum.facade.Ethereum; + +import java.util.List; + +public class shh_getFilterChanges extends JsonRpcServerMethod { + + public shh_getFilterChanges(Ethereum ethereum) { + super(ethereum); + } + + protected JSONRPC2Response worker(JSONRPC2Request req, MessageContext ctx) { + + List params = req.getPositionalParams(); + if (params.size() != 1) { + return new JSONRPC2Response(JSONRPC2Error.INVALID_PARAMS, req.getID()); + } else { + int id = jsToInt((String)params.get(0)); + JSONRPC2Response res = new JSONRPC2Response(FilterManager.getInstance().toJS(id), req.getID()); + return res; + } + + } +} \ No newline at end of file diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_getMessages.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_getMessages.java new file mode 100644 index 00000000..a1e97a36 --- /dev/null +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_getMessages.java @@ -0,0 +1,29 @@ +package org.ethereum.android.jsonrpc.light.method; + +import com.thetransactioncompany.jsonrpc2.*; +import com.thetransactioncompany.jsonrpc2.server.*; +import org.ethereum.android.jsonrpc.light.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.light.whisper.FilterManager; +import org.ethereum.facade.Ethereum; + +import java.util.List; + +public class shh_getMessages extends JsonRpcServerMethod { + + public shh_getMessages(Ethereum ethereum) { + super(ethereum); + } + + protected JSONRPC2Response worker(JSONRPC2Request req, MessageContext ctx) { + + List params = req.getPositionalParams(); + if (params.size() != 1) { + return new JSONRPC2Response(JSONRPC2Error.INVALID_PARAMS, req.getID()); + } else { + int id = jsToInt((String)params.get(0)); + JSONRPC2Response res = new JSONRPC2Response(FilterManager.getInstance().toJSAll(id), req.getID()); + return res; + } + + } +} \ No newline at end of file diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_hasIdentity.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_hasIdentity.java new file mode 100644 index 00000000..1252051f --- /dev/null +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_hasIdentity.java @@ -0,0 +1,32 @@ +package org.ethereum.android.jsonrpc.light.method; + +import com.thetransactioncompany.jsonrpc2.*; +import com.thetransactioncompany.jsonrpc2.server.*; +import org.ethereum.android.jsonrpc.light.JsonRpcServerMethod; +import org.ethereum.facade.Ethereum; + +import java.util.List; + +/* +TODO: done it when shh will be ready in -core +*/ +public class shh_hasIdentity extends JsonRpcServerMethod { + + public shh_hasIdentity(Ethereum ethereum) { + super(ethereum); + } + + protected JSONRPC2Response worker(JSONRPC2Request req, MessageContext ctx) { + + List params = req.getPositionalParams(); + if (params.size() != 1) { + return new JSONRPC2Response(JSONRPC2Error.INVALID_PARAMS, req.getID()); + } else { + byte[] identity = jsToAddress((String)params.get(0)); + + JSONRPC2Response res = new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND, req.getID()); + return res; + } + + } +} \ No newline at end of file diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_newFilter.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_newFilter.java new file mode 100644 index 00000000..43c6acfe --- /dev/null +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_newFilter.java @@ -0,0 +1,35 @@ +package org.ethereum.android.jsonrpc.light.method; + +import com.thetransactioncompany.jsonrpc2.*; +import com.thetransactioncompany.jsonrpc2.server.*; + +import net.minidev.json.JSONObject; + +import org.ethereum.android.jsonrpc.light.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.light.whisper.Filter; +import org.ethereum.android.jsonrpc.light.whisper.FilterManager; +import org.ethereum.facade.Ethereum; + +import java.util.List; + +public class shh_newFilter extends JsonRpcServerMethod { + + public shh_newFilter(Ethereum ethereum) { + super(ethereum); + } + + protected JSONRPC2Response worker(JSONRPC2Request req, MessageContext ctx) { + + List params = req.getPositionalParams(); + if (params.size() != 1) { + return new JSONRPC2Response(JSONRPC2Error.INVALID_PARAMS, req.getID()); + } else { + JSONObject obj = (JSONObject)params.get(0); + int id = FilterManager.getInstance().addFilter(new Filter(obj)); + String tmp = "0x" + Integer.toHexString(id); + JSONRPC2Response res = new JSONRPC2Response(tmp, req.getID()); + return res; + } + + } +} \ No newline at end of file diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_newGroup.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_newGroup.java new file mode 100644 index 00000000..e2c39b6e --- /dev/null +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_newGroup.java @@ -0,0 +1,23 @@ +package org.ethereum.android.jsonrpc.light.method; + +import com.thetransactioncompany.jsonrpc2.*; +import com.thetransactioncompany.jsonrpc2.server.*; +import org.ethereum.android.jsonrpc.light.JsonRpcServerMethod; +import org.ethereum.facade.Ethereum; + +/* +TODO: not present clear specification for this method, also cpp and go version not provide it. +*/ +public class shh_newGroup extends JsonRpcServerMethod { + + public shh_newGroup(Ethereum ethereum) { + super(ethereum); + } + + protected JSONRPC2Response worker(JSONRPC2Request req, MessageContext ctx) { + + JSONRPC2Response res = new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND, req.getID()); + return res; + + } +} \ No newline at end of file diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_newIdentity.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_newIdentity.java new file mode 100644 index 00000000..d9f776c2 --- /dev/null +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_newIdentity.java @@ -0,0 +1,23 @@ +package org.ethereum.android.jsonrpc.light.method; + +import com.thetransactioncompany.jsonrpc2.*; +import com.thetransactioncompany.jsonrpc2.server.*; +import org.ethereum.android.jsonrpc.light.JsonRpcServerMethod; +import org.ethereum.facade.Ethereum; + +/* +TODO: done it when shh will be ready in -core +*/ +public class shh_newIdentity extends JsonRpcServerMethod { + + public shh_newIdentity(Ethereum ethereum) { + super(ethereum); + } + + protected JSONRPC2Response worker(JSONRPC2Request req, MessageContext ctx) { + + JSONRPC2Response res = new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND, req.getID()); + return res; + + } +} \ No newline at end of file diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_post.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_post.java new file mode 100644 index 00000000..ae7d2925 --- /dev/null +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_post.java @@ -0,0 +1,60 @@ +package org.ethereum.android.jsonrpc.light.method; + +import com.thetransactioncompany.jsonrpc2.*; +import com.thetransactioncompany.jsonrpc2.server.*; + +import net.minidev.json.JSONArray; +import net.minidev.json.JSONObject; + +import org.ethereum.android.jsonrpc.light.JsonRpcServerMethod; +import org.ethereum.facade.Ethereum; +import org.spongycastle.util.encoders.Hex; + +import java.util.ArrayList; +import java.util.List; + +/* +TODO: done it when shh will be ready in -core +*/ +public class shh_post extends JsonRpcServerMethod { + + public shh_post (Ethereum ethereum) { + super(ethereum); + } + + protected JSONRPC2Response worker(JSONRPC2Request req, MessageContext ctx) { + + List params = req.getPositionalParams(); + if (params.size() != 1) { + return new JSONRPC2Response(JSONRPC2Error.INVALID_PARAMS, req.getID()); + } else { + JSONObject obj = (JSONObject)params.get(0); + + byte[] from = null; + if (obj.containsKey("from")) + from = jsToAddress((String)obj.get("from")); + + byte[] to = null; + if (obj.containsKey("to")) + to = jsToAddress((String)obj.get("to")); + + ArrayList topics = new ArrayList<>(); + for (Object item : (JSONArray)obj.get("topics")) { + if (item instanceof String) { + topics.add(jsToAddress((String)item)); + } + } + + byte[] payload = jsToAddress((String)obj.get("payload")); + + int priority = jsToInt((String) obj.get("priority")); + + int ttl = jsToInt((String)obj.get("ttl")); + +//TODO: implement after Adrian merge with dev + + JSONRPC2Response res = new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND, req.getID()); + return res; + } + } +} \ No newline at end of file diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_uninstallFilter.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_uninstallFilter.java new file mode 100644 index 00000000..d3094d01 --- /dev/null +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_uninstallFilter.java @@ -0,0 +1,29 @@ +package org.ethereum.android.jsonrpc.light.method; + +import com.thetransactioncompany.jsonrpc2.*; +import com.thetransactioncompany.jsonrpc2.server.*; +import org.ethereum.android.jsonrpc.light.JsonRpcServerMethod; +import org.ethereum.android.jsonrpc.light.whisper.FilterManager; +import org.ethereum.facade.Ethereum; + +import java.util.List; + +public class shh_uninstallFilter extends JsonRpcServerMethod { + + public shh_uninstallFilter(Ethereum ethereum) { + super(ethereum); + } + + protected JSONRPC2Response worker(JSONRPC2Request req, MessageContext ctx) { + + List params = req.getPositionalParams(); + if (params.size() != 1) { + return new JSONRPC2Response(JSONRPC2Error.INVALID_PARAMS, req.getID()); + } else { + int id = jsToInt((String)params.get(0)); + JSONRPC2Response res = new JSONRPC2Response(FilterManager.getInstance().uninstallFilter(id), req.getID()); + return res; + } + + } +} \ No newline at end of file diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_version.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_version.java new file mode 100644 index 00000000..c3ea6e0f --- /dev/null +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/method/shh_version.java @@ -0,0 +1,22 @@ +package org.ethereum.android.jsonrpc.light.method; + +import com.thetransactioncompany.jsonrpc2.*; +import com.thetransactioncompany.jsonrpc2.server.*; +import org.ethereum.android.jsonrpc.light.JsonRpcServerMethod; +import org.ethereum.facade.Ethereum; +import org.ethereum.net.shh.ShhHandler; + +public class shh_version extends JsonRpcServerMethod { + + public shh_version (Ethereum ethereum) { + super(ethereum); + } + + protected JSONRPC2Response worker(JSONRPC2Request req, MessageContext ctx) { + + String tmp = "" + ShhHandler.VERSION; + JSONRPC2Response res = new JSONRPC2Response(tmp, req.getID()); + return res; + + } +} \ No newline at end of file diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/whisper/Filter.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/whisper/Filter.java new file mode 100644 index 00000000..7d318f43 --- /dev/null +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/whisper/Filter.java @@ -0,0 +1,86 @@ +package org.ethereum.android.jsonrpc.light.whisper; + +import net.minidev.json.JSONArray; +import net.minidev.json.JSONObject; + +import org.ethereum.facade.Ethereum; +import org.ethereum.net.shh.ShhMessage; +import org.spongycastle.util.encoders.Hex; + +import java.util.ArrayList; + +/* +TODO: replace ShhMessage with real class when Roman finish Shh. +*/ +public class Filter { + protected int id; + protected ArrayList messages; + byte[] to = null; + boolean isWildcard = false; + ArrayList> or; + ArrayList and; + int sendID = 0; + + public Filter (JSONObject data) { + messages = new ArrayList(); + if (data.containsKey("to")) { + to = Hex.decode(((String)data.get("to")).substring(2)); + } + JSONArray topics = (JSONArray)data.get("topics"); + for (Object item : topics) { + if (item == null) { + isWildcard = true; + } + else if (item instanceof JSONArray) { + ArrayList tmp = new ArrayList(); + for (Object ori : (JSONArray)item) { + if (ori instanceof String) { + tmp.add(Hex.decode(((String)ori).substring(2))); + } + } + or.add(tmp); + } else if (item instanceof String) { + and.add(Hex.decode(((String)item).substring(2))); + } + } + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public void processEvent(Object data) { +//TODO: parse incomming data when we will know what comes. + } + + public JSONArray toJS() { + JSONArray res = new JSONArray(); + synchronized (messages) { + for (int i = sendID; i < messages.size(); i++) { + res.add(toJS(messages.get(i))); + } + sendID = messages.size(); + } + return res; + } + + public JSONArray toJSAll() { + JSONArray res = new JSONArray(); + synchronized (messages) { + for (int i = 0; i < messages.size(); i++) { + res.add(toJS(messages.get(i))); + } + sendID = messages.size(); + } + return res; + } + + private JSONObject toJS (ShhMessage data) { + JSONObject res = new JSONObject(); + return res; + } +} diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/whisper/FilterManager.java b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/whisper/FilterManager.java new file mode 100644 index 00000000..ab6c2227 --- /dev/null +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/jsonrpc/light/whisper/FilterManager.java @@ -0,0 +1,80 @@ +package org.ethereum.android.jsonrpc.light.whisper; + +import net.minidev.json.JSONArray; + +import org.ethereum.facade.Ethereum; + +import java.util.Hashtable; +import java.util.Map; +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.TimeUnit; + +/* +This class must receive notification from -core about new whisper message. Right now I not see the way to do that. +TODO: ask advice from Roman about how to send notification to this class. +*/ +public class FilterManager { + + protected static FilterManager instance = null; + + public static FilterManager getInstance() { + if (instance == null) + instance = new FilterManager(); + return instance; + } + + protected Hashtable filters; + protected int last_id = 0; + + private FilterManager() { + filters = new Hashtable(); + } + + public void processEvent(Object data) { + synchronized (filters) { + for (Map.Entry item : filters.entrySet()) { + item.getValue().processEvent(data); + } + } + } + + public int addFilter(Filter filter) { + filter.setId(++last_id); + filters.put(filter.getId(), filter); + return filter.getId(); + } + + public Filter getFilter(int id) { + if (filters.containsKey(id)) { + return filters.get(id); + } + return null; + } + + public boolean uninstallFilter(int id) { + synchronized (filters) { + if (!filters.containsKey(id)) + return false; + filters.remove(id); + } + return true; + } + + public JSONArray toJS(int id) { + synchronized (filters) { + if (!filters.containsKey(id)) + return null; + return filters.get(id).toJS(); + } + } + + public JSONArray toJSAll(int id) { + synchronized (filters) { + if (!filters.containsKey(id)) + return null; + return filters.get(id).toJSAll(); + } + } + +} \ No newline at end of file diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/service/EthereumAidlService.java b/ethereumj-core-android/src/main/java/org/ethereum/android/service/EthereumAidlService.java index adfe5e80..505d0807 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/service/EthereumAidlService.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/service/EthereumAidlService.java @@ -62,7 +62,8 @@ public class EthereumAidlService extends EthereumService { public void startJsonRpcServer() throws RemoteException { - jsonRpcServer = new JsonRpcServer(ethereum); + //TODO: add here switch between full and light version + jsonRpcServer = new org.ethereum.android.jsonrpc.light.JsonRpcServer(ethereum); } public void getLog(IAsyncCallback callback) throws RemoteException { diff --git a/ethereumj-core-android/src/main/java/org/ethereum/android/service/EthereumRemoteService.java b/ethereumj-core-android/src/main/java/org/ethereum/android/service/EthereumRemoteService.java index 35552e42..bc71288e 100644 --- a/ethereumj-core-android/src/main/java/org/ethereum/android/service/EthereumRemoteService.java +++ b/ethereumj-core-android/src/main/java/org/ethereum/android/service/EthereumRemoteService.java @@ -302,7 +302,8 @@ public class EthereumRemoteService extends EthereumService { protected void startJsonRpc(Message message) { // TODO: Maybe send back if it started succesfully ? - jsonRpcServer = new JsonRpcServer(ethereum); + //TODO: add here switch between full and light version + jsonRpcServer = new org.ethereum.android.jsonrpc.light.JsonRpcServer(ethereum); try { jsonRpcServer.start(); logger.info("Started json rpc server!");