Skip to content

CLN balance offer fix and makeoffer fix#2373

Merged
rolznz merged 2 commits into
getAlby:masterfrom
daywalker90:cln-balance-offer-fix
May 23, 2026
Merged

CLN balance offer fix and makeoffer fix#2373
rolznz merged 2 commits into
getAlby:masterfrom
daywalker90:cln-balance-offer-fix

Conversation

@daywalker90
Copy link
Copy Markdown
Contributor

@daywalker90 daywalker90 commented May 22, 2026

Fixes: #2361

I think these fields got deprecated between opening and merging the original CLN PR. In go my editor is not able to show deprecated fields for some reason...

Also fixes makeoffer, it was missing the amount field which is required.

Summary by CodeRabbit

  • Refactor
    • Internal mechanisms for balance calculation and tracking across all balance management systems have been improved to enhance accuracy and consistency in balance reporting. This includes standardized handling of balance data and improved offer request configuration. These refinements ensure better system reliability, accuracy, and overall compatibility.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 22, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dd9db8cd-9fbe-4f9b-95a9-94c00f01ac8b

📥 Commits

Reviewing files that changed from the base of the PR and between 3a2f935 and 0796e84.

📒 Files selected for processing (1)
  • lnclient/cln/cln.go

📝 Walkthrough

Walkthrough

Updates CLN provider balance aggregation to use properly denominated fields: GetBalances now uses millisatoshi fields (TotalSpendableMsat, TotalReceivableMsat, NextMaxSpendableMsat, NextMaxReceivableMsat), GetOnchainBalance uses satoshi fields (TotalSat, ReservedSat, SpendableSat, AmountSat, PendingBalancesFromChannelClosuresSat), and MakeOffer sets OfferRequest.Amount to "any".

Changes

Balance and Offer Field Denomination Updates

Layer / File(s) Summary
Lightning balance millisatoshi fields
lnclient/cln/cln.go
GetBalances aggregation logic updated to accumulate and track millisatoshi-denominated balance fields (TotalSpendableMsat, TotalReceivableMsat, NextMaxSpendableMsat, NextMaxReceivableMsat) and derives MPP-related millisatoshi next-max fields from those totals.
On-chain balance satoshi fields
lnclient/cln/cln.go
GetOnchainBalance UTXO accounting switched to satoshi-denominated fields (TotalSat, ReservedSat, SpendableSat), pending sweep details now use AmountSat instead of Amount, and pending balances from channel closures populate PendingBalancesFromChannelClosuresSat with per-channel AmountSat records.
Offer amount field
lnclient/cln/cln.go
MakeOffer now explicitly sets CLN OfferRequest.Amount to the string constant "any".

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • getAlby/hub#2153: Both PRs update balance/amount denomination handling to add or switch to sat/millisatoshi-specific fields (notably GetBalances/GetOnchainBalance in lnclient/cln/cln.go aligning with the unit-suffixed *Sat/*Msat API field convention introduced in #2153).

Suggested reviewers

  • rolznz
  • im-adithya

Poem

🐰 Fields now measured true and clear,
Msat and Sat fields appear!
Balances no longer hide,
Lightning shows with proper pride.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: fixing CLN balance field issues and correcting makeoffer functionality.
Linked Issues check ✅ Passed The PR addresses the root cause of issue #2361 by updating deprecated CLN balance fields in GetBalances and GetOnchainBalance, and fixes makeoffer by adding the required amount field.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the CLN balance reporting issue and makeoffer functionality; no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rolznz
Copy link
Copy Markdown
Member

rolznz commented May 23, 2026

Sorry, I think we broke this with some recent renaming. Thanks for fixing it.

@rolznz
Copy link
Copy Markdown
Member

rolznz commented May 23, 2026

EDIT: we really need to fix this properly. We should only have one version in our non-API models, lnclient models should not have json properties. CC @im-adithya

@rolznz rolznz merged commit 12a3b11 into getAlby:master May 23, 2026
7 of 11 checks passed
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.

Bug? Alby Hub displaying 0 lightning wallet balance with CLN Backend

2 participants