Problem
GET /api/v1/txmeta/{txid}/json returns parallel arrays of every block a tx appears in (blockIDs, blockHashes, blockHeights, subtreeIdxs, subtreeHashes) with no way to know which entry is on the current main chain. Callers must perform a second round-trip per blockHash to determine the canonical block.
Asked for in discussion #960. Caller use-case: exchange / wallet wants the canonical confirmation height for a tx without N extra calls.
Proposal
Add a single field to the response identifying the main-chain entry:
{
"blockIDs": [1849362, 1849364],
"blockHashes": ["...orphan...", "...main..."],
"blockHeights": [1737884, 1737885],
"subtreeIdxs": [0, 0],
"subtreeHashes": ["...", "..."],
"mainChainIndex": 1,
...
}
mainChainIndex = index into the parallel arrays for the main-chain block, or -1 if the tx is only in orphans / mempool.
Compute via BlockchainClient.CheckBlockIsInCurrentChain per block ID (small N — usually 1).
Alternatives considered
- Filter response to only main-chain block: breaks diagnostic value (callers debugging forks need to see all blocks).
- Boolean per entry (
onMainChain: [false, true]): more verbose, no advantage over an index.
Tests
- TX in 1 main-chain block →
mainChainIndex: 0.
- TX in fork + main chain → index points to main block.
- TX in orphan only →
mainChainIndex: -1.
- TX in mempool →
mainChainIndex: -1, empty block arrays (existing behaviour).
Problem
GET /api/v1/txmeta/{txid}/jsonreturns parallel arrays of every block a tx appears in (blockIDs,blockHashes,blockHeights,subtreeIdxs,subtreeHashes) with no way to know which entry is on the current main chain. Callers must perform a second round-trip per blockHash to determine the canonical block.Asked for in discussion #960. Caller use-case: exchange / wallet wants the canonical confirmation height for a tx without N extra calls.
Proposal
Add a single field to the response identifying the main-chain entry:
{ "blockIDs": [1849362, 1849364], "blockHashes": ["...orphan...", "...main..."], "blockHeights": [1737884, 1737885], "subtreeIdxs": [0, 0], "subtreeHashes": ["...", "..."], "mainChainIndex": 1, ... }mainChainIndex= index into the parallel arrays for the main-chain block, or-1if the tx is only in orphans / mempool.Compute via
BlockchainClient.CheckBlockIsInCurrentChainper block ID (small N — usually 1).Alternatives considered
onMainChain: [false, true]): more verbose, no advantage over an index.Tests
mainChainIndex: 0.mainChainIndex: -1.mainChainIndex: -1, empty block arrays (existing behaviour).