Skip to content

feat: full report system with PDF export and BTC balance fix#10

Merged
BitHighlander merged 4 commits intodevelopfrom
feature-reports
Mar 6, 2026
Merged

feat: full report system with PDF export and BTC balance fix#10
BitHighlander merged 4 commits intodevelopfrom
feature-reports

Conversation

@BitHighlander
Copy link
Collaborator

Summary

  • Full report system with 7 sections: device info, portfolio overview, chain balances, cached pubkeys, token details, BTC transaction history, and address flow analysis
  • PDF export using pdf-lib with landscape layout, gold (#FFD700) KeepKey branding, alternating row colors, and pie chart on first page
  • BTC balance fix: GetPortfolio (/charts/portfolio) returns empty for BTC xpubs — added GetPortfolioBalances (/portfolio) fallback to both dashboard and report generator
  • DB fallback for BTC xpubs when BtcAccountManager fails to initialize
  • Code review fixes: progress bar race condition, CSV formula injection prevention, balances array clone to prevent caller mutation

Files Changed

File Change
src/shared/types.ts Simplified report types (LOD 5 only)
src/shared/rpc-schema.ts Report RPC methods + saveReportFile with pdf support
src/bun/reports.ts New — full report generator + CSV + PDF export
src/bun/index.ts Report RPC handlers + BTC balance fallback
src/bun/db.ts Reports table CRUD
src/mainview/components/ReportDialog.tsx New — report dialog with progress bar + download buttons
src/mainview/components/Dashboard.tsx Reports button in nav bar

Test plan

  • make vault builds without errors
  • Generate report — all 7 sections populated
  • JSON download — valid JSON with all sections
  • CSV download — properly escaped, no formula injection
  • PDF download — landscape layout, pie chart, gold headers
  • BTC balance appears in dashboard after refresh
  • BTC balance appears in report pie chart
  • Delete report works
  • Progress bar updates during generation

🤖 Generated with Claude Code

BitHighlander and others added 3 commits March 4, 2026 12:13
- Add report generator with 7 sections: device info, portfolio overview,
  chain balances, cached pubkeys, token details, BTC detailed report
  (tx history + address flow analysis)
- Add PDF export with pie chart dashboard on first page using pdf-lib
- Fix BTC balance missing from dashboard: GetPortfolio (charts/portfolio)
  returns empty for BTC xpubs, now falls back to GetPortfolioBalances
  (/portfolio) which correctly returns BTC data
- Fix BTC balance missing from report pie chart: pre-fetch BTC balance
  from Pioneer direct API when cached balances show $0
- Add DB fallback for BTC xpubs when BtcAccountManager init fails
- Add ReportDialog UI with JSON/CSV/PDF download buttons
- BTC report uses /utxo/pubkey-info + /tx/history endpoints (not
  the broken /reports/bitcoin endpoint)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… mutation

- Fix progress bar race condition: capture report ID from first progress
  message instead of waiting for await to resolve (ReportDialog.tsx)
- Prevent CSV formula injection by prefixing dangerous chars in csvCell()
- Clone balances array in generateReport to avoid caller mutation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
HIGH:
- H1: Scope getReport/deleteReport to current device ID
- H2: Sanitize chain in filenames, append report ID for uniqueness

MEDIUM:
- M1: Generate Pioneer auth key lazily per request (not stale at module load)
- M2: Use Number()+Math.round() instead of parseInt for satoshi values
- M3: Consolidate per-tx detail sections into single table (was 50 sections)
- M4: Optimize pie chart rendering (~4x fewer draw operations)
- M5: Add report pruning (max 50 per device) and LIMIT on list queries
- M6: Handle JSON parse corruption gracefully instead of returning null
- M7: Check reportExists before final save (prevents delete+save race)
- M9: Sanitize error messages to strip auth keys and URLs
- M10: Strengthen CSV formula injection (handle whitespace + newlines)

LOW:
- L1: Discriminated union type for ReportSection (compile-time safety)
- L2: Remove unused type variants from ReportSection
- L3: Wrap Bun.spawn file reveal in try/catch
- L4: Move os/path to top-level imports
- L5: Add LIMIT 20 to report list DB query
- L6: Per-button saving state (not global disable)
- L7: Remove unused useTranslation import
- L8: Add delete confirmation step

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@BitHighlander BitHighlander merged commit 419bd57 into develop Mar 6, 2026
1 of 2 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.

1 participant