Closed thuhc closed 5 years ago
seems like server does not allow transaction announcements as PUT to /transaction/ and now it is PUT to /transaction (without the trailing slash) will review all endpoints and prepare patch for 5.0.1
pull request #124 created and pending approval
public static String sendPlainMessage(NetworkType networkType, String apiUrl, String senderPrivateKey, String recipientAddress, String message) throws Exception { final Account account = Account.createFromPrivateKey(senderPrivateKey, networkType); BlockchainApi blockchainApi = new BlockchainApi(new URL(apiUrl), networkType); final TransferTransaction transferTransaction = blockchainApi.transact().transfer() .deadline(Deadline.create(1, ChronoUnit.HOURS)) .to(Address.createFromRawAddress(recipientAddress)) .mosaics(new ArrayList())
.message(PlainMessage.create(message))
.networkType(networkType)
.build();
final SignedTransaction signedTransaction = blockchainApi.sign(transferTransaction, account);
final TransactionHttp transactionHttp = (TransactionHttp) blockchainApi.createTransactionRepository();
transactionHttp.announce(signedTransaction).toFuture().get();
signedTransaction.getHash());
return signedTransaction.getHash();
}