MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / connectAddress

Method connectAddress

src/ipc/interfaces.cpp:84–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82 return true;
83 }
84 std::unique_ptr<interfaces::Init> connectAddress(std::string& address) override
85 {
86 if (address.empty() || address == "0") return nullptr;
87 int fd;
88 if (address == "auto") {
89 // Treat "auto" the same as "unix" except don't treat it an as error
90 // if the connection is not accepted. Just return null so the caller
91 // can work offline without a connection, or spawn a new
92 // bitcoin-node process and connect to it.
93 address = "unix";
94 try {
95 fd = m_process->connect(gArgs.GetDataDirNet(), "bitcoin-node", address);
96 } catch (const std::system_error& e) {
97 // If connection type is auto and socket path isn't accepting connections, or doesn't exist, catch the error and return null;
98 if (e.code() == std::errc::connection_refused || e.code() == std::errc::no_such_file_or_directory || e.code() == std::errc::not_a_directory) {
99 return nullptr;
100 }
101 throw;
102 } catch (const std::invalid_argument&) {
103 // Catch 'Unix address path "..." exceeded maximum socket path length' error
104 return nullptr;
105 }
106 } else {
107 fd = m_process->connect(gArgs.GetDataDirNet(), "bitcoin-node", address);
108 }
109 return m_protocol->connect(fd, m_exe_name);
110 }
111 void listenAddress(std::string& address) override
112 {
113 int fd = m_process->bind(gArgs.GetDataDirNet(), m_exe_name, address);

Callers 1

CallIPCFunction · 0.80

Calls 3

GetDataDirNetMethod · 0.80
emptyMethod · 0.45
connectMethod · 0.45

Tested by

no test coverage detected