Skip to content

Commit e30fd40

Browse files
committed
feature(cmd): add input parameter verification
1 parent e1a8dc7 commit e30fd40

File tree

10 files changed

+343
-83
lines changed

10 files changed

+343
-83
lines changed

README.md

Lines changed: 77 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,21 @@ The rest of the users will be granted
788788
```console
789789
> Updateaccountpermission TRGhNNfnmgLegT4zHNjEqDSADjgmnHvubJ {"owner_permission":{"type":0,"permission_name":"owner","threshold":1,"keys":[{"address":"TRGhNNfnmgLegT4zHNjEqDSADjgmnHvubJ","weight":1}]},"witness_permission":{"type":1,"permission_name":"owner","threshold":1,"keys":[{"address":"TRGhNNfnmgLegT4zHNjEqDSADjgmnHvubJ","weight":1}]},"active_permissions":[{"type":2,"permission_name":"active12323","threshold":2,"operations":"7fff1fc0033e0000000000000000000000000000000000000000000000000000","keys":[{"address":"TNhXo1GbRNCuorvYu5JFWN3m2NYr9QQpVR","weight":1},{"address":"TKwhcDup8L2PH5r6hxp5CQvQzZqJLmKvZP","weight":1}]}]}
790790
```
791+
or
792+
```console
793+
wallet> updateAccountPermission
794+
=== UpdateAccountPermission Interactive Mode ===
795+
796+
Select permission to modify:
797+
1. owner_permission
798+
2. witness_permission
799+
3. active_permissions
800+
4. Add new active_permission
801+
5. Delete active_permission
802+
6. Show preview and Confirm
803+
7. Exit
804+
>
805+
```
791806

792807
The account TRGhNNfnmgLegT4zHNjEqDSADjgmnHvubJ gives the owner access to itself, active access to
793808
TNhXo1GbRNCuorvYu5JFWN3m2NYr9QQpVR and TKwhcDup8L2PH5r6hxp5CQvQzZqJLmKvZP. Active access will
@@ -2533,44 +2548,76 @@ Make a USDT transfer.
25332548

