feat: add GET /auth/finance/revenue endpoint#15
Closed
mukama wants to merge 4 commits intotetherto:developfrom
Closed
feat: add GET /auth/finance/revenue endpoint#15mukama wants to merge 4 commits intotetherto:developfrom
mukama wants to merge 4 commits intotetherto:developfrom
Conversation
Port pool transaction revenue data from legacy dashboard to API v2. Separates revenue from pool fees, supporting both F2Pool (changed_balance + tx_fee) and Ocean (satoshis_net_earned + fees_colected_satoshis) formats. Aggregates by period with optional pool filter.
tekwani
reviewed
Feb 19, 2026
tekwani
previously approved these changes
Feb 19, 2026
paragmore
reviewed
Feb 20, 2026
| if (!ts) continue | ||
| const day = daily[ts] ??= { revenueBTC: 0, feesBTC: 0 } | ||
| if (t.satoshis_net_earned) { | ||
| day.revenueBTC += Math.abs(t.satoshis_net_earned) / BTC_SATS |
There was a problem hiding this comment.
@mukama this logic seems to be repeating in lots of places in different apis. Can we make this common function ?
- Create finance.utils.js with shared utilities:
- validateStartEnd: replaces duplicated validation in every handler
- normalizeTimestampMs: moved from finance.handlers.js
- processTransactions: consolidates processTransactionData and
processEbitdaTransactions (fixes missing normalizeTimestampMs and
incorrect BTC_SATS division bugs), supports trackFees option
- extractCurrentPrice: merges flat and nested EBITDA price formats
- processBlockData: extracted for reuse across revenue endpoints
- Refactor finance.handlers.js to use shared utils
- Add comprehensive unit tests for all utils (24 tests)
- Update handler tests to remove tests for deleted functions
- Merge refactor/finance-utils branch
- Replace processRevenueTransactions with processTransactions({trackFees: true})
- Replace inline validation with validateStartEnd in getRevenue
- Remove duplicate processRevenueTransactions tests (covered by utils)
mukama
added a commit
to mukama/miningos-app-node
that referenced
this pull request
Feb 20, 2026
Merge feat/finance-revenue (PR tetherto#15) and feat/finance-revenue-summary (PR tetherto#16) into a single branch with shared finance utilities refactor: - GET /auth/finance/revenue - per-pool transaction revenue with fees - GET /auth/finance/revenue-summary - comprehensive revenue dashboard - Shared finance.utils.js with consolidated transaction processing - Fixes duplicate code, normalizes timestamp handling, renames ambiguous functions
Contributor
Author
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.
Summary
GET /auth/finance/revenueAPI v2 endpoint that fetches pool transaction data, separates revenue from pool fees, and aggregates by periodchanged_balance+tx_fee) and Ocean (satoshis_net_earned+fees_colected_satoshis) transaction formatsdaily,weekly,monthly,yearlyperiod aggregation with optionalpoolfilterUsage
GET /auth/finance/revenue?start=1700000000000&end=1700100000000&period=daily&pool=f2pool&overwriteCache=trueOptional: period ("daily" | "weekly" | "monthly" | "yearly"), pool, overwriteCache