-
Notifications
You must be signed in to change notification settings - Fork 786
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
Allow RPC 'nano_to_raw' to accept decimals. #3777
Comments
We force the API caller to do the conversion because of the general problem of using floating point math in finance. |
I do wonder if we could interpret it as a fixed-fraction so it can be assured precision won't be lost. |
Btw you don't have to write your own code, just use one of the existing Nano libraries to do the conversion. This is one of them if you're writing code in JS: I agree it would be nice to have a |
Thank you, gentlemen. Wish I could respond to Colin, intelligently. Math is not my strong suit. Indeed, a single RPC call that returns the calculated new balance of a "new block" would be lovely. I feel bad not being able to provide a PR, so for future readers: I'd like to personally offer a bounty Ӿ50 (~$50) to anyone that provides a PR on my behalf with the proposed changes: 'add decimal support' to the existing RPC 'nano_to_raw'. And core team gives the thumbs up at least. |
Ai sẽ giải đáp bài toán này |
Summary
RPC:
What problem would be solved by this feature?
Would be nice if the Node handle decimals.
When creating new blocks, it's expected that you provide the 'new balance'... a lot of math that can be solved by the Node.
I'd also like to propose a new RPC call: 'calculate_new_balance' -- or something like that.
The use case is to avoid having to code my own arithmetic.
I'm not lazy, I just don't trust my own code, and prefer to depend on Node when working with such small decimals.
Are there any previous requests for this feature?
Could not find any.
Do you have a suggested solution?
My apologies. Don't speak C++. Only JS.
If this feature is approved, would you be willing to submit a pull request with the solution?
I am willing to collaborate
Possible solution
Accept decimals.
Additionally, (and I can make a separate Issue) add a RPC call(s) to handle 'subtraction' & 'addition' to be used in the 'block_create' RPC and anywhere a 'new balance' is expected.
Supporting files
I was pointe to this file in the source code:
nano-node/nano/node/json_handler.cpp
Lines 272 to 284 in 4752c66
The text was updated successfully, but these errors were encountered: