Translations: Sample Java Programs/43/en

From ArdorDocs
Jump to: navigation, search

public static void main(String[] args) throws MalformedURLException {

       URL url = new URL("http://localhost:26876/nxt"); // Start your local testnet node
       MessageDecryption messageDecryption = new MessageDecryption();
       List<TransactionResponse> transactions = messageDecryption.getTransactions(1, 380158, SENDER_ACCOUNT, url);
       for (TransactionResponse transaction : transactions) {
           JO attachmentJson = transaction.getAttachmentJson();
           if (!attachmentJson.isExist("encryptedMessage")) {
               continue;
           }
           JO encryptedData = attachmentJson.getJo("encryptedMessage");
           JO response = DecryptFromCall.create().account(SENDER_ACCOUNT).secretPhrase(RECIPIENT_SECRET_PHRASE).
                   data(encryptedData.getString("data")).nonce(encryptedData.getString("nonce")).remote(url).call();
           System.out.println(response);
       }
   }