1111import org .springframework .beans .factory .annotation .Autowired ;
1212import org .springframework .stereotype .Component ;
1313import org .tron .api .GrpcAPI .BytesMessage ;
14+ import org .tron .common .utils .ByteArray ;
1415import org .tron .core .Wallet ;
1516import org .tron .core .services .http .JsonFormat .ParseException ;
1617
@@ -30,9 +31,12 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) {
3031 BytesMessage .Builder build = BytesMessage .newBuilder ();
3132 JsonFormat .merge (jsonObject .toJSONString (), build );
3233 byte [] address = wallet .createAdresss (build .getValue ().toByteArray ());
33- BytesMessage .Builder builder = BytesMessage .newBuilder ();
34- builder .setValue (ByteString .copyFrom (address ));
35- response .getWriter ().println (JsonFormat .printToString (builder .build ()));
34+ String base58check = Wallet .encode58Check (address );
35+ String hexString = ByteArray .toHexString (address );
36+ JSONObject jsonAddress = new JSONObject ();
37+ jsonAddress .put ("base58checkAddress" , base58check );
38+ jsonAddress .put ("value" , hexString );
39+ response .getWriter ().println (jsonAddress .toJSONString ());
3640 } catch (Exception e ) {
3741 logger .debug ("Exception: {}" , e .getMessage ());
3842 try {
@@ -50,9 +54,12 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
5054 BytesMessage .Builder build = BytesMessage .newBuilder ();
5155 JsonFormat .merge (input , build );
5256 byte [] address = wallet .createAdresss (build .getValue ().toByteArray ());
53- BytesMessage .Builder builder = BytesMessage .newBuilder ();
54- builder .setValue (ByteString .copyFrom (address ));
55- response .getWriter ().println (JsonFormat .printToString (builder .build ()));
57+ String base58check = Wallet .encode58Check (address );
58+ String hexString = ByteArray .toHexString (address );
59+ JSONObject jsonAddress = new JSONObject ();
60+ jsonAddress .put ("base58checkAddress" , base58check );
61+ jsonAddress .put ("value" , hexString );
62+ response .getWriter ().println (jsonAddress .toJSONString ());
5663 } catch (Exception e ) {
5764 logger .debug ("Exception: {}" , e .getMessage ());
5865 try {
0 commit comments