25342549
Example:
25352550
```console
2536-
wallet> TransferUSDT TGDjv2KKD4UqEmFTnZgLzup5WWjTex4Mvq 1
2551+
wallet> transferusdt TR311sD6KasRnofj5RnFiFBA2rH8RH2kYk 1
2552+
balanceOf(address):70a08231
2553+
Execution result = {
2554+
"constant_result": [
2555+
"000000000000000000000000000000000000000000000000000000006544ae57"
2556+
],
2557+
"result": {
2558+
"result": true
2559+
},
2560+
"energy_used": 935
2561+
}
2562+
USDT balance = 1698999895
25372563
transfer(address,uint256):a9059cbb
2564+
It is estimated that 345 bandwidth and 29650 energy will be consumed.
2565+
Execution result = {
2566+
"constant_result": [
2567+
"0000000000000000000000000000000000000000000000000000000000000000"
2568+
],
2569+
"result": {
2570+
"result": true
2571+
},
2572+
"energy_used": 29650,
2573+
"logs": [
2574+
{
2575+
"address": "NaMomAhUzuFzMNFzzQHVNsR8xbmP3A5LT",
2576+
"topics": [
2577+
"ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
2578+
"000000000000000000000000caf9798d70a3c609b600f163e53cfe8f586e1b9f",
2579+
"000000000000000000000000a5418b8da12e73075abb46375e7a15c758ea21fc"
2580+
],
2581+
"data": "0000000000000000000000000000000000000000000000000000000000000001"
2582+
}
2583+
]
2584+
}
25382585
{
2539-
"raw_data":{
2540-
"contract":[
2541-
{
2542-
"parameter":{
2543-
"value":{
2544-
"data":"a9059cbb00000000000000000000004144906218dac49fbff3a1245aed4b8df68359d2360000000000000000000000000000000000000000000000000000000000000001",
2545-
"owner_address":"TUUSMd58eC3fKx3fn7whxJyr1FR56tgaP8",
2546-
"contract_address":"TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf"
2547-
},
2548-
"type_url":"type.googleapis.com/protocol.TriggerSmartContract"
2549-
},
2550-
"type":"TriggerSmartContract"
2551-
}
2552-
],
2553-
"ref_block_bytes":"9147",
2554-
"ref_block_hash":"f8a6545ca048d745",
2555-
"expiration":1761547422000,
2556-
"fee_limit":1000000000,
2557-
"timestamp":1761547364794
2558-
},
2559-
"raw_data_hex":"0a0291472208f8a6545ca048d74540b092a2a3a2335aae01081f12a9010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412740a1541caf9798d70a3c609b600f163e53cfe8f586e1b9f121541eca9bc828a3005b9a3b909f2cc5c2a54794de05f2244a9059cbb00000000000000000000004144906218dac49fbff3a1245aed4b8df68359d236000000000000000000000000000000000000000000000000000000000000000170bad39ea3a23390018094ebdc03"
2586+
"raw_data":{
2587+
"contract":[
2588+
{
2589+
"parameter":{
2590+
"value":{
2591+
"data":"a9059cbb000000000000000000000041a5418b8da12e73075abb46375e7a15c758ea21fc0000000000000000000000000000000000000000000000000000000000000001",
2592+
"owner_address":"TUUSMd58eC3fKx3fn7whxJyr1FR56tgaP8",
2593+
"contract_address":"TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf"
2594+
},
2595+
"type_url":"type.googleapis.com/protocol.TriggerSmartContract"
2596+
},
2597+
"type":"TriggerSmartContract"
2598+
}
2599+
],
2600+
"ref_block_bytes":"08c7",
2601+
"ref_block_hash":"c02252c2ae3b92e1",
2602+
"expiration":1761639507000,
2603+
"fee_limit":1000000000,
2604+
"timestamp":1761639448851
2605+
},
2606+
"raw_data_hex":"0a0208c72208c02252c2ae3b92e140b8c896cfa2335aae01081f12a9010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412740a1541caf9798d70a3c609b600f163e53cfe8f586e1b9f121541eca9bc828a3005b9a3b909f2cc5c2a54794de05f2244a9059cbb000000000000000000000041a5418b8da12e73075abb46375e7a15c758ea21fc000000000000000000000000000000000000000000000000000000000000000170938293cfa23390018094ebdc03"
25602607
}
2561-
Before sign transaction hex string is 0ad4010a0291472208f8a6545ca048d74540b092a2a3a2335aae01081f12a9010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412740a1541caf9798d70a3c609b600f163e53cfe8f586e1b9f121541eca9bc828a3005b9a3b909f2cc5c2a54794de05f2244a9059cbb00000000000000000000004144906218dac49fbff3a1245aed4b8df68359d236000000000000000000000000000000000000000000000000000000000000000170bad39ea3a23390018094ebdc03
2608+
Before sign transaction hex string is 0ad4010a0208c72208c02252c2ae3b92e140b8c896cfa2335aae01081f12a9010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412740a1541caf9798d70a3c609b600f163e53cfe8f586e1b9f121541eca9bc828a3005b9a3b909f2cc5c2a54794de05f2244a9059cbb000000000000000000000041a5418b8da12e73075abb46375e7a15c758ea21fc000000000000000000000000000000000000000000000000000000000000000170938293cfa23390018094ebdc03
25622609
Please confirm and input your permission id, if input y/Y means default 0, other non-numeric characters will cancel transaction.
25632610
y
25642611
Please choose your key for sign.
25652612

25662613
No. Address Name
2567-
1 TUUSMd58eC3fKx3fn7whxJyr1FR56tgaP8 22
2568-
Please choose No. between 1 and 4, or enter search to search wallets
2614+
1 TUUSMd58eC3fKx3fn7whxJyr1FR56tgaP8 test
2615+
Please choose No. between 1 and 1, or enter search to search wallets
25692616
1
25702617
Please input your password.
2571-
password:
2572-
After sign transaction hex string is 0ad4010a0291472208f8a6545ca048d74540e781c5ada2335aae01081f12a9010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412740a1541caf9798d70a3c609b600f163e53cfe8f586e1b9f121541eca9bc828a3005b9a3b909f2cc5c2a54794de05f2244a9059cbb00000000000000000000004144906218dac49fbff3a1245aed4b8df68359d236000000000000000000000000000000000000000000000000000000000000000170bad39ea3a23390018094ebdc031241544a4e8bf10f0c03ef77e31ea9ba905a35b9d3f4ae6ebe5d0e2760adff3d44305617a1386f62b93501239d208e12edfd2095c5fd2d420fe8b2ff34b05b98bf2901
2573-
TxId is f16dd75e1b07fbcd089a2403349de8eed82ad070ad479e36711f222ec822724f
2574-
Transfer 1 to TGDjv2KKD4UqEmFTnZgLzup5WWjTex4Mvq successful.
2575-
Please check the given transaction id to get the result on blockchain using getTransactionInfoById command
2618+
Lxc1992117
2619+
After sign transaction hex string is 0ad4010a0208c72208c02252c2ae3b92e1409fb0b9d9a2335aae01081f12a9010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412740a1541caf9798d70a3c609b600f163e53cfe8f586e1b9f121541eca9bc828a3005b9a3b909f2cc5c2a54794de05f2244a9059cbb000000000000000000000041a5418b8da12e73075abb46375e7a15c758ea21fc000000000000000000000000000000000000000000000000000000000000000170938293cfa23390018094ebdc031241a776830e5cd054c6a94631b6d62704e249e7587ab3f036e5e4fac15cbf49e671262532e094e1a32ad858272da3e101958102df61b0f72f26756a94b608883a6f01
2620+
TxId is 9c8d4b84e9a71ccaad86b0a96f790067d3fc7ea85c26b425e5d748b81d31a8b8
2621+
Transfer 1 to TR311sD6KasRnofj5RnFiFBA2rH8RH2kYk broadcast successful.
2622+
Please check the given transaction id to get the result on blockchain using getTransactionInfoById command.
25762623
```

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.ArrayList;
2828
import java.util.Arrays;
2929
import java.util.List;
30+
import org.apache.commons.lang3.StringUtils;
3031
import org.bouncycastle.util.encoders.Hex;
3132

3233
public class ByteUtil {
@@ -419,7 +420,9 @@ public static List<Boolean> convertBytesVectorToVector(final byte[] bytes) {
419420

420421
public static List<Integer> hexStringToIntegerList(String hexString) {
421422
List<Integer> result = new ArrayList<>();
422-
423+
if (StringUtils.isEmpty(hexString)) {
424+
return result;
425+
}
423426
byte[] bytes = hexStringToByteArray(hexString);
424427

425428
for (int byteIndex = 0; byteIndex < bytes.length; byteIndex++) {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,10 @@ public static String greenBoldHighlight(int i) {
11841184
return ANSI_BOLD + ANSI_GREEN + i + ANSI_RESET;
11851185
}
11861186

1187+
public static String greenBoldHighlight(long i) {
1188+
return ANSI_BOLD + ANSI_GREEN + i + ANSI_RESET;
1189+
}
1190+
11871191
public static String blueBoldHighlight(String str) {
11881192
return ANSI_BOLD + ANSI_BLUE + str + ANSI_RESET;
11891193
}

0 commit comments

Comments
 (0)