@@ -214,6 +214,9 @@ public class Wallet {
214214
215215 private static final String SHIELDED_ID_NOT_ALLOWED = "ShieldedTransactionApi is not allowed" ;
216216 private static final String PAYMENT_ADDRESS_FORMAT_WRONG = "paymentAddress format is wrong" ;
217+ private static final String SHIELDED_TRANSACTION_SCAN_RANGE =
218+ "request requires start_block_index >= 0 && end_block_index > "
219+ + "start_block_index && end_block_index - start_block_index <= 1000" ;
217220 private static String addressPreFixString = Constant .ADD_PRE_FIX_STRING_MAINNET ;//default testnet
218221 private static final byte [] SHIELDED_TRC20_LOG_TOPICS_MINT = Hash .sha3 (ByteArray .fromString (
219222 "MintNewLeaf(uint256,bytes32,bytes32,bytes32,bytes32[21])" ));
@@ -2555,8 +2558,7 @@ private GrpcAPI.DecryptNotes queryNoteByIvk(long startNum, long endNum, byte[] i
25552558 GrpcAPI .DecryptNotes .Builder builder = GrpcAPI .DecryptNotes .newBuilder ();
25562559 if (!(startNum >= 0 && endNum > startNum && endNum - startNum <= 1000 )) {
25572560 throw new BadItemException (
2558- "request requires start_block_index >= 0 && end_block_index > start_block_index "
2559- + "&& end_block_index - start_block_index <= 1000" );
2561+ SHIELDED_TRANSACTION_SCAN_RANGE );
25602562 }
25612563 BlockList blockList = this .getBlocksByLimitNext (startNum , endNum - startNum );
25622564 for (Block block : blockList .getBlockList ()) {
@@ -2669,8 +2671,7 @@ public GrpcAPI.DecryptNotes scanNoteByOvk(long startNum, long endNum,
26692671 GrpcAPI .DecryptNotes .Builder builder = GrpcAPI .DecryptNotes .newBuilder ();
26702672 if (!(startNum >= 0 && endNum > startNum && endNum - startNum <= 1000 )) {
26712673 throw new BadItemException (
2672- "request require start_block_index >= 0 && end_block_index > start_block_index "
2673- + "&& end_block_index - start_block_index <= 1000" );
2674+ SHIELDED_TRANSACTION_SCAN_RANGE );
26742675 }
26752676 BlockList blockList = this .getBlocksByLimitNext (startNum , endNum - startNum );
26762677 for (Block block : blockList .getBlockList ()) {
@@ -2914,7 +2915,7 @@ public ShieldedTRC20Parameters createShieldedContractParameters(
29142915
29152916 private void buildShieldedTRC20InputWithAK (
29162917 ShieldedTRC20ParametersBuilder builder , GrpcAPI .SpendNoteTRC20 spendNote ,
2917- byte [] ak , byte [] nsk , byte [] ovk ) throws ZksnarkException {
2918+ byte [] ak , byte [] nsk ) throws ZksnarkException {
29182919 GrpcAPI .Note note = spendNote .getNote ();
29192920 PaymentAddress paymentAddress = KeyIo .decodePaymentAddress (note .getPaymentAddress ());
29202921 if (Objects .isNull (paymentAddress )) {
@@ -2925,7 +2926,6 @@ private void buildShieldedTRC20InputWithAK(
29252926 paymentAddress .getPkD (), note .getValue (), note .getRcm ().toByteArray ());
29262927 builder .addSpend (ak ,
29272928 nsk ,
2928- ovk ,
29292929 baseNote ,
29302930 spendNote .getAlpha ().toByteArray (),
29312931 spendNote .getRoot ().toByteArray (),
@@ -2997,7 +2997,7 @@ public ShieldedTRC20Parameters createShieldedContractParametersWithoutAsk(
29972997 throw new ContractValidateException ("No shielded TRC-20 ak, nsk or ovk" );
29982998 }
29992999 for (GrpcAPI .SpendNoteTRC20 spendNote : shieldedSpends ) {
3000- buildShieldedTRC20InputWithAK (builder , spendNote , ak , nsk , ovk );
3000+ buildShieldedTRC20InputWithAK (builder , spendNote , ak , nsk );
30013001 }
30023002 for (ReceiveNote receiveNote : shieldedReceives ) {
30033003 buildShieldedTRC20Output (builder , receiveNote , ovk );
@@ -3023,7 +3023,7 @@ public ShieldedTRC20Parameters createShieldedContractParametersWithoutAsk(
30233023 .encryptBurnMessageByOvk (ovk , toAmount , transparentToAddress );
30243024 cipher .ifPresent (builder ::setBurnCiphertext );
30253025 GrpcAPI .SpendNoteTRC20 spendNote = shieldedSpends .get (0 );
3026- buildShieldedTRC20InputWithAK (builder , spendNote , ak , nsk , ovk );
3026+ buildShieldedTRC20InputWithAK (builder , spendNote , ak , nsk );
30273027 if (receiveSize == 1 ) {
30283028 buildShieldedTRC20Output (builder , shieldedReceives .get (0 ), ovk );
30293029 }
@@ -3128,8 +3128,7 @@ private DecryptNotesTRC20 queryTRC20NoteByIvk(long startNum, long endNum,
31283128 throws BadItemException , ZksnarkException , ContractExeException {
31293129 if (!(startNum >= 0 && endNum > startNum && endNum - startNum <= 1000 )) {
31303130 throw new BadItemException (
3131- "request requires start_block_index >= 0 && end_block_index > start_block_index "
3132- + "&& end_block_index - start_block_index <= 1000" );
3131+ SHIELDED_TRANSACTION_SCAN_RANGE );
31333132 }
31343133
31353134 DecryptNotesTRC20 .Builder builder = DecryptNotesTRC20 .newBuilder ();
@@ -3215,7 +3214,7 @@ private boolean isShieldedTRC20NoteSpent(GrpcAPI.Note note, long pos, byte[] ak,
32153214 }
32163215
32173216 String code = trxExt .getResult ().getCode ().toString ();
3218- if (code . equals ( "SUCCESS" )) {
3217+ if ("SUCCESS" . equals ( code )) {
32193218 List <ByteString > list = trxExt .getConstantResultList ();
32203219 byte [] listBytes = new byte [0 ];
32213220 for (ByteString bs : list ) {
@@ -3316,8 +3315,7 @@ public DecryptNotesTRC20 scanShieldedTRC20NotesByOvk(long startNum, long endNum,
33163315 DecryptNotesTRC20 .Builder builder = DecryptNotesTRC20 .newBuilder ();
33173316 if (!(startNum >= 0 && endNum > startNum && endNum - startNum <= 1000 )) {
33183317 throw new BadItemException (
3319- "request requires start_block_index >= 0 && end_block_index > start_block_index "
3320- + "&& end_block_index - start_block_index <= 1000" );
3318+ SHIELDED_TRANSACTION_SCAN_RANGE );
33213319 }
33223320 BlockList blockList = this .getBlocksByLimitNext (startNum , endNum - startNum );
33233321 for (Block block : blockList .getBlockList ()) {
@@ -3480,7 +3478,7 @@ private byte[] getShieldedContractScalingFactor(byte[] contractAddress)
34803478 }
34813479
34823480 String code = trxExt .getResult ().getCode ().toString ();
3483- if (code . equals ( "SUCCESS" )) {
3481+ if ("SUCCESS" . equals ( code )) {
34843482 List <ByteString > list = trxExt .getConstantResultList ();
34853483 byte [] listBytes = new byte [0 ];
34863484 for (ByteString bs : list ) {
0 commit comments