Skip to content

Commit 1969636

Browse files
docs: update openapi spec (#2618)
Fixes #1406 <img width="1445" height="604" alt="Screenshot 2025-11-03 at 09 27 28" src="https://github.com/user-attachments/assets/a439e41a-a2ca-4224-993d-e8cf70d53d3b" /> <img width="1433" height="790" alt="Screenshot 2025-11-03 at 09 27 37" src="https://github.com/user-attachments/assets/7c3c8720-9713-4aa0-be30-6e5fb3601444" />
1 parent c72deed commit 1969636

File tree

3 files changed

+139
-10
lines changed

3 files changed

+139
-10
lines changed

rpc/core/tx.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,12 @@ func (env *Environment) TxStatus(ctx *rpctypes.Context, hash []byte) (*ctypes.Re
265265
return &ctypes.ResultTxStatus{Status: TxStatusRejected, ExecutionCode: code, Error: log}, nil
266266
}
267267

268-
// If the tx is not in the mempool, evicted, or committed, return unknown
268+
// If the tx is not in the mempool, evicted, or committed, return unknown.
269+
// This can happen in the following cases:
270+
// - Tx was never submitted to this node
271+
// - Tx was evicted/rejected and has expired from the cache
272+
// - Tx was submitted to a different node and not yet propagated
273+
// - Tx is invalid and was immediately rejected without caching
269274
return &ctypes.ResultTxStatus{Status: TxStatusUnknown}, nil
270275
}
271276

