Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add & modify mpc APIs #28

Merged
merged 1 commit into from
Dec 16, 2022
Merged
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
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.cobo.custody.api.client;

import com.cobo.custody.api.client.domain.ApiResponse;
import com.cobo.custody.api.client.domain.account.MPCAddressList;
import com.cobo.custody.api.client.domain.account.MPCAddresses;
import com.cobo.custody.api.client.domain.account.MPCChains;
import com.cobo.custody.api.client.domain.account.MPCCoins;
import com.cobo.custody.api.client.domain.account.*;
import com.cobo.custody.api.client.domain.asset.MPCUnspentInputs;
import com.cobo.custody.api.client.domain.asset.MPCWalletAsset;
import com.cobo.custody.api.client.domain.transaction.*;
Expand All @@ -13,25 +10,37 @@

public interface CoboMPCApiRestClient {
ApiResponse<MPCChains> getSupportedChains();

ApiResponse<MPCCoins> getSupportedCoins(String chainCode);

ApiResponse<MPCAddressList> getMainAddress(String chainCode);

ApiResponse<MPCAddressList> batchGenerateAddresses(String chainCode, int count);
ApiResponse<MPCAddresses> getAddressList(String chainCode, int pageIndex, int pageLength, Integer sortFlag);
ApiResponse<MPCWalletAsset> getWalletAssetList(String address, String chainCode);

ApiResponse<MPCAddresses> getAddressList(String chainCode, String startId, String endId, Integer limit, Integer sort);

ApiResponse<MPCBalance> getBalance(String address, String chainCode, String coin);

ApiResponse<MPCListBalances> listBalances(String coin, Integer pageIndex, Integer pageLength);

ApiResponse<MPCListSpendable> listSpendable(String coin, String address);

ApiResponse<MPCUnspentInputs> getWalletUnspentInputList(String address, String coin);

ApiResponse<MPCPostTransaction> createTransaction(String coin, String requestId, String fromAddr, String toAddr, BigInteger amount,
String toAddressDetails, BigInteger fee, BigInteger gasPrice, BigInteger gasLimit,
String extraParameters);
Integer operation, String extraParameters);

ApiResponse<MPCPostTransaction> speedUpTransaction(String coboId, BigInteger fee, BigInteger gasPrice, BigInteger gasLimit);
ApiResponse<MPCPostTransaction> speedUpTransaction(String coboId, String requestId, BigInteger fee, BigInteger gasPrice, BigInteger gasLimit);

ApiResponse<MPCPostTransaction> dropTransaction(String coboId, BigInteger fee, BigInteger gasPrice, BigInteger gasLimit);
ApiResponse<MPCPostTransaction> dropTransaction(String coboId, String requestId, BigInteger fee, BigInteger gasPrice, BigInteger gasLimit);

ApiResponse<MPCTransactionInfos> getTransactionByRequestIds(String requestIds, Integer status);

ApiResponse<MPCTransactionInfos> getTransactionByCoboIds(String coboIds, Integer status);

ApiResponse<MPCTransactionInfos> getTransactionByTxHash(String txId, Integer transactionType);

ApiResponse<MPCTransactions> listWalletTransactions(Long startTime, Long endTime, Integer status, String order,
Integer transactionType, String coins, String fromAddr, String toAddr,
Integer limit);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.cobo.custody.api.client.domain.account;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;

