restore jsonrpc api consistency to display only TRX as value#5469
restore jsonrpc api consistency to display only TRX as value#5469alexqrid wants to merge 1 commit intotronprotocol:developfrom
Conversation
|
I don't agree with this modification. It's not compatible with the data ago. And tronscan uses this value though it's not TRX. I think it's not necessary to do it. |
Thank you for the answer. Let me clarify some points: |
|
@317787106 Use |
@halibobo1205 |
|
@317787106 Help figure out what this field was used for before, or add a new field? |
|
Seems that |
|
Also I'm not quite sure with correctness of this part. And this would be wrong for ShieldedTransaction, as the value can be either from or to, currently actual information for ShieldedTransaction types isn't displayed correctly for such a case. |
@alexqrid You are right, |
|
@alexqrid Any transaction's type in java-tron is 0x0. |
|
@alexqrid The reason that we use amount in TransferAssetContract and other contract is to be compatible with tronscan and trongrid api. You can look at this https://apilist.tronscanapi.com/api/transaction-info?hash=af1094b946e947795656a9df3da7fef311b790c6ee067b29251b13fd5463c510. There is column |
|
@alexqrid For compatibility reasons, no changes will be considered for now, cc @317787106 @jwrct . |
@317787106 @jwrct Please Take A Look |
I think this is a good idea, let's discuss it, maybe we could add a new field. @317787106 @jwrct |
|
@alexqrid There may be compatible problem with previous version. Let's suppose that one user has used this value (same as amount) of the api eth_getTransactionByHash, if your changes take effect, vaule will be zero except TRX related. If this user don't acquire this changes, the data will be wrong. If you only want value only related to TRX, you can use other api to get the ContractType. This is not time consuming. |
What does this PR do?
This PR restores consistency in JSON-RPC API. Previously
valuefield inJSON-RPCresponse displayed various currencies(TRC-10 or TRX) and this is incorrect.Why are these changes required?
As we can't distinguish the transaction type in
JSON-RPCresponse it's weird to return various currencies amount invaluefield or vote amount.For instance, for transaction types
UnfreezeAssetContract,TransferAssetContractvaluefield indicates token amount, forVoteWitnessContractit indicates vote count, forExchange*Contractit indicates unknown currency at all as the currency depends on exchange.This PR has been tested by:
Follow up
System information
java-tron version:
GreatVoyage-v4.7.2OS & Version: Linux
Expected behaviour
In order to keep consistent API,
valuefield in JSON-RPC response should indicate TRX(TRON) amount, neither asset amount nor vote count.Actual behaviour
valuefield indicates not only TRX(TRON) value but TRC-10 token value as well.Check for example transaction
64e594ccb2cb47b23ade85adbcb3404a501d2627291b09a0ed49364049c5abfa:eth_getTransactionByHash response
{ "jsonrpc": "2.0", "id": 1, "result": { "blockHash": "0x0000000003197e6a40297fe291280f9c7ad3cc970564b93f96ced133d305a55e", "blockNumber": "0x3197e6a", "from": "0x4da5ddaaea7f1138c030ac8d97017d5020dd6536", "gas": "0x0", "gasPrice": "0x1a4", "hash": "0x64e594ccb2cb47b23ade85adbcb3404a501d2627291b09a0ed49364049c5abfa", "input": "0x", "nonce": "0x0000000000000000", "r": "0x49a16c9c202a9ab7b2b71e172e440d475733169a90514dc9fb6c89be576a57ad", "s": "0x150276b20b7aa21f96afbde95d4f31b30a10b0839bb8f7af85c99e274de248d3", "to": "0x49d216cb7b1cc41f166be76241301781f87e039a", "transactionIndex": "0x5", "type": "0x0", "v": "0x1c", "value": "0x87a238" } }Steps to reproduce the behaviour
Extra details
With this PR jsonrpc response is consistent and returns correct value of tron for the transacion above (
0x64e594ccb2cb47b23ade85adbcb3404a501d2627291b09a0ed49364049c5abfa):{ "jsonrpc": "2.0", "id": 7704110, "result": { "blockHash": "0x0000000003197e6a40297fe291280f9c7ad3cc970564b93f96ced133d305a55e", "blockNumber": "0x3197e6a", "from": "0x4da5ddaaea7f1138c030ac8d97017d5020dd6536", "gas": "0x0", "gasPrice": "0x1a4", "hash": "0x64e594ccb2cb47b23ade85adbcb3404a501d2627291b09a0ed49364049c5abfa", "input": "0x", "nonce": "0x0000000000000000", "r": "0x49a16c9c202a9ab7b2b71e172e440d475733169a90514dc9fb6c89be576a57ad", "s": "0x150276b20b7aa21f96afbde95d4f31b30a10b0839bb8f7af85c99e274de248d3", "to": "0x49d216cb7b1cc41f166be76241301781f87e039a", "transactionIndex": "0x5", "type": "0x0", "v": "0x1c", "value": "0x0" } }