@@ -29,6 +29,7 @@ public class HttpMethed {
29
29
static String transactionSignString ;
30
30
static JSONObject responseContent ;
31
31
static JSONObject signResponseContent ;
32
+ static JSONObject transactionApprovedListContent ;
32
33
33
34
/**
34
35
* constructor.
@@ -104,6 +105,73 @@ public static HttpResponse voteWitnessAccount(String httpNode, byte[] ownerAddre
104
105
return response ;
105
106
}
106
107
108
+ /**
109
+ * constructor.
110
+ */
111
+ public static HttpResponse createAccount (String httpNode , byte [] ownerAddress ,
112
+ byte [] accountAddress , String fromKey ) {
113
+ try {
114
+ final String requestUrl = "http://" + httpNode + "/wallet/createaccount" ;
115
+ JsonObject userBaseObj2 = new JsonObject ();
116
+ userBaseObj2 .addProperty ("account_address" , ByteArray .toHexString (accountAddress ));
117
+ userBaseObj2 .addProperty ("owner_address" , ByteArray .toHexString (ownerAddress ));
118
+ response = createConnect (requestUrl , userBaseObj2 );
119
+ transactionString = EntityUtils .toString (response .getEntity ());
120
+ transactionSignString = gettransactionsign (httpNode ,transactionString ,fromKey );
121
+ response = broadcastTransaction (httpNode ,transactionSignString );
122
+ } catch (Exception e ) {
123
+ e .printStackTrace ();
124
+ httppost .releaseConnection ();
125
+ return null ;
126
+ }
127
+ return response ;
128
+ }
129
+
130
+ /**
131
+ * constructor.
132
+ */
133
+ public static HttpResponse createWitness (String httpNode , byte [] ownerAddress , String url ) {
134
+ try {
135
+ final String requestUrl = "http://" + httpNode + "/wallet/createwitness" ;
136
+ JsonObject userBaseObj2 = new JsonObject ();
137
+ userBaseObj2 .addProperty ("url" , str2hex (url ));
138
+ userBaseObj2 .addProperty ("owner_address" , ByteArray .toHexString (ownerAddress ));
139
+ response = createConnect (requestUrl , userBaseObj2 );
140
+ logger .info (userBaseObj2 .toString ());
141
+ //transactionString = EntityUtils.toString(response.getEntity());
142
+ //transactionSignString = gettransactionsign(httpNode,transactionString,fromKey);
143
+ //response = broadcastTransaction(httpNode,transactionSignString);
144
+ } catch (Exception e ) {
145
+ e .printStackTrace ();
146
+ httppost .releaseConnection ();
147
+ return null ;
148
+ }
149
+ return response ;
150
+ }
151
+
152
+ /**
153
+ * constructor.
154
+ */
155
+ public static HttpResponse withdrawBalance (String httpNode , byte [] witnessAddress ) {
156
+ try {
157
+ final String requestUrl = "http://" + httpNode + "/wallet/withdrawbalance" ;
158
+ JsonObject userBaseObj2 = new JsonObject ();
159
+ userBaseObj2 .addProperty ("owner_address" , ByteArray .toHexString (witnessAddress ));
160
+ response = createConnect (requestUrl , userBaseObj2 );
161
+ logger .info (userBaseObj2 .toString ());
162
+ //transactionString = EntityUtils.toString(response.getEntity());
163
+ //transactionSignString = gettransactionsign(httpNode,transactionString,fromKey);
164
+ //response = broadcastTransaction(httpNode,transactionSignString);
165
+ } catch (Exception e ) {
166
+ e .printStackTrace ();
167
+ httppost .releaseConnection ();
168
+ return null ;
169
+ }
170
+ return response ;
171
+ }
172
+
173
+
174
+
107
175
/**
108
176
* constructor.
109
177
*/
@@ -141,12 +209,20 @@ public static HttpResponse sendCoin(String httpNode, byte[] fromAddress, byte[]
141
209
response = createConnect (requestUrl , userBaseObj2 );
142
210
transactionSignString = EntityUtils .toString (response .getEntity ());
143
211
HttpResponse getSignWeightResponse ;
212
+ HttpResponse getTransactionApprovedListResponse ;
213
+
144
214
for (String key : managerKeys ) {
145
215
transactionSignString = gettransactionsign (httpNode ,transactionSignString ,key );
146
216
getSignWeightResponse = getSignWeight (httpNode ,transactionSignString );
147
217
signResponseContent = parseResponseContent (getSignWeightResponse );
218
+ logger .info ("-----------sign information-----------------" );
219
+ printJsonContent (signResponseContent );
220
+ getSignWeightResponse = getTransactionApprovedList (httpNode ,transactionSignString );
221
+ signResponseContent = parseResponseContent (getSignWeightResponse );
222
+ logger .info ("-----------get Transaction Approved List-----------------" );
148
223
printJsonContent (signResponseContent );
149
224
225
+
150
226
}
151
227
response = broadcastTransaction (httpNode ,transactionSignString );
152
228
} catch (Exception e ) {
@@ -560,6 +636,34 @@ public static HttpResponse participateAssetIssue(String httpNode, byte[] toAddre
560
636
return response ;
561
637
}
562
638
639
+ /**
640
+ * constructor.
641
+ */
642
+ public static HttpResponse updateAssetIssue (String httpNode , byte [] ownerAddress ,
643
+ String description , String url ,Long newLimit , Long newPublicLimit , String fromKey ) {
644
+ try {
645
+ final String requestUrl = "http://" + httpNode + "/wallet/updateasset" ;
646
+ JsonObject userBaseObj2 = new JsonObject ();
647
+ userBaseObj2 .addProperty ("owner_address" , ByteArray .toHexString (ownerAddress ));
648
+ userBaseObj2 .addProperty ("url" , str2hex (url ));
649
+ userBaseObj2 .addProperty ("description" , str2hex (description ));
650
+ userBaseObj2 .addProperty ("new_limit" , newLimit );
651
+ userBaseObj2 .addProperty ("new_public_limit" , newPublicLimit );
652
+ response = createConnect (requestUrl , userBaseObj2 );
653
+ transactionString = EntityUtils .toString (response .getEntity ());
654
+ logger .info (transactionString );
655
+ transactionSignString = gettransactionsign (httpNode ,transactionString ,fromKey );
656
+ logger .info (transactionSignString );
657
+ response = broadcastTransaction (httpNode ,transactionSignString );
658
+ } catch (Exception e ) {
659
+ e .printStackTrace ();
660
+ httppost .releaseConnection ();
661
+ return null ;
662
+ }
663
+ return response ;
664
+ }
665
+
666
+
563
667
/**
564
668
* constructor.
565
669
*/
@@ -763,6 +867,35 @@ public static HttpResponse getSignWeight(String httpNode,String transactionSignS
763
867
return response ;
764
868
}
765
869
870
+ /**
871
+ * constructor.
872
+ */
873
+ public static HttpResponse getTransactionApprovedList (String httpNode ,
874
+ String transactionSignString ) {
875
+ try {
876
+ String requestUrl = "http://" + httpNode + "/wallet/getapprovedlist" ;
877
+ httpClient .getParams ().setParameter (CoreConnectionPNames .CONNECTION_TIMEOUT ,
878
+ connectionTimeout );
879
+ httpClient .getParams ().setParameter (CoreConnectionPNames .SO_TIMEOUT , soTimeout );
880
+ httppost = new HttpPost (requestUrl );
881
+ httppost .setHeader ("Content-type" , "application/json; charset=utf-8" );
882
+ httppost .setHeader ("Connection" , "Close" );
883
+ if (transactionSignString != null ) {
884
+ StringEntity entity = new StringEntity (transactionSignString , Charset .forName ("UTF-8" ));
885
+ entity .setContentEncoding ("UTF-8" );
886
+ entity .setContentType ("application/json" );
887
+ httppost .setEntity (entity );
888
+ }
889
+ response = httpClient .execute (httppost );
890
+ } catch (Exception e ) {
891
+ e .printStackTrace ();
892
+ httppost .releaseConnection ();
893
+ return null ;
894
+ }
895
+ httppost .releaseConnection ();
896
+ return response ;
897
+ }
898
+
766
899
767
900
768
901
/**
0 commit comments