package com.xcong.excoin.modules.blackchain.service; import java.io.IOException; import java.math.BigDecimal; import java.text.MessageFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Map; import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang3.StringUtils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.ripple.core.coretypes.AccountID; import com.ripple.core.coretypes.Amount; import com.ripple.core.coretypes.uint.UInt32; import com.ripple.core.types.known.tx.signed.SignedTransaction; import com.ripple.core.types.known.tx.txns.Payment; import com.xcong.excoin.modules.blackchain.model.XrpTransResult; public class XrpService { /** * 平台钱包地址 */ public final static String ACCOUNT="rKMGEyjXErL2dx9ck5QXFJVH8onSfHF5gn"; /** * 官方接口地址 */ private static String getUrl = "https://data.ripple.com"; private String postUrl = "https://s1.ripple.com:51234"; /** * 结果类型 */ private final static String TES_SUCCESS = "tesSUCCESS"; /** * start YYYY-MM-DDThh:mm:ssZ String - Timestamp Start time of query range. The default is the * earliest date available. * end String - Timestamp End time of query range. The * default is the current date. * min_sequence String Minimum sequence number to * query. * max_sequence String Max sequence number to query. * type String Restrict results to a specified transaction type. * result String Restrict results to a specified transaction result. * binary Boolean Return results in binary format. * descending Boolean If true, return results in reverse chronological order.The default is false. * limit Integer Maximum results per page. The default is 20. Cannot be more than 1,000. * marker String Pagination key from previously * returned response. * * https://github.com/ripple/rippled-historical-database * 接口文档:https://xrpl.org/data-api.html#get-account */ public static XrpTransResult getTransactions(Date start) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); String startTime = dateFormat.format(start); String url ="https://data.ripple.com/v2/accounts/"+ACCOUNT+"/transactions?type=Payment&result=tesSUCCESS&limit=100&start="+startTime; // 十分钟查一次 每次100条 String result = HttpUtil.get(url); try { JSONObject json = JSONObject.parseObject(result); XrpTransResult res = json.toJavaObject(XrpTransResult.class); return res; }catch(Exception e) { e.printStackTrace(); } return null; } }