Skip to content

Commit

Permalink
Merge pull request #675 from tronprotocol/release_v4.7.3
Browse files Browse the repository at this point in the history
merge release_4.7.3 into master
  • Loading branch information
forfreeday committed Oct 25, 2023
2 parents 31e626e + 230a078 commit 631ccea
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 16 deletions.
64 changes: 48 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,42 +64,43 @@ We can configure java-tron node IP and port in ``src/main/resources/config.conf`
Following is a list of Tron Wallet-cli commands:
For more information on a specific command, just type the command on terminal when you start your Wallet.

| [AddTransactionSign](#How-to-use-the-multi-signature-feature-of-wallet-cli) | [ApproveProposal](#Approvecancel-the-proposal) | [AssetIssue](#How-to-issue-TRC10-tokens) |
| [AddTransactionSign](#How-to-use-the-multi-signature-feature-of-wallet-cli) | [ApproveProposal](#Approve--disapprove-a-proposal) | [AssetIssue](#Issue-trc10-tokens) |
| :---------:|:---------:|:--------: |
| [BackupShieldedTRC20Wallet](#How-to-transfer-shielded-TRC20-token) | [BackupWallet](#Wallet-related-commands)| [BackupWallet2Base64](#Wallet-related-commands) |
| [BroadcastTransaction](#Some-others) | [ChangePassword](#Wallet-related-commands)| [CreateProposal](#How-to-initiate-a-proposal)
| [DeleteProposal](#Cancel-the-created-proposal) | [DeployContract](#How-to-use-smart-contract) | [ExchangeCreate](#How-to-trade-on-the-exchange) |
| [BroadcastTransaction](#Some-others) | [ChangePassword](#Wallet-related-commands)| [CreateProposal](#Initiate-a-proposal)
| [DeleteProposal](#Delete-an-existed-proposal) | [DeployContract](#How-to-use-smart-contract) | [ExchangeCreate](#How-to-trade-on-the-exchange) |
| [ExchangeInject](#How-to-trade-on-the-exchange) | [ExchangeTransaction](#How-to-trade-on-the-exchange) | [ExchangeWithdraw](#How-to-trade-on-the-exchange) |
| [FreezeBalance](#How-to-delegate-resourcee) | [GenerateAddress](#Account-related-commands) | [GenerateShieldedTRC20Address](#How-to-transfer-shielded-TRC20-token)|
| [FreezeBalance](#Delegate-resource) | [GenerateAddress](#Account-related-commands) | [GenerateShieldedTRC20Address](#How-to-transfer-shielded-TRC20-token)|
| [GetAccount](#Account-related-commands) |[GetAccountNet](#Account-related-commands) | [GetAccountResource](#Account-related-commands) |
| [GetAddress](#Account-related-commands) | [GetAkFromAsk](#How-to-transfer-shielded-TRC20-token) |[GetAssetIssueByAccount](#How-to-issue-TRC10-tokens) |
| [GetAssetIssueById](#How-to-issue-TRC10-tokens) | [GetAssetIssueByName](#How-to-issue-TRC10-tokens) |[GetAssetIssueListByName](#How-to-issue-TRC10-tokens) |
| [GetAddress](#Account-related-commands) | [GetAkFromAsk](#How-to-transfer-shielded-TRC20-token) |[GetAssetIssueByAccount](#How-to-obtain-trc10-token-information) |
| [GetAssetIssueById](#How-to-obtain-trc10-token-information) | [GetAssetIssueByName](#How-to-obtain-trc10-token-information) |[GetAssetIssueListByName](#How-to-obtain-trc10-token-information) |
| [GetBalance](#Account-related-commands) | [GetBlock](#How-to-get-block-information) |[GetBlockById](#How-to-get-block-information) |
| [GetBlockByLatestNum](#How-to-get-block-information) | [GetBlockByLimitNext](#How-to-get-block-information) | [GetBrokerage](#Brokerage) |
| [GetContract](#How-to-use-smart-contracts) | [GetDelegatedResource](#How-to-delegate-resource) |[GetDelegatedResourceAccountIndex](#How-to-delegate-resource) |
| [GetContract](#Get-details-of-a-smart-contract) | [GetDelegatedResource](#How-to-delegate-resource) |[GetDelegatedResourceAccountIndex](#How-to-delegate-resource) |
| [GetDiversifier](#How-to-transfer-shielded-TRC20-token)| [GetExpandedSpendingKey](#How-to-transfer-shielded-TRC20-token)| [GetIncomingViewingKey](#How-to-transfer-shielded-TRC20-token) |
| [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) |
| [GetMarketPairList](#How-to-use-tron-dex-to-sell-asset)| [GetMarketPriceByPair](#How-to-use-tron-dex-to-sell-asset)| [GetNextMaintenanceTime](#Some-others) |
| [GetNkFromNsk](#How-to-transfer-shielded-TRC20-token) | [GetProposal](#Get-proposal-information) | [GetShieldedPaymentAddress](#How-to-transfer-shielded-TRC20-token)|
| [GetNkFromNsk](#How-to-transfer-shielded-TRC20-token) | [GetProposal](#Obtain-proposal-information) | [GetShieldedPaymentAddress](#How-to-transfer-shielded-TRC20-token)|
| [GetSpendingKey](#How-to-transfer-shielded-TRC20-token) | [GetReward](#Brokerage) | [GetTransactionApprovedList](#How-to-use-the-multi-signature-feature-of-wallet-cli) |
| [GetTransactionById](#How-to-get-transaction-information) | [GetTransactionCountByBlockNum](#How-to-get-transaction-information) | [GetTransactionInfoByBlockNum](#How-to-get-transaction-information) |
| [GetTransactionInfoById](#How-to-get-transaction-information) | [GetTransactionSignWeight](#How-to-use-the-multi-signature-feature-of-wallet-cli) | [ImportShieldedTRC20Wallet](#How-to-transfer-shielded-TRC20-token) |
| [ImportWallet](#Wallet-related-commands) | [ImportWalletByBase64](#Wallet-related-commands) | [ListAssetIssue](#Get-Token10) |
| [ImportWallet](#Wallet-related-commands) | [ImportWalletByBase64](#Wallet-related-commands) | [ListAssetIssue](#How-to-obtain-trc10-token-information) |
| [ListExchanges](#How-to-trade-on-the-exchange) | [ListExchangesPaginated](#How-to-trade-on-the-exchange) | [ListNodes](#Some-others) |
| [ListShieldedTRC20Address](#How-to-transfer-shielded-TRC20-token) | [ListShieldedTRC20Note](#How-to-transfer-shielded-TRC20-token) | [ListProposals](#How-to-initiate-a-proposal) |
| [ListProposalsPaginated](#How-to-initiate-a-proposal) | [ListWitnesses](#Some-others) | [LoadShieldedTRC20Wallet](#How-to-transfer-shielded-TRC20-token) |
| [ListShieldedTRC20Address](#How-to-transfer-shielded-TRC20-token) | [ListShieldedTRC20Note](#How-to-transfer-shielded-TRC20-token) | [ListProposals](#Obtain-proposal-information) |
| [ListProposalsPaginated](#Obtain-proposal-information) | [ListWitnesses](#Some-others) | [LoadShieldedTRC20Wallet](#How-to-transfer-shielded-TRC20-token) |
| [Login](#Command-line-operation-flow-example) | [MarketCancelOrder](#How-to-use-tron-dex-to-sell-asset) | [MarketSellAsset](#How-to-use-tron-dex-to-sell-asset)|
| [ParticipateAssetIssue](#How-to-issue-TRC10-tokens) | [RegisterWallet](#Wallet-related-commands) | [ResetShieldedTRC20Note](#How-to-transfer-shielded-TRC20-token) |
| [ParticipateAssetIssue](#Participating-in-the-issue-of-trc10-token) | [RegisterWallet](#Wallet-related-commands) | [ResetShieldedTRC20Note](#How-to-transfer-shielded-TRC20-token) |
| [ScanShieldedTRC20NoteByIvk](#How-to-transfer-shielded-TRC20-token) | [ScanShieldedTRC20NoteByOvk](#How-to-transfer-shielded-TRC20-token) |[SendCoin](#How-to-use-the-multi-signature-feature-of-wallet-cli) |
| [SendShieldedTRC20Coin](#How-to-transfer-shielded-TRC20-token) | [SendShieldedTRC20CoinWithoutAsk](#How-to-transfer-shielded-TRC20-token) | [SetShieldedTRC20ContractAddress](#How-to-transfer-shielded-TRC20-token) |
| [ShowShieldedTRC20AddressInfo](#How-to-transfer-shielded-TRC20-token) | [TransferAsset](#How-to-issue-TRC10-tokens) | [TriggerContract](#How-to-use-smart-contracts) |
| [UnfreezeAsset](#How-to-issue-TRC10-tokens) | [UnfreezeBalance](#How-to-delegate-resource) |[UpdateAsset](#How-to-issue-TRC10-tokens) |
| [UpdateBrokerage](#Brokerage) | [UpdateEnergyLimit](#How-to-use-smart-contracts) |[UpdateSetting](#How-to-use-smart-contracts) |
| [ShowShieldedTRC20AddressInfo](#How-to-transfer-shielded-TRC20-token) | [TransferAsset](#Trc10-token-transfer) | [TriggerContract](#Trigger-smart-contarct) |
| [UnfreezeAsset](#Unfreeze-trc10-token) | [UnfreezeBalance](#How-to-delegate-resource) |[UpdateAsset](#Update-parameters-of-trc10-token) |
| [UpdateBrokerage](#Brokerage) | [UpdateEnergyLimit](#Update-smart-contract-parameters) |[UpdateSetting](#Update-smart-contract-parameters) |
| [UpdateAccountPermission](#How-to-use-the-multi-signature-feature-of-wallet-cli) | [VoteWitness](#How-to-vote) | [FreezeBalanceV2](#How-to-freezev2) |
| [UnfreezeBalanceV2](#How-to-freezev2) | [DelegateResource](#How-to-freezev2) | [UnDelegateResource](#How-to-freezev2) |
| [WithdrawExpireUnfreeze](#How-to-freezev2) | [CancelAllUnfreezeV2](#How-to-freezev2) |[GetDelegatedResourceV2](#How-to-freezev2) |
| [GetDelegatedResourceAccountIndexV2](#How-to-freezev2) | [GetCanDelegatedMaxSize](#How-to-freezev2) | [GetAvailableUnfreezeCount](#How-to-freezev2) |
| [GetCanWithdrawUnfreezeAmount](#How-to-freezev2) | | |
| [GetCanWithdrawUnfreezeAmount](#How-to-freezev2) |[GetBandwidthPrices](#Get-resource-prices-and-memo-fee) | [GetEnergyPrices](#Get-resource-prices-and-memo-fee)|
| [GetMemoFee](#Get-resource-prices-and-memo-fee) |||

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

Expand Down Expand Up @@ -1474,6 +1475,37 @@ wallet> getCanWithdrawUnfreezeAmount TJAVcszse667FmSNCwU2fm6DmfM5D4AyDh 16711003
"amount": 9000000
}
```
## Get resource prices and memo fee
> getbandwidthprices
> get historical unit price of bandwidth
Example:
```console
wallet> getBandwidthPrices
{
"prices": "0:10,1606537680000:40,1614238080000:140,1626581880000:1000,1626925680000:140,1627731480000:1000"
}
```
> getenergyprices
> get historical unit price of energy
Example:
```console
wallet> getEnergyPrices
{
"prices": "0:100,1575871200000:10,1606537680000:40,1614238080000:140,1635739080000:280,1681895880000:420"
}
```
> getmemofee
> get memo fee
Example:
```console
wallet> getMemoFee
{
"prices": "0:0,1675492680000:1000000"
}
```


