From a976e48f6b599b11737e184b08f01dce629340a1 Mon Sep 17 00:00:00 2001 From: pinpong Date: Fri, 23 Dec 2016 18:34:27 +0100 Subject: [PATCH] added replayTransfer --- src/main/java/jota/IotaAPIProxy.java | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/java/jota/IotaAPIProxy.java b/src/main/java/jota/IotaAPIProxy.java index 6ac88d2..6dceab3 100644 --- a/src/main/java/jota/IotaAPIProxy.java +++ b/src/main/java/jota/IotaAPIProxy.java @@ -285,7 +285,7 @@ public class IotaAPIProxy { * @param {array} trytes * @param {int} depth * @param {int} minWeightMagnitude - * @return + * @return */ public List sendTrytes(final String trytes, final int minWeightMagnitude) { @@ -627,6 +627,30 @@ public class IotaAPIProxy { return null; //IotaAPIUtils.getBundle(transaction); } + /** + * Replays a transfer by doing Proof of Work again + * + * @method replayBundle + * @param {string} tail + * @param {int} depth + * @param {int} minWeightMagnitude + * @param {function} callback + * @returns {object} analyzed Transaction objects + **/ + public List replayTransfer(String transaction, int depth, int minWeightMagnitude) { + + List bundleTrytes = new ArrayList<>(); + + GetBundleResponse bundle = getBundle(transaction); + + for (Transaction element : bundle.getTransactions()) { + + bundleTrytes.add(IotaAPIUtils.transactionTrytes(element)); + } + + return sendTrytes(bundleTrytes, minWeightMagnitude); + } + /** * Wrapper function for getNodeInfo and getInclusionStates *