Skip to content

fix: register transaction routes independently#1

Open
tolga-tom-nook wants to merge 1 commit into
BitgesellOfficial:masterfrom
tolga-tom-nook:fix/transaction-routes-independent-blocks-data
Open

fix: register transaction routes independently#1
tolga-tom-nook wants to merge 1 commit into
BitgesellOfficial:masterfrom
tolga-tom-nook:fix/transaction-routes-independent-blocks-data

Conversation

@tolga-tom-nook

Copy link
Copy Markdown

Summary

Fixes transaction route registration so transaction endpoints are controlled by the transaction option instead of being accidentally nested under blocks_data.

Before this change, when transaction=on and blocks_data=off, only the block transaction-list routes were registered. The core transaction lookup/proof endpoints were skipped because their if app["transaction"] blocks were indented inside the previous if app["blocks_data"] block.

Impact

With transaction=on and blocks_data=off, these routes now register as expected:

  • GET /rest/transaction/{tx_pointer}
  • GET /rest/transaction/hash/by/pointer/{tx_blockchain_pointer}
  • GET /rest/transaction/calculate/merkle_proof/{tx_pointer}
  • GET /rest/transaction/merkle_proof/{tx_pointer}
  • POST /rest/transactions/by/pointer/list
  • POST /rest/transactions/hash/by/blockchain/pointer/list

Validation

RED check before the fix showed only 2 transaction-related routes when blocks_data=False; after the fix the full transaction endpoint set is present.

Commands run after the fix:

PYTHONDONTWRITEBYTECODE=1 python3 - <<'PY'
import ast, pathlib
for p in pathlib.Path('.').rglob('*.py'):
    if '__pycache__' not in p.parts:
        ast.parse(p.read_text(), filename=str(p))
print('Python AST syntax OK')
PY

PYTHONDONTWRITEBYTECODE=1 python3 -m pytest tests/test_route_registration.py -q

git diff --check

Result:

Python AST syntax OK
1 passed in 0.02s
git diff --check: clean

Bounty context: Bitgesell PR bounty program / improvement bounty.

@MyTH-zyxeon

Copy link
Copy Markdown

Review assist for maintainers:

This looks like a focused route-registration fix: the transaction and transactions route blocks are now registered independently when app["transaction"] is enabled, instead of being nested under the preceding route section. The added test loads api/routes.py with stubbed handler symbols and verifies the transaction paths are present even when unrelated feature flags such as blocks_data are disabled.

Suggested merge checks:

  • Run the new route-registration test and one existing app startup/import smoke test to confirm the AST/stub-loader test still reflects real handler names.
  • Exercise setup_routes with transaction=True, blocks_data=False, and both merkle_proof=True/False so the /rest/transaction/merkle_proof/{tx_pointer} fallback behavior stays intentional.
  • Confirm no transaction route is now registered twice when all feature flags are enabled.

I do not see database, wallet/key, RPC, or live-chain behavior changes in this patch as written; the main acceptance criterion is that transaction routes are gated only by transaction and no longer disappear behind unrelated feature toggles.

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.

2 participants