Repository navigation
fix(fees): verify single-use payment before fee-bump signing - #1539
Merged
greatest0fallt1me merged 2 commits intoOct 21, 2026
Conversation
|
@TMTOFFUTA 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.
Overview
This PR hardens
POST /api/billing/fee-abstractionso that the platform's fee account can no longer be drained by any authenticated user. It introduces signed, single-use quotes persisted in a newfee_abstraction_quotestable, verifies the app-token payment on-chain before any fee-bump is signed, enforces an inner-transaction policy (hash, source, allowlisted operations), computes Soroban-aware fees in integer stroops, and makes the app-token rate configurable. The execute route is placed behind the existing idempotency middleware.Related Issue
Changes
🔒 Fee Abstraction Hardening
[MODIFY]
prisma/schema.prismaFeeAbstractionQuotemodel backing the newfee_abstraction_quotestable: user id,innerTxHash, fee in stroops (bigint), app-token amount (integer units), status,expiresAt, and the consumed payment id.[ADD]
migrations/0027_fee_abstraction_quotes.sqlfee_abstraction_quotestable with the unique payment-id constraint and indexes needed by the quote/execute flow.[MODIFY]
src/config/env.tsXLM_TO_APP_TOKEN_RATE = 0.10with configurableFEE_ABSTRACTION_RATE_*settings, integer-scaled so no float math is used for amounts.[MODIFY]
src/services/feeBumper.tscalculateFeeQuotenow adds the inner transaction'ssorobanData.resourceFeetobaseFeeStroops × (ops + 1) × multiplier, all inbigint.createFeeBumpTransactionis only reachable after the caller has verified the quote and payment; it no longer signs arbitrary XDR on its own.🧪 Verification
npm run db:check-migrations— passes with the new migration.npm run lint,npm run typecheck,npm run build,npm test— expected green in CI.npm run test:unit -- src/routes/billing/feeAbstraction src/services/feeBumper.Threat Model & Double-Spend Prevention
appTokenPaymentTxIdand gets the platform to pay network fees.invokeHostFunctiontargeting the configured vault contract ids), and (e) the on-chain payment is successful, from the user's address, created after the quote, and transfers at least the quoted app-token amount to the treasury.consumedin the same transaction that records the payment id, and a unique constraint on the payment id guarantees one payment backs at most one fee-bump. Reuse returns 409 even under concurrent requests, because the constraint — not application logic alone — is the final gate.npm run db:check-migrationspassesfeeBumper.tsandfeeAbstraction.tsCloses #1495