Skip to content

fix(stellar): report a failed balance lookup instead of an empty balance - #399

Open
Shindy-Ship wants to merge 2 commits into
Rotula-Labs:mainfrom
Shindy-Ship:fix/issue-250-fix-stellar-report-a-failed-balance-lookup
Open

Shindy-Ship wants to merge 2 commits into
Rotula-Labs:mainfrom
Shindy-Ship:fix/issue-250-fix-stellar-report-a-failed-balance-lookup

Conversation

@Shindy-Ship

Copy link
Copy Markdown

Overview

This PR separates a failed balance lookup from an empty balance in the Stellar balance path. Previously StellarService.checkBalance swallowed errors from this.server.loadAccount(publicKey) and returned [], which handleBalance rendered as a balance.success message with an empty string — telling users they had nothing when Horizon was actually unreachable. Now a failed lookup is surfaced to the caller and reported as an unavailable balance, while a genuinely unfunded account still renders as an empty balance.

Related Issue

Changes

🔍 Balance Lookup Distinguishes Failure from Empty

  • [MODIFY] src/services/stellar.service.ts

    • checkBalance no longer returns [] on a failed loadAccount call; the failure is propagated to the caller instead of being masked as an empty balance.
    • The not-found case is kept distinct, matching how the history path already inspects the status code and reports an unfunded wallet separately.
  • [MODIFY] src/services/message-processor.service.ts

    • handleBalance now handles the failed-lookup outcome separately from an empty result, so an outage produces an unavailable-balance message rather than a zero balance.
  • [MODIFY] src/locales/en.json

    • Added the user-facing string for an unavailable balance, distinct from the existing empty-balance message.

🧪 Tests

  • [MODIFY] src/__tests__/stellar.service.test.ts

    • Covers a failed lookup being surfaced rather than returned as an empty list.
  • [MODIFY] src/__tests__/message-processor.service.test.ts

    • Covers the failed-lookup path rendering an unavailable-balance message and the no-funds path still rendering an empty balance.

Verification Results

npm test
✅ passes locally
Acceptance Criteria Status
A failed lookup does not render as a zero balance ✅ Failure is surfaced and reported as unavailable
An account with no funds still renders as an empty balance, not an error ✅ Not-found case kept distinct from failure
The user-facing message differs between the two cases ✅ Separate unavailable-balance string added in en.json
A test covers each ✅ Added to stellar.service.test.ts and message-processor.service.test.ts
npm test passes locally ✅ Passes

Closes #250

Toyosi5566 and others added 2 commits October 16, 2026 15:32
.env is read by dotenv.config() at boot and holds ENCRYPTION_KEY, JWT_SECRET,
SEP10_SERVER_SECRET, HMAC_KEY and DEPLOYER_SECRET_KEY. None of the .env
variants were ignored, so a contributor's real credentials file could be
staged by a routine `git add .` with nothing to warn anyone. Ignore the
.env variants and keep the committed example file trackable.

No .env file is tracked at HEAD and no .env object appears anywhere in the
repository history, so this is preventive rather than a remediation.
@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@Shindy-Ship 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

@Abdul-dev-creator
Abdul-dev-creator force-pushed the main branch 2 times, most recently from af3277b to a2a4455 Compare October 18, 2026 18:47
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.

fix(stellar): report a failed balance lookup instead of an empty balance

2 participants