Skip to content

Webhook large_tx polling uses stale balances endpoint #7063

Description

@pqmfei

Summary

tools/webhooks/webhook_server.py advertises a large_tx webhook event, but its poller reads balances from /api/balances without any node admin credential support. On the current production node, that URL returns nginx 404; the maintained all-balances endpoint is /wallet/balances/all, which returns a balances envelope and requires X-Admin-Key.

As a result, deployments pointed at the live RustChain node cannot populate _prev_balances, so large_tx events silently never fire.

Steps to reproduce

  1. Check the endpoint currently used by the webhook dispatcher:
curl -sk -i "https://rustchain.org/api/balances?limit=5"
  1. Observe that the live node returns an nginx 404 HTML response.

  2. Check the current all-balances endpoint:

curl -sk -i "https://rustchain.org/wallet/balances/all"
  1. Observe the endpoint exists but correctly requires admin auth:
{"ok":false,"reason":"admin_required"}
  1. Review the dispatcher source: _check_large_tx() calls _get("/api/balances"), and RustChainPoller has no way to send a node X-Admin-Key for admin read endpoints.

Expected behavior

The webhook dispatcher should be able to poll the current batch-balance endpoint when configured with a node admin key, parse the current balance response envelope, and emit large_tx events when a miner balance delta crosses large_tx_threshold.

Public node reads such as /health, /headers/tip, /api/stats, and /api/miners should not receive the admin key unnecessarily.

Actual behavior

large_tx polling requests a stale/non-routed /api/balances path and receives no usable balance list. Since _prev_balances remains empty or unchanged, balance-change notifications are effectively disabled for live-node deployments.

Impact

Low-to-medium operational reliability issue: one of the webhook dispatcher's documented event types is non-functional against the current node routing/auth shape. Operators relying on large_tx notifications would miss large wallet movements without an explicit error.

Fix PR

#7062

The PR:

  • adds optional RUSTCHAIN_NODE_ADMIN_KEY / --node-admin-key support;
  • sends X-Admin-Key only for explicit admin node reads;
  • switches large_tx polling to /wallet/balances/all;
  • parses current balances envelopes and amount_i64 micro-RTC rows;
  • adds focused regression tests.

Validation

PYTHONPATH=tools/webhooks python -m pytest -q tools/webhooks/test_webhook_server.py
# 6 passed
python -m py_compile tools/webhooks/webhook_server.py tools/webhooks/test_webhook_server.py
git diff --check -- tools/webhooks/webhook_server.py tools/webhooks/test_webhook_server.py

Payout handle if accepted under #305: github:pqmfei.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriagedReviewed and categorized

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions