Skip to content

Commit e32bdf5

Browse files
committed
add 7 http interface
1 parent 6946c26 commit e32bdf5

2 files changed

Lines changed: 150 additions & 2 deletions

File tree

‎src/test/java/stest/tron/wallet/common/client/utils/HttpMethed.java‎

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,6 +1491,154 @@ public static HttpResponse updateEnergyLimit(String httpNode, byte[] ownerAddres
14911491
return response;
14921492
}
14931493

1494+
/**
1495+
* constructor.
1496+
*/
1497+
public static HttpResponse createAddress(String httpNode, String value) {
1498+
try {
1499+
final String requestUrl = "http://" + httpNode + "/wallet/createaddress";
1500+
JsonObject userBaseObj2 = new JsonObject();
1501+
userBaseObj2.addProperty("value", str2hex(value));
1502+
response = createConnect(requestUrl, userBaseObj2);
1503+
logger.info(userBaseObj2.toString());
1504+
} catch (Exception e) {
1505+
e.printStackTrace();
1506+
httppost.releaseConnection();
1507+
return null;
1508+
}
1509+
return response;
1510+
}
1511+
1512+
/**
1513+
* constructor.
1514+
*/
1515+
public static HttpResponse generateAddress(String httpNode) {
1516+
try {
1517+
final String requestUrl = "http://" + httpNode + "/wallet/generateaddress";
1518+
JsonObject userBaseObj2 = new JsonObject();
1519+
response = createConnect(requestUrl, userBaseObj2);
1520+
} catch (Exception e) {
1521+
e.printStackTrace();
1522+
httppost.releaseConnection();
1523+
return null;
1524+
}
1525+
return response;
1526+
}
1527+
1528+
1529+
/**
1530+
* constructor.
1531+
*/
1532+
public static HttpResponse validateAddress(String httpNode, String address) {
1533+
try {
1534+
final String requestUrl = "http://" + httpNode + "/wallet/validateaddress";
1535+
JsonObject userBaseObj2 = new JsonObject();
1536+
userBaseObj2.addProperty("address", address);
1537+
response = createConnect(requestUrl, userBaseObj2);
1538+
logger.info(userBaseObj2.toString());
1539+
} catch (Exception e) {
1540+
e.printStackTrace();
1541+
httppost.releaseConnection();
1542+
return null;
1543+
}
1544+
return response;
1545+
}
1546+
1547+
/**
1548+
* constructor.
1549+
*/
1550+
public static HttpResponse easyTransfer(String httpNode, String value, byte[] toAddress,
1551+
Long amount) {
1552+
try {
1553+
final String requestUrl = "http://" + httpNode + "/wallet/easytransfer";
1554+
JsonObject userBaseObj2 = new JsonObject();
1555+
userBaseObj2.addProperty("toAddress", ByteArray.toHexString(toAddress));
1556+
userBaseObj2.addProperty("passPhrase", str2hex(value));
1557+
userBaseObj2.addProperty("amount", amount);
1558+
response = createConnect(requestUrl, userBaseObj2);
1559+
logger.info(userBaseObj2.toString());
1560+
transactionString = EntityUtils.toString(response.getEntity());
1561+
logger.info(transactionString);
1562+
} catch (Exception e) {
1563+
e.printStackTrace();
1564+
httppost.releaseConnection();
1565+
return null;
1566+
}
1567+
return response;
1568+
}
1569+
1570+
/**
1571+
* constructor.
1572+
*/
1573+
public static HttpResponse easyTransferByPrivate(String httpNode, String privateKey,
1574+
byte[] toAddress, Long amount) {
1575+
try {
1576+
final String requestUrl = "http://" + httpNode + "/wallet/easytransferbyprivate";
1577+
JsonObject userBaseObj2 = new JsonObject();
1578+
userBaseObj2.addProperty("privateKey", privateKey);
1579+
userBaseObj2.addProperty("toAddress", ByteArray.toHexString(toAddress));
1580+
userBaseObj2.addProperty("amount", amount);
1581+
response = createConnect(requestUrl, userBaseObj2);
1582+
logger.info(userBaseObj2.toString());
1583+
transactionString = EntityUtils.toString(response.getEntity());
1584+
logger.info(transactionString);
1585+
} catch (Exception e) {
1586+
e.printStackTrace();
1587+
httppost.releaseConnection();
1588+
return null;
1589+
}
1590+
return response;
1591+
}
1592+
1593+
/**
1594+
* constructor.
1595+
*/
1596+
public static HttpResponse easyTransferAsset(String httpNode, String value, byte[] toAddress,
1597+
Long amount, String assetId) {
1598+
try {
1599+
final String requestUrl = "http://" + httpNode + "/wallet/easytransferasset";
1600+
JsonObject userBaseObj2 = new JsonObject();
1601+
userBaseObj2.addProperty("toAddress", ByteArray.toHexString(toAddress));
1602+
userBaseObj2.addProperty("passPhrase", str2hex(value));
1603+
userBaseObj2.addProperty("amount", amount);
1604+
userBaseObj2.addProperty("assetId", assetId);
1605+
response = createConnect(requestUrl, userBaseObj2);
1606+
logger.info(userBaseObj2.toString());
1607+
transactionString = EntityUtils.toString(response.getEntity());
1608+
logger.info(transactionString);
1609+
} catch (Exception e) {
1610+
e.printStackTrace();
1611+
httppost.releaseConnection();
1612+
return null;
1613+
}
1614+
return response;
1615+
}
1616+
1617+
/**
1618+
* constructor.
1619+
*/
1620+
public static HttpResponse easyTransferAssetByPrivate(String httpNode, String privateKey,
1621+
byte[] toAddress, Long amount, String assetId) {
1622+
try {
1623+
final String requestUrl = "http://" + httpNode + "/wallet/easytransferassetbyprivate";
1624+
JsonObject userBaseObj2 = new JsonObject();
1625+
userBaseObj2.addProperty("privateKey", privateKey);
1626+
userBaseObj2.addProperty("toAddress", ByteArray.toHexString(toAddress));
1627+
userBaseObj2.addProperty("amount", amount);
1628+
userBaseObj2.addProperty("assetId", assetId);
1629+
response = createConnect(requestUrl, userBaseObj2);
1630+
logger.info(userBaseObj2.toString());
1631+
transactionString = EntityUtils.toString(response.getEntity());
1632+
logger.info(transactionString);
1633+
} catch (Exception e) {
1634+
e.printStackTrace();
1635+
httppost.releaseConnection();
1636+
return null;
1637+
}
1638+
return response;
1639+
}
1640+
1641+
14941642
/**
14951643
* constructor.
14961644
*/

‎src/test/resources/testng.conf‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ solidityNode = {
5454
httpnode = {
5555
ip.list = [
5656
# "39.105.89.183:8090",
57-
"127.0.0.1:8090",
58-
"127.0.0.1:8093",
57+
#"127.0.0.1:8090",
58+
#"127.0.0.1:8093",
5959
"47.94.197.215:8091",
6060
"101.200.52.146:8091"
6161
]

0 commit comments

Comments
 (0)