rpc/core/types/responses.go

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -267,15 +267,30 @@ type ResultSignedBlock struct {
267267
// ResultTxStatus represents the status of a transaction during its life cycle.
268268
// It contains info to locate a tx in a committed block as well as its execution code, log if it fails and status.
269269
type ResultTxStatus struct {
270-
Height int64 `json:"height"`
271-
Index uint32 `json:"index"`
272-
ExecutionCode uint32 `json:"execution_code"`
273-
Error string `json:"error"`
274-
Status string `json:"status"`
275-
Codespace string `json:"codespace,omitempty"`
276-
GasWanted int64 `json:"gas_wanted,omitempty"`
277-
GasUsed int64 `json:"gas_used,omitempty"`
278-
Signers []string `json:"signers,omitempty"`
270+
// Height is the block height where the transaction was committed. Only populated for COMMITTED status.
271+
Height int64 `json:"height"`
272+
// Index is the index of the transaction in the block. Only populated for COMMITTED status.
273+
Index uint32 `json:"index"`
274+
// ExecutionCode is the ABCI code returned by the application (0 = success, non-zero = error).
275+
// Populated for REJECTED and COMMITTED statuses.
276+
ExecutionCode uint32 `json:"execution_code"`
277+
// Error contains the error message if the transaction failed. Populated for REJECTED and failed COMMITTED transactions.
278+
Error string `json:"error"`
279+
// Status represents the current state of the transaction. Possible values:
280+
// - UNKNOWN: Transaction not found (never submitted, expired from cache, or submitted to different node)
281+
// - PENDING: Transaction is in the mempool awaiting inclusion
282+
// - EVICTED: Transaction was removed from mempool due to space constraints
283+
// - REJECTED: Transaction was rejected by the application (e.g., during recheck)
284+
// - COMMITTED: Transaction was included in a block
285+
Status string `json:"status"`
286+
// Codespace is the ABCI codespace for the error. Only populated for failed transactions.
287+
Codespace string `json:"codespace,omitempty"`
288+
// GasWanted is the maximum gas requested by the transaction. Only populated for COMMITTED status.
289+
GasWanted int64 `json:"gas_wanted,omitempty"`
290+
// GasUsed is the actual gas consumed during execution. Only populated for COMMITTED status.
291+
GasUsed int64 `json:"gas_used,omitempty"`
292+
// Signers contains the list of addresses that signed the transaction. Only populated for COMMITTED status.
293+
Signers []string `json:"signers,omitempty"`
279294
}
280295

281296
type ResultDataCommitment struct {

rpc/openapi/openapi.yaml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,46 @@ paths:
11311131
application/json:
11321132
schema:
11331133
$ref: "#/components/schemas/ErrorResponse"
1134+
/tx_status:
1135+
get:
1136+
summary: Get transaction status by hash
1137+
operationId: tx_status
1138+
parameters:
1139+
- in: query
1140+
name: hash
1141+
description: Transaction hash to query
1142+
required: true
1143+
schema:
1144+
type: string
1145+
example: "145c8332ce4cbd96b78605e1a6fcefda8d29750870b4bec653795b99d995de11"
1146+
tags:
1147+
- Tx
1148+
description: |
1149+
Get the status of a transaction by its hash. This endpoint provides information
1150+
about a transaction's current state in its lifecycle.
1151+
1152+
The possible status values are:
1153+
- **UNKNOWN**: Transaction is not found anywhere (not in mempool, not evicted, not committed)
1154+
- **PENDING**: Transaction is currently in the mempool awaiting inclusion in a block
1155+
- **EVICTED**: Transaction was removed from the mempool (e.g., due to mempool being full)
1156+
- **REJECTED**: Transaction was rejected by the application (e.g., during recheck after a block)
1157+
- **COMMITTED**: Transaction has been included in a block
1158+
1159+
For REJECTED transactions, the response includes the execution code and error message.
1160+
For COMMITTED transactions, the response includes block height, index, execution details, gas usage, and signers.
1161+
responses:
1162+
"200":
1163+
description: Transaction status information
1164+
content:
1165+
application/json:
1166+
schema:
1167+
$ref: "#/components/schemas/TxStatusResponse"
1168+
"500":
1169+
description: Error
1170+
content:
1171+
application/json:
1172+
schema:
1173+
$ref: "#/components/schemas/ErrorResponse"
11341174

11351175
components:
11361176
schemas:
@@ -2397,6 +2437,75 @@ components:
23972437
example: "5wHwYl3uCkaoo2GaChQmSIu8hxpJxLcCuIi8fiHN4TMwrRIU/Af1cEG7Rcs/6LjTl7YjRSymJfYaFAoFdWF0b20SCzE0OTk5OTk1MDAwEhMKDQoFdWF0b20SBDUwMDAQwJoMGmoKJuta6YchAwswBShaB1wkZBctLIhYqBC3JrAI28XGzxP+rVEticGEEkAc+khTkKL9CDE47aDvjEHvUNt+izJfT4KVF2v2JkC+bmlH9K08q3PqHeMI9Z5up+XMusnTqlP985KF+SI5J3ZOIhhNYWRlIGJ5IENpcmNsZSB3aXRoIGxvdmU="
23982438
type: object
23992439

2440+
TxStatusResponse:
2441+
type: object
2442+
required:
2443+
- "jsonrpc"
2444+
- "id"
2445+
- "result"
2446+
properties:
2447+
jsonrpc:
2448+
type: string
2449+
example: "2.0"
2450+
id:
2451+
type: integer
2452+
example: 0
2453+
result:
2454+
required:
2455+
- "status"
2456+
properties:
2457+
height:
2458+
type: string
2459+
example: "12345"
2460+
description: "Block height where the transaction was included (only for COMMITTED status)"
2461+
index:
2462+
type: integer
2463+
example: 0
2464+
description: "Index of the transaction within the block (only for COMMITTED status)"
2465+
execution_code:
2466+
type: integer
2467+
example: 0
2468+
description: "Execution code from the application (0 means success, non-zero means failure)"
2469+
error:
2470+
type: string
2471+
example: ""
2472+
description: "Error message if the transaction failed (for REJECTED or failed COMMITTED transactions)"
2473+
status:
2474+
type: string
2475+
enum:
2476+
- "UNKNOWN"
2477+
- "PENDING"
2478+
- "EVICTED"
2479+
- "REJECTED"
2480+
- "COMMITTED"
2481+
example: "COMMITTED"
2482+
description: |
2483+
Current status of the transaction:
2484+
- UNKNOWN: Not found in mempool, cache, or blockchain
2485+
- PENDING: Currently in the mempool awaiting inclusion in a block
2486+
- EVICTED: Removed from mempool due to space constraints/priority
2487+
- REJECTED: Rejected by the application (during recheck)
2488+
- COMMITTED: Included in a block
2489+
codespace:
2490+
type: string
2491+
example: "sdk"
2492+
description: "ABCI codespace for the error (only present if execution failed)"
2493+
gas_wanted:
2494+
type: string
2495+
example: "200000"
2496+
description: "Gas requested by the transaction (only for COMMITTED status)"
2497+
gas_used:
2498+
type: string
2499+
example: "85000"
2500+
description: "Gas actually used by the transaction (only for COMMITTED status)"
2501+
signers:
2502+
type: array
2503+
items:
2504+
type: string
2505+
example: ["celestia1abc...", "celestia1def..."]
2506+
description: "List of signer addresses (only for COMMITTED status)"
2507+
type: object
2508+
24002509
ABCIInfoResponse:
24012510
type: object
24022511
required:

0 commit comments

Comments
 (0)