mirror of
https://github.com/gosticks/iota.lib.java.git
synced 2026-10-04 13:37:00 +00:00
added sednTransfer
This commit is contained in:
@@ -287,8 +287,7 @@ public class IotaAPIProxy {
|
||||
* @param {int} minWeightMagnitude
|
||||
* @return
|
||||
*/
|
||||
public List<Transaction> sendTrytes(final String trytes, final int minWeightMagnitude) {
|
||||
|
||||
public List<Transaction> sendTrytes(final String[] trytes, final int minWeightMagnitude) {
|
||||
final GetTransactionsToApproveResponse txs = getTransactionsToApprove(minWeightMagnitude);
|
||||
|
||||
// attach to tangle - do pow
|
||||
@@ -443,7 +442,7 @@ public class IotaAPIProxy {
|
||||
|
||||
// Case 1: user provided inputs
|
||||
// Validate the inputs by calling getBalances
|
||||
if (!inputs.isEmpty()) {
|
||||
if (inputs != null && !inputs.isEmpty()) {
|
||||
|
||||
// Get list if addresses of the provided inputs
|
||||
List<String> inputsAddresses = new ArrayList<>();
|
||||
@@ -453,7 +452,6 @@ public class IotaAPIProxy {
|
||||
|
||||
GetBalancesResponse resbalances = getBalances(100, inputsAddresses);
|
||||
String[] balances = resbalances.getBalances();
|
||||
|
||||
|
||||
List<Input> confirmedInputs = new ArrayList<>();
|
||||
int totalBalance = 0; int i = 0;
|
||||
@@ -502,7 +500,7 @@ public class IotaAPIProxy {
|
||||
return bundleTrytes;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the inputs of a seed
|
||||
*
|
||||
@@ -628,7 +626,7 @@ public class IotaAPIProxy {
|
||||
bundleTrytes.add(IotaAPIUtils.transactionTrytes(element));
|
||||
}
|
||||
|
||||
return sendTrytes(bundleTrytes.get(0), minWeightMagnitude);
|
||||
return sendTrytes(bundleTrytes.toArray(new String[bundleTrytes.size()]), minWeightMagnitude);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -648,6 +646,13 @@ public class IotaAPIProxy {
|
||||
return getInclusionStates(hashes, latestMilestone);
|
||||
}
|
||||
|
||||
public Transaction[] sendTransfer(String seed, int depth, int minWeightMagnitude, Transfer[] transactions, Input[] inputs, String address) {
|
||||
|
||||
List<String> trytes = prepareTransfers(seed, Arrays.asList(transactions), address, Arrays.asList(inputs));
|
||||
List<Transaction> trxs = sendTrytes(trytes.toArray(new String[trytes.size()]), minWeightMagnitude);
|
||||
return trxs.toArray(new Transaction[trxs.size()]);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
String protocol, host, port;
|
||||
|
||||
@@ -6,6 +6,7 @@ import jota.dto.response.*;
|
||||
import jota.model.Transfer;
|
||||
import org.hamcrest.core.Is;
|
||||
import org.hamcrest.core.IsNull;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -162,12 +163,15 @@ public class IotaAPIProxyTest {
|
||||
public void shouldPrepareTransfer() {
|
||||
List<Transfer> transfers = new ArrayList<>();
|
||||
transfers.add(new jota.model.Transfer(TEST_ADDRESS_WITH_CHECKSUM, 0, TEST_MESSAGE, TEST_TAG));
|
||||
proxy.prepareTransfers(TEST_SEED, transfers, null, null);
|
||||
transfers.add(new jota.model.Transfer(TEST_ADDRESS_WITH_CHECKSUM, 1, TEST_MESSAGE, TEST_TAG));
|
||||
List<String> trytes = proxy.prepareTransfers(TEST_SEED, transfers, null, null);
|
||||
Assert.assertNotNull(trytes);
|
||||
assertThat(trytes.isEmpty(), Is.is(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldSendTrytes() {
|
||||
proxy.sendTrytes(TEST_TRYTES, 18);
|
||||
proxy.sendTrytes(new String[]{TEST_TRYTES}, 18);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user