XRPLF / rippled

Decentralized cryptocurrency blockchain daemon implementing the XRP Ledger protocol in C++
https://xrpl.org
ISC License
4.5k stars 1.45k forks source link

account_tx commandline syntax returns internal error (Version: 0.80.0 - 1.5.0-b6) #3279

Closed carlhua closed 1 year ago

carlhua commented 4 years ago

on v0.80.0 through v1.5.0-b6, the following commandline syntax returns an internal error:

$ ./rippled -- account_tx r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59 -1 -1 2 false false false Loading: "/home/mduo13/.config/ripple/rippled.cfg" { "error" : "internal", "error_code" : 70, "error_message" : "Internal error.", "error_what" : "std::bad_cast" }

I think the request should actually succeed, but even if it errors, it should be a non-internal error such as "invalidParams".

The second of the three "false" parameters refers to the deprecated "count" parameter which triggers the deprecated "Old" account_tx, and I'm not sure if the third is be interpreted as "forward" (the new-style) or "descending" (the deprecated old style) parameter. So the internal error may be coming from the deprecated code, in which case removing it ( RIPD-1569 ) would fix this problem by default.

Using 0 for false makes the command work without error.

In addition, another related very minor bug is that the help text for the account_tx commandline syntax lists ledger_index_min and ledger_index_max as being optional, but you have to specify at least one of them in the WebSocket format. (In the commandline syntax, I think you have to specify _min because the arguments are positional.)

Original reporter @mDuo13 - RIPD-1570

cjcobb23 commented 4 years ago

@carlhua @mDuo13 The comandline argument parsing code looks for an integer parameter as the 5th positional parameter (the first false parameter in the example). This explains why changing false to 0 fixes the problem. The parser is trying to parse the offset parameter (side note, the documentation at https://xrpl.org/account_tx.html for command line syntax has the offset and limit positional parameters flipped). Here is the code: https://github.com/ripple/rippled/blob/develop/src/ripple/net/impl/RPCCall.cpp#L316

Also, unless I am mistaken, specifying false for the last 3 parameters is bit misleading, though it works as intended; the code expects the last 3 arguments to be strings with the value binary, count or descending. If they are present, the value of that argument is set to true, else it is set to false (which explains why passing false works, but passing true would not). You can see this in the code as well.

This error occurs at the argument parsing level, and not the handler level, meaning the error is not in deprecated code. So the example request is actually malformed, though I think it should return invalidParams as opposed to just an internal error. Seems like a simple case of adding some try-catch statements.

mDuo13 commented 4 years ago

I went to try and fix the docs for this, but it's still kind of confusing. https://github.com/ripple/rippled/issues/2926 should help, I think.

intelliot commented 1 year ago

Closing due to inactivity. If you encounter a similar problem, please open a new issue.