Feature Request: Forking Bitcoin for Native gRPC/dRPC Integration #32076

issue bearycool11 openend this issue on March 15, 2025
  1. bearycool11 commented at 12:53 pm on March 15, 2025: none

    Please describe the feature you’d like to see added.

    So I noticed on mintscan that we have bitcoin API, but… we don’t have gRPC/dRPC hooking in bitcore, which is causing a lot of wacky stuff to occur on Coinbase.

    Then again, if we’re going to introduce this feature we to be careful of this following bug vulnerability

    interface ProviderRpcError { message: string; code: number; data?: { method?: string }; stack?: string; }

    Because we all know what that does. Coinbase, the cryptocurrency exchange, announced a security bug in their API that would have allowed an attacker to take over user accounts. Coinbase halted all trading and withdrawals while they investigated the issue. The bug has since been fixed, and Coinbase has resumed trading. I mean, I’m grateful that bitcore has deprecated the private key generation function for a legac wallet, becausr if you combine that RPC error within the API with bitcore’s… unique console commands, well, let’s just say you get more than a misconfigured graph going the opposite direction, while your crypto wallet is showing the inverse of the graph (my friend James told me about this issue with his crypto and… it’s jarring, I hope to God y’all didn’t put an AI model without persistent stateful memory like I ahve been telling you all to do time and time again…

    So yeah, there are going to be hurdles with this developing this feature, yes I deserve to get paid for bringing this problem up because I will be the one coming to a solution with dRPC.org so that interchain.io has a better bitcoin cryptocurrency that isn’t as easily hackable.

    Because you all realize that’s why bitcoin is going down? I mean sure, there’s the political drama and bullshit, but it’s because the network is not secure in the trenches, in those data mines. @coderabbitai can you provide some solutions for us?

    …. for now, this is our proposal and we will provide code examples of current vulnerabilities still found via RPC hooking in coinbase that have not been addressed

    1. Introduction Objective Fork the Bitcoin Core repository to add a native gRPC (or dRPC) interface to bitcoind, enabling direct streaming and RPC calls without relying solely on JSON-RPC proxies or wrappers. Why gRPC or dRPC? Modern Capabilities

    gRPC offers bidirectional streaming, a standardized protocol buffer (protobuf) approach, and improved performance compared to REST/JSON-RPC in many cases. Multi-Chain Interoperability

    Many Cosmos-based chains expose gRPC endpoints, making Bitcoin a “special case” on cross-chain platforms like Mintscan or interchain.io. Currently, Mintscan/interchain.io only have a limited HTTP “API” for Bitcoin and no standard RPC, introducing unnecessary complexity and potential security gaps. Future Alignment with Bitcore

    Tools like Bitcore (JavaScript/TypeScript with optional C/C++ bindings) integrate more smoothly when there is a native gRPC or dRPC server available, reducing friction for multi-chain solutions. Impact on Bitcoin’s Price

    Although external factors (political, economic) influence Bitcoin’s valuation, technical weaknesses—such as lacking robust cross-chain interfaces—can erode confidence and adoption. This perceived security and integration gap can contribute to negative market sentiment. The downward pressure on Bitcoin’s price has been partly attributed to concerns over network security “in the trenches,” especially as institutional and retail users demand more reliable, modern tools. Cosmos SDK Roadblocks

    The Cosmos SDK team has historically been protective of its own ecosystem, causing difficulties for third-party or cross-chain solutions (particularly around interchain queries). Julien’s involvement (cited in multiple issue threads) has introduced major bugs or blocked proposals aimed at bridging Bitcoin more seamlessly into the Cosmos ecosystem. This friction exacerbates multi-chain fragmentation, impacting both Bitcoin and Cosmos-based projects. 2. Repository Structure and File Changes 2.1 New Files Create three new core files in src/grpc/:

    gRPC.h – The header file defining your main gRPC server class and public methods. gRPC.c – (Optional) C-based scaffolding if bridging with lower-level libraries or external dependencies. gRPC.cpp – The main implementation of your gRPC server logic, method stubs, and request handlers. css Copy Edit bitcoin/ ├─ src/ │ ├─ grpc/ │ │ ├─ gRPC.h │ │ ├─ gRPC.cpp │ │ └─ gRPC.c │ ├─ rpc/ # Existing JSON-RPC logic │ └─ … other Bitcoin Core files └─ … rest of repo 2.2 Protobuf Definitions Place your .proto files (e.g., bitcoin_service.proto, messages.proto) in a directory such as proto/:

    plaintext Copy Edit proto/ bitcoin_service.proto messages.proto An example bitcoin_service.proto:

    protobuf Copy Edit syntax = “proto3”;

    package bitcoin;

    // Basic gRPC service for Bitcoin service BitcoinRPC { // Get the current block height rpc GetBlockHeight (EmptyRequest) returns (BlockHeightResponse);

    // Get the balance for a given address rpc GetBalance (BalanceRequest) returns (BalanceResponse); }

    message EmptyRequest {} message BlockHeightResponse { int64 height = 1; } message BalanceRequest { string address = 1; } message BalanceResponse { double balance = 1; } 3. Implementation Outline 3.1 gRPC Dependencies Add gRPC and Protocol Buffers to your depends/ folder or build system. Update configure.ac or CMakeLists.txt to detect and link against gRPC. Optionally introduce a build flag (e.g., –enable-grpc). 3.2 gRPC.h — Header Example cpp Copy Edit #ifndef BITCOIN_GRPC_H #define BITCOIN_GRPC_H

    #include #include

    namespace grpc { class Server; class Service; class ServerBuilder; }

    class BitcoinGrpcServer { public: BitcoinGrpcServer(const std::string& server_address); ~BitcoinGrpcServer();

    // Start and stop the server
    void Start();
    void Shutdown();
    

    private: std::unique_ptrgrpc::ServerBuilder builder; std::unique_ptrgrpc::Server server;

    // e.g., std::unique_ptr<BitcoinServiceImpl> service;
    

    };

    #endif // BITCOIN_GRPC_H 3.3 gRPC.cpp — Implementation Example cpp Copy Edit #include “gRPC.h” #include <grpcpp/grpcpp.h> // #include “bitcoin_service.grpc.pb.h” // generated from your .proto

    // Example stub for the gRPC service class BitcoinServiceImpl final /* : public bitcoin::BitcoinRPC::Service / { public: / // e.g., Implementation of GetBlockHeight grpc::Status GetBlockHeight( grpc::ServerContext* context, const bitcoin::EmptyRequest* request, bitcoin::BlockHeightResponse* response ) override { int64_t height = GetActiveChainHeight(); response->set_height(height); return grpc::Status::OK; } */ };

    BitcoinGrpcServer::BitcoinGrpcServer(const std::string& server_address) { builder = std::make_uniquegrpc::ServerBuilder(); builder->AddListeningPort(server_address, grpc::InsecureServerCredentials());

    // auto service = std::make_unique<BitcoinServiceImpl>();
    // builder->RegisterService(service.get());
    
    server = builder->BuildAndStart();
    

    }

    BitcoinGrpcServer::~BitcoinGrpcServer() { if (server) { server->Shutdown(); } }

    void BitcoinGrpcServer::Start() { if (server) { // Typically run in a separate thread; demonstration uses a blocking Wait() server->Wait(); } }

    void BitcoinGrpcServer::Shutdown() { if (server) { server->Shutdown(); } } 3.4 gRPC.c — C Fallback or Bridge Example c Copy Edit #include “gRPC.h” #include <stdio.h>

    void initialize_grpc_module() { printf(“Initializing gRPC module…\n”); // Specialized C logic or bridging if needed } 4. Bitcore Alignment Node.js Native Addons: Bitcore-based apps (JavaScript/TypeScript) can load your C/C++ gRPC server via native addons. JSON-like I/O: Although gRPC uses protobuf, you can create helper utilities to convert requests/responses to JSON for existing Bitcore workflows. Performance Focus: Keep bridging overhead minimal so gRPC’s speed advantage is preserved. 5. Integration with Bitcoin Core Fork the Repo

    Create a new branch, e.g., feature/grpc-integration. Add Build Options

    In configure.ac or CMakeLists.txt, insert logic to detect gRPC libraries: bash Copy Edit ./configure –enable-grpc Conditional Compilation

    Wrap gRPC code with #ifdef ENABLE_GRPC to make it optional. Initialization (init.cpp)

    cpp Copy Edit #ifdef ENABLE_GRPC #include “gRPC.h”

    static std::unique_ptr g_grpcServer;

    bool AppInitServers(…) { if (gArgs.GetBoolArg("-grpcenabled", false)) { g_grpcServer = std::make_unique(“0.0.0.0:50051”); g_grpcServer->Start(); } … } #endif Shutdown (shutdown.cpp)

    cpp Copy Edit #ifdef ENABLE_GRPC if (g_grpcServer) { g_grpcServer->Shutdown(); } #endif 6. Code Vulnerabilities & Security Considerations Expanding Bitcoin’s API surface with gRPC/dRPC can open new attack vectors. This is especially relevant since Mintscan and interchain.io only see Bitcoin through a limited HTTP “API,” lacking a formal, secured RPC approach.

    ProviderRpcError Leaks

    Potentially exposing internal stack traces or method data (interface ProviderRpcError { … }) can reveal node internals. Mitigation: Sanitize error messages and avoid sending debug info in production. Unauthenticated gRPC Endpoints

    If gRPC runs on an open port without TLS or token-based auth, attackers might invoke critical node methods. Mitigation: Use TLS certificates, IP allowlists, or replicate JSON-RPC’s cookie-based approach. Streaming Overflows

    gRPC streams can exceed normal message sizes, risking DoS or memory exhaustion. Mitigation: Enforce maximum message size; monitor streaming traffic. Concurrency & Race Conditions

    gRPC typically handles multiple requests in parallel. If wallet or UTXO data isn’t thread-safe, you risk race conditions. Mitigation: Add concurrency controls, locks, or thread-safe data structures. Replay/Signature Attacks (for dRPC)

    A dRPC system might allow cross-chain transactions or custom signing. Without robust replay protection, signatures can be reused. Mitigation: Use nonces/timestamps, domain separation, and strict validation. 7. Proposed Solutions & Best Practices Wrapper Approach (Short-Term)

    A standalone “bridge” service that proxies between the existing JSON-RPC and gRPC/dRPC. Pros: Quick to prototype, no changes to Bitcoin Core required. Cons: Additional maintenance overhead; potential single point of failure. Native Integration (Long-Term)

    Integrate gRPC/dRPC directly within bitcoind. Pros: Single source of truth, minimal overhead. Cons: Requires consensus from Bitcoin Core devs (notoriously conservative), adds complexity. Security Best Practices

    Authentication: TLS, tokens, IP filtering. Granular Permissions: Restrict sensitive wallet commands. Error Sanitization: Strip stack traces in production. Incremental Rollout: Thorough testing on testnet/regtest, security audits, then mainnet. 8. Potential Hurdles Conservative Bitcoin Community: The project’s maintainers may be hesitant to include a new interface like gRPC/dRPC. Maintenance Overhead: A fork must be continuously updated to sync with upstream security patches. Adoption & Ecosystem: Exchanges, wallets, and node operators would need to adopt the new interface for it to become widely used. Cosmos SDK Conflicts: Cosmos’s SDK team, along with devs like Julien, have historically introduced obstacles or bugs that limit certain bridging or cross-chain proposals. This tension may hinder cross-chain synergy if not addressed collaboratively. 9. Conclusion By adding a native gRPC/dRPC interface to Bitcoin, we modernize the network’s developer experience and reduce vulnerabilities introduced by ad-hoc HTTP APIs on platforms like Mintscan and interchain.io. While other factors (e.g., political, economic) drive Bitcoin’s price, technological confidence plays a critical role—continuing to rely on inconsistent integrations can undermine market trust, contributing to downward price trends.

    A short-term wrapper can confirm feasibility, but a carefully reviewed, optional build flag for native gRPC/dRPC might be the long-term path if it gains acceptance in the Bitcoin ecosystem. Collaboration with or awareness of the Cosmos SDK team’s (and developers like Julien’s) stance is also crucial, as friction there can reverberate across multiple chains and hamper stable cross-chain functionality.

    dRPC gRPC Hooking Alongside the API That Bitcoin Uses

    yes, RPC and AAPI vulnerability hacking in the millions because there is no gRPC.

    Describe the solution you’d like

    Below is a concise, solution-focused summary of the proposal, describing the ideal approach to implementing a native gRPC/dRPC interface in a Bitcoin Core fork. It highlights the most critical steps, benefits, and security considerations:

    Solution Overview Fork Bitcoin Core & Introduce gRPC/dRPC

    Create a specialized branch (e.g., feature/grpc-integration) in the Bitcoin Core repository. Add gRPC/dRPC functionality as optional via a build flag (–enable-grpc or similar). Maintain the existing JSON-RPC interface for backward compatibility, so developers can choose between the old and new interfaces. File & Code Structure

    Add a src/grpc/ directory containing: gRPC.h / gRPC.cpp for core gRPC server classes and methods. gRPC.c if lower-level or C-based bridging code is needed. Define .proto files (e.g., bitcoin_service.proto) in a proto/ folder, describing request/response structures (e.g., GetBlockHeight, GetBalance). Initialization & Compilation

    Extend Bitcoin Core’s build system (Autotools/CMake) to detect and link against gRPC and protobuf libraries. Wrap all new gRPC/dRPC code with #ifdef ENABLE_GRPC guards to ensure the core remains minimal if the feature is disabled. Modify init.cpp and shutdown.cpp to start and stop the gRPC/dRPC server (e.g., listening on 0.0.0.0:50051). Core Functionality

    BitcoinServiceImpl: Implement necessary Bitcoin RPC calls in gRPC form, such as: GetBlockHeight() to retrieve chain height, GetBalance() or more advanced features for multi-chain queries and wallet management. Ensure each gRPC handler carefully validates user inputs (to prevent injection or tampering). Security & Best Practices

    Authentication: Support TLS for secure connections; use token/cookie-based auth mirroring the existing JSON-RPC approach. Error Handling: Sanitize all error messages (avoid leaking stack traces, method details, or sensitive data). Concurrency Controls: gRPC is multi-threaded by default. Add locks around wallet or UTXO data to prevent race conditions. Replay Protection (for dRPC): If integrating signing/cross-chain bridging, enforce nonces and domain checks. Incremental Rollout: Test thoroughly on regtest or testnet environments before any mainnet release. Multi-Chain & Ecosystem Alignment

    Integrate with Bitcore via Node.js “native addons,” allowing JavaScript/TypeScript apps to call the new gRPC services seamlessly. Provide optional JSON bridging for developers already reliant on JSON-formatted inputs/outputs. Coordinate with cross-chain platforms (e.g., Mintscan, interchain.io) to standardize calls, reduce custom bridging hacks, and bolster security across the ecosystem. Addressing Bitcoin’s Price & Cosmos SDK Friction

    By demonstrably improving Bitcoin’s developer experience and cross-chain readiness, user confidence may rise—alleviating some negative market sentiment and reinforcing Bitcoin’s position in multi-chain solutions. Collaboration or at least dialogue with the Cosmos SDK team—especially regarding repeated issues or “blocking” behaviors—will help ensure stable, robust interoperability across ecosystems. What This Solution Achieves Modernizes Bitcoin’s Developer API: gRPC or dRPC can provide streaming, structured messaging, and higher throughput compared to JSON-RPC. Strengthens Cross-Chain Reliability: A clear, well-secured gRPC/dRPC interface prevents ad-hoc or insecure bridging, reducing vulnerabilities. Retains Bitcoin’s Core Ethos: Making it an optional build feature respects Bitcoin’s minimal, consensus-driven philosophy while allowing progressive adoption. Addresses Ecosystem Tensions: Transparent, standardized interfaces reduce friction with Cosmos-based chains, minimize duplication, and build trust—potentially improving Bitcoin’s market perception. This solution’s end goal: a smoother, more secure interaction model for Bitcoin, delivering improved multi-chain support without compromising the stability and consensus processes that the Bitcoin community holds dear.

    Describe any alternatives you’ve considered

    BNB bridging is still vulnerable as a bridge because of the lack of gRPC hooking within the API

    Below is a brief overview of alternative approaches considered (beyond forking Bitcoin Core to natively integrate gRPC/dRPC). Each has distinct pros and cons regarding security, performance, and maintainability.

    1. External “Bridge” or Proxy Service What It Entails

    Develop a standalone daemon (or microservice) that runs alongside bitcoind. This service communicates with Bitcoin Core over the existing JSON-RPC interface, then exposes a gRPC/dRPC endpoint externally. Pros

    No Upstream Changes: Avoids modifying Bitcoin Core directly, so there’s no need for a dedicated fork or consensus from Bitcoin Core maintainers. Quick Prototyping: Faster to build and iterate upon since you’re simply layering a new service over the existing JSON-RPC. Cons

    Maintenance Overhead: Yet another moving piece to install, update, and secure—potentially duplicating logic. Potential Desynchronization: Must keep the external proxy’s code and endpoint definitions in sync with any changes to Bitcoin Core JSON-RPC. Performance Bottleneck: Additional network hops (gRPC/dRPC → Bridge → JSON-RPC → bitcoind) might reduce efficiency. 2. Retrofitting btcd or Other Bitcoin Implementations What It Entails

    Instead of modifying “Bitcoin Core” itself, implement gRPC/dRPC in alternative full-node implementations such as btcd (written in Go) or bcoin (JavaScript-based). These projects have different architectures and may be more open to additional services. Pros

    Community-Friendlier: Smaller dev communities can be more receptive to changes. Rapid Iteration: Generally, alt-implementations move faster than Bitcoin Core in adding features. Cons

    Less Adoption: Bitcoin Core remains the de facto standard client; many exchanges, wallet providers, and node operators only trust or support “Core.” Fragmentation: Splitting development efforts across multiple Bitcoin implementations can create inconsistencies and compatibility challenges. 3. Relying on Cosmos or Bitcore to Solve It What It Entails

    Waiting for Cosmos SDK or Bitcore teams to develop bridging modules or wrappers that handle Bitcoin’s JSON-RPC internally and unify it under a new or existing gRPC/dRPC interface. Pros

    No Direct Bitcoin Changes: Offloads development and maintenance efforts to third-party ecosystems. Potential Ecosystem Standards: If Cosmos and Bitcore unify around a single bridging interface, multi-chain devs might benefit from a standardized solution. Cons

    Dependency on External Roadmaps: Cosmos/Bitcore maintainers may have other priorities or be blocked by internal disagreements (e.g., issues caused by “Julien” in Cosmos). Unpredictable Timelines: No guarantee if or when they’ll deliver a robust, secure bridging solution. Limited Control: You’re reliant on external teams for critical security and feature decisions, which can hamper timely fixes or customizations. 4. Staying With JSON-RPC Only What It Entails

    Continue using the existing JSON-RPC interface for all Bitcoin operations, possibly augmenting with improved documentation or partial bridging solutions. Pros

    No Changes Needed: Zero modification to Bitcoin Core or external dependencies. Widely Understood: JSON-RPC has been in place for years, so tooling and documentation already exist. Cons

    No Streaming: Lacks the real-time streaming or efficient chunked data transfers that gRPC can offer. Less Interoperable: Multi-chain solutions often use gRPC/dRPC, making Bitcoin the “odd one out” and requiring special-case handling. Potential Security Gaps: If bridging scripts remain ad hoc, they may not follow best security practices or might inadvertently leak sensitive data. 5. Using REST Endpoints for Partial Functionality What It Entails

    Exposing more advanced REST endpoints in Bitcoin Core (similar to the “REST interface” that already exists for some data), but not adopting full gRPC/dRPC. Pros

    Minimal Code Changes: Expanding the existing REST capabilities requires less structural alteration than a wholly new gRPC server. Familiar to Web Developers: REST is widely used, so devs might find it straightforward. Cons

    No Real-Time/Streaming: REST generally lacks native streaming and requires multiple polling requests for updates. Still Not gRPC: Cross-chain and advanced tooling typically leverage protocol buffers for efficient data transfer and wide language support; REST remains a less efficient fallback. Summary of Alternatives External Bridge: Simplifies short-term implementation but increases operational complexity. Alternate Implementations (btcd, bcoin, etc.): Potentially more open to feature additions, but lacks mainstream adoption. Rely on Cosmos/Bitcore: Offloads effort but surrenders control to external roadmaps and priorities. Stick to JSON-RPC: Zero changes but perpetuates multi-chain friction and security workarounds. Enhanced REST Endpoints: Minor expansion but still not a full replacement for real-time gRPC/dRPC features. Each approach addresses different constraints, but none offers the same performance, flexibility, and direct cross-chain compatibility as a native gRPC/dRPC fork of Bitcoin Core.

    Please leave any additional context

    If you have any new or follow-up questions about these alternatives—such as how to implement a specific one, how to mitigate certain security issues, or how to align the solution with existing tooling—feel free to let me know, and I’ll be happy to help.

  2. bearycool11 added the label Feature on Mar 15, 2025
  3. bearycool11 commented at 1:07 pm on March 15, 2025: none

    as for the coinbase SDK with the AI model causing further mayhem because I’m quite sure they didn’t even look at my repos and just let the thing loose…. yeah that’s another problem and bug we will need to resolvde– I mean if you all just used Dr. Steve Scargal’s and my adaptive persistent memory architecture, we wouldn’t be having these issues with bugwatcher.c/.h and custodian.c/h,

    Also the Github Staff needs to get off their butts and approve me so I can get sponsored and paid for this stuff guys.

    This getting ridculous I haven’t gottten paid for 7 months of hard iterative code work with you all, and it’s still this fraudently buggy?

    Let’s not even go over the incorrect handling that TRM Labs did by not hiring me because I didn’t spin in kuberenetes yet when I interviewed with this. This is what happens, guys, next time stop being holier than thou, pay me, and maybe coinbase wouldn’t have such a catastrophic failure that causes everyone to potentially be hackable and loose millions of crypto like this is QuadrigaCX all over again.

  4. pinheadmz closed this on Mar 15, 2025

  5. pinheadmz commented at 1:18 pm on March 15, 2025: member

    gRPC is a reasonable feature request and has been discussed before: #29912 https://github.com/bitcoin/bitcoin/issues/16719

    This issue was closed due to the personal information involved. It is reasonable to have a discussion on github about this techincal topic as long as it stays techincal.


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-03-29 06:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me