public String txId;
+ public String accountId;
+
public QueryBuilder setTxId(String txId) {
this.txId = txId;
return this;
}
+ public QueryBuilder setAccountId(String accountId) {
+ this.accountId = accountId;
+ return this;
+ }
+
+
/**
* call list-transactions api
*
public List<Transaction> list(Client client) throws BytomException {
Type listType = new ParameterizedTypeImpl(List.class, new Class[]{Transaction.class});
- List<Transaction> transactionList = client.request("list-transactions", this, listType);
+ List<Transaction> transactionList = client.request("list-transactions", null, listType);
+
logger.info("list-transactions:");
logger.info("size of transactionList:" + transactionList.size());
- logger.info(transactionList.get(0).toJson());
+ logger.info("all transactions:");
+ for (int i = 0; i < transactionList.size(); i++) {
+ logger.info(transactionList.get(i).toJson());
+ }
+
+ return transactionList;
+ }
+
+ public List<Transaction> listById(Client client) throws BytomException {
+ Map<String, Object> req = new HashMap<String, Object>();
+ req.put("tx_id", this.txId);
+ req.put("detail", true);
+
+ Type listType = new ParameterizedTypeImpl(List.class, new Class[]{Transaction.class});
+ List<Transaction> transactionList = client.request("list-transactions", req, listType);
+
+ logger.info("list-transactions:");
+ logger.info("size of transactionList:" + transactionList.size());
+ logger.info("all transactions:");
+ for (int i = 0; i < transactionList.size(); i++) {
+ logger.info(transactionList.get(i).toJson());
+ }
+
+ return transactionList;
+ }
+
+ public List<Transaction> listByAccountId(Client client) throws BytomException {
+ Map<String, Object> req = new HashMap<String, Object>();
+ req.put("account_id", this.accountId);
+
+ Type listType = new ParameterizedTypeImpl(List.class, new Class[]{Transaction.class});
+ List<Transaction> transactionList = client.request("list-transactions", req, listType);
+
+ logger.info("list-transactions:");
+ logger.info("size of transactionList:" + transactionList.size());
+ logger.info("all transactions:");
+ for (int i = 0; i < transactionList.size(); i++) {
+ logger.info(transactionList.get(i).toJson());
+ }
return transactionList;
}
* @throws BytomException
*/
public Transaction get(Client client) throws BytomException {
- // TODO: 2018/5/23 need to test
- Transaction transaction = client.request("get-transaction", this, Transaction.class);
+ Map<String, Object> req = new HashMap<String, Object>();
+ req.put("tx_id", this.txId);
+
+ Transaction transaction = client.request("get-transaction", req, Transaction.class);
+
logger.info("get-transaction:");
logger.info(transaction.toJson());
+
return transaction;
}
}
@Test
- public void testListTransactions() throws Exception {
- String tx_id = "b9a1baa1ae391b502fe5543a9559e6d98dc6cf77f9327daaebcb7222c3bebda6";
+ public void testListByIdTransactions() throws Exception {
+ String tx_id = "f04d4d9b2580ff6496f9f08d903de5a2365975fb8d65b66ca4259f152c5dd134";
List<Transaction> transactionList =
new Transaction.QueryBuilder().setTxId(tx_id).list(client);
for (Transaction tx: transactionList
) {
if (tx.txId.equalsIgnoreCase(tx_id)) {
+ logger.info("this transaction is :");
logger.info(tx.toJson());
}
}
}
+ @Test
+ public void testListByAccountIdTransactions() throws Exception {
+ String account_id = "0E6KP8C100A02";
+ List<Transaction> transactionList =
+ new Transaction.QueryBuilder().setAccountId(account_id).list(client);
+ }
+
+
+
+
public void testSenderKeyCreate() throws Exception {
String alias = "sender-key";
String password = "123456";