diff --git a/Makefile.am b/Makefile.am
index 368fa4ae..cea8151d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -183,6 +183,7 @@ include_bitcoin_node_channels_HEADERS = \
include/bitcoin/node/channels/channel.hpp \
include/bitcoin/node/channels/channel_http.hpp \
include/bitcoin/node/channels/channel_peer.hpp \
+ include/bitcoin/node/channels/channel_rpc.hpp \
include/bitcoin/node/channels/channel_tcp.hpp \
include/bitcoin/node/channels/channel_ws.hpp \
include/bitcoin/node/channels/channels.hpp
@@ -246,6 +247,7 @@ include_bitcoin_node_protocols_HEADERS = \
include/bitcoin/node/protocols/protocol_observer.hpp \
include/bitcoin/node/protocols/protocol_peer.hpp \
include/bitcoin/node/protocols/protocol_performer.hpp \
+ include/bitcoin/node/protocols/protocol_rpc.hpp \
include/bitcoin/node/protocols/protocol_stratum_v1.hpp \
include/bitcoin/node/protocols/protocol_stratum_v2.hpp \
include/bitcoin/node/protocols/protocol_tcp.hpp \
diff --git a/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj b/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj
index 0db943d7..f4662b04 100644
--- a/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj
+++ b/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj
@@ -175,6 +175,7 @@
+
@@ -229,6 +230,7 @@
+
diff --git a/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj.filters b/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj.filters
index 44319bde..4a167287 100644
--- a/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj.filters
+++ b/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj.filters
@@ -221,6 +221,9 @@
include\bitcoin\node\channels
+
+ include\bitcoin\node\channels
+
include\bitcoin\node\channels
@@ -383,6 +386,9 @@
include\bitcoin\node\protocols
+
+ include\bitcoin\node\protocols
+
include\bitcoin\node\protocols
diff --git a/include/bitcoin/node.hpp b/include/bitcoin/node.hpp
index 8a3be6d4..517b5687 100644
--- a/include/bitcoin/node.hpp
+++ b/include/bitcoin/node.hpp
@@ -30,6 +30,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -77,6 +78,7 @@
#include
#include
#include
+#include
#include
#include
#include
diff --git a/include/bitcoin/node/channels/channel_rpc.hpp b/include/bitcoin/node/channels/channel_rpc.hpp
new file mode 100644
index 00000000..f2827385
--- /dev/null
+++ b/include/bitcoin/node/channels/channel_rpc.hpp
@@ -0,0 +1,52 @@
+/**
+ * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS)
+ *
+ * This file is part of libbitcoin.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+#ifndef LIBBITCOIN_NODE_CHANNELS_CHANNEL_RPC_HPP
+#define LIBBITCOIN_NODE_CHANNELS_CHANNEL_RPC_HPP
+
+#include
+#include
+#include
+#include
+
+namespace libbitcoin {
+namespace node {
+
+/// Channel for electrum and stratum v1 channels (non-http json-rpc).
+class BCN_API channel_rpc
+ : public node::channel,
+ public network::channel_rpc,
+ protected network::tracker
+{
+public:
+ typedef std::shared_ptr ptr;
+
+ inline channel_rpc(const network::logger& log,
+ const network::socket::ptr& socket, uint64_t identifier,
+ const node::configuration& config, const options_t& options) NOEXCEPT
+ : node::channel(log, socket, identifier, config),
+ network::channel_rpc(log, socket, identifier, config.network, options),
+ network::tracker(log)
+ {
+ }
+};
+
+} // namespace node
+} // namespace libbitcoin
+
+#endif
diff --git a/include/bitcoin/node/channels/channel_tcp.hpp b/include/bitcoin/node/channels/channel_tcp.hpp
index 100f9a45..8871cc06 100644
--- a/include/bitcoin/node/channels/channel_tcp.hpp
+++ b/include/bitcoin/node/channels/channel_tcp.hpp
@@ -28,7 +28,7 @@ namespace libbitcoin {
namespace node {
/// Abstract base TCP channel state for the node.
-/// This is a placeholder for electrum, bitcoind, and stratum v1/v2 channels.
+/// This is a placeholder for stratum v2 (any unimplemented).
class BCN_API channel_tcp
: public node::channel,
public network::channel,
diff --git a/include/bitcoin/node/channels/channels.hpp b/include/bitcoin/node/channels/channels.hpp
index 061168c0..01b0a5b9 100644
--- a/include/bitcoin/node/channels/channels.hpp
+++ b/include/bitcoin/node/channels/channels.hpp
@@ -20,9 +20,10 @@
#define LIBBITCOIN_NODE_CHANNELS_CHANNELS_HPP
#include
+#include
#include
+#include
#include
-#include
#include
#endif
diff --git a/include/bitcoin/node/interfaces/electrum.hpp b/include/bitcoin/node/interfaces/electrum.hpp
index 4b8b3254..696e6156 100644
--- a/include/bitcoin/node/interfaces/electrum.hpp
+++ b/include/bitcoin/node/interfaces/electrum.hpp
@@ -31,8 +31,8 @@ struct electrum_methods
static constexpr std::tuple methods
{
/// Blockchain methods.
- method<"blockchain.block.header", number_t, optional<0>>{ "height", "cp_height" },
- method<"blockchain.block.headers", number_t, number_t, optional<0>>{ "start_height", "count", "cp_height" },
+ method<"blockchain.block.header", number_t, optional<0.0>>{ "height", "cp_height" },
+ method<"blockchain.block.headers", number_t, number_t, optional<0.0>>{ "start_height", "count", "cp_height" },
method<"blockchain.estimatefee", number_t>{ "number" },
method<"blockchain.headers.subscribe">{},
method<"blockchain.relayfee">{},
diff --git a/include/bitcoin/node/interfaces/stratum_v1.hpp b/include/bitcoin/node/interfaces/stratum_v1.hpp
index 0c052b35..d76e405e 100644
--- a/include/bitcoin/node/interfaces/stratum_v1.hpp
+++ b/include/bitcoin/node/interfaces/stratum_v1.hpp
@@ -31,7 +31,7 @@ struct stratum_v1_methods
static constexpr std::tuple methods
{
/// Client requests.
- method<"mining.subscribe", optional<""_t>, optional<0>>{ "user_agent", "extranonce1_size" },
+ method<"mining.subscribe", optional<""_t>, optional<0.0>>{ "user_agent", "extranonce1_size" },
method<"mining.authorize", string_t, string_t>{ "username", "password" },
method<"mining.submit", string_t, string_t, string_t, number_t, string_t>{ "worker_name", "job_id", "extranonce2", "ntime", "nonce" },
method<"mining.extranonce.subscribe">{},
diff --git a/include/bitcoin/node/protocols/protocol.hpp b/include/bitcoin/node/protocols/protocol.hpp
index 9b820302..9ad86a2f 100644
--- a/include/bitcoin/node/protocols/protocol.hpp
+++ b/include/bitcoin/node/protocols/protocol.hpp
@@ -40,7 +40,7 @@ class BCN_API protocol
/// -----------------------------------------------------------------------
// reinterpret_pointer_cast because channel is abstract.
- protocol(const auto& session,
+ inline protocol(const auto& session,
const network::channel::ptr& channel) NOEXCEPT
: channel_(std::reinterpret_pointer_cast(channel)),
session_(session)
diff --git a/include/bitcoin/node/protocols/protocol_electrum.hpp b/include/bitcoin/node/protocols/protocol_electrum.hpp
index 7a26e519..a262f95a 100644
--- a/include/bitcoin/node/protocols/protocol_electrum.hpp
+++ b/include/bitcoin/node/protocols/protocol_electrum.hpp
@@ -22,13 +22,13 @@
#include
#include
#include
-#include
+#include
namespace libbitcoin {
namespace node {
class BCN_API protocol_electrum
- : public node::protocol_tcp,
+ : public node::protocol_rpc,
protected network::tracker
{
public:
@@ -37,7 +37,7 @@ class BCN_API protocol_electrum
inline protocol_electrum(const auto& session,
const network::channel::ptr& channel,
const options_t& options) NOEXCEPT
- : node::protocol_tcp(session, channel, options),
+ : node::protocol_rpc(session, channel, options),
network::tracker(session->log)
{
}
@@ -45,12 +45,8 @@ class BCN_API protocol_electrum
/// Public start is required.
inline void start() NOEXCEPT override
{
- node::protocol_tcp::start();
+ node::protocol_rpc::start();
}
-
-private:
- // This is thread safe.
- ////const options_t& options_;
};
} // namespace node
diff --git a/include/bitcoin/node/protocols/protocol_rpc.hpp b/include/bitcoin/node/protocols/protocol_rpc.hpp
new file mode 100644
index 00000000..92f22dd5
--- /dev/null
+++ b/include/bitcoin/node/protocols/protocol_rpc.hpp
@@ -0,0 +1,54 @@
+/**
+ * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS)
+ *
+ * This file is part of libbitcoin.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+#ifndef LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_RPC_HPP
+#define LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_RPC_HPP
+
+#include
+#include
+#include
+#include
+
+ // Only session.hpp.
+#include
+
+namespace libbitcoin {
+namespace node {
+
+/// Abstract base for RPC protocols, thread safe.
+class BCN_API protocol_rpc
+ : public node::protocol,
+ public network::protocol_rpc
+{
+public:
+ using channel_t = node::channel_rpc;
+
+protected:
+ inline protocol_rpc(const auto& session,
+ const network::channel::ptr& channel,
+ const options_t& options) NOEXCEPT
+ : node::protocol(session, channel),
+ network::protocol_rpc(session, channel, options)
+ {
+ }
+};
+
+} // namespace node
+} // namespace libbitcoin
+
+#endif
diff --git a/include/bitcoin/node/protocols/protocol_stratum_v1.hpp b/include/bitcoin/node/protocols/protocol_stratum_v1.hpp
index 3f3cff5d..3d73ad1d 100644
--- a/include/bitcoin/node/protocols/protocol_stratum_v1.hpp
+++ b/include/bitcoin/node/protocols/protocol_stratum_v1.hpp
@@ -21,23 +21,22 @@
#include
#include
-#include
+#include
namespace libbitcoin {
namespace node {
class BCN_API protocol_stratum_v1
- : public node::protocol_tcp,
+ : public node::protocol_rpc,
protected network::tracker
{
public:
typedef std::shared_ptr ptr;
- protocol_stratum_v1(const auto& session,
+ inline protocol_stratum_v1(const auto& session,
const network::channel::ptr& channel,
const options_t& options) NOEXCEPT
- : node::protocol_tcp(session, channel, options),
- ////options_(options),
+ : node::protocol_rpc(session, channel, options),
network::tracker(session->log)
{
}
@@ -45,12 +44,8 @@ class BCN_API protocol_stratum_v1
/// Public start is required.
void start() NOEXCEPT override
{
- node::protocol_tcp::start();
+ node::protocol_rpc::start();
}
-
-private:
- // This is thread safe.
- ////const options_t& options_;
};
} // namespace node
diff --git a/include/bitcoin/node/protocols/protocol_stratum_v2.hpp b/include/bitcoin/node/protocols/protocol_stratum_v2.hpp
index fdc71358..ac601c08 100644
--- a/include/bitcoin/node/protocols/protocol_stratum_v2.hpp
+++ b/include/bitcoin/node/protocols/protocol_stratum_v2.hpp
@@ -33,7 +33,7 @@ class BCN_API protocol_stratum_v2
public:
typedef std::shared_ptr ptr;
- protocol_stratum_v2(const auto& session,
+ inline protocol_stratum_v2(const auto& session,
const network::channel::ptr& channel,
const options_t& options) NOEXCEPT
: node::protocol_tcp(session, channel, options),
diff --git a/include/bitcoin/node/protocols/protocols.hpp b/include/bitcoin/node/protocols/protocols.hpp
index da7815c8..2568214a 100644
--- a/include/bitcoin/node/protocols/protocols.hpp
+++ b/include/bitcoin/node/protocols/protocols.hpp
@@ -24,6 +24,7 @@
#include
#include
#include
+#include
#include
/// peer