fix(receipts): verify locally stored payment receipts against Horizon… - #412
Merged
Emmy123222 merged 2 commits intoSep 3, 2026
Merged
Conversation
…Emmy123222#136) - Add Horizon receipt verification engine validating network, txHash, asset, amount, and destination - Distinguish unverified, pending, confirmed, and mismatched receipt states with distinct badges and diagnostics - Enrich receipt persistence in useSearch with asset, destination, and verification metadata - Add verifyBundleOnline for end-to-end ledger verification of receipt bundles - Add comprehensive unit and integration tests across receipt verification and Dashboard audit log
|
@Anadudev 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! 🚀 |
|
@Anadudev is attempting to deploy a commit to the Emmanuel's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Closes #136
Overview
Previously, payment receipts stored in browser
localStoragewere trusted implicitly and displayed as confirmed in the Dashboard without verifying transaction existence, ledger confirmation, or on-chain settlement parameters against Stellar Horizon.This PR introduces an on-chain Horizon verification engine that checks the network, transaction hash, asset, amount, and destination receiving address for each receipt. Receipts in the Dashboard are now displayed with distinct visual statuses (
unverified,pending,confirmed, andmismatched), with granular discrepancy diagnostic banners and manual re-verification capabilities.Key Changes
Horizon Receipt Verification Engine (
src/lib/receiptVerification.ts):verifyReceiptAgainstHorizon(receipt, options): Queries the Stellar Horizon ledger endpoint for the given transaction hash and operations.successful: trueon the ledger.USDCorXLM), amount (normalized float comparison), and destination receiving address.invoke_host_function) for x402 payments are verified.stellar:mainnetvsstellar:testnet) match.verifyReceiptsAgainstHorizon(receipts, options): Batch verification utility.getHorizonUrlForNetwork(network): Network URL resolution.Distinct Verification States & Dashboard UI (
src/pages/DashboardPage.tsx):verificationMap) and status badges for each receipt:CONFIRMED #<ledger>badge with check icon.VERIFYING...badge with animated loader.MISMATCHEDbadge with alert icon, diagnostic banner displaying specific discrepancy details (e.g., amount, asset, or destination mismatch), and aRe-verifybutton.UNVERIFIEDbadge with help icon, and aRe-verifybutton.VERIFY ALLaction button to trigger parallel on-chain re-verification.DOWNLOAD BUNDLEaction button to export cryptographic receipt bundles.Receipt Storage & Integrity Enrichment (
src/hooks/useSearch.ts):stellarsearch_receiptslocalStorage to storeasset,destination,amount,network, andstatus: 'unverified'.Online Bundle Verification (
src/lib/receiptBundle.ts):verifyBundleOnline(bundle, options)to perform both offline cryptographic SHA-256 proof checks and on-chain Horizon ledger verification for all included receipts.Type System Updates (
src/types/index.ts):ReceiptVerificationStatus('unverified' | 'pending' | 'confirmed' | 'mismatched').ReceiptVerificationDetailwith ledger sequence, timestamp, and mismatch details.SearchReceiptandSearchResponsewithasset,destination, and verification status.Verification & Testing
src/lib/receiptVerification.test.ts):src/pages/DashboardPage.test.tsx):src/hooks/useSearch.test.ts):src/lib/receiptBundle.test.ts):npm test: all 37 test suites and 376 tests passed.npx tsc --noEmitandnpm run buildpassed with zero errors.