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

Commit d5b9140

Browse files
integrated ZILLIQA and updated BTC_BASED and ETH_BASED
1 parent c2b12de commit d5b9140

File tree

14 files changed

+414
-2
lines changed

14 files changed

+414
-2
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,16 @@ System.out.println(res.getResponse());
10081008
| | | getTransactionsByPropertyId x2 |
10091009
| | | getUnconfirmedTransactions x2 |
10101010
| | | |
1011+
1012+
### Zilliqa
1013+
1014+
| AddressService | BlockchainService | TransactionService | BlockService |
1015+
| ---------------------- | -------------------- | ------------------ | -------------- |
1016+
| getAddressInfo | getBlockchainInfo | getTx x3 | getBlock x2 |
1017+
| getTxsByAddress | | signTransaction | getLatestBlock |
1018+
| generateNewAddress | | getTxByIdxAndLimit | |
1019+
| | | | |
1020+
10111021
10121022
### Query Params
10131023

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
package io.cryptoapis.blockchains.bitcoin_based.models.Transaction;
2+
3+
import io.cryptoapis.common_models.Stringify;
4+
5+
import java.util.List;
6+
7+
public class HdWalletTransactionSize extends Stringify {
8+
private String walletName;
9+
private String password;
10+
private List<CreateTransaction.Inputs> inputs;
11+
private List<CreateTransaction.Outputs> outputs;
12+
private CreateTransaction.Fee fee;
13+
private Integer locktime;
14+
15+
//btc
16+
private Boolean replaceable;
17+
private String data;
18+
19+
private HdWalletTransactionSize(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+
27+
private HdWalletTransactionSize(String walletName, String password, List<CreateTransaction.Inputs> inputs,
28+
List<CreateTransaction.Outputs> outputs, CreateTransaction.Fee fee, Integer locktime) {
29+
this.walletName = walletName;
30+
this.password = password;
31+
if (inputs != null && inputs.size() > 0) {
32+
this.inputs = inputs;
33+
}
34+
35+
this.outputs = outputs;
36+
37+
if (fee != null) {
38+
this.fee = fee;
39+
}
40+
this.locktime = locktime != null ? locktime : 0;
41+
}
42+
43+
public static HdWalletTransactionSize getHdWalletTransactionSize(String walletName, String password, List<CreateTransaction.Inputs> inputs,
44+
List<CreateTransaction.Outputs> outputs, CreateTransaction.Fee fee, Integer locktime) {
45+
46+
return new HdWalletTransactionSize(walletName, password, inputs, outputs, fee, locktime);
47+
}
48+
49+
public static HdWalletTransactionSize getHdWalletTransactionSizeBtc(String walletName, String password, List<CreateTransaction.Inputs> inputs,
50+
List<CreateTransaction.Outputs> outputs, CreateTransaction.Fee fee, Integer locktime,
51+
Boolean replaceable, String data ) {
52+
53+
return new HdWalletTransactionSize(walletName, password, inputs, outputs,fee , locktime, replaceable, data);
54+
}
55+
56+
public String getWalletName() {
57+
return walletName;
58+
}
59+
60+
public void setWalletName(String walletName) {
61+
this.walletName = walletName;
62+
}
63+
64+
public String getPassword() {
65+
return password;
66+
}
67+
68+
public void setPassword(String password) {
69+
this.password = password;
70+
}
71+
72+
public List<CreateTransaction.Inputs> getInputs() {
73+
return inputs;
74+
}
75+
76+
public void setInputs(List<CreateTransaction.Inputs> inputs) {
77+
this.inputs = inputs;
78+
}
79+
80+
public List<CreateTransaction.Outputs> getOutputs() {
81+
return outputs;
82+
}
83+
84+
public void setOutputs(List<CreateTransaction.Outputs> outputs) {
85+
this.outputs = outputs;
86+
}
87+
88+
public CreateTransaction.Fee getFee() {
89+
return fee;
90+
}
91+
92+
public void setFee(CreateTransaction.Fee fee) {
93+
this.fee = fee;
94+
}
95+
96+
public Integer getLocktime() {
97+
return locktime;
98+
}
99+
100+
public void setLocktime(Integer locktime) {
101+
this.locktime = locktime;
102+
}
103+
104+
public Boolean getReplaceable() {
105+
return replaceable;
106+
}
107+
108+
public void setReplaceable(Boolean replaceable) {
109+
this.replaceable = replaceable;
110+
}
111+
112+
public String getData() {
113+
return data;
114+
}
115+
116+
public void setData(String data) {
117+
this.data = data;
118+
}
119+
}

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,28 @@ public ApiResponse getTxsByAddress(String address, Map<String, String> params) {
5454
return WebServices.httpsRequest(WebServices.formatUrl(url.concat(pair.getKey()), endpointConfig, endpoint),
5555
HttpsRequestsEnum.GET.name(), endpointConfig, null);
5656
}
57+
58+
public ApiResponse getUnconfirmedTxsByAddress(String address, Map<String, String> params) {
59+
String endpoint = String.format("/%s/unconfirmed-transactions", address);
60+
61+
Pair<String, ApiError> pair = Utils.setQueryParams(params);
62+
if (pair.getValue() != null) {
63+
return Utils.setApiResponse(pair.getValue());
64+
}
65+
66+
return WebServices.httpsRequest(WebServices.formatUrl(url.concat(pair.getKey()), endpointConfig, endpoint),
67+
HttpsRequestsEnum.GET.name(), endpointConfig, null);
68+
}
69+
70+
public ApiResponse getBasicTxsByAddress(String address, Map<String, String> params) {
71+
String endpoint = String.format("/%s/basic/transactions", address);
72+
73+
Pair<String, ApiError> pair = Utils.setQueryParams(params);
74+
if (pair.getValue() != null) {
75+
return Utils.setApiResponse(pair.getValue());
76+
}
77+
78+
return WebServices.httpsRequest(WebServices.formatUrl(url.concat(pair.getKey()), endpointConfig, endpoint),
79+
HttpsRequestsEnum.GET.name(), endpointConfig, null);
80+
}
5781
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ public ApiResponse getTxByHash(String hash) {
3030
return getTransaction(endpoint, null);
3131
}
3232

33+
public ApiResponse getRawTxByHash(String hash) {
34+
String endpoint = String.format("raw/txid/%s", hash);
35+
36+
return WebServices.httpsRequest(WebServices.formatUrl(url, endpointConfig, endpoint), HttpsRequestsEnum.GET.name(), endpointConfig, null);
37+
}
38+
39+
public ApiResponse getBasicTxByHash(String hash) {
40+
String endpoint = String.format("basic/txid/%s", hash);
41+
42+
return WebServices.httpsRequest(WebServices.formatUrl(url, endpointConfig, endpoint), HttpsRequestsEnum.GET.name(), endpointConfig, null);
43+
}
44+
3345
public ApiResponse getTxByBlock(String blockHash, Map<String, String> params) {
3446
String endpoint = String.format("block/%s", blockHash);
3547

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

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

3+
import io.cryptoapis.blockchains.bitcoin_based.models.Transaction.CreateTransaction;
4+
import io.cryptoapis.blockchains.bitcoin_based.models.Transaction.HdWalletTransactionSize;
35
import io.cryptoapis.blockchains.bitcoin_based.models.Wallet.HDWallet;
46
import io.cryptoapis.blockchains.bitcoin_based.models.Wallet.ImportAddress;
57
import io.cryptoapis.blockchains.bitcoin_based.models.Wallet.Wallet;
@@ -143,4 +145,12 @@ private ApiResponse deleteWallets(String path) {
143145
return WebServices.httpsRequest(WebServices.formatUrl(url, endpointConfig, endpoint), HttpsRequestsEnum.DELETE.name(), endpointConfig,
144146
null);
145147
}
148+
149+
public ApiResponse getHdWalletTransactionSize(String walletName, String password, List<CreateTransaction.Inputs> inputs,
150+
List<CreateTransaction.Outputs> outputs, CreateTransaction.Fee fee, Integer locktime) {
151+
String endpoint = "/hd/txs/size";
152+
153+
return WebServices.httpsRequest(WebServices.formatUrl(url, endpointConfig, endpoint), HttpsRequestsEnum.POST.name(), endpointConfig,
154+
HdWalletTransactionSize.getHdWalletTransactionSize(walletName, password, inputs, outputs, fee, locktime).toString());
155+
}
146156
}

src/main/java/io/cryptoapis/blockchains/ethereum_based/services/AddressService.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ public ApiResponse getTxsByAddress(String address, Map<String, String> params) {
5252
return WebServices.httpsRequest(WebServices.formatUrl(url.concat(pair.getKey()), endpointConfig, endpoint), HttpsRequestsEnum.GET.name(), endpointConfig, null);
5353
}
5454

55+
public ApiResponse getBasicTxsByAddress(String address, Map<String, String> params) {
56+
String endpoint = String.format("%s/%s/basic/transactions", ADDRESS, address);
57+
Pair<String, ApiError> pair = Utils.setQueryParams(params);
58+
if (pair.getValue() != null) {
59+
return Utils.setApiResponse(pair.getValue());
60+
}
61+
62+
return WebServices.httpsRequest(WebServices.formatUrl(url.concat(pair.getKey()), endpointConfig, endpoint), HttpsRequestsEnum.GET.name(), endpointConfig, null);
63+
}
64+
5565
public ApiResponse getNonce(String address) {
5666
String endpoint = String.format("%s/%s/nonce", ADDRESS, address);
5767

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ public ApiResponse getTx(String hash) {
4040
return getApiResponse(endpoint);
4141
}
4242

43+
public ApiResponse getBasicTx(String hash) {
44+
String endpoint = String.format("basic/hash/%s", hash);
45+
46+
return getApiResponse(endpoint);
47+
}
48+
4349
public ApiResponse getTx(int blockNumber, int index) {
4450
String endpoint = String.format("block/%s/%s", blockNumber, index);
4551

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package io.cryptoapis.blockchains.zilliqa.services;
2+
3+
import io.cryptoapis.abstractServices.AbstractServicesConfig;
4+
import io.cryptoapis.common_models.ApiError;
5+
import io.cryptoapis.common_models.ApiResponse;
6+
import io.cryptoapis.utils.Utils;
7+
import io.cryptoapis.utils.config.EndpointConfig;
8+
import io.cryptoapis.utils.enums.HttpsRequestsEnum;
9+
import io.cryptoapis.utils.rest.WebServices;
10+
import javafx.util.Pair;
11+
import org.apache.commons.lang.StringUtils;
12+
13+
import java.util.Map;
14+
15+
public class AddressService extends AbstractServicesConfig {
16+
17+
private static final String PATH = "/{0}/bc/{1}/{2}/{3}";
18+
19+
private static final String ADDRESS = "address";
20+
21+
protected AddressService(EndpointConfig endpointConfig) {
22+
super(endpointConfig);
23+
}
24+
25+
@Override
26+
protected String getPath() {
27+
return PATH;
28+
}
29+
30+
public ApiResponse getAddressInfo(String address) {
31+
String endpoint = String.format("%s/%s", ADDRESS, address);
32+
33+
return WebServices.httpsRequest(WebServices.formatUrl(url, endpointConfig, endpoint), HttpsRequestsEnum.GET.name(), endpointConfig, null);
34+
}
35+
36+
public ApiResponse generateNewAddress() {
37+
return WebServices.httpsRequest(WebServices.formatUrl(url, endpointConfig, ADDRESS), HttpsRequestsEnum.POST.name(), endpointConfig, StringUtils.EMPTY);
38+
}
39+
40+
public ApiResponse getTxsByAddress(String address, Map<String, String> params) {
41+
String endpoint = String.format("%s/%s/transactions", ADDRESS, address);
42+
Pair<String, ApiError> pair = Utils.setQueryParams(params);
43+
if (pair.getValue() != null) {
44+
return Utils.setApiResponse(pair.getValue());
45+
}
46+
47+
return WebServices.httpsRequest(WebServices.formatUrl(url.concat(pair.getKey()), endpointConfig, endpoint), HttpsRequestsEnum.GET.name(), endpointConfig, null);
48+
}
49+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package io.cryptoapis.blockchains.zilliqa.services;
2+
3+
import io.cryptoapis.abstractServices.AbstractServicesConfig;
4+
import io.cryptoapis.common_models.ApiResponse;
5+
import io.cryptoapis.utils.config.EndpointConfig;
6+
import io.cryptoapis.utils.constants.CryptoApisConstants;
7+
import io.cryptoapis.utils.enums.HttpsRequestsEnum;
8+
import io.cryptoapis.utils.rest.WebServices;
9+
10+
public class BlockService extends AbstractServicesConfig {
11+
private static final String PATH = "/{0}/bc/{1}/{2}/blocks/{3}";
12+
13+
protected BlockService(EndpointConfig endpointConfig) {
14+
super(endpointConfig);
15+
}
16+
17+
@Override
18+
protected String getPath() {
19+
return PATH;
20+
}
21+
22+
public ApiResponse getBlock(String blockHash) {
23+
return fetchBlock(blockHash);
24+
}
25+
26+
public ApiResponse getBlock(int blockNumber) {
27+
return fetchBlock(String.format("%s", blockNumber));
28+
}
29+
30+
public ApiResponse getLatestBlock() {
31+
return fetchBlock(CryptoApisConstants.LATEST);
32+
}
33+
34+
private ApiResponse fetchBlock(String endpoint) {
35+
return WebServices.httpsRequest(WebServices.formatUrl(url, endpointConfig, endpoint), HttpsRequestsEnum.GET.name(), endpointConfig, null);
36+
}
37+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package io.cryptoapis.blockchains.zilliqa.services;
2+
3+
import io.cryptoapis.abstractServices.AbstractServicesConfig;
4+
import io.cryptoapis.common_models.ApiResponse;
5+
import io.cryptoapis.utils.config.EndpointConfig;
6+
import io.cryptoapis.utils.enums.HttpsRequestsEnum;
7+
import io.cryptoapis.utils.rest.WebServices;
8+
9+
public class BlockchainService extends AbstractServicesConfig {
10+
private static final String PATH = "/{0}/bc/{1}/{2}/info";
11+
12+
protected BlockchainService(EndpointConfig endpointConfig) {
13+
super(endpointConfig);
14+
}
15+
16+
@Override
17+
protected String getPath() {
18+
return PATH;
19+
}
20+
21+
public ApiResponse getBlockchainInfo() {
22+
return WebServices.httpsRequest(WebServices.formatUrl(url, endpointConfig, null), HttpsRequestsEnum.GET.name(), endpointConfig, null);
23+
}
24+
}

0 commit comments

Comments
 (0)