Skip to content
This repository was archived by the owner on Dec 1, 2025. It is now read-only.

Commit 3a7e504

Browse files
author
Vehbi Malkoch
committed
ETC && new features added
1 parent fc8ebe4 commit 3a7e504

38 files changed

Lines changed: 533 additions & 325 deletions

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@
190190
<properties>
191191
<java.version>1.8</java.version>
192192
<project.name>cryptoapis-java-client</project.name>
193-
<project.version>1.2.0</project.version>
193+
<project.version>1.2.1</project.version>
194194
</properties>
195195

196196
</project>

release.properties

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#release configuration
2+
#Tue Oct 22 16:11:03 EEST 2019
3+
scm.tagNameFormat=@{project.artifactId}-@{project.version}
4+
pushChanges=false
5+
scm.url=scm\:git\:[email protected]\:github.com\:Crypto-APIs/Java-Library.git
6+
preparationGoals=clean verify
7+
remoteTagging=true
8+
projectVersionPolicyId=default
9+
scm.commentPrefix=[maven-release-plugin]
10+
exec.additionalArguments=-Dgpg.passphrase\=CDWBkZmH>3E;wzP>
11+
exec.snapshotReleasePluginAllowed=false
12+
completedPhase=check-poms

src/main/java/io/cryptoapis/abstractServices/AbstractWebhookService.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
package io.cryptoapis.abstractServices;
22

3+
import io.cryptoapis.common_models.ApiError;
34
import io.cryptoapis.common_models.ApiResponse;
45
import io.cryptoapis.common_models.Webhook;
56
import io.cryptoapis.utils.Utils;
67
import io.cryptoapis.utils.config.EndpointConfig;
78
import io.cryptoapis.utils.enums.HttpsRequestsEnum;
89
import io.cryptoapis.utils.enums.WebhookEnum;
910
import io.cryptoapis.utils.rest.WebServices;
11+
import javafx.util.Pair;
1012
import org.apache.commons.lang.StringUtils;
1113

