Skip to content
This repository was archived by the owner on Oct 24, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.blockcypher</groupId>
<artifactId>java-client</artifactId>
<version>0.1.2-SNAPSHOT</version>
<version>0.1.3-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
Expand Down Expand Up @@ -63,6 +63,11 @@
<artifactId>jersey-client</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-jdk-http</artifactId>
Expand Down Expand Up @@ -105,7 +110,7 @@
<!-- <bitcoinj.version>0.12-SNAPSHOT</bitcoinj.version>-->
<!-- <bitcoinj.version>0.11.1</bitcoinj.version>-->
<spongycastle.version>1.47.0.3</spongycastle.version>
<jersey.version>2.9</jersey.version>
<jersey.version>2.29.1</jersey.version>
<!-- github server corresponds to entry in ~/.m2/settings.xml -->
<github.global.server>github</github.global.server>
</properties>
Expand All @@ -117,7 +122,7 @@
</snapshots>
<id>central</id>
<name>Maven Repository Switchboard</name>
<url>http://repo1.maven.org/maven2</url>
<url>https://repo1.maven.org/maven2</url>
</repository>
<repository>
<id>maven-restlet</id>
Expand Down Expand Up @@ -155,7 +160,7 @@
</snapshots>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>http://repo1.maven.org/maven2</url>
<url>https://repo1.maven.org/maven2</url>
</pluginRepository>
</pluginRepositories>

Expand Down Expand Up @@ -188,7 +193,7 @@
<plugin>
<groupId>com.github.github</groupId>
<artifactId>site-maven-plugin</artifactId>
<!-- Have to take snapshot but even this one is buggy... https://api.github.com/users/xxx does not have email and user while SiteMojo expect one so recompile snapshot...
<!-- Have to take snapshot but even this one is buggy... https://api.github.com/users/xxx does not have email and user while SiteMojo expect one so recompile snapshot...
https://github.com/github/maven-plugins/issues/70
-->
<version>0.10-SNAPSHOT</version>
Expand Down
34 changes: 34 additions & 0 deletions src/main/java/com/blockcypher/service/TransactionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.blockcypher.utils.rest.RestUtils;

import java.math.BigDecimal;
import java.util.Iterator;
import java.util.List;

/**
Expand Down Expand Up @@ -63,6 +64,38 @@ private NullData postNullData(String nullData, String id) throws BlockCypherExce
return RestUtils.post(RestUtils.formatUrl(resourceUrl, endpointConfig, id), nullData, id, NullData.class);
}

/**
* Create an Intermediary Transaction from skeleton. You will then need to sign this transaction with your private key
*
* @param inputAddresses input addresses
* @param outputAddresses output addresses
* @param satoshis values
* @return Partially built transaction with the data to sign
* @throws BlockCypherException In case there is some error, ie: <code>Address xxx with balance 0 does not have enough funds to transfer 510000.</code>
*/
public IntermediaryTransaction newTransaction(List<String> inputAddresses, List<String> outputAddresses,
List<Long> satoshis) throws BlockCypherException {
Transaction transaction = new Transaction();

for (String address : inputAddresses) {
Input input = new Input();
input.addAddress(address);
transaction.addInput(input);
}

Iterator<Long> satoshiIterator = satoshis.iterator();

for (String address : outputAddresses) {
Output output = new Output();
output.addAddress(address);
output.setValue(new BigDecimal(satoshiIterator.next()));
transaction.addOutput(output);
}
String transactionJson = GsonFactory.getGson().toJson(transaction);
return postSkeletonTransaction(transactionJson, "new");
}


/**
* Create an Intermediary Transaction from skeleton. You will then need to sign this transaction with your private key
*
Expand All @@ -72,6 +105,7 @@ private NullData postNullData(String nullData, String id) throws BlockCypherExce
* @return Partially built transaction with the data to sign
* @throws BlockCypherException In case there is some error, ie: <code>Address xxx with balance 0 does not have enough funds to transfer 510000.</code>
*/
@Deprecated
public IntermediaryTransaction newTransaction(List<String> inputAddresses, List<String> outputAddresses,
long satoshis) throws BlockCypherException {
Transaction transaction = new Transaction();
Expand Down