-
Notifications
You must be signed in to change notification settings - Fork 649
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
Change format of get_htlc output #1656
Conversation
The latest version formats the output to what I believe is the intent of the issue. Note that the amount is in "BitShares format", and not decimalized. Is that what is desired?
|
Yes, User is required to know the asset precision. Consistent with other responses. |
The latest commits change the internal representation to somewhat match the output of the cli_wallet::get_htlc() call. Unfortunately, there must exist ugly code in order to "pretty" the eventual output for the user. I guess the ugly code is a necessary evil, but if some have suggestions to improve it, I would be happy to consider them. |
I guess it's better to always format bitshares-core/libraries/app/database_api.cpp Lines 418 to 419 in f087fe8
|
So by that comment you think we should include the decimal? Or are you only saying the amount should be enclosed in quotes to be read as a string? |
For readability, IMHO we should include the decimal (I know |
Should we round to a certain decimal place, or just print the results? Here is the result of simply casting to double and dividing by the precision of the asset:
|
How embarrassing. The answer is there in my previous comment. We have the precision. I will cut the zeros off at the appropriate place. |
Don't round in a serious financial system. Don't use bitshares-core/libraries/app/util.cpp Line 54 in f087fe8
Update: just saw the latest comment/commit. |
If appropriate to add a change order at this late moment, please consider adding "time_lock countdown" or similar:
|
libraries/wallet/wallet.cpp
Outdated
ret_val["preimage_size"] = obj.preimage_size; | ||
return ret_val; | ||
fc::optional<htlc_object> optional_obj = my->get_htlc(htlc_id); | ||
if (optional_obj) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if this will work, as far as i know object.valid()
is used to check optionals in bitshares codebase. If we change to valid()
then if (!obj.is_null())
in line 687 can be changed for consistency as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed this location to use the more expressive .valid(). The object on line 687 is not an optional, but a variant. So I left it as .is_null()
It looks good to me @jmjatlanta . From learned lessons in the This way if we some day change the output in an incompatible manner for any reason test will fail. This, if useful can be done in a separated issue. |
I believe that would be good to do. But as not to hold up progress, I would ask that it be done in a separate issue, which I will create (and probably do the work on). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you @jmjatlanta
Fixes #1645
The output of the get_htlc method was cryptic and difficult to parse. This cleans up the formatting of the results.