I am working on a small and very basic project, essentially doing a POC involving stellar transactions. I am a newbie with stellar. I have two clients running the same code, and a 'banker' who collects the transactions and notifies the two clients of received transactions. I followed the stellar developer documentation and am able to successfully send two transactions (one from each client) to the banker, and receive/parse the incoming transactions from the banker.
However, when I go to reply to the clients from the banker, the transaction is seemingly never sent. There is no exception, but when I query the server for transactions involving the banker test account immediately following the submission of the transactions, the latest record (descending order) is still the incoming message from the client. If anyone could provide any insight as to what I may be doing wrong, it would be greatly appreciated.
Here is the client transaction being sent:
Network.useTestNetwork();
Server server = new Server("https://horizon-testnet.stellar.org");
KeyPair destination = KeyPair.fromAccountId(bankerAccountId);
try {
server.accounts().account(destination);
}
catch(Exception e) {
System.out.println(e.getMessage());
return;
}
AccountResponse sourceAccount;
try {
sourceAccount = server.accounts().account(pair);
} catch (Exception e) {
System.out.println(e.getMessage());
return;
}
Transaction transaction = new Transaction.Builder(sourceAccount)
.addOperation(new PaymentOperation.Builder(destination, new AssetTypeNative(), betAmount).build())
.addMemo(Memo.text(Double.parseDouble(betAmount) + " " + randomNumber))
.build();
// Sign the transaction to prove you are actually the person sending it.
transaction.sign(pair);
// 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());
}
And here is my attempt (after receiving the client message(s)) to reply:
KeyPair destination1 = KeyPair.fromAccountId(player1.getAccountId());
System.out.println(player1.getAccountId());
KeyPair destination2 = KeyPair.fromAccountId(player2.getAccountId());
System.out.println(player2.getAccountId());
Network.useTestNetwork();
server = new Server("https://horizon-testnet.stellar.org");
try {
server.accounts().account(destination1);
server.accounts().account(destination2);
}
catch(Exception e) {
System.out.println(e.getMessage());
return;
}
AccountResponse sourceAccount;
try {
sourceAccount = server.accounts().account(pair);
} catch (Exception e) {
System.out.println(e.getMessage());
return;
}
Transaction t1 = new Transaction.Builder(sourceAccount)
.addOperation(new PaymentOperation.Builder(destination1, new AssetTypeNative(), noBet).build())
.addMemo(Memo.text("reveal values"))
.build();
t1.sign(pair);
Transaction t2 = new Transaction.Builder(sourceAccount)
.addOperation(new PaymentOperation.Builder(destination2, new AssetTypeNative(), noBet).build())
.addMemo(Memo.text("reveal values"))
.build();
t2.sign(pair);
try {
SubmitTransactionResponse response1 = server.submitTransaction(t1);
SubmitTransactionResponse response2 = server.submitTransaction(t2);
System.out.println("Success!");
} catch (Exception e) {
System.out.println("Something went wrong!");
System.out.println(e.getMessage());
}
I have verified that the destination and source accounts are the correct values. Right after this, I query the server and check the records (in descending order..) and the two transactions are not present.
pair
defined?