refactor: add msat model to encapsulate conversions#889
Open
refactor: add msat model to encapsulate conversions#889
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3d2db8b to
286655e
Compare
73b5102 to
b3b2aeb
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
b3b2aeb to
ebc01a1
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
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.
This PR introduces an
MSatinline value class that replaces all scattered(x + 999u) / 1000uceiling andx / 1000ufloor patterns with self-documenting conversions.Description
The msat-to-sat conversions were spread across 13 files with no domain type to explain what's happening. After PR #879 added more ceiling conversions, it became harder to understand the intent behind
(x + 999u) / 1000uwithout reading the PR context. The newMSatvalue class (zero runtime overhead) makes the rounding intent self-documenting.MSatinline value class inmodels/withceil()andfloor()functionsmsatCeilOf()andmsatFloorOf()top-level sugar functions for concise call sites(x + 999u) / 1000u,msatsToSatsCeil) withmsatCeilOf(x)x / 1000u,x / MSATS_PER_SAT) withmsatFloorOf(x)msatsToSatsCeil()function andMSATS_PER_SATconstant fromLnurl.ktMSat.PER_SATconstant for the sat→msat directionMSatTest.ktwith 10 test casesPreview
N/A — no UI changes, pure refactor.
QA Notes
All tests listed and checked below were verified manually, this is a refactoring PR which shouldn't require extensive retesting by reviewer.
Tests
All tests should use msat values: