Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lxcmyf opened this issue Feb 27, 2024 · 11 comments
Open

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

lxcmyf opened this issue Feb 27, 2024 · 11 comments
Assignees

Comments

@lxcmyf
Copy link
Contributor

lxcmyf commented Feb 27, 2024

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

  • Identify the current exception class being thrown for the "Account resource insufficient" error.

  • Currently, there is an exception type called "BalanceInsufficientException", which can be used instead of the previously misreported "AccountResourceInsufficientException", specifically for the case of insufficient TRX balance for multi-signature transactions.

  • Update the relevant code paths within the specific implementation to throw this new exception type when the TRX balance is insufficient.

  • Update the error handling and messaging systems to recognize and display the new exception type with an appropriate error message.

Solution 2: Extending the Existing Exception Type

  • Identify the current exception class being thrown for the "Account resource insufficient" error.

  • Modify the exception class's description or message to include the possibility of insufficient TRX balance for multi-signature transactions, perhaps by adding an "or" clause.

  • Update the relevant code paths within the specific implementation to throw this modified exception when either the bandwidth resources or the TRX balance is insufficient.

  • Update the error handling and messaging systems to recognize and display the modified exception with an appropriate error message.

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
Copy link
Contributor

Nice, I support option one

@halibobo1205
Copy link
Contributor

Nice, I support option one

+1, The error message is clear

@lxcmyf lxcmyf changed the title Improving Error Messaging for getcandelegatedmaxsize Interface Improving Error Messaging for delegateresource Interface Feb 28, 2024
@tomatoishealthy
Copy link
Contributor

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

@lxcmyf
Copy link
Contributor Author

lxcmyf commented Feb 28, 2024

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 lxcmyf changed the title Improving Error Messaging for delegateresource Interface Improving Error Messaging description for Resource Delegating transactions in multi sign scenarios Mar 2, 2024
@lxcmyf lxcmyf changed the title Improving Error Messaging description for Resource Delegating transactions in multi sign scenarios Improving Error Messaging description for Resource Delegating in multi sign scenarios Mar 2, 2024
@lxcmyf lxcmyf changed the title Improving Error Messaging description for Resource Delegating in multi sign scenarios Improving Error Messaging description for transactions in multi sign scenarios Mar 2, 2024
@lxcmyf lxcmyf changed the title Improving Error Messaging description for transactions in multi sign scenarios Optimize error message of Multi-sign Transactions Mar 4, 2024
@lxcmyf
Copy link
Contributor Author

lxcmyf commented Mar 12, 2024

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

@lxcmyf lxcmyf changed the title Optimize error message of Multi-sign Transactions Optimize TRX insufficient error message of multi-sign transaction Mar 18, 2024
@lxcmyf lxcmyf changed the title Optimize TRX insufficient error message of multi-sign transaction Optimize Insufficient TRX Error Message of Multi-Sign Transaction Mar 18, 2024
@abn2357
Copy link

abn2357 commented Jun 24, 2024

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
Copy link
Contributor Author

lxcmyf commented Jun 28, 2024

@YuMenGuan
It's feasible, good advice.

@lxcmyf
Copy link
Contributor Author

lxcmyf commented Jul 23, 2024

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.

@studentforcode
Copy link

studentforcode commented Mar 3, 2025

Hello ,

is any help to my tronpy sample add ? i will be appreciate is some one engage

i realized problem from multisig wallet how to bypas it ?

E:\tronwallet>python a.py
{'permission': {'keys': [{'address': '417b3be285dc2ec40c30f950814303b',
'weight': 1}],
'permission_name': 'owner',
'threshold': 1},
'raw_data': {'contract': [{'parameter': {'type_url': 'type.googleapis.com/protocol.TransferContract',
'value': {'amount': 300,
'owner_address': '417b3be285dc40c30f950814303b',
'to_address': '414297483ba5927
66cca876e58fa10f'}},
'type': 'TransferContract'}],
'data': '7465737
6d656d6f',
'expiration': 17410
65651,
'ref_block_bytes': '71fd',
'ref_block_hash': 'b4e5e6425f269',
'timestamp': 174105651},
'signature': [],
'txID': 'ae6faf35528fabf
*****************cf50c7862b89f590878fd5a5ab61'}
Traceback (most recent call last):
File "E:\tronwallet\a.py", line 14, in
.broadcast()
~~~~~~~~~^^
File "C:\Users\j\AppData\Local\Programs\Python\Python313\Lib\site-packages\tronpy\tron.py", line 184, in broadcast
return TransactionRet(self._client.broadcast(self), client=self._client, method=self._method)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "C:\Users\j\AppData\Local\Programs\Python\Python313\Lib\site-packages\tronpy\tron.py", line 1079, in broadcast
self._handle_api_error(payload)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File "C:\Users\j\AppData\Local\Programs\Python\Python313\Lib\site-packages\tronpy\tron.py", line 618, in _handle_api_error
raise UnknownError(msg, payload["code"])
tronpy.exceptions.UnknownError: ('Account resource insufficient error.', 'BANDWITH_ERROR')

E:\tronwallet>

a.py application code

from tronpy import Tron
from tronpy.keys import PrivateKey

client = Tron(network='nile')

Private key of TMCorX**********vMkDr1pFN4JW56

priv_key = PrivateKey(bytes.fromhex("e796f91b583929096********************800f44f14c35b84d3d"))

txn = (
client.trx.transfer("TMCorXWTUC********r1pFN4JW56", "TG3JpzHoDCBcj*******yzGFDw", 3_00)
.memo("test memo")
.build()
.inspect()
.sign(priv_key)
.broadcast()
)

print(txn)

> {'result': True, 'txid': '5182b96bc0d74f416d6b************6a11d4df030459132'}

print()

> {'id': '5182b96bc0d74f*************5a6a11d4df030459132', 'blockNumber': 6415370, 'blockTimeStamp': 1591951155000, 'contractResult': [''], 'receipt': {'net_usage': 283}}

tron.py

https://github.com/andelf/tronpy/blob/master/tronpy/tron.py

@Sunny6889
Copy link

@studentforcode I noticed the error: 'Account resource insufficient error.', 'BANDWIDTH_ERROR'. Please ensure that your account has sufficient bandwidth or TRX. You can also delegate TRX for additional bandwidth. For more information, check the developer documentation.

@studentforcode
Copy link

studentforcode commented Mar 4, 2025

@Sunny6889 No brother the account has sufficient bandwidth , sorry that i forgot to say , the owner account is multysig , and i am using the owner private key as developer to challenge myselft and other respect and vip peoples like you , to see if possible we can make transaction this way with out the active account's permission.

File "E:\tronwallet\d.py", line 14, in
.broadcast()
~~~~~~~~~^^
File "C:\Users\j\AppData\Local\Programs\Python\Python313\Lib\site-packages\tronpy\tron.py", line 184, in broadcast
return TransactionRet(self._client.broadcast(self), client=self._client, method=self._method)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "C:\Users\j\AppData\Local\Programs\Python\Python313\Lib\site-packages\tronpy\tron.py", line 1079, in broadcast
self._handle_api_error(payload)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File "C:\Users\j\AppData\Local\Programs\Python\Python313\Lib\site-packages\tronpy\tron.py", line 618, in _handle_api_error
raise UnknownError(msg, payload["code"])
tronpy.exceptions.UnknownError: ('Account resource insufficient error.', 'BANDWITH_ERROR')

https://github.com/andelf/tronpy/blob/master/tronpy/tron.py

thanks for your quick reply ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants