feat: persist routing fee paid on community earnings withdrawals#868
feat: persist routing fee paid on community earnings withdrawals#868grunch wants to merge 1 commit into
Conversation
Community earnings withdrawals pay the withdrawal amount plus a Lightning routing fee. That fee (payment.fee) was available but discarded, only ever written to the log, so the operator had no DB record of what community withdrawals cost to route. Unlike buyer payouts, these payments have no associated order to hold the fee. Add a `fee` field to PendingPayment (default 0) and set it from payment.fee in the community-withdrawal success branch of attemptCommunitiesPendingPayments, so the routing cost lives in the record the bot already writes. Adds a regression spec covering the successful and non-confirming paths. Closes #867. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X5uNqd26cC88p5HVqErRDU
|
Warning Review limit reached
Next review available in: 3 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
| // payouts (whose fee is stored on the order), community withdrawals | ||
| // have no order, so without this the cost would only live in the log | ||
| // and be invisible to the operator/accounting (see issue #867). | ||
| pending.fee = payment.fee; |
There was a problem hiding this comment.
Just for completitue i think it will be better if fee is also persisted on buyer payouts, it creates a little inconsistency that fee in PendingPayments is only persisted on community earnings payout.
I know it is persisted in Order but just for completitude i would add it on buyer payouts
Closes #867.
Problem
Community earnings withdrawals pay the withdrawal
amountplus a Lightning routing fee. That fee is available on the payment result (payment.fee) but is discarded — only written to the log, never persisted. Unlike buyer payouts (whose fee is stored on the order asorder.routing_fee), community withdrawals have no associated order, so the routing cost is lost and the operator has no DB record of what these payouts actually cost.Fix
feefield toPendingPayment(models/pending_payment.ts), defaulting to0.pending.fee = payment.feein the success branch ofattemptCommunitiesPendingPayments, so the routing cost lives in the record the bot already writes.Scoped to the community-withdrawal path (the actual gap); buyer payouts already capture the fee on the order.
Scope note
This records the fee going forward. Withdrawals already paid before this change have no stored fee, so external consumers (e.g. the stats dashboard) still need a node-side fallback for the historical backlog. The two are complementary.
Tests
Adds
tests/jobs/community_pending_payments.spec.ts:pending.feeis set to the paid routing fee,pending.paidtrue, communityorders_to_redeemreset;pending.feestays0and the payment is not marked paid.Both pass;
npx tsccompiles cleanly and Prettier/ESLint report no issues.🤖 Generated with Claude Code
https://claude.ai/code/session_01X5uNqd26cC88p5HVqErRDU
Generated by Claude Code