Skip to content

Don't read a settled swap amount out of a failed transaction - #3003

Merged
JakeUrban merged 1 commit into
masterfrom
claude/ecstatic-babbage-5angwt
Sep 9, 2026
Merged

Don't read a settled swap amount out of a failed transaction#3003
JakeUrban merged 1 commit into
masterfrom
claude/ecstatic-babbage-5angwt

Conversation

@JakeUrban

@JakeUrban JakeUrban commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Fixes a bug that returned swap amounts for use in telemetry if the operation was successful but the transaction wasn't.

…saction

getSettledPathPaymentStrictSendAmount accepted both txSuccess and txFailed
before selecting the operation result. A txFailed result still carries
per-operation results, and an operation that succeeded before a later one
failed reports its own pathPaymentStrictSendSuccess there — but Stellar
transactions are atomic, so that path payment was rolled back and nothing
settled. The helper would return the rolled-back amount, contradicting the
clean-success contract its own docstring states and reporting to_amount /
to_amount_usd for a swap that never happened.

Require txSuccess. The fee-bump descent is unchanged: an inner result that
is not txSuccess now returns null through the same check.

The added test builds a txFailed result whose first operation is a settled
path payment and whose second failed; it returns "5" against the previous
code and null with the fix. The existing txFailed case only covered the path
payment itself failing, so this gap was untested.

Found by Copilot on the mobile port of this telemetry
(stellar/freighter-mobile#996), which carries the identical helper and the
same fix.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TVe5MM4mHCXUTevzdvHhq4
Copilot AI balanced review requested due to automatic review settings September 9, 2026 17:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Ensures failed atomic transactions cannot report rolled-back swap amounts as settled telemetry.

Changes:

  • Requires a successful transaction result before reading operation amounts.
  • Adds regression coverage for an earlier successful operation followed by failure.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
extension/src/helpers/transactionResult.ts Rejects all non-success transaction results.
extension/src/helpers/transactionResult.test.ts Tests the atomic rollback scenario.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

PR Preview build is ready: https://github.com/stellar/freighter/releases/tag/untagged-70585ed3f7616afdaf48
Backend: V1 prod + V2 beta (no sandbox configured for @JakeUrban). SDF collaborators only — install instructions in the release description.

@JakeUrban
JakeUrban merged commit 5ee1226 into master Sep 9, 2026
12 checks passed
@JakeUrban
JakeUrban deleted the claude/ecstatic-babbage-5angwt branch September 9, 2026 18:43
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.

4 participants