@@ -153,6 +153,63 @@ public class PublicMethed {
153153 * constructor.
154154 */
155155
156+ public static String createAssetIssueGetTxid (byte [] address , String name , String abbreviation ,
157+ Long totalSupply , Integer trxNum , Integer icoNum , Long startTime , Long endTime ,
158+ Integer voteScore , String description , String url , Long freeAssetNetLimit ,
159+ Long publicFreeAssetNetLimit , Long fronzenAmount , Long frozenDay , String priKey ,
160+ WalletGrpc .WalletBlockingStub blockingStubFull ) {
161+ Wallet .setAddressPreFixByte (CommonConstant .ADD_PRE_FIX_BYTE_MAINNET );
162+ ECKey temKey = null ;
163+ try {
164+ BigInteger priK = new BigInteger (priKey , 16 );
165+ temKey = ECKey .fromPrivate (priK );
166+ } catch (Exception ex ) {
167+ ex .printStackTrace ();
168+ }
169+ ECKey ecKey = temKey ;
170+ try {
171+ AssetIssueContract .Builder builder = AssetIssueContract .newBuilder ();
172+ builder .setOwnerAddress (ByteString .copyFrom (address ));
173+ builder .setName (ByteString .copyFrom (name .getBytes ()));
174+ builder .setAbbr (ByteString .copyFrom (abbreviation .getBytes ()));
175+ builder .setTotalSupply (totalSupply );
176+ builder .setTrxNum (trxNum );
177+ builder .setNum (icoNum );
178+ builder .setStartTime (startTime );
179+ builder .setEndTime (endTime );
180+ builder .setVoteScore (voteScore );
181+ builder .setDescription (ByteString .copyFrom (description .getBytes ()));
182+ builder .setUrl (ByteString .copyFrom (url .getBytes ()));
183+ builder .setFreeAssetNetLimit (freeAssetNetLimit );
184+ builder .setPublicFreeAssetNetLimit (publicFreeAssetNetLimit );
185+ AssetIssueContract .FrozenSupply .Builder frozenBuilder = AssetIssueContract .FrozenSupply
186+ .newBuilder ();
187+ frozenBuilder .setFrozenAmount (fronzenAmount );
188+ frozenBuilder .setFrozenDays (frozenDay );
189+ builder .addFrozenSupply (0 , frozenBuilder );
190+
191+ Protocol .Transaction transaction = blockingStubFull .createAssetIssue (builder .build ());
192+ if (transaction == null || transaction .getRawData ().getContractCount () == 0 ) {
193+ logger .info ("transaction == null" );
194+ return null ;
195+ }
196+ transaction = signTransaction (ecKey , transaction );
197+
198+ GrpcAPI .Return response = broadcastTransaction (transaction , blockingStubFull );
199+
200+ return ByteArray .toHexString (Sha256Hash
201+ .hash (CommonParameter .getInstance ().isECKeyCryptoEngine (),
202+ transaction .getRawData ().toByteArray ()));
203+ } catch (Exception ex ) {
204+ ex .printStackTrace ();
205+ return null ;
206+ }
207+ }
208+
209+
210+ /**
211+ * constructor.
212+ */
156213 public static Boolean createAssetIssue (byte [] address , String name , Long totalSupply ,
157214 Integer trxNum , Integer icoNum , Long startTime , Long endTime , Integer voteScore ,
158215 String description , String url , Long freeAssetNetLimit , Long publicFreeAssetNetLimit ,
@@ -1864,6 +1921,43 @@ public static byte[] getFinalAddress(String priKey) {
18641921 return walletClient .getAddress ();
18651922 }
18661923
1924+ /**
1925+ * constructor.
1926+ */
1927+
1928+ public static String createAccountGetTxid (byte [] ownerAddress , byte [] newAddress , String priKey ,
1929+ WalletGrpc .WalletBlockingStub blockingStubFull ) {
1930+ Wallet .setAddressPreFixByte (CommonConstant .ADD_PRE_FIX_BYTE_MAINNET );
1931+ ECKey temKey = null ;
1932+ try {
1933+ BigInteger priK = new BigInteger (priKey , 16 );
1934+ temKey = ECKey .fromPrivate (priK );
1935+ } catch (Exception ex ) {
1936+ ex .printStackTrace ();
1937+ }
1938+ final ECKey ecKey = temKey ;
1939+
1940+ byte [] owner = ownerAddress ;
1941+ AccountCreateContract .Builder builder = AccountCreateContract .newBuilder ();
1942+ builder .setOwnerAddress (ByteString .copyFrom (owner ));
1943+ builder .setAccountAddress (ByteString .copyFrom (newAddress ));
1944+ AccountCreateContract contract = builder .build ();
1945+ Transaction transaction = blockingStubFull .createAccount (contract );
1946+ if (transaction == null || transaction .getRawData ().getContractCount () == 0 ) {
1947+ logger .info ("transaction == null" );
1948+ }
1949+ transaction = signTransaction (ecKey , transaction );
1950+ GrpcAPI .Return response = broadcastTransaction (transaction , blockingStubFull );
1951+ if (response .getResult () == false ) {
1952+ return null ;
1953+ } else {
1954+ //logger.info("brodacast succesfully");
1955+ return ByteArray .toHexString (Sha256Hash
1956+ .hash (CommonParameter .getInstance ().isECKeyCryptoEngine (),
1957+ transaction .getRawData ().toByteArray ()));
1958+ }
1959+ }
1960+
18671961 /**
18681962 * constructor.
18691963 */
@@ -6942,7 +7036,6 @@ public static Map<String, Long> getAllowance2(Long startNum, Long endNum,
69427036 WalletGrpc .WalletBlockingStub blockingStubFull ) {
69437037 final String blackHole = Configuration .getByPath ("testng.conf" )
69447038 .getString ("defaultParameter.blackHoleAddress" );
6945- Long balanceBlackHole = 0L ;
69467039 Long totalCount = 0L ;
69477040 Map <String , Integer > witnessBlockCount = new HashMap <>();
69487041 Map <String , Long > witnessBrokerage = new HashMap <>();
@@ -6972,24 +7065,10 @@ public static Map<String, Long> getAllowance2(Long startNum, Long endNum,
69727065 tem .getRawData ().toByteArray ()));
69737066 logger .info ("----ss txid:" + txid );
69747067 infoById = PublicMethed .getTransactionInfoById (txid , blockingStubFull );
7068+ Long packingFee = infoById .get ().getPackingFee ();
69757069
6976- Long energyFee = infoById .get ().getReceipt ().getEnergyFee ();
6977- Long netFee = infoById .get ().getReceipt ().getNetFee ();
6978- if ("AccountCreateContract" .equals (tem .getRawData ().getContract (0 ).getType ().toString ())) {
6979- logger .info ("------account create witnessAdd:" + witnessAdd + " before add:"
6980- + witnessAllowance .getOrDefault (witnessAdd , 0L ) + " netfee:" + netFee );
6981- witnessAllowance .put (witnessAdd , witnessAllowance .getOrDefault (witnessAdd , 0L ) + netFee );
6982- } else {
6983- if (infoById .get ().getReceipt ().getResult ().toString ().contains ("OUT_OF_TIME" )) {
6984- logger .info ("---out of time " + infoById .get ().getReceipt ().getResult ());
6985- balanceBlackHole += infoById .get ().getReceipt ().getEnergyFee ();
6986- witnessAllowance .put (witnessAdd , witnessAllowance .getOrDefault (witnessAdd , 0L )
6987- + netFee );
6988- } else {
6989- witnessAllowance .put (witnessAdd , witnessAllowance .getOrDefault (witnessAdd , 0L )
6990- + energyFee + netFee );
6991- }
6992- }
7070+ witnessAllowance .put (witnessAdd , witnessAllowance .getOrDefault (witnessAdd , 0L )
7071+ + packingFee );
69937072 }
69947073 }
69957074
@@ -7033,7 +7112,6 @@ public static Map<String, Long> getAllowance2(Long startNum, Long endNum,
70337112 witnessAllowance .put (witnessAdd , pay );
70347113 logger .info ("****** " + witnessAdd + " : " + pay );
70357114 }
7036- witnessAllowance .put (blackHole , balanceBlackHole );
70377115 return witnessAllowance ;
70387116 }
70397117
0 commit comments