mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-07 22:28:02 +02:00
Merge bitcoin/bitcoin#32297: bitcoin-cli: Add -ipcconnect option
4565cff72cbitcoin-gui: Implement missing Init::makeMining method (Ryan Ofsky)fbea576c26test: add interface_ipc_cli.py testing bitcoin-cli -ipcconnect (Ryan Ofsky)0448a19b1bipc: Improve -ipcconnect error checking (Ryan Ofsky)8d614bfa47bitcoin-cli: Add -ipcconnect option (Ryan Ofsky)6a54834895ipc: Expose an RPC interface over the -ipcbind socket (Ryan Ofsky)df76891a3brefactor: Add ExecuteHTTPRPC function (Ryan Ofsky)3cd1cd3ad3ipc: Add MakeBasicInit function (Ryan Ofsky) Pull request description: This implements an idea from sipa in https://github.com/bitcoin/bitcoin/issues/28722#issuecomment-2807026958 to allow `bitcoin-cli` to connect to the node via IPC instead of TCP, if the ENABLE_IPC cmake option is enabled and the node has been started with `-ipcbind`. This feature can be tested with: ``` build/bin/bitcoin-node -regtest -ipcbind=unix -debug=ipc build/bin/bitcoin-cli -regtest -ipcconnect=unix -getinfo ``` The -ipconnect parameter can also be omitted, since this change also makes `bitcoin-cli` prefer IPC over HTTP by default, and falling back to HTTP if an IPC connection can't be established. --- This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/issues/28722). ACKs for top commit: achow101: ACK4565cff72cpinheadmz: ACK4565cff72cenirox001: Tested ACK4565cff72cTree-SHA512: cb0dc521d82591e4eb2723a37ae60949309a206265e0ccfbee1f4d59b426b770426fafa1e842819a2fa27322ecdfcd226f31da70f91c2c31b8095e1380666f1f
This commit is contained in:
@@ -12,12 +12,14 @@
|
||||
#include <consensus/validation.h>
|
||||
#include <deploymentstatus.h>
|
||||
#include <external_signer.h>
|
||||
#include <httprpc.h>
|
||||
#include <index/blockfilterindex.h>
|
||||
#include <init.h>
|
||||
#include <interfaces/chain.h>
|
||||
#include <interfaces/handler.h>
|
||||
#include <interfaces/mining.h>
|
||||
#include <interfaces/node.h>
|
||||
#include <interfaces/rpc.h>
|
||||
#include <interfaces/types.h>
|
||||
#include <interfaces/wallet.h>
|
||||
#include <kernel/chain.h>
|
||||
@@ -81,6 +83,7 @@ using interfaces::Handler;
|
||||
using interfaces::MakeSignalHandler;
|
||||
using interfaces::Mining;
|
||||
using interfaces::Node;
|
||||
using interfaces::Rpc;
|
||||
using interfaces::WalletLoader;
|
||||
using kernel::ChainstateRole;
|
||||
using node::BlockAssembler;
|
||||
@@ -1015,6 +1018,24 @@ public:
|
||||
bool m_interrupt_mining{false};
|
||||
NodeContext& m_node;
|
||||
};
|
||||
|
||||
class RpcImpl : public Rpc
|
||||
{
|
||||
public:
|
||||
explicit RpcImpl(NodeContext& node) : m_node(node) {}
|
||||
|
||||
UniValue executeRpc(UniValue request, std::string uri, std::string user) override
|
||||
{
|
||||
JSONRPCRequest req;
|
||||
req.context = &m_node;
|
||||
req.URI = std::move(uri);
|
||||
req.authUser = std::move(user);
|
||||
HTTPStatusCode status;
|
||||
return ExecuteHTTPRPC(request, req, status);
|
||||
}
|
||||
|
||||
NodeContext& m_node;
|
||||
};
|
||||
} // namespace
|
||||
} // namespace node
|
||||
|
||||
@@ -1034,4 +1055,5 @@ std::unique_ptr<Mining> MakeMining(node::NodeContext& context, bool wait_loaded)
|
||||
}
|
||||
return std::make_unique<node::MinerImpl>(context);
|
||||
}
|
||||
std::unique_ptr<Rpc> MakeRpc(node::NodeContext& context) { return std::make_unique<node::RpcImpl>(context); }
|
||||
} // namespace interfaces
|
||||
|
||||
Reference in New Issue
Block a user