I am getting the following Exception while performing send transaction using the Java Stellar SDK.
This is my send transaction code:
import org.stellar.sdk.AssetTypeNative;
import org.stellar.sdk.KeyPair;
import org.stellar.sdk.Memo;
import org.stellar.sdk.Network;
import org.stellar.sdk.PaymentOperation;
import org.stellar.sdk.Server;
import org.stellar.sdk.Transaction;
import org.stellar.sdk.responses.AccountResponse;
import org.stellar.sdk.responses.SubmitTransactionResponse;
public class sendTransaction {
public static void main(String args[]) {
Network.useTestNetwork();
Server server = new Server("https://horizon-testnet.stellar.org");
KeyPair source = KeyPair.fromSecretSeed("SXXXXXXXXXXXXXXXXXXXXXXXXXXX");
KeyPair destination = KeyPair.fromAccountId("GXXXXXXXXXXXXXXXXXXXXXXXXX");
try {
server.accounts().account(destination);
}
catch(Exception e) {
System.out.println(e.getMessage());
return;
}
AccountResponse sourceAccount;
try {
sourceAccount = server.accounts().account(source);
} catch (Exception e) {
System.out.println(e.getMessage());
return;
}
Transaction transaction = new Transaction.Builder(sourceAccount)
.addOperation(new PaymentOperation.Builder(destination, new AssetTypeNative(), "10").build())
.addMemo(Memo.text("hello"))
.build();
// Sign the transaction to prove you are actually the person sending it.
transaction.sign(source);
// And finally, send it off to Stellar!
try {
SubmitTransactionResponse response = server.submitTransaction(transaction);
System.out.println("Success!");
} catch (Exception e) {
System.out.println("Something went wrong!");
System.out.println(e.getMessage());
}
}
}
I am getting exception:
Exception in thread "main" java.lang.RuntimeException: TimeBounds has to be set or you must call setTimeout(TIMEOUT_INFINITE).
at org.stellar.sdk.Transaction$Builder.build(Transaction.java:385)
at com.apiservice.controller.sendTransaction.main(sendTransaction.java:45)
Here's my pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.stellar</groupId>
<artifactId>java-stellar-sdk</artifactId>
<version>0.2.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
0.6.0
, or whatever is the latest at time of reading at github.com/stellar/java-stellar-sdk/releases