tronprotocol / java-tron

Java implementation of the Tron whitepaper
GNU Lesser General Public License v3.0
3.74k stars 1.41k forks source link

Optimize Insufficient TRX Error Message of Multi-Sign Transaction #5736

Open lxcmyf opened 8 months ago

lxcmyf commented 8 months ago

Rationale

Currently, when users try to query the maximum delegated bandwidth through the /wallet/getcandelegatedmaxsize interface, they find that the bandwidth margin is sufficient. However, when using the /wallet/delegateresource interface for delegateing resource, they may encounter an error message "Account resource insufficient error." After investigation, it was found that the actual reason for this error is not insufficient bandwidth resources, but insufficient transaction (TRX) balance in the account. This is because this transaction is a multi signature transaction, and the transaction cost of the multi signature operation needs to be deducted from the TRX balance of the account.

The current issue lies in the broad and sometimes inaccurate definition of the exception thrown. This can lead to confusion and misunderstanding among users, who may wrongly believe that they need to purchase more bandwidth resources instead of simply topping up their TRX balance.

To address this, we propose two solutions:

  1. Replacing the Exception Type: Currently, there is an exception type called "BalanceInsufficientException", which can be used instead of the previously misreported "AccountResourceInsufficientException", insufficient TRX balance for multi-signature transactions.
  2. Extending the Existing Exception Type: Alternatively, we can expand the meaning of the current exception type to include the possibility of insufficient TRX balance, perhaps by adding an "or" clause to its description.

Implementation

Solution 1: Replacing the exception type

Solution 2: Extending the Existing Exception Type

Either solution would help improve the user experience by providing a more accurate and useful error message in the case of insufficient TRX balance for multi-signature transactions.

CarlChaoCarl commented 8 months ago

Nice, I support option one

halibobo1205 commented 8 months ago

Nice, I support option one

+1, The error message is clear

tomatoishealthy commented 8 months ago

Is it possible to determine the account type during the query and return the correct amount of available resources?

lxcmyf commented 8 months ago

Is it possible to determine the account type during the query and return the correct amount of available resources?

@tomatoishealthy This may not be related to the account type, as this transaction is a multi signature transaction, so an additional deduction of account TRX is required, and this fee consumption is not deducted from the available bandwidth of the account.

lxcmyf commented 8 months ago

Considering that the abnormal information thrown by option 2 may cause ambiguity, option 1 will be used to optimize this issue.

abn2357 commented 4 months ago

Considering that the abnormal information thrown by option 2 may cause ambiguity, option 1 will be used to optimize this issue. @lxcmyf
Option 1 is also my choose. But I have another question, whether the error message can contain the information of minimum quantity of TRX the account should have.

lxcmyf commented 4 months ago

@YuMenGuan It's feasible, good advice.

lxcmyf commented 3 months ago

For this issue, further assessment will be conducted on the current error message return mechanism to identify the most suitable improvement direction. Ensuring better compatibility in future version updates is a priority.