From 644f141114e5b1cc698f7b62226f76790f026eaf Mon Sep 17 00:00:00 2001 From: haofengjiang <115331712+haofengjiang@users.noreply.github.com> Date: Tue, 20 Dec 2022 10:43:35 +0800 Subject: [PATCH] release new mpc api --- .../api/client/CoboMPCApiRestClient.java | 6 +- .../api/client/domain/account/MPCAddress.java | 38 ++++++++--- .../client/domain/asset/MPCUnspentInputs.java | 68 ------------------- .../domain/transaction/EstimateFeeDetail.java | 2 +- .../transaction/MPCPostTransaction.java | 10 --- .../domain/transaction/MPCTransaction.java | 50 ++++++++++---- .../client/domain/transaction/RBFDetail.java | 33 --------- .../client/impl/CoboMPCApiRestClientImpl.java | 16 +---- .../api/client/impl/CoboMPCApiService.java | 7 +- .../impl/CoboMPCApiRestClientImplTest.java | 3 +- 10 files changed, 74 insertions(+), 159 deletions(-) delete mode 100644 src/main/java/com/cobo/custody/api/client/domain/asset/MPCUnspentInputs.java delete mode 100644 src/main/java/com/cobo/custody/api/client/domain/transaction/RBFDetail.java diff --git a/src/main/java/com/cobo/custody/api/client/CoboMPCApiRestClient.java b/src/main/java/com/cobo/custody/api/client/CoboMPCApiRestClient.java index 0c54b0b..29d268d 100644 --- a/src/main/java/com/cobo/custody/api/client/CoboMPCApiRestClient.java +++ b/src/main/java/com/cobo/custody/api/client/CoboMPCApiRestClient.java @@ -2,8 +2,6 @@ import com.cobo.custody.api.client.domain.ApiResponse; 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.*; import java.math.BigInteger; @@ -25,8 +23,6 @@ public interface CoboMPCApiRestClient { ApiResponse listSpendable(String coin, String address); - ApiResponse getWalletUnspentInputList(String address, String coin); - ApiResponse createTransaction(String coin, String requestId, String fromAddr, String toAddr, BigInteger amount, String toAddressDetails, BigInteger fee, BigInteger gasPrice, BigInteger gasLimit, Integer operation, String extraParameters); @@ -41,7 +37,7 @@ ApiResponse createTransaction(String coin, String requestId, ApiResponse getTransactionByTxHash(String txId, Integer transactionType); - ApiResponse listWalletTransactions(Long startTime, Long endTime, Integer status, String order, + ApiResponse listWalletTransactions(Long startTime, Long endTime, Integer status, String orderBy, String order, Integer transactionType, String coins, String fromAddr, String toAddr, Integer limit); diff --git a/src/main/java/com/cobo/custody/api/client/domain/account/MPCAddress.java b/src/main/java/com/cobo/custody/api/client/domain/account/MPCAddress.java index 4e04cb6..42ac7c5 100644 --- a/src/main/java/com/cobo/custody/api/client/domain/account/MPCAddress.java +++ b/src/main/java/com/cobo/custody/api/client/domain/account/MPCAddress.java @@ -1,10 +1,22 @@ package com.cobo.custody.api.client.domain.account; -import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + public class MPCAddress { + private String id; private String address; - private Integer type; + @JsonProperty(value = "hd_path") + private String hdPath; + private Integer encoding; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } public String getAddress() { return address; @@ -14,19 +26,29 @@ public void setAddress(String address) { this.address = address; } - public Integer getType() { - return type; + public String getHdPath() { + return hdPath; + } + + public void setHdPath(String hdPath) { + this.hdPath = hdPath; + } + + public Integer getEncoding() { + return encoding; } - public void setType(Integer type) { - this.type = type; + public void setEncoding(Integer encoding) { + this.encoding = encoding; } @Override public String toString() { return "{" + - "address='" + address + '\'' + - ", type='" + type + '\'' + + "id='" + id + '\'' + + ", address='" + address + '\'' + + ", hdPath='" + hdPath + '\'' + + ", encoding='" + encoding + '\'' + '}'; } } diff --git a/src/main/java/com/cobo/custody/api/client/domain/asset/MPCUnspentInputs.java b/src/main/java/com/cobo/custody/api/client/domain/asset/MPCUnspentInputs.java deleted file mode 100644 index 98196e6..0000000 --- a/src/main/java/com/cobo/custody/api/client/domain/asset/MPCUnspentInputs.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.cobo.custody.api.client.domain.asset; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.math.BigInteger; - -public class MPCUnspentInputs { - private String address; - @JsonProperty(value = "tx_hash") - private String txHash; - @JsonProperty(value = "vout_n") - private Integer voutN; - - private BigInteger amount; - @JsonProperty(value = "confirmed_num") - private Integer confirmedNum; - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - - 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 BigInteger getAmount() { - return amount; - } - - public void setAmount(BigInteger amount) { - this.amount = amount; - } - - public Integer getConfirmedNum() { - return confirmedNum; - } - - public void setConfirmedNum(Integer confirmedNum) { - this.confirmedNum = confirmedNum; - } - - @Override - public String toString() { - return "{" + - "txHash='" + txHash + '\'' + - ", voutN='" + voutN + '\'' + - ", address='" + address + '\'' + - ", amount='" + amount + '\'' + - ", confirmedNum='" + confirmedNum + '\'' + - '}'; - } -} diff --git a/src/main/java/com/cobo/custody/api/client/domain/transaction/EstimateFeeDetail.java b/src/main/java/com/cobo/custody/api/client/domain/transaction/EstimateFeeDetail.java index fb16cbc..098ae7b 100644 --- a/src/main/java/com/cobo/custody/api/client/domain/transaction/EstimateFeeDetail.java +++ b/src/main/java/com/cobo/custody/api/client/domain/transaction/EstimateFeeDetail.java @@ -9,7 +9,7 @@ public class EstimateFeeDetail { private BigInteger feePerByte; @JsonProperty(value = "gas_price") private BigInteger gasPrice; - @JsonProperty(value = "gasLimit") + @JsonProperty(value = "gas_limit") private BigInteger gasLimit; public BigInteger getFeePerByte() { diff --git a/src/main/java/com/cobo/custody/api/client/domain/transaction/MPCPostTransaction.java b/src/main/java/com/cobo/custody/api/client/domain/transaction/MPCPostTransaction.java index dd26448..febf46f 100644 --- a/src/main/java/com/cobo/custody/api/client/domain/transaction/MPCPostTransaction.java +++ b/src/main/java/com/cobo/custody/api/client/domain/transaction/MPCPostTransaction.java @@ -5,7 +5,6 @@ public class MPCPostTransaction { @JsonProperty(value = "cobo_id") private String coboId; - private Integer status; public String getCoboId() { return coboId; @@ -15,18 +14,9 @@ public void setCoboId(String coboId) { this.coboId = coboId; } - public Integer getStatus() { - return status; - } - - public void setStatus(Integer status) { - this.status = status; - } - public String toString() { return "{" + "coboId='" + coboId + '\'' + - ", status='" + status + '\'' + '}'; } } diff --git a/src/main/java/com/cobo/custody/api/client/domain/transaction/MPCTransaction.java b/src/main/java/com/cobo/custody/api/client/domain/transaction/MPCTransaction.java index df8ff19..d1621c2 100644 --- a/src/main/java/com/cobo/custody/api/client/domain/transaction/MPCTransaction.java +++ b/src/main/java/com/cobo/custody/api/client/domain/transaction/MPCTransaction.java @@ -3,7 +3,6 @@ import com.cobo.custody.api.client.domain.account.*; import com.fasterxml.jackson.annotation.JsonProperty; -import java.math.BigInteger; import java.util.List; public class MPCTransaction { @@ -23,8 +22,8 @@ public class MPCTransaction { @JsonProperty(value = "fee_detail") private MPCFee feeDetail; - @JsonProperty(value = "source_address") - private String sourceAddress; + @JsonProperty(value = "source_addresses") + private List sourceAddresses; @JsonProperty(value = "from_address") private String fromAddress; @@ -38,15 +37,19 @@ public class MPCTransaction { @JsonProperty(value = "vout_n") private Integer voutN; + private Integer nonce; + @JsonProperty(value = "confirmed_number") private Integer confirmedNumber; - @JsonProperty(value = "rbf_detail") - private RBFDetail rbfDetail; + @JsonProperty(value = "replace_cobo_id") + private String replaceCoboId; @JsonProperty(value = "transaction_type") private Integer transactionType; + private Integer operation; + @JsonProperty(value = "block_detail") private MPCBlock blockDetail; @@ -112,12 +115,12 @@ public void setFeeDetail(MPCFee feeDetail) { this.feeDetail = feeDetail; } - public String getSourceAddress() { - return sourceAddress; + public List getSourceAddresses() { + return sourceAddresses; } - public void setSourceAddress(String sourceAddress) { - this.sourceAddress = sourceAddress; + public void setSourceAddresses(List sourceAddresses) { + this.sourceAddresses = sourceAddresses; } public String getFromAddress() { @@ -152,6 +155,14 @@ public void setVoutN(Integer voutN) { this.voutN = voutN; } + public Integer getNonce() { + return nonce; + } + + public void setNonce(Integer nonce) { + this.nonce = nonce; + } + public Integer getConfirmedNumber() { return confirmedNumber; } @@ -160,12 +171,12 @@ public void setConfirmedNumber(Integer confirmedNumber) { this.confirmedNumber = confirmedNumber; } - public RBFDetail getRbfDetail() { - return rbfDetail; + public String getReplaceCoboId() { + return replaceCoboId; } - public void setRbfDetail(RBFDetail rbfDetail) { - this.rbfDetail = rbfDetail; + public void setReplaceCoboId(String replaceCoboId) { + this.replaceCoboId = replaceCoboId; } public Integer getTransactionType() { @@ -176,6 +187,14 @@ public void setTransactionType(Integer transactionType) { this.transactionType = transactionType; } + public Integer getOperation() { + return operation; + } + + public void setOperation(Integer operation) { + this.operation = operation; + } + public MPCBlock getBlockDetail() { return blockDetail; } @@ -233,11 +252,16 @@ public String toString() { ", coinDetail='" + coinDetail + '\'' + ", amountDetail='" + amountDetail + '\'' + ", feeDetail='" + feeDetail + '\'' + + ", sourceAddresses='" + sourceAddresses + '\'' + ", fromAddress='" + fromAddress + '\'' + ", toAddress='" + toAddress + '\'' + ", txHash='" + txHash + '\'' + ", voutN='" + voutN + '\'' + + ", nonce='" + nonce + '\'' + + ", confirmedNumber='" + confirmedNumber + '\'' + + ", replaceCoboId='" + replaceCoboId + '\'' + ", transactionType='" + transactionType + '\'' + + ", operation='" + operation + '\'' + ", blockDetail='" + blockDetail + '\'' + ", txDetail='" + txDetail + '\'' + ", extraParameters='" + extraParameters + '\'' + diff --git a/src/main/java/com/cobo/custody/api/client/domain/transaction/RBFDetail.java b/src/main/java/com/cobo/custody/api/client/domain/transaction/RBFDetail.java deleted file mode 100644 index 65b084a..0000000 --- a/src/main/java/com/cobo/custody/api/client/domain/transaction/RBFDetail.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.cobo.custody.api.client.domain.transaction; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class RBFDetail { - @JsonProperty(value = "replaced_by") - private String replacedBy; - private String replaced; - - public String getReplacedBy() { - return replacedBy; - } - - public void setReplacedBy(String replacedBy) { - this.replacedBy = replacedBy; - } - - public String getReplaced() { - return replaced; - } - - public void setReplaced(String replaced) { - this.replaced = replaced; - } - - @Override - public String toString() { - return "{" + - "replacedBy='" + replacedBy + '\'' + - ", replaced='" + replaced + '\'' + - '}'; - } -} diff --git a/src/main/java/com/cobo/custody/api/client/impl/CoboMPCApiRestClientImpl.java b/src/main/java/com/cobo/custody/api/client/impl/CoboMPCApiRestClientImpl.java index 67aeda8..808b200 100644 --- a/src/main/java/com/cobo/custody/api/client/impl/CoboMPCApiRestClientImpl.java +++ b/src/main/java/com/cobo/custody/api/client/impl/CoboMPCApiRestClientImpl.java @@ -5,16 +5,9 @@ import com.cobo.custody.api.client.config.Env; import com.cobo.custody.api.client.domain.ApiResponse; 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.*; -import retrofit2.Call; -import retrofit2.http.Field; -import retrofit2.http.GET; -import retrofit2.http.Query; import java.math.BigInteger; -import java.util.List; import static com.cobo.custody.api.client.impl.CoboApiServiceGenerator.createService; import static com.cobo.custody.api.client.impl.CoboApiServiceGenerator.executeSync; @@ -63,11 +56,6 @@ public ApiResponse listSpendable(String coin, String address) return executeSync(coboMPCApiService.listSpendable(coin, address)); } - @Override - public ApiResponse getWalletUnspentInputList(String address, String coin) { - return executeSync(coboMPCApiService.getWalletUnspentInputList(address, coin)); - } - @Override public ApiResponse createTransaction(String coin, String requestId, String fromAddr, String toAddr, BigInteger amount, String toAddressDetails, BigInteger fee, BigInteger gasPrice, BigInteger gasLimit, @@ -102,10 +90,10 @@ public ApiResponse getTransactionByTxHash(String txHash, In } @Override - public ApiResponse listWalletTransactions(Long startTime, Long endTime, Integer status, String order, + public ApiResponse listWalletTransactions(Long startTime, Long endTime, Integer status, String orderBy, String order, Integer transactionType, String coins, String fromAddr, String toAddr, Integer limit) { - return executeSync(coboMPCApiService.listWalletTransactions(startTime, endTime, status, order, transactionType, + return executeSync(coboMPCApiService.listWalletTransactions(startTime, endTime, status, orderBy, order, transactionType, coins, fromAddr, toAddr, limit)); } diff --git a/src/main/java/com/cobo/custody/api/client/impl/CoboMPCApiService.java b/src/main/java/com/cobo/custody/api/client/impl/CoboMPCApiService.java index e133522..62337cf 100644 --- a/src/main/java/com/cobo/custody/api/client/impl/CoboMPCApiService.java +++ b/src/main/java/com/cobo/custody/api/client/impl/CoboMPCApiService.java @@ -2,8 +2,6 @@ import com.cobo.custody.api.client.domain.ApiResponse; 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.*; import retrofit2.Call; import retrofit2.http.*; @@ -46,10 +44,6 @@ Call> listBalances(@Query("coin") String coin, Call> listSpendable(@Query("coin") String coin, @Query("address") String address); - @GET("/v1/custody/mpc/list_unspent_inputs/") - Call> getWalletUnspentInputList(@Query("address") String address, - @Query("coin") String coin); - @FormUrlEncoded @POST("/v1/custody/mpc/create_transaction/") Call> createTransaction(@Field("coin") String coin, @@ -96,6 +90,7 @@ Call> getTransactionByTxhash(@Query("tx_hash") Call> listWalletTransactions(@Query("start_time") Long startTime, @Query("end_time") Long endTime, @Query("status") Integer status, + @Query("order_by") String orderBy, @Query("order") String order, @Query("transaction_type") Integer transactionType, @Query("coins") String coins, diff --git a/src/test/java/com/cobo/custody/api/client/impl/CoboMPCApiRestClientImplTest.java b/src/test/java/com/cobo/custody/api/client/impl/CoboMPCApiRestClientImplTest.java index 69ad39e..0323895 100644 --- a/src/test/java/com/cobo/custody/api/client/impl/CoboMPCApiRestClientImplTest.java +++ b/src/test/java/com/cobo/custody/api/client/impl/CoboMPCApiRestClientImplTest.java @@ -132,6 +132,7 @@ public void testListWalletTransactions() { Long startTime = null; Long endTime = null; Integer status = null; + String orderBy = null; String order = null; Integer transactionType = null; String coins = null; @@ -139,7 +140,7 @@ public void testListWalletTransactions() { String toAddress = null; Integer limit = null; - ApiResponse res = mpcClient.listWalletTransactions(startTime, endTime, status, order, + ApiResponse res = mpcClient.listWalletTransactions(startTime, endTime, status, orderBy, order, transactionType, coins, fromAddress, toAddress, limit); System.out.println(res.getResult()); assertTrue(res.isSuccess());