Use exact monetary arithmetic and preserve millisatoshi precision - #543
Merged
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Support multiple output currencies and JSON output
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Conversions previously used
f64, losing decimal precision before rounding. For example, converting 1,500 MSAT to BTC produced 0.00000001 BTC. Preserve decimal values from CLI input, legacy YAML defaults, and ticker JSON, calculate exact rate ratios, and round only the final result with midpoint ties away from zero.Bitcoin denominations now retain millisatoshi precision: BTC has up to 11 decimals, MBTC 8, BITS 5, SAT 3, and MSAT 0. For example, 1 MSAT becomes 0.00000000001 BTC, and 1,500 MSAT becomes 0.000000015 BTC.
--integercontinues to round to whole output units, while fiat output keeps its existing currency precision.Bound numeric inputs and exponents, validate positive rates, and report missing rates or conversion overflow without partial stdout. The ticker response is bounded before arbitrary-precision parsing. YAML reading uses the existing parser backend directly to retain numeric text; existing numeric defaults remain compatible.
Validation:
cargo fmt --all --checkandcargo clippy --all-targets -- -D warningspass.Stacked on #542; review this diff against
fix/cli-input-validation. Merge the input-validation PR first and retarget this PR tomasterif GitHub does not do so automatically.