Skip to content

Side-by-Side Transaction Envelope Comparator with Field-Level Change Annotation #75

Description

@grantfox-oss

Overview

Developers debugging Stellar transaction failures often need to compare two transaction envelopes — a failed XDR against a known-good one, a before-and-after after modifying an operation, or two competing path payment routes. There is currently no tooling anywhere in the Stellar ecosystem that decodes two XDR envelopes simultaneously and surfaces the structural diff at the field level. This tool must decode both envelopes completely, walk the operation tree recursively, and annotate every changed, added, and removed field — including nested types like PathPayment, ManageOffer, and SetOptions with their inner structs.

What needs to be built

apps/api/src/modules/transaction/diff.service.ts

  • POST /transaction/diff — accepts { xdrA: string, xdrB: string, type: 'envelope' | 'result' | 'meta' }:

    • Decodes both XDR strings using the Stellar SDK's xdr namespace
    • Walks both decoded trees in parallel using a recursive diffing algorithm — handles nested objects, arrays (operations list, signers list, path hops), and primitive fields
    • Returns a structured DiffResult: { summary: { added, removed, changed }, fields: DiffField[] } where each DiffField = { path: string, type: 'added' | 'removed' | 'changed' | 'unchanged', valueA: string | null, valueB: string | null, humanLabel: string }
    • humanLabel maps raw field names to English descriptions: source_account → "Source Account", destination_min → "Minimum Destination Amount", fee → "Transaction Fee (stroops)"
    • Array diff uses sequence alignment (LCS algorithm) to match operations by type before diffing fields — avoids false positives when operations are reordered
  • GET /transaction/diff/fields — returns the full field label map as JSON — used by the frontend to render tooltips
    apps/web/src/app/inspector/diff/

  • Two Monaco editors side by side — left (XDR A), right (XDR B); both accept raw XDR or a tx hash (auto-fetched from Horizon)

  • XDR type selector: Envelope / Result / Meta

  • "Compare" button — calls the diff endpoint and renders the result below

  • Diff output panel:

    • Summary bar: X changed, Y added, Z removed
    • Field tree — hierarchical: Transaction → Operation 1 → fields; each field row shows left value, right value, and change type badge (colour-coded)
    • Filter toggles: show only changed, show only added/removed, show unchanged
    • "Copy diff as JSON" button
  • Deep-link support: ?xdrA=...&xdrB=... pre-populates and auto-runs the diff on page load

Acceptance criteria

  • Diff of two identical XDR envelopes returns zero changed/added/removed fields
  • Diff correctly identifies a changed destination_min on a PathPaymentStrictReceive operation — including correct LCS-based operation matching when the operation order differs between the two envelopes
  • humanLabel is present for every field in a standard Payment, PathPayment, CreateAccount, and SetOptions operation — no raw field names shown in the UI
  • XDR hash input auto-fetches and decodes from Horizon within 1 second on testnet
  • Deep-link with ?xdrA&xdrB auto-runs the diff without requiring a button click
  • Diff of a 10-operation envelope with changes across 3 operations returns the correct annotated tree with no missing fields

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions