Skip to content

feat: add lightning fees widget to dashboard#2385

Draft
reneaaron wants to merge 1 commit into
masterfrom
lightning-fees-widget
Draft

feat: add lightning fees widget to dashboard#2385
reneaaron wants to merge 1 commit into
masterfrom
lightning-fees-widget

Conversation

@reneaaron

@reneaaron reneaaron commented May 30, 2026

Copy link
Copy Markdown
Member

Summary

Adds a Lightning fees widget to the home dashboard to highlight how cheap lightning payments are.

  • New GET /api/transactions/stats endpoint aggregating settled outgoing payments into totalVolume, totalFeesPaid, and numPayments (self-payments excluded — they never traverse the network and would dilute the rate toward zero).
  • FeeRateWidget renders a volume-weighted average fee rate (fees ÷ volume) plus a one-line supporting sentence. Hidden until there's payment volume, so it never shows a hollow 0% to brand-new users.
  • Flat layout, no title icon (matches the other dashboard cards), <0.01% formatting for tiny rates.

Screenshots

image

Notes

  • Scaling: the aggregate query's WHERE is index-assisted (state, type) so it won't full-table-scan, but amount_msat/fee_msat aren't indexed, so each matching row is fetched for the SUM. Fine for typical hubs (thousands of payments); a code comment documents adding a covering index transactions(type, state, self_payment, amount_msat, fee_msat) before this needs to scale to millions. This is already a better pattern than the existing GetForwards widget, which loads all rows into memory.
  • Works on SQLite + Postgres (plain SUM/COUNT, no DB-specific percentile — chose a weighted rate over avg/median deliberately).

Test plan

  • go test ./api/ -run TestGetTransactionStats — verifies the sums and that pending/incoming/self-payment rows are excluded, plus the empty case.
  • go build ./..., frontend tsc + eslint + prettier clean.
  • Manual: widget renders on Home once there are settled outgoing payments.

Adds a GET /api/transactions/stats endpoint that aggregates settled
outgoing payments (excluding self-payments) into total volume, total
fees paid, and payment count. The new FeeRateWidget on the home
dashboard surfaces a volume-weighted average fee rate to highlight how
cheap lightning payments are, hidden until there is payment volume.
@coderabbitai

coderabbitai Bot commented May 30, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9ce11a64-9caa-4293-b691-d1152bd7bd88

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch lightning-fees-widget

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.

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.

1 participant