fix
Helius
2021-11-23 9699d339f596847ac541cb4c1a370847c6e76b68
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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;
    }
 
}