14+
import java.util.Map;
15+
1216
public abstract class AbstractWebhookService extends AbstractServicesConfig {
17+
18+
private static final String DELETE_ALL_URL = "all";
19+
1320
protected AbstractWebhookService(EndpointConfig endpointConfig) {
1421
super(endpointConfig);
1522
}
@@ -42,12 +49,20 @@ protected ApiResponse deleteWebhook(String whUuid) {
4249
return Utils.deleteUnit(whUuid, url, endpointConfig);
4350
}
4451

45-
protected ApiResponse listWebhooks() {
46-
return getWebhooks();
52+
protected ApiResponse deleteAllWebhooks() {
53+
return Utils.deleteUnit(DELETE_ALL_URL, url, endpointConfig);
54+
}
55+
56+
protected ApiResponse listWebhooks(Map<String, String> params) {
57+
return getWebhooks(params);
4758
}
4859

49-
private ApiResponse getWebhooks() {
50-
return WebServices.httpsRequest(WebServices.formatUrl(url, endpointConfig, StringUtils.EMPTY), HttpsRequestsEnum.GET.name(), endpointConfig, null);
60+
private ApiResponse getWebhooks(Map<String, String> params) {
61+
Pair<String, ApiError> pair = Utils.setQueryParams(params);
62+
if (pair.getValue() != null) {
63+
return Utils.setApiResponse(pair.getValue());
64+
}
65+
return WebServices.httpsRequest(WebServices.formatUrl(url.concat(pair.getKey()), endpointConfig, StringUtils.EMPTY), HttpsRequestsEnum.GET.name(), endpointConfig, null);
5166
}
5267

5368
protected ApiResponse broadcastWebhook(Webhook wh) {

src/main/java/io/cryptoapis/blockchains/bitcoin_based/models/Transaction/CreateHDWalletTransaction.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ public class CreateHDWalletTransaction extends Stringify {
1212
private CreateTransaction.Fee fee;
1313
private Integer locktime;
1414

15+
//btc
16+
private Boolean replaceable;
17+
private String data;
18+
19+
private CreateHDWalletTransaction(String walletName, String password, List<CreateTransaction.Inputs> inputs,
20+
List<CreateTransaction.Outputs> outputs, CreateTransaction.Fee fee, Integer locktime,
21+
Boolean replaceable, String data) {
22+
this(walletName, password, inputs, outputs, fee, locktime);
23+
this.replaceable = replaceable;
24+
this.data = data;
25+
}
26+
1527
private CreateHDWalletTransaction(String walletName, String password, List<CreateTransaction.Inputs> inputs,
1628
List<CreateTransaction.Outputs> outputs, CreateTransaction.Fee fee, Integer locktime) {
1729
this.walletName = walletName;
@@ -20,7 +32,7 @@ private CreateHDWalletTransaction(String walletName, String password, List<Creat
2032
this.inputs = inputs;
2133
}
2234

23-
this.outputs=outputs;
35+
this.outputs = outputs;
2436
this.fee = fee;
2537
this.locktime = locktime != null ? locktime : 0;
2638
}
@@ -29,4 +41,10 @@ public static CreateHDWalletTransaction create(String walletName, String passwor
2941
List<CreateTransaction.Outputs> outputs, CreateTransaction.Fee fee, Integer locktime) {
3042
return new CreateHDWalletTransaction(walletName, password, inputs, outputs, fee, locktime);
3143
}
44+
45+
public static CreateHDWalletTransaction createBtc(String walletName, String password, List<CreateTransaction.Inputs> inputs,
46+
List<CreateTransaction.Outputs> outputs, CreateTransaction.Fee fee, Integer locktime,
47+
Boolean replaceable, String data) {
48+
return new CreateHDWalletTransaction(walletName, password, inputs, outputs, fee, locktime, replaceable, data);
49+
}
3250
}

src/main/java/io/cryptoapis/blockchains/bitcoin_based/models/Transaction/CreateTransaction.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ public class CreateTransaction extends Stringify {
1111
private Integer locktime;
1212
private Fee fee;
1313

14+
//btc
15+
private Boolean replaceable;
16+
private String data;
17+
1418
public static class Inputs extends Base {
1519

1620
}
@@ -19,7 +23,14 @@ public static class Outputs extends Base {
1923

2024
}
2125

22-
private CreateTransaction(List<Inputs> inputs, List<Outputs> outputs, Fee fee, Integer locktime) {
26+
protected CreateTransaction(List<Inputs> inputs, List<Outputs> outputs, CreateTransaction.Fee fee, Integer locktime, Boolean replaceable, String data) {
27+
this(inputs, outputs, fee, locktime);
28+
this.replaceable = replaceable;
29+
this.data = data;
30+
}
31+
32+
33+
protected CreateTransaction(List<Inputs> inputs, List<Outputs> outputs, Fee fee, Integer locktime) {
2334
this.inputs = inputs;
2435
this.outputs = outputs;
2536
this.locktime = locktime;
@@ -35,6 +46,10 @@ public static CreateTransaction createTx(List<Inputs> inputs, List<Outputs> outp
3546
return new CreateTransaction(inputs, outputs, fee, locktime);
3647
}
3748

49+
public static CreateTransaction btcCreateTransaction(List<Inputs> inputs, List<Outputs> outputs, CreateTransaction.Fee fee, Integer locktime, Boolean replaceable, String data) {
50+
return new CreateTransaction(inputs, outputs, fee, locktime, replaceable, data);
51+
}
52+
3853
public List<Inputs> getInputs() {
3954
return inputs;
4055
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package io.cryptoapis.blockchains.bitcoin_based.models.Transaction;
2+
3+
import io.cryptoapis.common_models.Stringify;
4+
5+
public class RefundTransaction extends Stringify {
6+
private String txid;
7+
private String wif;
8+
private String fee;
9+
10+
public RefundTransaction(String txid, String wif, String fee) {
11+
this.txid = txid;
12+
this.wif = wif;
13+
if (fee != null)
14+
this.fee = fee;
15+
}
16+
17+
public static RefundTransaction refundTx(String txid, String wif, String fee) {
18+
return new RefundTransaction(txid, wif, fee);
19+
}
20+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package io.cryptoapis.blockchains.bitcoin_based.services;
2+
3+
import io.cryptoapis.blockchains.bitcoin_based.models.Transaction.CreateHDWalletTransaction;
4+
import io.cryptoapis.blockchains.bitcoin_based.models.Transaction.CreateTransaction;
5+
import io.cryptoapis.common_models.ApiResponse;
6+
import io.cryptoapis.utils.config.EndpointConfig;
7+
import io.cryptoapis.utils.enums.HttpsRequestsEnum;
8+
import io.cryptoapis.utils.rest.WebServices;
9+
10+
import java.util.List;
11+
12+
public class BtcTransactionService extends TransactionService {
13+
14+
public BtcTransactionService(EndpointConfig endpointConfig) {
15+
super(endpointConfig);
16+
}
17+
18+
public ApiResponse createTx(List<CreateTransaction.Inputs> inputs, List<CreateTransaction.Outputs> outputs, CreateTransaction.Fee fee, Integer locktime, Boolean replaceable, String data) {
19+
CreateTransaction createTransaction = CreateTransaction.btcCreateTransaction(inputs, outputs, fee, locktime, replaceable, data);
20+
return WebServices.httpsRequest(WebServices.formatUrl(url, endpointConfig, "create"), HttpsRequestsEnum.POST.name(),
21+
endpointConfig, createTransaction.toString());
22+
}
23+
24+
public ApiResponse newTxWithHDWallet(String walletName, String password, List<CreateTransaction.Inputs> inputs,
25+
List<CreateTransaction.Outputs> outputs, CreateTransaction.Fee fee, Integer locktime,
26+
Boolean replaceable, String data) {
27+
return WebServices.httpsRequest(WebServices.formatUrl(url, endpointConfig, "hdwallet"), HttpsRequestsEnum.POST.name(), endpointConfig,
28+
CreateHDWalletTransaction.createBtc(walletName, password, inputs, outputs, fee, locktime, replaceable, data).toString());
29+
}
30+
}

src/main/java/io/cryptoapis/blockchains/bitcoin_based/services/TransactionService.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package io.cryptoapis.blockchains.bitcoin_based.services;
22

3-
import io.cryptoapis.blockchains.bitcoin_based.models.Transaction.CompleteTransaction;
4-
import io.cryptoapis.blockchains.bitcoin_based.models.Transaction.CreateHDWalletTransaction;
5-
import io.cryptoapis.blockchains.bitcoin_based.models.Transaction.CreateTransaction;
3+
import io.cryptoapis.blockchains.bitcoin_based.models.Transaction.*;
64
import io.cryptoapis.blockchains.bitcoin_based.models.Hex;
7-
import io.cryptoapis.blockchains.bitcoin_based.models.Transaction.SignTransaction;
85
import io.cryptoapis.common_models.ApiError;
96
import io.cryptoapis.common_models.ApiResponse;
107
import io.cryptoapis.utils.Utils;
@@ -53,7 +50,6 @@ public ApiResponse getTxByBlock(int blockNumber, Map<String, String> params) {
5350
return getTransaction(endpoint, pair.getKey());
5451
}
5552

56-
5753
public ApiResponse getUnconfirmedTxs(Map<String, String> params) {
5854
Pair<String, ApiError> pair = Utils.setQueryParams(params);
5955
if (pair.getValue() != null) {
@@ -103,6 +99,13 @@ public ApiResponse getFees() {
10399
return getTransaction("fee", null);
104100
}
105101

102+
public ApiResponse refundTx(String txid, String wif, String fee) {
103+
String endpoint = "refund";
104+
105+
return WebServices.httpsRequest(WebServices.formatUrl(url, endpointConfig, endpoint), HttpsRequestsEnum.POST.name(), endpointConfig,
106+
RefundTransaction.refundTx(txid, wif, fee).toString());
107+
}
108+
106109
private ApiResponse getTransaction(String endpoint, String params) {
107110
if (params != null) {
108111
url = url.concat(params);

src/main/java/io/cryptoapis/blockchains/bitcoin_based/services/WebhookService.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import io.cryptoapis.common_models.ApiResponse;
55
import io.cryptoapis.utils.config.EndpointConfig;
66

7+
import java.util.Map;
8+
79
public class WebhookService extends AbstractWebhookService {
810
private static final String PATH = "/{0}/bc/{1}/{2}/hooks/{3}";
911

@@ -42,7 +44,12 @@ public ApiResponse deleteWebhook(String webhookId) {
4244
}
4345

4446
@Override
45-
public ApiResponse listWebhooks() {
46-
return super.listWebhooks();
47+
public ApiResponse deleteAllWebhooks() {
48+
return super.deleteAllWebhooks();
49+
}
50+
51+
@Override
52+
public ApiResponse listWebhooks(Map<String, String> map) {
53+
return super.listWebhooks(map);
4754
}
4855
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package io.cryptoapis.blockchains.ethereum.models;
2+
3+
import io.cryptoapis.common_models.Stringify;
4+
5+
public class Account extends Stringify {
6+
private String password;
7+
8+
private Account(String password) {
9+
this.password = password;
10+
}
11+
12+
public static Account createAccount(String password) {
13+
return new Account(password);
14+
}
15+
}

0 commit comments

Comments
 (0)