Skip to content

refactor: add msat model to encapsulate conversions#889

Open
ovitrif wants to merge 6 commits intomasterfrom
refactor/add-msat-model
Open

refactor: add msat model to encapsulate conversions#889
ovitrif wants to merge 6 commits intomasterfrom
refactor/add-msat-model

Conversation

@ovitrif
Copy link
Copy Markdown
Collaborator

@ovitrif ovitrif commented Apr 5, 2026

This PR introduces an MSat inline value class that replaces all scattered (x + 999u) / 1000u ceiling and x / 1000u floor 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) / 1000u without reading the PR context. The new MSat value class (zero runtime overhead) makes the rounding intent self-documenting.

  • Adds MSat inline value class in models/ with ceil() and floor() functions
  • Adds msatCeilOf() and msatFloorOf() top-level sugar functions for concise call sites
  • Replaces all ceiling patterns ((x + 999u) / 1000u, msatsToSatsCeil) with msatCeilOf(x)
  • Replaces all floor patterns (x / 1000u, x / MSATS_PER_SAT) with msatFloorOf(x)
  • Removes msatsToSatsCeil() function and MSATS_PER_SAT constant from Lnurl.kt
  • Adds MSat.PER_SAT constant for the sat→msat direction
  • Adds MSatTest.kt with 10 test cases

Preview

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:

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ovitrif ovitrif force-pushed the refactor/add-msat-model branch 2 times, most recently from 3d2db8b to 286655e Compare April 5, 2026 22:23
@ovitrif ovitrif force-pushed the refactor/add-msat-model branch from 73b5102 to b3b2aeb Compare April 5, 2026 22:40
ovitrif and others added 3 commits April 6, 2026 00:42
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>
@ovitrif ovitrif force-pushed the refactor/add-msat-model branch from b3b2aeb to ebc01a1 Compare April 5, 2026 22:42
@ovitrif ovitrif enabled auto-merge April 5, 2026 22:43
@ovitrif ovitrif added this to the 2.2.0 milestone Apr 5, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ovitrif ovitrif changed the title refactor: add MSat value class for msat-to-sat conversions refactor: add MSat model to encapsulate conversions Apr 5, 2026
@claude
Copy link
Copy Markdown
Contributor

claude bot commented Apr 5, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@ovitrif ovitrif changed the title refactor: add MSat model to encapsulate conversions refactor: add msat model to encapsulate conversions Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants