Skip to content

fix(config): validate STELLAR_NETWORK at boot and derive host/passphrase from it - #381

Open
testimonyblockchain wants to merge 2 commits into
Rotula-Labs:mainfrom
testimonyblockchain:fix/issue-233-fix-config-validate-the-stellar-network-at-boot
Open

testimonyblockchain wants to merge 2 commits into
Rotula-Labs:mainfrom
testimonyblockchain:fix/issue-233-fix-config-validate-the-stellar-network-at-boot

Conversation

@testimonyblockchain

Copy link
Copy Markdown

Overview

This PR validates STELLAR_NETWORK at boot against the supported set (TESTNET, PUBLIC) and rejects anything else, then derives both the Horizon host and the network passphrase from that single validated value so they can never disagree. It removes the permissive fallback to the public network that let a typo point the passphrase at mainnet while the Horizon host stayed on testnet.

Related Issue

Changes

🔒 Config Validation

  • [MODIFY] src/config/env.ts
    • Validate STELLAR_NETWORK against the supported set at boot; throw an error naming the variable and the accepted values on any unsupported input.
    • Export the validated network so downstream code consumes one source of truth.

🌐 Stellar Service

  • [MODIFY] src/services/stellar.service.ts
    • Derive the Horizon host and the network passphrase from the same validated STELLAR_NETWORK value.
    • Remove the permissive fallback to the public network in networkPassphrase() and the mismatched fallthrough in Horizon host selection, so host and passphrase can never diverge.

✅ Tests

  • [MODIFY] src/__tests__/stellar.service.test.ts
    • Cover both supported values (TESTNET, PUBLIC) for host and passphrase derivation.
    • Cover rejection of an unsupported value at boot.

Verification Results

npm test
✅ passes locally
Acceptance Criteria Status
An unsupported value throws at boot naming the variable and the accepted values ✅ Validation in src/config/env.ts names STELLAR_NETWORK and the accepted values
The Horizon host and the network passphrase are derived from one validated source ✅ Both derived from the single validated STELLAR_NETWORK value
A test covers both supported values and the rejection ✅ Added to src/__tests__/stellar.service.test.ts
npm test passes locally ✅ Passes

Closes #233

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

@testimonyblockchain 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(config): validate the stellar network at boot

2 participants