Skip to content

Commit b03c0cf

Browse files
authored
Merge pull request #707 from evoskuil/master
Add btcd interface definition.
2 parents c427074 + af130e8 commit b03c0cf

6 files changed

Lines changed: 94 additions & 0 deletions

File tree

Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ include_bitcoin_server_interfacesdir = ${includedir}/bitcoin/server/interfaces
196196
include_bitcoin_server_interfaces_HEADERS = \
197197
include/bitcoin/server/interfaces/bitcoind_rest.hpp \
198198
include/bitcoin/server/interfaces/bitcoind_rpc.hpp \
199+
include/bitcoin/server/interfaces/btcd.hpp \
199200
include/bitcoin/server/interfaces/electrum.hpp \
200201
include/bitcoin/server/interfaces/interfaces.hpp \
201202
include/bitcoin/server/interfaces/native.hpp \

builds/msvc/vs2022/libbitcoin-server/libbitcoin-server.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@
170170
<ClInclude Include="..\..\..\..\include\bitcoin\server\estimator.hpp" />
171171
<ClInclude Include="..\..\..\..\include\bitcoin\server\interfaces\bitcoind_rest.hpp" />
172172
<ClInclude Include="..\..\..\..\include\bitcoin\server\interfaces\bitcoind_rpc.hpp" />
173+
<ClInclude Include="..\..\..\..\include\bitcoin\server\interfaces\btcd.hpp" />
173174
<ClInclude Include="..\..\..\..\include\bitcoin\server\interfaces\electrum.hpp" />
174175
<ClInclude Include="..\..\..\..\include\bitcoin\server\interfaces\interfaces.hpp" />
175176
<ClInclude Include="..\..\..\..\include\bitcoin\server\interfaces\native.hpp" />

builds/msvc/vs2022/libbitcoin-server/libbitcoin-server.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@
206206
<ClInclude Include="..\..\..\..\include\bitcoin\server\interfaces\bitcoind_rpc.hpp">
207207
<Filter>include\bitcoin\server\interfaces</Filter>
208208
</ClInclude>
209+
<ClInclude Include="..\..\..\..\include\bitcoin\server\interfaces\btcd.hpp">
210+
<Filter>include\bitcoin\server\interfaces</Filter>
211+
</ClInclude>
209212
<ClInclude Include="..\..\..\..\include\bitcoin\server\interfaces\electrum.hpp">
210213
<Filter>include\bitcoin\server\interfaces</Filter>
211214
</ClInclude>

include/bitcoin/server.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <bitcoin/server/channels/channels.hpp>
3333
#include <bitcoin/server/interfaces/bitcoind_rest.hpp>
3434
#include <bitcoin/server/interfaces/bitcoind_rpc.hpp>
35+
#include <bitcoin/server/interfaces/btcd.hpp>
3536
#include <bitcoin/server/interfaces/electrum.hpp>
3637
#include <bitcoin/server/interfaces/interfaces.hpp>
3738
#include <bitcoin/server/interfaces/native.hpp>
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS)
3+
*
4+
* This file is part of libbitcoin-server.
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Affero General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Affero General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
#ifndef LIBBITCOIN_SERVER_INTERFACES_BTCD_HPP
20+
#define LIBBITCOIN_SERVER_INTERFACES_BTCD_HPP
21+
22+
#include <bitcoin/server/define.hpp>
23+
#include <bitcoin/server/interfaces/types.hpp>
24+
25+
namespace libbitcoin {
26+
namespace server {
27+
namespace interface {
28+
29+
struct btcd_methods
30+
{
31+
/// BTCD protocol (unversioned, json-rpc v1.0 over ws/s).
32+
static constexpr std::tuple methods
33+
{
34+
/// Handshake (disallowed when basic auth has been established).
35+
method<"authenticate", string_t, string_t>{ "username", "password" },
36+
37+
/// Admin.
38+
method<"session">{},
39+
40+
/// Block subscription.
41+
method<"notifyblocks">{},
42+
method<"stopnotifyblocks">{},
43+
44+
/// Tx subscription.
45+
method<"notifynewtransactions", optional<false>>{ "verbose" },
46+
method<"stopnotifynewtransactions">{},
47+
48+
/// Address/outpoint filtering.
49+
method<"loadtxfilter", boolean_t, value_t, value_t>{ "reload", "addresses", "outpoints" },
50+
method<"rescanblocks", value_t>{ "blockhashes" },
51+
52+
/// Deprecated (address/outpoint filtering).
53+
method<"notifyreceived", value_t>{ "addresses" },
54+
method<"stopnotifyreceived", value_t>{ "addresses" },
55+
method<"notifyspent", value_t>{ "outpoints" },
56+
method<"stopnotifyspent", value_t>{ "outpoints" },
57+
method<"rescan", string_t, value_t, value_t, optional<""_t>>{ "beginblock", "addresses", "outpoints", "endblock" }
58+
};
59+
60+
template <typename... Args>
61+
using subscriber = network::subscriber<Args...>;
62+
63+
template <size_t Index>
64+
using at = method_at<methods, Index>;
65+
66+
// Derive this from above in c++26 using reflection.
67+
using authenticate = at<0>;
68+
using session = at<1>;
69+
using notify_blocks = at<2>;
70+
using stop_notify_blocks = at<3>;
71+
using notify_new_transactions = at<4>;
72+
using stop_notify_new_transactions = at<5>;
73+
using load_tx_filter = at<6>;
74+
using rescan_blocks = at<7>;
75+
using notify_received = at<8>;
76+
using stop_notify_received = at<9>;
77+
using notify_spent = at<10>;
78+
using stop_notify_spent = at<11>;
79+
using rescan = at<12>;
80+
};
81+
82+
} // namespace interface
83+
} // namespace server
84+
} // namespace libbitcoin
85+
86+
#endif

include/bitcoin/server/interfaces/interfaces.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include <bitcoin/server/interfaces/bitcoind_rest.hpp>
2323
#include <bitcoin/server/interfaces/bitcoind_rpc.hpp>
24+
#include <bitcoin/server/interfaces/btcd.hpp>
2425
#include <bitcoin/server/interfaces/electrum.hpp>
2526
#include <bitcoin/server/interfaces/native.hpp>
2627
#include <bitcoin/server/interfaces/stratum_v1.hpp>
@@ -33,6 +34,7 @@ namespace interface {
3334

3435
using bitcoind_rest = publish<bitcoind_rest_methods>;
3536
using bitcoind_rpc = publish<bitcoind_rpc_methods>;
37+
using btcd = publish<btcd_methods>;
3638
using electrum = publish<electrum_methods>;
3739
using native = publish<native_methods>;
3840
using stratum_v1 = publish<stratum_v1_methods>;

0 commit comments

Comments
 (0)