Skip to content

Commit 31e626e

Browse files
authored
Merge pull request #655 from tronprotocol/release_v4.7.2
feat(master): merge release v4.7.2 into master
2 parents 2c60edc + b75b232 commit 31e626e

File tree

11 files changed

+156
-37
lines changed

11 files changed

+156
-37
lines changed

README.md

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ For more information on a specific command, just type the command on terminal wh
7777
| [GetBalance](#Account-related-commands) | [GetBlock](#How-to-get-block-information) |[GetBlockById](#How-to-get-block-information) |
7878
| [GetBlockByLatestNum](#How-to-get-block-information) | [GetBlockByLimitNext](#How-to-get-block-information) | [GetBrokerage](#Brokerage) |
7979
| [GetContract](#How-to-use-smart-contracts) | [GetDelegatedResource](#How-to-delegate-resource) |[GetDelegatedResourceAccountIndex](#How-to-delegate-resource) |
80-
| [GetDiversifier](#How-to-transfer-shielded-TRC20-token)| [GetExpandedSpendingKey](#How-to-transfer-shielded-TRC20-token)| [GetIncomingViewingKey](#How-to-transfer-shielded-TRC20-token) |
81-
| [GetMarketOrderByAccount](#How-to-use-tron-dex-to-sell-asset)| [GetMarketOrderById](#How-to-use-tron-dex-to-sell-asset)| [GetMarketOrderListByPair](#How-to-use-tron-dex-to-sell-asset) |
80+
| [GetDiversifier](#How-to-transfer-shielded-TRC20-token)| [GetExpandedSpendingKey](#How-to-transfer-shielded-TRC20-token)| [GetIncomingViewingKey](#How-to-transfer-shielded-TRC20-token) |
81+
| [GetMarketOrderByAccount](#How-to-use-tron-dex-to-sell-asset)| [GetMarketOrderById](#How-to-use-tron-dex-to-sell-asset)| [GetMarketOrderListByPair](#How-to-use-tron-dex-to-sell-asset) |
8282
| [GetMarketPairList](#How-to-use-tron-dex-to-sell-asset)| [GetMarketPriceByPair](#How-to-use-tron-dex-to-sell-asset)| [GetNextMaintenanceTime](#Some-others) |
8383
| [GetNkFromNsk](#How-to-transfer-shielded-TRC20-token) | [GetProposal](#Get-proposal-information) | [GetShieldedPaymentAddress](#How-to-transfer-shielded-TRC20-token)|
8484
| [GetSpendingKey](#How-to-transfer-shielded-TRC20-token) | [GetReward](#Brokerage) | [GetTransactionApprovedList](#How-to-use-the-multi-signature-feature-of-wallet-cli) |
@@ -97,8 +97,9 @@ For more information on a specific command, just type the command on terminal wh
9797
| [UpdateBrokerage](#Brokerage) | [UpdateEnergyLimit](#How-to-use-smart-contracts) |[UpdateSetting](#How-to-use-smart-contracts) |
9898
| [UpdateAccountPermission](#How-to-use-the-multi-signature-feature-of-wallet-cli) | [VoteWitness](#How-to-vote) | [FreezeBalanceV2](#How-to-freezev2) |
9999
| [UnfreezeBalanceV2](#How-to-freezev2) | [DelegateResource](#How-to-freezev2) | [UnDelegateResource](#How-to-freezev2) |
100-
| [WithdrawExpireUnfreeze](#How-to-freezev2) | [GetDelegatedResourceV2](#How-to-freezev2) | [GetDelegatedResourceAccountIndexV2](#How-to-freezev2) |
101-
| [GetCanDelegatedMaxSize](#How-to-freezev2) | [GetAvailableUnfreezeCount](#How-to-freezev2) | [GetCanWithdrawUnfreezeAmount](#How-to-freezev2) |
100+
| [WithdrawExpireUnfreeze](#How-to-freezev2) | [CancelAllUnfreezeV2](#How-to-freezev2) |[GetDelegatedResourceV2](#How-to-freezev2) |
101+
| [GetDelegatedResourceAccountIndexV2](#How-to-freezev2) | [GetCanDelegatedMaxSize](#How-to-freezev2) | [GetAvailableUnfreezeCount](#How-to-freezev2) |
102+
| [GetCanWithdrawUnfreezeAmount](#How-to-freezev2) | | |
102103

103104
Type any one of the listed commands, to display how-to tips.
104105

@@ -1342,6 +1343,46 @@ wallet> GetTransactionById e5763ab8dfb1e7ed076770d55cf3c1ddaf36d75e23ec8330f99df
13421343
"raw_data_hex":"0a020000220819b59068c6058ff44096e18bb5d1305a5a083812560a3b747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5769746864726177457870697265556e667265657a65436f6e747261637412170a154159e3741a68ec3e1ebba80ad809d5ccd31674236e7093b3e5aad130"
13431344
}
13441345
```
1346+
> cancelAllUnfreezeV2 [OwnerAddress]
1347+
1348+
OwnerAddress
1349+
> The address of the account that initiated the transaction, optional, default is the address of the login account.
1350+
1351+
Example:
1352+
```console
1353+
wallet> cancelAllUnfreezeV2 TJAVcszse667FmSNCwU2fm6DmfM5D4AyDh
1354+
txid is e5763ab8dfb1e7ed076770d55cf3c1ddaf36d75e23ec8330f99df7e98f54a147
1355+
wallet> GetTransactionById e5763ab8dfb1e7ed076770d55cf3c1ddaf36d75e23ec8330f99df7e98f54a147
1356+
{
1357+
"ret":[
1358+
{
1359+
"contractRet":"SUCCESS"
1360+
}
1361+
],
1362+
"signature":[
1363+
"f8f02b5aa634b8666862a6d2ed68fcfd90afc616d14062952b0b09f0404d9bca6c4d3dc6dab082784950ff1ded235a07dab0d738c8a202be9451d5ca92b8eece01"
1364+
],
1365+
"txID":"e5763ab8dfb1e7ed076770d55cf3c1ddaf36d75e23ec8330f99df7e98f54a147",
1366+
"raw_data":{
1367+
"contract":[
1368+
{
1369+
"parameter":{
1370+
"value":{
1371+
"owner_address":"4159e3741a68ec3e1ebba80ad809d5ccd31674236e"
1372+
},
1373+
"type_url":"type.googleapis.com/protocol.CancelAllUnfreezeV2"
1374+
},
1375+
"type":"CancelAllUnfreezeV2Contract"
1376+
}
1377+
],
1378+
"ref_block_bytes":"0000",
1379+
"ref_block_hash":"19b59068c6058ff4",
1380+
"expiration":1671122055318,
1381+
"timestamp":1671100455315
1382+
},
1383+
"raw_data_hex":"0a020000220819b59068c6058ff44096e18bb5d1305a5a083812560a3b747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5769746864726177457870697265556e667265657a65436f6e747261637412170a154159e3741a68ec3e1ebba80ad809d5ccd31674236e7093b3e5aad130"
1384+
}
1385+
```
13451386

13461387
### get resource delegation information use v2 API
13471388

src/main/java/org/tron/common/utils/AbiUtil.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ static class CoderArray extends Coder {
7979
if (length == -1) {
8080
this.dynamic = true;
8181
}
82-
this.dynamic = true;
8382
}
8483

8584
@Override

src/main/java/org/tron/common/utils/HttpSelfFormatFieldName.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ public class HttpSelfFormatFieldName {
106106
//ShieldedTransferContract
107107
AddressFieldNameMap.put("protocol.ShieldedTransferContract.transparent_from_address", 1);
108108
AddressFieldNameMap.put("protocol.ShieldedTransferContract.transparent_to_address", 1);
109-
110109
//FreezeBalanceV2Contract
111110
AddressFieldNameMap.put("protocol.FreezeBalanceV2Contract.owner_address", 1);
112111
//UnfreezeBalanceV2Contract
@@ -119,6 +118,9 @@ public class HttpSelfFormatFieldName {
119118
//UnDelegateResourceContract
120119
AddressFieldNameMap.put("protocol.UnDelegateResourceContract.owner_address", 1);
121120
AddressFieldNameMap.put("protocol.UnDelegateResourceContract.receiver_address", 1);
121+
//CancelAllUnfreezeV2Contract
122+
AddressFieldNameMap.put("protocol.CancelAllUnfreezeV2Contract.owner_address", 1);
123+
122124
AddressFieldNameMap.put("protocol.CanDelegatedMaxSizeRequestMessage.owner_address", 1);
123125
AddressFieldNameMap.put("protocol.GetAvailableUnfreezeCountRequestMessage.owner_address", 1);
124126
AddressFieldNameMap.put("protocol.CanWithdrawUnfreezeAmountRequestMessage.owner_address", 1);

src/main/java/org/tron/common/utils/Utils.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
package org.tron.common.utils;
2020

21+
import com.alibaba.fastjson.JSON;
2122
import com.alibaba.fastjson.JSONArray;
2223
import com.alibaba.fastjson.JSONObject;
2324
import com.google.protobuf.Any;
@@ -55,6 +56,7 @@
5556
import org.tron.protos.contract.AssetIssueContractOuterClass.TransferAssetContract;
5657
import org.tron.protos.contract.AssetIssueContractOuterClass.UnfreezeAssetContract;
5758
import org.tron.protos.contract.AssetIssueContractOuterClass.UpdateAssetContract;
59+
import org.tron.protos.contract.BalanceContract.CancelAllUnfreezeV2Contract;
5860
import org.tron.protos.contract.BalanceContract.FreezeBalanceContract;
5961
import org.tron.protos.contract.BalanceContract.TransferContract;
6062
import org.tron.protos.contract.BalanceContract.UnfreezeBalanceContract;
@@ -618,6 +620,12 @@ public static JSONObject printTransactionToJSON(Transaction transaction, boolean
618620
JSONObject.parseObject(
619621
JsonFormat.printToString(unDelegateResourceContract, selfType));
620622
break;
623+
case CancelAllUnfreezeV2Contract:
624+
CancelAllUnfreezeV2Contract cancelAllUnfreezeV2Contract =
625+
contractParameter.unpack(CancelAllUnfreezeV2Contract.class);
626+
contractJson = JSON.parseObject(
627+
JsonFormat.printToString(cancelAllUnfreezeV2Contract, selfType));
628+
break;
621629
// new freeze end
622630
// todo add other contract
623631
default:

src/main/java/org/tron/walletcli/Client.java

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import java.io.IOException;
44
import java.math.BigInteger;
5-
import java.security.SecureRandom;
65
import java.text.SimpleDateFormat;
76
import java.util.*;
87
import java.util.Base64.Decoder;
@@ -37,7 +36,6 @@
3736
import org.tron.common.zksnark.LibrustzcashParam;
3837
import org.tron.core.exception.CancelException;
3938
import org.tron.core.exception.CipherException;
40-
import org.tron.core.exception.EncodingException;
4139
import org.tron.core.exception.ZksnarkException;
4240
import org.tron.core.zen.ShieldedAddressInfo;
4341
import org.tron.core.zen.ShieldedNoteInfo;
@@ -87,6 +85,7 @@ public class Client {
8785
"BackupWallet",
8886
"BackupWallet2Base64",
8987
"BroadcastTransaction",
88+
"CancelAllUnfreezeV2",
9089
"ChangePassword",
9190
"ClearContractABI",
9291
"Create2",
@@ -229,6 +228,7 @@ public class Client {
229228
"BackupWallet",
230229
"BackupWallet2Base64",
231230
"BroadcastTransaction",
231+
"CancelAllUnfreezeV2",
232232
"ChangePassword",
233233
"ClearContractABI",
234234
"Create2",
@@ -1413,30 +1413,32 @@ private void withdrawExpireUnfreeze(String[] parameters)
14131413

14141414
private void delegateResource(String[] parameters)
14151415
throws IOException, CipherException, CancelException {
1416-
if (parameters == null || !(parameters.length == 3 || parameters.length == 4 || parameters.length == 5)) {
1416+
if (parameters == null || !(parameters.length == 3 || parameters.length == 4 || parameters.length == 5 || parameters.length == 6)) {
14171417
System.out.println("Use delegateResource command with below syntax: ");
14181418
System.out.println(
1419-
"delegateResource [OwnerAddress] balance ResourceCode(0 BANDWIDTH,1 ENERGY), ReceiverAddress [lock]");
1419+
"delegateResource [OwnerAddress] balance ResourceCode(0 BANDWIDTH,1 ENERGY), "
1420+
+ "ReceiverAddress [lock] [lockPeriod]");
14201421
return;
14211422
}
14221423

14231424
int index = 0;
14241425
byte[] ownerAddress = null;
1425-
long balance = 0;
1426-
int resourceCode = 0;
1427-
byte[] receiverAddress = null;
1426+
long balance;
1427+
int resourceCode;
1428+
byte[] receiverAddress;
14281429
boolean lock = false;
1430+
long lockPeriod = 0;
14291431

14301432
if (parameters.length == 3) {
14311433
balance = Long.parseLong(parameters[index++]);
14321434
resourceCode = Integer.parseInt(parameters[index++]);
1433-
receiverAddress = getAddressBytes(parameters[index++]);
1435+
receiverAddress = getAddressBytes(parameters[index]);
14341436
if (receiverAddress == null) {
14351437
System.out.println(
14361438
"delegateResource receiverAddress is invalid");
14371439
return;
14381440
}
1439-
} else if (parameters.length == 4 || parameters.length == 5) {
1441+
} else {
14401442
ownerAddress = getAddressBytes(parameters[index]);
14411443
if (ownerAddress != null) {
14421444
index ++;
@@ -1450,14 +1452,17 @@ private void delegateResource(String[] parameters)
14501452
return;
14511453
}
14521454

1453-
if (parameters.length == 5 ||
1454-
(ownerAddress == null && parameters.length == 4)) {
1455+
if ((ownerAddress != null && parameters.length == 5) || (ownerAddress == null && parameters.length == 4)) {
14551456
lock = Boolean.parseBoolean(parameters[index++]);
14561457
}
1458+
if (parameters.length == 6 || (ownerAddress == null && parameters.length == 5)) {
1459+
lock = Boolean.parseBoolean(parameters[index++]);
1460+
lockPeriod = Long.parseLong(parameters[index]);
1461+
}
14571462
}
14581463

14591464
boolean result = walletApiWrapper.delegateresource(
1460-
ownerAddress, balance, resourceCode, receiverAddress, lock);
1465+
ownerAddress, balance, resourceCode, receiverAddress, lock, lockPeriod);
14611466
if (result) {
14621467
System.out.println("delegateResource successful !!!");
14631468
} else {
@@ -1513,6 +1518,21 @@ private void unDelegateResource(String[] parameters)
15131518
}
15141519
}
15151520

1521+
private void cancelAllUnfreezeV2(String[] parameters)
1522+
throws IOException, CipherException, CancelException {
1523+
if (parameters.length > 0) {
1524+
System.out.println("Use CancelAllUnfreezeV2 command with below syntax: ");
1525+
System.out.println("CancelAllUnfreezeV2");
1526+
return;
1527+
}
1528+
boolean result = walletApiWrapper.cancelAllUnfreezeV2();
1529+
if (result) {
1530+
System.out.println("cancelAllUnfreezeV2 successful !!!");
1531+
} else {
1532+
System.out.println("cancelAllUnfreezeV2 failed !!!");
1533+
}
1534+
}
1535+
15161536
private void unfreezeAsset(String[] parameters) throws IOException,
15171537
CipherException, CancelException {
15181538
System.out.println("Use UnfreezeAsset command like: ");
@@ -4528,6 +4548,10 @@ private void run() {
45284548
unDelegateResource(parameters);
45294549
break;
45304550
}
4551+
case "cancelallunfreezev2": {
4552+
cancelAllUnfreezeV2(parameters);
4553+
break;
4554+
}
45314555
case "withdrawbalance": {
45324556
withdrawBalance(parameters);
45334557
break;

src/main/java/org/tron/walletcli/WalletApiWrapper.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.tron.core.zen.address.SpendingKey;
2929
import org.tron.keystore.StringUtils;
3030
import org.tron.keystore.WalletFile;
31-
import org.tron.keystore.WalletUtils;
3231
import org.tron.protos.Protocol.Account;
3332
import org.tron.protos.Protocol.Block;
3433
import org.tron.protos.Protocol.ChainParameters;
@@ -548,15 +547,15 @@ public boolean withdrawExpireUnfreeze(byte[] ownerAddress)
548547
}
549548

550549
public boolean delegateresource(byte[] ownerAddress, long balance
551-
, int resourceCode, byte[] receiverAddress, boolean lock)
550+
, int resourceCode, byte[] receiverAddress, boolean lock, long lockPeriod)
552551
throws CipherException, IOException, CancelException {
553552
if (wallet == null || !wallet.isLoginState()) {
554553
System.out.println("Warning: delegateresource failed, Please login first !!");
555554
return false;
556555
}
557556

558557
return wallet.delegateResource(ownerAddress, balance
559-
, resourceCode, receiverAddress, lock);
558+
, resourceCode, receiverAddress, lock, lockPeriod);
560559
}
561560

562561
public boolean undelegateresource(byte[] ownerAddress, long balance
@@ -570,6 +569,15 @@ public boolean undelegateresource(byte[] ownerAddress, long balance
570569
return wallet.unDelegateResource(ownerAddress, balance, resourceCode, receiverAddress);
571570
}
572571

572+
public boolean cancelAllUnfreezeV2()
573+
throws CipherException, IOException, CancelException {
574+
if (wallet == null || !wallet.isLoginState()) {
575+
System.out.println("Warning: cancelAllUnfreezeV2 failed, Please login first !!");
576+
return false;
577+
}
578+
return wallet.cancelAllUnfreezeV2();
579+
}
580+
573581
public boolean unfreezeAsset(byte[] ownerAddress)
574582
throws CipherException, IOException, CancelException {
575583
if (wallet == null || !wallet.isLoginState()) {

src/main/java/org/tron/walletserver/GrpcClient.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import org.tron.protos.contract.AssetIssueContractOuterClass.UnfreezeAssetContract;
4545
import org.tron.protos.contract.AssetIssueContractOuterClass.UpdateAssetContract;
4646
import org.tron.protos.contract.BalanceContract;
47+
import org.tron.protos.contract.BalanceContract.CancelAllUnfreezeV2Contract;
4748
import org.tron.protos.contract.BalanceContract.FreezeBalanceContract;
4849
import org.tron.protos.contract.BalanceContract.TransferContract;
4950
import org.tron.protos.contract.BalanceContract.UnfreezeBalanceContract;
@@ -229,6 +230,10 @@ public TransactionExtention createTransactionV2(BalanceContract.UnDelegateResour
229230
return blockingStubFull.unDelegateResource(contract);
230231
}
231232

233+
public TransactionExtention createTransactionV2(CancelAllUnfreezeV2Contract contract) {
234+
return blockingStubFull.cancelAllUnfreezeV2(contract);
235+
}
236+
232237
public Transaction createTransaction(UnfreezeAssetContract contract) {
233238
return blockingStubFull.unfreezeAsset(contract);
234239
}

0 commit comments

Comments
 (0)