Repository navigation
fix: exact batch totals, payout retry worker and webhook hardening (#1163-#1166) - #1293
Merged
github-actions[bot] merged 1 commit intoOct 17, 2026
Conversation
Closes Smartdevs17#1163, Smartdevs17#1164, Smartdevs17#1165, Smartdevs17#1166 (iterations 6-7). - batch: sum amounts in exact decimal arithmetic and never total across assets - payouts: drive backed-off retries from a scheduled worker - webhooks: reject unparseable timestamps and use timingSafeEqual for digests - docs: document the batch, retry and webhook behaviour Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
|
@QueenGiba is attempting to deploy a commit to the smartdevs17's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@UltimateUser1 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.
Summary
Delivers the next increment of four templated iteration issues. Each issue takes one concrete, verifiable problem rather than a broad sweep, so every change stays independently reviewable.
Closes #1163
Closes #1164
Closes #1165
Closes #1166
Scope
#1164 - Fix payment correctness bugs
estimateBatchandgetBatchReportsummed amounts withparseFloat, so totals drifted with binary floating point. They now usesumAmounts(exact decimal, 7 dp).estimateBatchsummed XLM and USDC into onetotalAmount. The total is nownullunless the batch spans exactly one asset.byAssetis unchanged.#1165 - Improve payout reliability
retryDueBatches()existed, and failures recorded a backoff timestamp, but nothing called the retry pass automatically. Failed batches waited until an operator hitPOST /api/v1/payouts/retries.startPayoutRetryWorker()(backend/src/services/payouts/retry-worker.ts) runs the pass on an interval (60s). Passes never overlap, the timer isunref'd, and a rejected pass is logged and retried on the next tick.backend/src/index.ts.#1166 - Strengthen payment security
NaNin the tolerance check, andNaN > toleranceis false, so it passed the replay window. It is now rejected.crypto.timingSafeEqualover the decoded bytes. Non-hex or wrong-length signatures fail closed.#1163 - Improve documentation
docs/PAYMENT_CORRECTNESS.md: new section on exact batch totals and per-asset totals.WEBHOOK_VERIFICATION.md: new section on the replay window and signature comparison.docs/PAYOUT_RELIABILITY.mdalready describes the retry worker as "driven by a scheduled worker"; that statement is now accurate.Files
backend/src/services/batch.tsbackend/src/services/webhooks/verification.tstimingSafeEqualbackend/src/services/payouts/retry-worker.tsretryDueBatchesbackend/src/index.tsbackend/src/services/payouts/__tests__/retry-worker.test.tsbackend/src/services/webhooks/__tests__/verification.test.tsdocs/PAYMENT_CORRECTNESS.md,WEBHOOK_VERIFICATION.mdTesting
backend/src/services/__tests__/batch.test.tsalready asserts the single-asset and mixed-asset total contract that this change implements.cd backend && npm run lint && npm test. Not executed in the authoring environment, so CI is the first run for these files.