getTransactions returns envelopeJson and resultMetaJson swapped when using xdrFormat=json

Open Beginner friendly
#627 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
go
Domain
api

Research direction

Start in cmd/stellar-rpc/internal/methods/get_transactions.go at the ResultJSON, ResultMetaJSON, and EnvelopeJSON assignments, then compare them with get_transaction.go. Reproduce the issue with the provided getTransactions and getTransaction curl requests and verify that envelopeJson contains the envelope while resultMetaJson contains the result metadata.

Written by the indexing model from the issue text.

Description

bug
What version are you using?

stellar-rpc 25.0.1 (testnet), also confirmed on HEAD of main.

What did you do?

When calling getTransactions with "xdrFormat": "json", the envelopeJson and resultMetaJson fields are swapped compared to getTransaction (singular).

To reproduce on testnet, pick any recent ledger that contains a transaction and compare the two endpoints. For example:

Step 1: Find a transaction via getTransactions:

curl -s -X POST https://soroban-testnet.stellar.org \
  -H 'Content-Type: application/json' \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getTransactions",
    "params": {
      "startLedger": 1412570,
      "xdrFormat": "json",
      "pagination": {"limit": 1}
    }
  }'

Note the txHash in the response, then query the same transaction via getTransaction:

Step 2: Get the same transaction via getTransaction:

curl -s -X POST https://soroban-testnet.stellar.org \
  -H 'Content-Type: application/json' \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getTransaction",
    "params": {
      "hash": "<txHash from step 1>",
      "xdrFormat": "json"
    }
  }'

Step 3: Compare the top-level keys of envelopeJson and resultMetaJson between the two responses.

What did you expect to see?

Both endpoints should return the same data in the same fields. Specifically, envelopeJson should contain the transaction envelope (a TransactionEnvelope with keys like tx, tx_fee_bump, etc.) and resultMetaJson should contain the transaction result metadata (a TransactionMeta with keys like v4, tx_changes_before, operations, etc.).

What did you see instead?

The fields are swapped in getTransactions:

Field getTransaction (correct) getTransactions (incorrect)
envelopeJson Envelope (tx_fee_bump, ...) ResultMeta (v4, ...)
resultMetaJson ResultMeta (v4, ...) Envelope (tx_fee_bump, ...)
resultJson Result (correct) Result (correct)

The root cause is in cmd/stellar-rpc/internal/methods/get_transactions.go lines 153-155:

txInfo.ResultJSON = result
txInfo.ResultMetaJSON = envelope    // BUG: should be EnvelopeJSON
txInfo.EnvelopeJSON = meta          // BUG: should be ResultMetaJSON

The correct assignments (as seen in get_transaction.go lines 100-102) should be:

txInfo.ResultJSON = result
txInfo.EnvelopeJSON = envelope
txInfo.ResultMetaJSON = meta
Dominant language
Go
Stars
59
Forks
77
Avg merge
3d 8h
Merged PRs (30d)
32

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from stellar/stellar-rpc

All issues in stellar/stellar-rpc

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.