Skip to content

feat: add Stellar transaction fee estimation and balance validation - #223

Open
Xhaka00 wants to merge 2 commits into
SudiptaPaul-31:mainfrom
Xhaka00:security/issue-220-implement-stellar-transaction-fee-estimation
Open

Xhaka00 wants to merge 2 commits into
SudiptaPaul-31:mainfrom
Xhaka00:security/issue-220-implement-stellar-transaction-fee-estimation

Conversation

@Xhaka00

@Xhaka00 Xhaka00 commented Oct 19, 2026

Copy link
Copy Markdown

Overview

This PR integrates Stellar transaction fee estimation into blockchain workflows so users can review expected transaction costs before submitting operations. It adds reusable fee-estimation and balance-validation utilities in lib/stellar.ts, exposes network-fee and validation endpoints for admin workflows, and introduces a FeeSummaryPanel component that displays the estimated network fee separately from the transaction amount, along with balance sufficiency and fee-change states.

Related Issue

Changes

🔌 Stellar Fee Estimation Utilities

  • [MODIFY] lib/stellar.ts
    • Added fee-estimation helpers that retrieve current network fee information from the configured Stellar network (testnet/mainnet).
    • Added balance sufficiency checks that validate the sender's account balance against the transaction amount plus the estimated fee.
    • Added fee validation that re-checks the estimate before submission and detects material fee changes between estimation and submission.
    • Added reusable estimation/validation utilities intended for all Stellar transaction workflows (wallet operations, escrow funding, milestone releases, refund requests, dispute resolutions, ownership proofs, snippet attestations).
    • Estimation failures (Horizon/RPC errors) are surfaced distinctly from insufficient-balance failures so callers can present appropriate messaging.

🛡️ Admin API Endpoints

  • [MODIFY] app/api/admin/metrics/route.ts

    • Wired in fee-estimation/validation handling consistent with the new utilities, following existing validation and error-handling standards for API responses.
  • [MODIFY] app/api/admin/recovery/route.ts

    • Applied the same fee-estimation and balance-validation flow so recovery operations validate fees and balances before submission.

🖥️ Fee Summary UI

  • [ADD] components/FeeSummaryPanel.tsx
    • Displays transaction amount, estimated network fee, total required, and available balance as separate line items.
    • Renders fee states: estimating, estimated, updated, insufficient balance, unable to estimate, and ready for submission.
    • Shows an insufficient-balance state with required vs. available amounts and a funding prompt.
    • Shows a fee-change warning with previous vs. current fee and a re-confirmation prompt when the estimate becomes outdated.

Verification Results

npm run build
✅ Build succeeded

Manual check:
✅ Fee estimate retrieved from configured Stellar network
✅ Estimated fee displayed separately from transaction amount
✅ Insufficient balance blocks submission with clear messaging
✅ Fee change between estimation and submission surfaces re-confirmation warning
Acceptance Criteria Status
Users can view an estimated Stellar transaction fee before submitting ✅ FeeSummaryPanel shows estimated fee prior to submission
Fee estimates use the currently configured Stellar network ✅ Estimation reads network config in lib/stellar.ts
Estimated fees displayed separately from transaction amounts ✅ Separate line items in FeeSummaryPanel
Wallet balance validation occurs before submission ✅ Balance sufficiency checks in lib/stellar.ts
Users receive clear warnings when balance is insufficient ✅ Insufficient-balance state in FeeSummaryPanel
Transactions requiring higher balance than available are blocked ✅ Validation blocks submission on insufficient balance
Fee estimates update when transaction parameters change ✅ Fee refresh handling in estimation utilities
Fee estimation failures communicated with error messages ✅ Unable-to-estimate state and distinct error handling
Submission validates fee information before broadcasting ✅ Pre-submission fee revalidation in lib/stellar.ts
Handles fee changes between estimation and submission ✅ Fee-change detection with re-approval prompt
Users informed when a fee estimate becomes outdated ✅ Fee-change warning state in FeeSummaryPanel
Fee-estimation utilities reusable across workflows ✅ Shared helpers in lib/stellar.ts
Loading, validation, estimation, submission errors handled consistently ✅ Consistent error handling across utilities and API routes
API responses follow established validation/error standards ✅ Admin routes follow existing response conventions

Closes #220

@vercel

vercel Bot commented Oct 19, 2026

Copy link
Copy Markdown

@Xhaka00 is attempting to deploy a commit to the Sudipta 's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Oct 19, 2026

Copy link
Copy Markdown

@Xhaka00 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Xhaka00
Xhaka00 force-pushed the security/issue-220-implement-stellar-transaction-fee-estimation branch from 96dd539 to 56edfe5 Compare October 22, 2026 01:29
Strips the payload this branch picked up (deleted api.js, truncated postcss.config.mjs, unhooked package.json). No functional change to the branch's own work.

This branch has not been deployed

No deployments
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.

Implement Stellar Transaction Fee Estimation

1 participant