|
| 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 |
0 commit comments