diff --git a/src/main/java/blockchains/iaas/uni/stuttgart/de/adaptation/adapters/bitcoin/BitcoinAdapter.java b/src/main/java/blockchains/iaas/uni/stuttgart/de/adaptation/adapters/bitcoin/BitcoinAdapter.java index f42a2ea..f3b9a12 100644 --- a/src/main/java/blockchains/iaas/uni/stuttgart/de/adaptation/adapters/bitcoin/BitcoinAdapter.java +++ b/src/main/java/blockchains/iaas/uni/stuttgart/de/adaptation/adapters/bitcoin/BitcoinAdapter.java @@ -18,6 +18,7 @@ import blockchains.iaas.uni.stuttgart.de.adaptation.BlockchainAdapterFactory; import blockchains.iaas.uni.stuttgart.de.adaptation.adapters.AbstractAdapter; +import blockchains.iaas.uni.stuttgart.de.adaptation.utils.PoWConfidenceCalculator; import blockchains.iaas.uni.stuttgart.de.exceptions.BlockchainNodeUnreachableException; import blockchains.iaas.uni.stuttgart.de.exceptions.InvalidTransactionException; import blockchains.iaas.uni.stuttgart.de.model.Block; @@ -184,11 +185,12 @@ public void blockDetected(com.neemre.btcdcli4j.core.domain.Block block) { } @Override - public CompletableFuture submitTransaction(long waitFor, String receiverAddress, BigDecimal value) throws InvalidTransactionException { + public CompletableFuture submitTransaction(String receiverAddress, BigDecimal value, double requiredConfidence) throws InvalidTransactionException { try { final BigDecimal valueBitcoins = BitcoinUtils.satoshiToBitcoin(value); final String transactionId = client.sendToAddress(receiverAddress, valueBitcoins); CompletableFuture result; + long waitFor = ((PoWConfidenceCalculator) this.confidenceCalculator).getEquivalentBlockDepth(requiredConfidence); if (waitFor > 0) { result = subscribeForTxEvent(transactionId, waitFor, TransactionState.NOT_FOUND, TransactionState.CONFIRMED); @@ -209,9 +211,10 @@ public CompletableFuture submitTransaction(long waitFor, String rec } @Override - public Observable receiveTransactions(long waitFor, String senderId) { + public Observable receiveTransactions(String senderId, double requiredConfidence) { final PublishSubject subject = PublishSubject.create(); + long waitFor = ((PoWConfidenceCalculator) this.confidenceCalculator).getEquivalentBlockDepth(requiredConfidence); final WalletListener listener = new WalletListener() { @Override public void walletChanged(com.neemre.btcdcli4j.core.domain.Transaction transaction) { @@ -252,7 +255,8 @@ public void walletChanged(com.neemre.btcdcli4j.core.domain.Transaction transacti } @Override - public CompletableFuture ensureTransactionState(long waitFor, String transactionId) { + public CompletableFuture ensureTransactionState(String transactionId, double requiredConfidence) { + long waitFor = ((PoWConfidenceCalculator) this.confidenceCalculator).getEquivalentBlockDepth(requiredConfidence); return subscribeForTxEvent(transactionId, waitFor, TransactionState.NOT_FOUND, TransactionState.CONFIRMED) .thenApply(Transaction::getState); } diff --git a/src/main/java/blockchains/iaas/uni/stuttgart/de/adaptation/adapters/ethereum/EthereumAdapter.java b/src/main/java/blockchains/iaas/uni/stuttgart/de/adaptation/adapters/ethereum/EthereumAdapter.java index a9d368e..3816a4a 100644 --- a/src/main/java/blockchains/iaas/uni/stuttgart/de/adaptation/adapters/ethereum/EthereumAdapter.java +++ b/src/main/java/blockchains/iaas/uni/stuttgart/de/adaptation/adapters/ethereum/EthereumAdapter.java @@ -175,7 +175,7 @@ else if (e.getCause() instanceof RuntimeException) } @Override - public CompletableFuture submitTransaction(long waitFor, String receiverAddress, BigDecimal value) + public CompletableFuture submitTransaction(String receiverAddress, BigDecimal value, double requiredConfidence) throws InvalidTransactionException { if (credentials == null) { log.error("Credentials are not set for the Ethereum user"); @@ -183,6 +183,7 @@ public CompletableFuture submitTransaction(long waitFor, String rec } try { + final long waitFor = ((PoWConfidenceCalculator)this.confidenceCalculator).getEquivalentBlockDepth(requiredConfidence); return Transfer.sendFunds(web3j, credentials, receiverAddress, value, Convert.Unit.WEI) // 1 wei = 10^-18 Ether .sendAsync() // when an exception (e.g., ConnectException happens), the following is skipped @@ -200,12 +201,13 @@ public CompletableFuture submitTransaction(long waitFor, String rec } @Override - public Observable receiveTransactions(long waitFor, String senderId) { + public Observable receiveTransactions(String senderId, double requiredConfidence) { if (credentials == null) { log.error("Credentials are not set for the Ethereum user"); throw new NullPointerException("Credentials are not set for the Ethereum user"); } + final long waitFor = ((PoWConfidenceCalculator)this.confidenceCalculator).getEquivalentBlockDepth(requiredConfidence); final String myAddress = credentials.getAddress(); final PublishSubject result = PublishSubject.create(); final Disposable newTransactionObservable = web3j.transactionFlowable().subscribe(tx -> { @@ -226,7 +228,8 @@ public Observable receiveTransactions(long waitFor, String senderId } @Override - public CompletableFuture ensureTransactionState(long waitFor, String transactionId) { + public CompletableFuture ensureTransactionState(String transactionId, double requiredConfidence) { + final long waitFor = ((PoWConfidenceCalculator)this.confidenceCalculator).getEquivalentBlockDepth(requiredConfidence); // only monitor the transition into the CONFIRMED state or the NOT_FOUND state return subscribeForTxEvent(transactionId, waitFor, TransactionState.CONFIRMED, TransactionState.NOT_FOUND) .thenApply(Transaction::getState) diff --git a/src/main/java/blockchains/iaas/uni/stuttgart/de/adaptation/adapters/fabric/FabricAdapter.java b/src/main/java/blockchains/iaas/uni/stuttgart/de/adaptation/adapters/fabric/FabricAdapter.java index 759a773..da77b0e 100644 --- a/src/main/java/blockchains/iaas/uni/stuttgart/de/adaptation/adapters/fabric/FabricAdapter.java +++ b/src/main/java/blockchains/iaas/uni/stuttgart/de/adaptation/adapters/fabric/FabricAdapter.java @@ -69,17 +69,21 @@ public void setConnectionProfilePath(String connectionProfilePath) { } @Override - public CompletableFuture submitTransaction(long waitFor, String receiverAddress, BigDecimal value) throws InvalidTransactionException, MethodNotSupportedException { + public CompletableFuture submitTransaction(String receiverAddress, BigDecimal value, double requiredConfidence + + + + ) throws InvalidTransactionException, MethodNotSupportedException { throw new MethodNotSupportedException("Fabric does not support submitting monetary transactions!"); } @Override - public Observable receiveTransactions(long waitFor, String senderId) throws MethodNotSupportedException { + public Observable receiveTransactions(String senderId, double requiredConfidence) throws MethodNotSupportedException { throw new MethodNotSupportedException("Fabric does not support receiving monetary transactions!"); } @Override - public CompletableFuture ensureTransactionState(long waitFor, String transactionId) throws MethodNotSupportedException { + public CompletableFuture ensureTransactionState(String transactionId, double requiredConfidence) throws MethodNotSupportedException { throw new MethodNotSupportedException("Fabric does not support monetary transactions!"); } diff --git a/src/main/java/blockchains/iaas/uni/stuttgart/de/adaptation/interfaces/BlockchainAdapter.java b/src/main/java/blockchains/iaas/uni/stuttgart/de/adaptation/interfaces/BlockchainAdapter.java index 7c71047..817ff8e 100644 --- a/src/main/java/blockchains/iaas/uni/stuttgart/de/adaptation/interfaces/BlockchainAdapter.java +++ b/src/main/java/blockchains/iaas/uni/stuttgart/de/adaptation/interfaces/BlockchainAdapter.java @@ -6,7 +6,6 @@ import blockchains.iaas.uni.stuttgart.de.exceptions.InvalidTransactionException; import blockchains.iaas.uni.stuttgart.de.model.SmartContractFunctionArgument; -import blockchains.iaas.uni.stuttgart.de.model.LinearChainTransaction; import blockchains.iaas.uni.stuttgart.de.model.Transaction; import blockchains.iaas.uni.stuttgart.de.model.TransactionState; import io.reactivex.Observable; @@ -27,9 +26,9 @@ public interface BlockchainAdapter { /** * submits a transaction to the blockchain that transfers an amount of the native crypto-currency to some address. * - * @param waitFor the number of block-confirmations to receive before emitting a result - * @param receiverAddress the address of the receiver - * @param value the value to transfer measured in the most granular unit, e.g., wei, satoshi + * @param requiredConfidence the degree-of-confidence required to be achieved before sending a callback message to the invoker. + * @param receiverAddress the address of the receiver + * @param value the value to transfer measured in the most granular unit, e.g., wei, satoshi * @return a completable future that emits a summary of the submitted transaction. * The future should normally complete with a transaction of the state CONFIRMED if the desired number of block-confirmations were received, * and with a transaction of the state NOT_FOUND if the transaction was committed to a block and then orphaned and invalidated. @@ -38,27 +37,27 @@ public interface BlockchainAdapter { * @throws InvalidTransactionException if the submitted transaction causes an immediate validation error, e.g., * insufficient funds, or incorrect receiverAddress (this seems to never be thrown) */ - CompletableFuture submitTransaction(long waitFor, String receiverAddress, BigDecimal value) throws InvalidTransactionException, MethodNotSupportedException; + CompletableFuture submitTransaction(String receiverAddress, BigDecimal value, double requiredConfidence) throws InvalidTransactionException, MethodNotSupportedException; /** * receives transactions addressed to us (potentially from a specific sender) * - * @param waitFor the number of block-confirmations to be detected before emitting a result - * @param senderId an optional address of the sender. If specified, only transactions from this sender are considered + * @param requiredConfidence the degree-of-confidence required to be achieved before sending a callback message to the invoker. + * @param senderId an optional address of the sender. If specified, only transactions from this sender are considered * @return an observable that emits a summary of the received transaction whenever one is detected */ - Observable receiveTransactions(long waitFor, String senderId) throws MethodNotSupportedException; + Observable receiveTransactions(String senderId, double requiredConfidence) throws MethodNotSupportedException; /** * ensures that a transaction receives enough block-confirmations * - * @param waitFor the number of block-confirmations to be detected before considering the transaction to be confirmed - * @param transactionId the hash of the transaction we want to monitor + * @param requiredConfidence the degree-of-confidence required to be achieved before sending a callback message to the invoker. + * @param transactionId the hash of the transaction we want to monitor * @return a completable future that emits the new state of the transaction (either COFIRMED in case the desired * number of block-confirmations got received, or NOT_FOUND if the transaction got invalidated). * The future should exceptionally complete with an exception of type BlockchainNodeUnreachableException if the blockchain node is not reachable */ - CompletableFuture ensureTransactionState(long waitFor, String transactionId) throws MethodNotSupportedException; + CompletableFuture ensureTransactionState(String transactionId, double requiredConfidence) throws MethodNotSupportedException; /** * detects that the given transaction got orphaned @@ -70,5 +69,14 @@ public interface BlockchainAdapter { */ CompletableFuture detectOrphanedTransaction(String transactionId) throws MethodNotSupportedException; + /** + * invokes a smart contract function + * + * @param functionIdentifier the scip identifier of the function to be invoked + * @param parameters the arguments to be passed to the function being invoked + * @param requiredConfidence the degree-of-confidence required to be achieved before sending a callback message to the invoker. + * @return a completable future that emits a new transaction object holding the result of the invocation. + * @throws MethodNotSupportedException if the underlying blockchain system does not support smart contracts. + */ CompletableFuture invokeSmartContract(String functionIdentifier, List parameters, double requiredConfidence) throws MethodNotSupportedException; } diff --git a/src/main/java/blockchains/iaas/uni/stuttgart/de/management/BlockchainManager.java b/src/main/java/blockchains/iaas/uni/stuttgart/de/management/BlockchainManager.java index a0cbcd5..d74756b 100644 --- a/src/main/java/blockchains/iaas/uni/stuttgart/de/management/BlockchainManager.java +++ b/src/main/java/blockchains/iaas/uni/stuttgart/de/management/BlockchainManager.java @@ -30,7 +30,6 @@ import blockchains.iaas.uni.stuttgart.de.management.model.Subscription; import blockchains.iaas.uni.stuttgart.de.management.model.SubscriptionType; import blockchains.iaas.uni.stuttgart.de.model.SmartContractFunctionArgument; -import blockchains.iaas.uni.stuttgart.de.model.LinearChainTransaction; import blockchains.iaas.uni.stuttgart.de.model.Transaction; import blockchains.iaas.uni.stuttgart.de.model.TransactionState; import io.reactivex.disposables.Disposable; @@ -49,20 +48,20 @@ public class BlockchainManager { * INVALID: the submitted transaction faild validation at the node * CONFIRMED (along with the tx itself): the submitted transaction received the desired number of block-confirmations * - * @param subscriptionId supplied by the remote application as a means for correlation - * @param to the address of the transaction recipient - * @param value the value of the transaction - * @param blockchainId the blockchain network id - * @param waitFor the number of block-confirmations to wait for until determining the transaction is durably persisted - * @param epUrl the url of the endpoint to send the callback message to + * @param subscriptionId supplied by the remote application as a means for correlation + * @param to the address of the transaction recipient + * @param value the value of the transaction + * @param blockchainId the blockchain network id + * @param requiredConfidence the degree-of-confidence required to be achieved before sending a callback message to the invoker. + * @param epUrl the url of the endpoint to send the callback message to */ public void submitNewTransaction(final String subscriptionId, final String to, final BigInteger value, - final String blockchainId, final long waitFor, final String epUrl) { + final String blockchainId, final double requiredConfidence, final String epUrl) { final AdapterManager adapterManager = AdapterManager.getInstance(); try { final BlockchainAdapter adapter = adapterManager.getAdapter(blockchainId); - final CompletableFuture future = adapter.submitTransaction(waitFor, to, new BigDecimal(value)); + final CompletableFuture future = adapter.submitTransaction(to, new BigDecimal(value), requiredConfidence); // This happens when a communication error, or an error with the tx exist. future. thenAccept(tx -> { @@ -116,19 +115,19 @@ else if (e.getCause() instanceof InvalidTransactionException) *

* CONFIRMED * - * @param subscriptionId supplied by the remote application as a means for correlation - * @param from an optional parameter.If supplied, it indicates the sending address of the transactions we are interested - * in. - * @param blockchainId the blockchain network id - * @param waitFor the number of block-confirmations to wait for until determining the transaction is durably persisted - * @param epUrl the url of the endpoint to send the callback message to + * @param subscriptionId supplied by the remote application as a means for correlation + * @param from an optional parameter.If supplied, it indicates the sending address of the transactions we are interested + * in. + * @param blockchainId the blockchain network id + * @param requiredConfidence the degree-of-confidence required to be achieved before sending a callback message to the invoker. + * @param epUrl the url of the endpoint to send the callback message to */ public void receiveTransactions(final String subscriptionId, final String from, final String blockchainId, - final long waitFor, final String epUrl) { + final double requiredConfidence, final String epUrl) { final AdapterManager adapterManager = AdapterManager.getInstance(); try { final BlockchainAdapter adapter = adapterManager.getAdapter(blockchainId); - final Disposable subscription = adapter.receiveTransactions(waitFor, from) + final Disposable subscription = adapter.receiveTransactions(from, requiredConfidence) .doFinally(() -> { // remove subscription from subscription list SubscriptionManager.getInstance().removeSubscription(subscriptionId); @@ -164,19 +163,19 @@ public void receiveTransactions(final String subscriptionId, final String from, * UNKNOWN: the blockchain network is not recognized, or connection to node is not possible. * CONFIRMED: the submitted transaction received the desired number of block-confirmations * - * @param subscriptionId supplied by the remote application as a means for correlation - * @param from an optional parameter.If supplied, it indicates the sending address of the transactions we are interested - * in. - * @param blockchainId the blockchain network id - * @param waitFor the number of block-confirmations to wait for until determining the transaction is durably persisted - * @param epUrl the url of the endpoint to send the callback message to + * @param subscriptionId supplied by the remote application as a means for correlation + * @param from an optional parameter.If supplied, it indicates the sending address of the transactions we are interested + * in. + * @param blockchainId the blockchain network id + * @param requiredConfidence the degree-of-confidence required to be achieved before sending a callback message to the invoker. + * @param epUrl the url of the endpoint to send the callback message to */ public void receiveTransaction(final String subscriptionId, final String from, final String blockchainId, - final long waitFor, final String epUrl) { + final double requiredConfidence, final String epUrl) { final AdapterManager adapterManager = AdapterManager.getInstance(); try { final BlockchainAdapter adapter = adapterManager.getAdapter(blockchainId); - final Disposable subscription = adapter.receiveTransactions(waitFor, from) + final Disposable subscription = adapter.receiveTransactions(from, requiredConfidence) .doFinally(() -> { // remove subscription from subscription list SubscriptionManager.getInstance().removeSubscription(subscriptionId); @@ -281,14 +280,15 @@ public void detectOrphanedTransaction(final String subscriptionId, final String * @param subscriptionId supplied by the remote application as a means for correlation * @param transactionId the hash of the transaction to monitor * @param blockchainId the blockchain network id + * @param requiredConfidence the degree-of-confidence required to be achieved before sending a callback message to the invoker. * @param epUrl the url of the endpoint to send the callback message to */ public void ensureTransactionState(final String subscriptionId, final String transactionId, final String blockchainId, - final long waitFor, final String epUrl) { + final double requiredConfidence, final String epUrl) { final AdapterManager adapterManager = AdapterManager.getInstance(); try { final BlockchainAdapter adapter = adapterManager.getAdapter(blockchainId); - final CompletableFuture future = adapter.ensureTransactionState(waitFor, transactionId); + final CompletableFuture future = adapter.ensureTransactionState(transactionId, requiredConfidence); future. thenAccept(txState -> { if (txState != null) { @@ -335,16 +335,17 @@ public void ensureTransactionState(final String subscriptionId, final String tra * INVALID: the submitted transaction failed validation at the node (if a transaction was required) * CONFIRMED (along with the tx itself): the submitted transaction received the desired number of block-confirmations * or the result returned from a read-only smart contract function. - * @param subscriptionId upplied by the remote application as a means for correlation - * @param scip a URI following the Smart Contract Invocation Protocol scheme representing the smart contract function to be invoked - * @param arguments the arguments to be passed to the smart contract function - * @param minimumConfidence the minimum confidence that the submitted transaction must reach before returning a CONFIRMED response (percentage) - * @param epUrl the url of the endpoint to send the callback message to + * + * @param subscriptionId upplied by the remote application as a means for correlation + * @param scip a URI following the Smart Contract Invocation Protocol scheme representing the smart contract function to be invoked + * @param arguments the arguments to be passed to the smart contract function + * @param requiredConfidence the minimum confidence that the submitted transaction must reach before returning a CONFIRMED response (percentage) + * @param epUrl the url of the endpoint to send the callback message to */ public void invokeSmartContractFunction(final String subscriptionId, final String scip, final List arguments, - final double minimumConfidence, final String epUrl) { + final double requiredConfidence, final String epUrl) { final AdapterManager adapterManager = AdapterManager.getInstance(); - final double minimumConfidenceAsProbability = minimumConfidence / 100.0; + final double minimumConfidenceAsProbability = requiredConfidence / 100.0; try { final ScipParser parser = ScipParser.parse(scip); diff --git a/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/Controllers/EnsureTransactionStateController.java b/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/Controllers/EnsureTransactionStateController.java index a204605..4644d44 100644 --- a/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/Controllers/EnsureTransactionStateController.java +++ b/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/Controllers/EnsureTransactionStateController.java @@ -36,7 +36,7 @@ public Response get(){ public Response ensureTransactionState(EnsureTransactionStateRequest request){ final BlockchainManager manager = new BlockchainManager(); manager.ensureTransactionState(request.getSubscriptionId(), request.getTxId(), request.getBlockchainId(), - request.getWaitFor(), request.getEpUrl()); + request.getRequiredConfidence(), request.getEpUrl()); return Response.created(UriUtil.generateSubResourceURI(this.uriInfo, request.getSubscriptionId(), false)) .build(); diff --git a/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/Controllers/ReceiveTransactionController.java b/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/Controllers/ReceiveTransactionController.java index 8793851..44d784f 100644 --- a/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/Controllers/ReceiveTransactionController.java +++ b/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/Controllers/ReceiveTransactionController.java @@ -39,7 +39,7 @@ public Response get(){ public Response receiveTransaction(ReceiveTransactionsRequest request){ final BlockchainManager manager = new BlockchainManager(); manager.receiveTransaction(request.getSubscriptionId(), request.getFrom(), request.getBlockchainId(), - request.getWaitFor(), request.getEpUrl()); + request.getRequiredConfidence(), request.getEpUrl()); return Response.created(UriUtil.generateSubResourceURI(this.uriInfo, request.getSubscriptionId(), false)) .build(); diff --git a/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/Controllers/ReceiveTransactionsController.java b/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/Controllers/ReceiveTransactionsController.java index 0aa5cc4..96a5082 100644 --- a/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/Controllers/ReceiveTransactionsController.java +++ b/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/Controllers/ReceiveTransactionsController.java @@ -34,7 +34,7 @@ public Response get(){ public Response receiveTransaction(ReceiveTransactionsRequest request){ final BlockchainManager manager = new BlockchainManager(); manager.receiveTransactions(request.getSubscriptionId(), request.getFrom(), request.getBlockchainId(), - request.getWaitFor(), request.getEpUrl()); + request.getRequiredConfidence(), request.getEpUrl()); return Response.created(UriUtil.generateSubResourceURI(this.uriInfo, request.getSubscriptionId(), false)) .build(); diff --git a/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/Controllers/SubmitTransactionController.java b/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/Controllers/SubmitTransactionController.java index 1956168..ed9183e 100644 --- a/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/Controllers/SubmitTransactionController.java +++ b/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/Controllers/SubmitTransactionController.java @@ -30,7 +30,7 @@ public Response get(){ public Response submitTransaction(SubmitTransactionRequest request){ final BlockchainManager manager = new BlockchainManager(); manager.submitNewTransaction(request.getSubscriptionId(), request.getTo(), request.getValue(), request.getBlockchainId(), - request.getWaitFor(), request.getEpUrl()); + request.getRequiredConfidence(), request.getEpUrl()); return Response.created(UriUtil.generateSubResourceURI(this.uriInfo, request.getSubscriptionId(), false)) .build(); diff --git a/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/model/request/EnsureTransactionStateRequest.java b/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/model/request/EnsureTransactionStateRequest.java index e21c5ff..d96c886 100644 --- a/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/model/request/EnsureTransactionStateRequest.java +++ b/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/model/request/EnsureTransactionStateRequest.java @@ -25,7 +25,7 @@ public class EnsureTransactionStateRequest { private String subscriptionId; private String epUrl; private String txId; - private long waitFor; + private double requiredConfidence; @XmlElement(name="EndPointUrl") @@ -64,12 +64,12 @@ public void setSubscriptionId(String subscriptionId) { this.subscriptionId = subscriptionId; } - @XmlElement(name="WaitFor") - public long getWaitFor() { - return waitFor; + @XmlElement(name="RequiredConfidence") + public double getRequiredConfidence() { + return requiredConfidence; } - public void setWaitFor(long waitFor) { - this.waitFor = waitFor; + public void setRequiredConfidence(double requiredConfidence) { + this.requiredConfidence = requiredConfidence; } } diff --git a/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/model/request/ReceiveTransactionsRequest.java b/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/model/request/ReceiveTransactionsRequest.java index 61e8868..3274e21 100644 --- a/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/model/request/ReceiveTransactionsRequest.java +++ b/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/model/request/ReceiveTransactionsRequest.java @@ -22,7 +22,7 @@ public class ReceiveTransactionsRequest { private String blockchainId; private String subscriptionId; - private long waitFor; + private double requiredConfidence; private String epUrl; private String from; @@ -62,12 +62,12 @@ public void setSubscriptionId(String subscriptionId) { this.subscriptionId = subscriptionId; } - @XmlElement(name = "WaitFor") - public long getWaitFor() { - return waitFor; + @XmlElement(name = "RequiredConfidence") + public double getRequiredConfidence() { + return requiredConfidence; } - public void setWaitFor(long waitFor) { - this.waitFor = waitFor; + public void setRequiredConfidence(double requiredConfidence) { + this.requiredConfidence = requiredConfidence; } } diff --git a/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/model/request/SubmitTransactionRequest.java b/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/model/request/SubmitTransactionRequest.java index 6c38218..2540266 100644 --- a/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/model/request/SubmitTransactionRequest.java +++ b/src/main/java/blockchains/iaas/uni/stuttgart/de/restapi/model/request/SubmitTransactionRequest.java @@ -29,7 +29,7 @@ public class SubmitTransactionRequest { private String subscriptionId; - private long waitFor; + private double requiredConfidence; private String epUrl; @@ -70,14 +70,14 @@ public void setSubscriptionId(String subscriptionId) { this.subscriptionId = subscriptionId; } - @XmlElement(name="WaitFor") - public long getWaitFor() { - return waitFor; + @XmlElement(name="RequiredConfidence") + public double getRequiredConfidence() { + return requiredConfidence; } - public void setWaitFor(long waitFor) { - this.waitFor = waitFor; + public void setRequiredConfidence(double requiredConfidence) { + this.requiredConfidence = requiredConfidence; } @XmlElement(name="Value") diff --git a/src/test/java/blockchains/iaas/uni/stuttgart/de/adaptation/adapters/ethereum/EthereumAdapterTest.java b/src/test/java/blockchains/iaas/uni/stuttgart/de/adaptation/adapters/ethereum/EthereumAdapterTest.java index b301656..6ffda0d 100644 --- a/src/test/java/blockchains/iaas/uni/stuttgart/de/adaptation/adapters/ethereum/EthereumAdapterTest.java +++ b/src/test/java/blockchains/iaas/uni/stuttgart/de/adaptation/adapters/ethereum/EthereumAdapterTest.java @@ -61,7 +61,7 @@ void testConnectionToNode() { void testSendTransaction() throws ExecutionException, InterruptedException { final String toAddress = "0x182761AC584C0016Cdb3f5c59e0242EF9834fef0"; final BigDecimal value = new BigDecimal(5000); - LinearChainTransaction result = (LinearChainTransaction) this.adapter.submitTransaction(3, toAddress, value).get(); + LinearChainTransaction result = (LinearChainTransaction) this.adapter.submitTransaction(toAddress, value, REQUIRED_CONFIDENCE).get(); log.debug("transaction hash is: " + result.getTransactionHash()); }