## Wallet related commands
Expand Down
48 changes: 48 additions & 0 deletions src/main/java/org/tron/walletcli/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public class Client {
"GetAssetIssueByName",
"GetAssetIssueListByName",
"GetBalance",
"GetBandwidthPrices",
"GetBlock",
"GetBlockById",
"GetBlockByIdOrNum",
Expand All @@ -132,6 +133,7 @@ public class Client {
"GetAvailableUnfreezeCount",
"GetCanWithdrawUnfreezeAmount",
"GetDiversifier",
"GetEnergyPrices",
"GetExchange",
"GetExpandedSpendingKey",
"GetIncomingViewingKey",
Expand All @@ -140,6 +142,7 @@ public class Client {
"GetMarketOrderListByPair",
"GetMarketPairList",
"GetMarketPriceByPair",
"GetMemoFee",
"GetNextMaintenanceTime",
"GetNkFromNsk",
"GetProposal",
Expand Down Expand Up @@ -258,6 +261,7 @@ public class Client {
"GetAssetIssueByName",
"GetAssetIssueListByName",
"GetBalance",
"GetBandwidthPrices",
"GetBlock",
"GetBlockById",
"GetBlockByIdOrNum",
Expand All @@ -275,6 +279,7 @@ public class Client {
"GetAvailableUnfreezeCount",
"GetCanWithdrawUnfreezeAmount",
"GetDiversifier",
"GetEnergyPrices",
"GetExchange",
"GetExpandedSpendingKey",
"GetIncomingViewingKey",
Expand All @@ -283,6 +288,7 @@ public class Client {
"GetMarketOrderListByPair",
"GetMarketPairList",
"GetMarketPriceByPair",
"GetMemoFee",
"GetNextMaintenanceTime",
"GetNkFromNsk",
"GetProposal",
Expand Down Expand Up @@ -1533,6 +1539,36 @@ private void cancelAllUnfreezeV2(String[] parameters)
}
}

private void getBandwidthPrices(String[] parameters) {
if (parameters.length > 0) {
System.out.println("Use GetBandwidthPrices command with below syntax: ");
System.out.println("GetBandwidthPrices");
return;
}
PricesResponseMessage result = walletApiWrapper.getBandwidthPrices();
System.out.println("The BandwidthPrices is " + result.getPrices());
}

private void getEnergyPrices(String[] parameters) {
if (parameters.length > 0) {
System.out.println("Use GetEnergyPrices command with below syntax: ");
System.out.println("GetEnergyPrices");
return;
}
PricesResponseMessage result = walletApiWrapper.getEnergyPrices();
System.out.println("The EnergyPrices is "+ result.getPrices());
}

private void getMemoFee(String[] parameters) {
if (parameters.length > 0) {
System.out.println("Use GetMemoFee command with below syntax: ");
System.out.println("GetMemoFee");
return;
}
PricesResponseMessage result = walletApiWrapper.getMemoFee();
System.out.println("The MemoFee is " + result.getPrices());
}

private void unfreezeAsset(String[] parameters) throws IOException,
CipherException, CancelException {
System.out.println("Use UnfreezeAsset command like: ");
Expand Down Expand Up @@ -4938,6 +4974,18 @@ private void run() {
getBlockByIdOrNum(parameters);
break;
}
case "getbandwidthprices": {
getBandwidthPrices(parameters);
break;
}
case "getenergyprices": {
getEnergyPrices(parameters);
break;
}
case "getmemofee": {
getMemoFee(parameters);
break;
}
case "exit":
case "quit": {
System.out.println("Exit !!!");
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/tron/walletcli/WalletApiWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,18 @@ public GrpcAPI.NumberMessage getBrokerage(byte[] ownerAddress) {
return WalletApi.getBrokerage(ownerAddress);
}

public PricesResponseMessage getBandwidthPrices() {
return WalletApi.getBandwidthPrices();
}

public PricesResponseMessage getEnergyPrices() {
return WalletApi.getEnergyPrices();
}

public PricesResponseMessage getMemoFee() {
return WalletApi.getMemoFee();
}

public boolean scanShieldedTRC20NoteByIvk(byte[] address, final String ivk,
final String ak, final String nk,
long start, long end, String[] events) {
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/org/tron/walletserver/GrpcClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,29 @@ public NumberMessage getBrokerage(byte[] address) {
}
}

public PricesResponseMessage getBandwidthPrices() {
EmptyMessage message = EmptyMessage.newBuilder().build();
if (blockingStubSolidity != null) {
return blockingStubSolidity.getBandwidthPrices(message);
} else {
return blockingStubFull.getBandwidthPrices(message);
}
}

public PricesResponseMessage getEnergyPrices() {
EmptyMessage message = EmptyMessage.newBuilder().build();
if (blockingStubSolidity != null) {
return blockingStubSolidity.getEnergyPrices(message);
} else {
return blockingStubFull.getEnergyPrices(message);
}
}

public PricesResponseMessage getMemoFee() {
EmptyMessage message = EmptyMessage.newBuilder().build();
return blockingStubFull.getMemoFee(message);
}

public Optional<TransactionInfoList> getTransactionInfoByBlockNum(long blockNum) {
TransactionInfoList transactionInfoList;
NumberMessage.Builder builder = NumberMessage.newBuilder();
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/org/tron/walletserver/WalletApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import org.tron.api.GrpcAPI.OvkDecryptParameters;
import org.tron.api.GrpcAPI.OvkDecryptTRC20Parameters;
import org.tron.api.GrpcAPI.PaymentAddressMessage;
import org.tron.api.GrpcAPI.PricesResponseMessage;
import org.tron.api.GrpcAPI.PrivateParameters;
import org.tron.api.GrpcAPI.PrivateParametersWithoutAsk;
import org.tron.api.GrpcAPI.PrivateShieldedTRC20Parameters;
Expand Down Expand Up @@ -2730,6 +2731,18 @@ public static GrpcAPI.NumberMessage getBrokerage(byte[] owner) {
return rpcCli.getBrokerage(owner);
}

public static PricesResponseMessage getBandwidthPrices() {
return rpcCli.getBandwidthPrices();
}

public static PricesResponseMessage getEnergyPrices() {
return rpcCli.getEnergyPrices();
}

public static PricesResponseMessage getMemoFee() {
return rpcCli.getMemoFee();
}

public static Optional<DecryptNotesTRC20> scanShieldedTRC20NoteByIvk(
IvkDecryptTRC20Parameters parameters, boolean showErrorMsg) {
try {
Expand Down
18 changes: 18 additions & 0 deletions src/main/protos/api/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,15 @@ service Wallet {

rpc GetBlock (BlockReq) returns (BlockExtention) {
}

rpc GetBandwidthPrices (EmptyMessage) returns (PricesResponseMessage) {
}

rpc GetEnergyPrices (EmptyMessage) returns (PricesResponseMessage) {
}

rpc GetMemoFee (EmptyMessage) returns (PricesResponseMessage) {
}
};

service WalletSolidity {
Expand Down Expand Up @@ -963,6 +972,11 @@ service WalletSolidity {
}
rpc GetBlock (BlockReq) returns (BlockExtention) {
}
rpc GetBandwidthPrices (EmptyMessage) returns (PricesResponseMessage) {
}

rpc GetEnergyPrices (EmptyMessage) returns (PricesResponseMessage) {
}
};

service WalletExtension {
Expand Down Expand Up @@ -1109,6 +1123,10 @@ message CanWithdrawUnfreezeAmountResponseMessage {
int64 amount = 1;
}

message PricesResponseMessage {
string prices = 1;
}

// Gossip node list
message NodeList {
repeated Node nodes = 1;
Expand Down
2 changes: 2 additions & 0 deletions src/main/protos/core/Tron.proto
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,8 @@ enum ReasonCode {
TOO_MANY_PEERS_WITH_SAME_IP = 0x22;
LIGHT_NODE_SYNC_FAIL = 0x23;
BELOW_THAN_ME = 0X24;
NOT_WITNESS = 0x25;
NO_SUCH_MESSAGE = 0x26;
UNKNOWN = 0xFF;
}

Expand Down

0 comments on commit 631ccea

Please sign in to comment.