diff --git a/ethereumj-core/src/main/java/org/ethereum/facade/Ethereum.java b/ethereumj-core/src/main/java/org/ethereum/facade/Ethereum.java index 9dd00be6..3222875c 100644 --- a/ethereumj-core/src/main/java/org/ethereum/facade/Ethereum.java +++ b/ethereumj-core/src/main/java/org/ethereum/facade/Ethereum.java @@ -1,12 +1,14 @@ package org.ethereum.facade; import org.ethereum.core.Block; +import org.ethereum.core.Transaction; import org.ethereum.listener.EthereumListener; import org.ethereum.net.client.ClientPeer; import org.ethereum.net.client.PeerData; import java.net.InetAddress; import java.util.Set; +import java.util.concurrent.Future; /** * www.ethereumJ.com @@ -77,6 +79,36 @@ public interface Ethereum { public void close(); + /** + * Factory for general transaction + * + * + * @param nonce - account nonce, based on number of transaction submited by + * this account + * @param gasPrice - gas price bid by miner , the user ask can be based on + * lastr submited block + * @param gas - the quantity of gas requested for the transaction + * @param recieveAddress - the target address of the transaction + * @param value - the ether value of the transaction + * @param data - can be init procedure for creational transaction, + * also msg data for invoke transaction for only value + * transactions this one is empty. + * @return newly created transaction + */ + public Transaction createTransaction(byte[] nonce, byte[] gasPrice, byte[] gas, + byte[] recieveAddress, byte[] value, byte[] data ); + + + /** + * + * @param transaction - submit transaction to the net, return + * option to wait for net return this transaction + * as approved + * @return + */ + public Future submitTransaction(Transaction transaction); + + // 1. WorldManager.getInstance().getWallet(); // 2. // is blockchain still loading - if buffer is not empty diff --git a/ethereumj-core/src/main/java/org/ethereum/facade/EthereumImpl.java b/ethereumj-core/src/main/java/org/ethereum/facade/EthereumImpl.java index 8a6e845b..e2685431 100644 --- a/ethereumj-core/src/main/java/org/ethereum/facade/EthereumImpl.java +++ b/ethereumj-core/src/main/java/org/ethereum/facade/EthereumImpl.java @@ -3,11 +3,15 @@ package org.ethereum.facade; import java.net.InetAddress; import java.util.HashSet; import java.util.Set; +import java.util.concurrent.Future; +import org.ethereum.core.Transaction; import org.ethereum.listener.EthereumListener; import org.ethereum.manager.WorldManager; import org.ethereum.net.client.ClientPeer; import org.ethereum.net.client.PeerData; +import org.ethereum.net.submit.TransactionExecutor; +import org.ethereum.net.submit.TransactionTask; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -161,6 +165,27 @@ public class EthereumImpl implements Ethereum { } + @Override + public Transaction createTransaction(byte[] nonce, byte[] gasPrice, byte[] gas, + byte[] recieveAddress, byte[] value, byte[] data ){ + + Transaction tx = new Transaction(nonce, gasPrice, gas, + recieveAddress, value, data); + + return tx; + } + + + @Override + public Future submitTransaction(Transaction transaction){ + + TransactionTask transactionTask = new TransactionTask(transaction); + Future future = TransactionExecutor.instance.submitTransaction(transactionTask); + + return future; + } + + // public Future submitTransaction() -- wait for approve (like in wallet dialog) } diff --git a/ethereumj-studio/src/main/java/org/ethereum/gui/DialogWorker.java b/ethereumj-studio/src/main/java/org/ethereum/gui/DialogWorker.java index 8d02a785..b2192b7d 100644 --- a/ethereumj-studio/src/main/java/org/ethereum/gui/DialogWorker.java +++ b/ethereumj-studio/src/main/java/org/ethereum/gui/DialogWorker.java @@ -35,8 +35,8 @@ public class DialogWorker extends SwingWorker { @Override protected Transaction doInBackground() throws Exception { - TransactionTask transactionTask = new TransactionTask(tx); - Future future = TransactionExecutor.instance.submitTransaction(transactionTask); + + Future future = UIEthereumManager.ethereum.submitTransaction(tx); dialog.infoStatusMsg("Transaction sent to the network, waiting for approve"); try {