public class MPCBalance {
@JsonProperty(value = "coin_data")
private List<MPCCoinBalanceDetail> coinData;

public List<MPCCoinBalanceDetail> getCoinData() {
return coinData;
}

public void setCoinData(List<MPCCoinBalanceDetail> coinData) {
this.coinData = coinData;
}

@Override
public String toString() {
return "{" +
"coinData=" + coinData +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package com.cobo.custody.api.client.domain.account;

import com.fasterxml.jackson.annotation.JsonProperty;

public class MPCCoinBalanceDetail {
@JsonProperty(value = "address")
private String address;

@JsonProperty(value = "coin")
private String coin;

@JsonProperty(value = "chain_code")
private String chainCode;

@JsonProperty(value = "display_code")
private String displayCode;

@JsonProperty(value = "description")
private String description;

@JsonProperty(value = "balance")
private String balance;

@JsonProperty(value = "decimal")
private Integer decimal;


public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}

public String getCoin() {
return coin;
}

public void setCoin(String coin) {
this.coin = coin;
}

public String getChainCode() {
return chainCode;
}

public void setChainCode(String chainCode) {
this.chainCode = chainCode;
}

public String getDisplayCode() {
return displayCode;
}

public void setDisplayCode(String displayCode) {
this.displayCode = displayCode;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public String getBalance() {
return balance;
}

public void setBalance(String balance) {
this.balance = balance;
}

public Integer getDecimal() {
return decimal;
}

public void setDecimal(Integer decimal) {
this.decimal = decimal;
}

@Override
public String toString() {
return "{" +
"address='" + address + '\'' +
", coin='" + coin + '\'' +
", chainCode='" + chainCode + '\'' +
", displayCode='" + displayCode + '\'' +
", description='" + description + '\'' +
", balance='" + balance + '\'' +
", decimal=" + decimal +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.cobo.custody.api.client.domain.account;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;

public class MPCListBalances {
@JsonProperty(value = "coin_data")
private List<MPCCoinBalanceDetail> coinData;

@JsonProperty(value = "total")
private Integer total;

public List<MPCCoinBalanceDetail> getCoinData() {
return coinData;
}

public void setCoinData(List<MPCCoinBalanceDetail> coinData) {
this.coinData = coinData;
}

public Integer getTotal() {
return total;
}

public void setTotal(Integer total) {
this.total = total;
}

@Override
public String toString() {
return "{" +
"coinData=" + coinData +
", total=" + total +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.cobo.custody.api.client.domain.account;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;

public class MPCListSpendable {
@JsonProperty(value = "utxos")
private List<UTXO> utxos;

public List<UTXO> getUtxos() {
return utxos;
}

public void setUtxos(List<UTXO> utxos) {
this.utxos = utxos;
}

@Override
public String toString() {
return "{" +
"utxos=" + utxos +
'}';
}
}
78 changes: 78 additions & 0 deletions src/main/java/com/cobo/custody/api/client/domain/account/UTXO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.cobo.custody.api.client.domain.account;

import com.fasterxml.jackson.annotation.JsonProperty;

public class UTXO {
@JsonProperty(value = "tx_hash")
private String txHash;
@JsonProperty(value = "vout_n")
private Integer voutN;
@JsonProperty(value = "address")
private String address;
@JsonProperty(value = "amount")
private Integer amount;
@JsonProperty(value = "is_coinbase")
private Boolean isCoinbase;
@JsonProperty(value = "confirmed_number")
private Integer confirmedNumber;

public String getTxHash() {
return txHash;
}

public void setTxHash(String txHash) {
this.txHash = txHash;
}

public Integer getVoutN() {
return voutN;
}

public void setVoutN(Integer voutN) {
this.voutN = voutN;
}

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}

public Integer getAmount() {
return amount;
}

public void setAmount(Integer amount) {
this.amount = amount;
}

public Boolean getCoinbase() {
return isCoinbase;
}

public void setCoinbase(Boolean coinbase) {
isCoinbase = coinbase;
}

public Integer getConfirmedNumber() {
return confirmedNumber;
}

public void setConfirmedNumber(Integer confirmedNumber) {
this.confirmedNumber = confirmedNumber;
}

@Override
public String toString() {
return "{" +
"txHash='" + txHash + '\'' +
", voutN=" + voutN +
", address='" + address + '\'' +
", amount=" + amount +
", isCoinbase=" + isCoinbase +
", confirmedNumber=" + confirmedNumber +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,21 @@ public ApiResponse<MPCAddressList> batchGenerateAddresses(String chainCode, int
}

@Override
public ApiResponse<MPCAddresses> getAddressList(String chainCode, int pageIndex, int pageLength, Integer sortFlag) {
return executeSync(coboMPCApiService.getAddressList(chainCode, pageIndex, pageLength, sortFlag));
public ApiResponse<MPCAddresses> getAddressList(String chainCode, String startId, String endId, Integer limit, Integer sort) {
return executeSync(coboMPCApiService.getAddressList(chainCode, startId, endId, limit, sort));
}

@Override
public ApiResponse<MPCWalletAsset> getWalletAssetList(String address, String chainCode) {
return executeSync(coboMPCApiService.getWalletAssetList(address, chainCode));
public ApiResponse<MPCBalance> getBalance(String address, String chainCode, String coin) {
return executeSync(coboMPCApiService.getBalance(address, chainCode, coin));
}

public ApiResponse<MPCListBalances> listBalances(String coin, Integer pageIndex, Integer pageLength) {
return executeSync(coboMPCApiService.listBalances(coin, pageIndex, pageLength));
}

public ApiResponse<MPCListSpendable> listSpendable(String coin, String address) {
return executeSync(coboMPCApiService.listSpendable(coin, address));
}

@Override
public ApiResponse<MPCUnspentInputs> getWalletUnspentInputList(String address, String coin) {
Expand All @@ -65,19 +71,19 @@ public ApiResponse<MPCUnspentInputs> getWalletUnspentInputList(String address, S
@Override
public ApiResponse<MPCPostTransaction> createTransaction(String coin, String requestId, String fromAddr, String toAddr, BigInteger amount,
String toAddressDetails, BigInteger fee, BigInteger gasPrice, BigInteger gasLimit,
String extraParameters) {
Integer operation, String extraParameters) {
return executeSync(coboMPCApiService.createTransaction(coin, requestId, fromAddr, toAddr, amount,
toAddressDetails, fee, gasPrice, gasLimit, extraParameters));
toAddressDetails, fee, gasPrice, gasLimit, operation, extraParameters));
}

@Override
public ApiResponse<MPCPostTransaction> speedUpTransaction(String coboId, BigInteger fee, BigInteger gasPrice, BigInteger gasLimit) {
return executeSync(coboMPCApiService.speedUpTransaction(coboId, fee, gasPrice, gasLimit));
public ApiResponse<MPCPostTransaction> speedUpTransaction(String coboId, String requestId, BigInteger fee, BigInteger gasPrice, BigInteger gasLimit) {
return executeSync(coboMPCApiService.speedUpTransaction(coboId, requestId, fee, gasPrice, gasLimit));
}

@Override
public ApiResponse<MPCPostTransaction> dropTransaction(String coboId, BigInteger fee, BigInteger gasPrice, BigInteger gasLimit) {
return executeSync(coboMPCApiService.dropTransaction(coboId, fee, gasPrice, gasLimit));
public ApiResponse<MPCPostTransaction> dropTransaction(String coboId, String requestId, BigInteger fee, BigInteger gasPrice, BigInteger gasLimit) {
return executeSync(coboMPCApiService.dropTransaction(coboId, requestId, fee, gasPrice, gasLimit));
}

@Override
Expand Down
Loading