feat: add idempotent Stellar payment verification#24
Merged
Jayrodri088 merged 1 commit intoStellarState:mainfrom Mar 27, 2026
Merged
Conversation
|
@Josue19-08 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! 🚀 |
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.
Description
Adds Horizon-backed Stellar payment verification and idempotent database reconciliation for investments.
Closes #7
Type of Change
Checklist
feat:,fix:,chore:, etc.) — enforced by CI.env, or credentials committed (seeCONTRIBUTING.md)Testing
How to Test
npm ci.STELLAR_HORIZON_URL,STELLAR_USDC_ASSET_CODE,STELLAR_USDC_ASSET_ISSUER,STELLAR_ESCROW_PUBLIC_KEY,STELLAR_VERIFY_ALLOWED_AMOUNT_DELTA,STELLAR_VERIFY_RETRY_ATTEMPTS,STELLAR_VERIFY_RETRY_BASE_DELAY_MS, andDATABASE_URLin.env.npm run lint,npm run type-check,npm test, andnpm run build.VerifyPaymentService.verifyPayment({ investmentId, stellarTxHash, operationIndex? })from the investment flow once the platform has a pending investment.Test Coverage
Additional Notes
Changes
src/services/stellar/verify-payment.service.tswith Horizon transaction fetch + operations fetch, payment matching, stable service errors, and retry/backoff for transient Horizon failures.transactionsrow idempotently.transactionstoinvestmentsand storingstellar_operation_indexon both entities.Verification criteria
The verifier treats a payment as valid only when the Horizon transaction is marked successful and exactly one payment operation matches the configured USDC asset code + issuer, the configured escrow public key, and the investment amount within the allowed delta. If multiple operations match, the caller must pass
operationIndexto disambiguate. Replaying the same hash for the same investment returns an idempotentalready_verifiedresult instead of applying state changes twice.Environment variables
STELLAR_HORIZON_URLSTELLAR_USDC_ASSET_CODESTELLAR_USDC_ASSET_ISSUERSTELLAR_ESCROW_PUBLIC_KEYSTELLAR_VERIFY_ALLOWED_AMOUNT_DELTASTELLAR_VERIFY_RETRY_ATTEMPTSSTELLAR_VERIFY_RETRY_BASE_DELAY_MSDATABASE_URLReviewer checklist
investment_id.verifyPayment({ investmentId: "<investment_id>", stellarTxHash: "<sample_testnet_hash>", operationIndex: 0 })or omitoperationIndexwhen the transaction has a single matching payment op.pendingtoconfirmedand the linked transaction row iscompletedwith the same Stellar hash.already_verifiedwithout creating duplicate transaction rows.For Reviewers