Skip to content

feat(rpc): integrate tower and tower-http for improved middleware support; refactor transaction fetching logic - #529

Open
priyashuu wants to merge 12 commits into
rpcsfrom
refactordepend
Open

priyashuu wants to merge 12 commits into
rpcsfrom
refactordepend

Conversation

@priyashuu

@priyashuu priyashuu commented Aug 20, 2026 •

Copy link
Copy Markdown
Member

Pull Request Overview

This PR extends the Braidpool node's JSON-RPC interface to expose transaction and mempool information needed by the dashboard. It also partially removes the dashboard's dependency on external mempool APIs by connecting it to the node's RPC endpoints.

Changes

  • Update the dashboard to use the new node RPCs for transaction and mempool data where applicable.
  • Add transaction stage information, filtering, and manual txid lookup to the dashboard.
  • Improve transaction dialogues and handling of missing/RPC failure states.
  • Add tower and tower-http with CORS support to the RPC server.

Overall, this connects the dashboard more closely with the Braidpool node and reduces its reliance on external mempool APIs for transaction monitoring.
This PR is dependent on PR #515.

Copilot AI lite review requested due to automatic review settings August 20, 2026 23:09
@priyashuu
priyashuu changed the base branch from dev to rpcs August 20, 2026 23:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands the node’s JSON-RPC surface to support transaction/mempool status queries (consumed by the dashboard), introduces a reverse index for committed txids in the braid, and wires in tower/tower-http to add HTTP middleware (CORS) support.

Changes:

  • Add new JSON-RPC methods for transaction status, mempool entries, and paginated committed txids; update the CLI and dashboard to consume them.
  • Add txid_to_bead reverse index to Braid and thread it through constructors/tests.
  • Add tower + tower-http and enable permissive CORS middleware for the RPC server.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
node/src/utils/test_utils.rs Update test braid construction for new txid_to_bead field.
node/src/rpc_server.rs Add new RPC methods, whitelist bitcoinproxy methods, and add tower-http CORS middleware.
node/src/db/schema.sql Add an index on Transactions(txid) for faster lookups.
node/src/braid/tests.rs Update braid struct literals for new txid_to_bead field.
node/src/braid/mod.rs Add/maintain txid_to_bead reverse index during braid creation/extension/reset.
node/Cargo.toml Add tower + tower-http to the node crate dependencies.
dashboard/src/URLs.ts Replace old mempool URL helpers with node JSON-RPC endpoint helper.
dashboard/src/components/BitcoinStats/Utils.ts Refactor tx fetching/status logic to call node JSON-RPC instead of external mempool APIs.
dashboard/src/components/BitcoinStats/Types.ts Make replaces optional for RBF transaction rows.
dashboard/src/components/BitcoinStats/TransactionTable.tsx Add stage badge, filter, and manual txid lookup UI.
dashboard/src/components/BitcoinStats/TransactionDialog.tsx Improve “not found”/N/A states and display stage + bead hash.
dashboard/src/components/BitcoinStats/RBFTransactionTable.tsx Minor UI text spacing adjustment.
dashboard/src/components/BitcoinStats/RBFTransactionRow.tsx Make replacements rendering null-safe with optional chaining.
dashboard/src/components/BitcoinStats/Prices.tsx Handle RPC failures without crashing the UI loop.
Cargo.toml Add workspace deps for tower + tower-http (cors feature).
braidpool-cli/src/main.rs Add CLI commands for new JSON-RPC endpoints.
Suppressed comments (3)

node/src/rpc_server.rs:1131

  • Same use-after-move issue as above: serde_json::json!([txid, true]) moves txid, but txid is used afterwards. Use txid.clone() (or a separate txid_str) for the JSON-RPC params.
                match call_bitcoin_rpc_direct(
                    rpc_config,
                    "gettransaction",
                    &serde_json::json!([txid, true]),
                )

node/src/rpc_server.rs:1193

  • limit is currently unbounded. Even though the mempool fetch is always full-size, returning an unbounded number of entries can create very large responses and increased CPU/memory pressure (easy DoS vector on an unauthenticated RPC). Consider clamping limit to a reasonable maximum.
    async fn get_mempool_entries(&self, limit: u32) -> Result<Value, ErrorObjectOwned> {
        info!(limit = %limit, "get_mempool_entries request received");

node/src/rpc_server.rs:1266

  • page_size is currently unbounded. A very large page_size can force the server to allocate and serialize an extremely large response (unauthenticated DoS risk). Consider clamping page_size to a reasonable maximum.
        info!(page = %page, page_size = %page_size, "get_committed_transactions request received");
        let page_size_usize = page_size as usize;
        let start = (page as usize).saturating_mul(page_size_usize);
        let end = start.saturating_add(page_size_usize);

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread node/src/rpc_server.rs
Comment thread node/src/rpc_server.rs
Comment thread dashboard/src/URLs.ts
Comment thread dashboard/src/components/BitcoinStats/Utils.ts

This branch has not been deployed

No deployments
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