Skip to content

Commit e28a284

Browse files
authored
Merge pull request #619 from evoskuil/master
Implement some electrum interface methods, refactor.
2 parents fbdab6a + 3512b36 commit e28a284

15 files changed

Lines changed: 128 additions & 44 deletions

Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ console_bs_SOURCES = \
8787
console/executor.cpp \
8888
console/executor.hpp \
8989
console/executor_commands.cpp \
90+
console/executor_daemon.cpp \
9091
console/executor_dumps.cpp \
9192
console/executor_events.cpp \
9293
console/executor_logging.cpp \

builds/cmake/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ if (with-console)
325325
"../../console/executor.cpp"
326326
"../../console/executor.hpp"
327327
"../../console/executor_commands.cpp"
328+
"../../console/executor_daemon.cpp"
328329
"../../console/executor_dumps.cpp"
329330
"../../console/executor_events.cpp"
330331
"../../console/executor_logging.cpp"

builds/msvc/vs2022/bs/bs.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
<ObjectFileName>$(IntDir)console_executor.obj</ObjectFileName>
133133
</ClCompile>
134134
<ClCompile Include="..\..\..\..\console\executor_commands.cpp" />
135+
<ClCompile Include="..\..\..\..\console\executor_daemon.cpp" />
135136
<ClCompile Include="..\..\..\..\console\executor_dumps.cpp" />
136137
<ClCompile Include="..\..\..\..\console\executor_events.cpp" />
137138
<ClCompile Include="..\..\..\..\console\executor_logging.cpp" />

builds/msvc/vs2022/bs/bs.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
<ClCompile Include="..\..\..\..\console\executor_commands.cpp">
5555
<Filter>src</Filter>
5656
</ClCompile>
57+
<ClCompile Include="..\..\..\..\console\executor_daemon.cpp">
58+
<Filter>src</Filter>
59+
</ClCompile>
5760
<ClCompile Include="..\..\..\..\console\executor_dumps.cpp">
5861
<Filter>src</Filter>
5962
</ClCompile>

console/executor_daemon.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS)
3+
*
4+
* This file is part of libbitcoin.
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+
#include "executor.hpp"
20+
21+
namespace libbitcoin {
22+
namespace server {
23+
24+
} // namespace server
25+
} // namespace libbitcoin

console/executor_signals.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void executor::set_signal_handlers()
6262
#if defined(HAVE_MSC)
6363
::SetConsoleCtrlHandler(&executor::control_handler, TRUE);
6464
#else
65-
// struct keywork avoids name conflict with posix function sigaction.
65+
// struct keyword avoids name conflict with posix function sigaction.
6666
struct sigaction action{};
6767

6868
// Restart interrupted system calls.

console/main.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,8 @@ BC_USE_LIBBITCOIN_MAIN
7878
/// All console input and output streams for the application originate here.
7979
int bc::system::main(int argc, char* argv[])
8080
{
81-
using namespace bc;
8281
using namespace bc::system;
8382
using namespace bc::network;
84-
using namespace bc::node;
8583
using namespace bc::server;
8684

8785
// en.cppreference.com/w/cpp/io/ios_base/sync_with_stdio

include/bitcoin/server/interfaces/bitcoind_rpc.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ struct bitcoind_rpc_methods
126126
////method<"listreceivedbyaddress", optional<1>, optional<false>, optional<false>, optional<""_t>>{ "minconf", "include_empty", "include_watchonly", "address_filter" },
127127
////method<"listreceivedbylabel", optional<1>, optional<false>, optional<false>>{ "minconf", "include_empty", "include_watchonly" },
128128
////method<"listtransactions", optional<""_t>, optional<10>, optional<0>, optional<false>>{ "label", "count", "skip", "include_watchonly" },
129-
////method<"listunspent", optional<1>, optional<empty::array>, optional<true>, optional<false>>{ "minconf", "addresses", "include_unsafe", "query_options" },
129+
////method<"list_unspent", optional<1>, optional<empty::array>, optional<true>, optional<false>>{ "minconf", "addresses", "include_unsafe", "query_options" },
130130
////method<"loadwallet", string_t, optional<false>>{ "filename", "load_on_startup" },
131131
////method<"lockunspent", boolean_t, optional<empty::array>>{ "unlock", "transactions" },
132132
////method<"removeprunedfunds", string_t>{ "txid" },

include/bitcoin/server/interfaces/electrum.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ struct electrum_methods
3535
method<"blockchain.block.header", number_t, number_t>{ "height", "cp_height" },
3636
method<"blockchain.block.headers", number_t, number_t, number_t>{ "start_height", "count", "cp_height" },
3737
method<"blockchain.headers.subscribe">{},
38-
method<"blockchain.estimatefee", number_t>{ "number" },
38+
method<"blockchain.estimatefee", number_t, optional<""_t>>{ "number", "mode" },
3939
method<"blockchain.relayfee">{},
4040
method<"blockchain.scripthash.get_balance", string_t>{ "scripthash" },
4141
method<"blockchain.scripthash.get_history", string_t>{ "scripthash" },
4242
method<"blockchain.scripthash.get_mempool", string_t>{ "scripthash" },
43-
method<"blockchain.scripthash.listunspent", string_t>{ "scripthash" },
43+
method<"blockchain.scripthash.list_unspent", string_t>{ "scripthash" },
4444
method<"blockchain.scripthash.subscribe", string_t>{ "scripthash" },
4545
method<"blockchain.scripthash.unsubscribe", string_t>{ "scripthash" },
4646
method<"blockchain.transaction.broadcast", string_t>{ "raw_tx" },
@@ -71,12 +71,12 @@ struct electrum_methods
7171
using blockchain_block_header = at<0>;
7272
using blockchain_block_headers = at<1>;
7373
using blockchain_headers_subscribe = at<2>;
74-
using blockchain_estimatefee = at<3>;
75-
using blockchain_relayfee = at<4>;
74+
using blockchain_estimate_fee = at<3>;
75+
using blockchain_relay_fee = at<4>;
7676
using blockchain_scripthash_get_balance = at<5>;
7777
using blockchain_scripthash_get_history = at<6>;
7878
using blockchain_scripthash_get_mempool = at<7>;
79-
using blockchain_scripthash_listunspent = at<8>;
79+
using blockchain_scripthash_list_unspent = at<8>;
8080
using blockchain_scripthash_subscribe = at<9>;
8181
using blockchain_scripthash_unsubscribe = at<10>;
8282
using blockchain_transaction_broadcast = at<11>;

include/bitcoin/server/protocols/protocol_electrum.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,11 @@ class BCS_API protocol_electrum
5959
double count, double cp_height) NOEXCEPT;
6060
void handle_blockchain_headers_subscribe(const code& ec,
6161
rpc_interface::blockchain_headers_subscribe) NOEXCEPT;
62-
void handle_blockchain_estimatefee(const code& ec,
63-
rpc_interface::blockchain_estimatefee, double) NOEXCEPT;
64-
void handle_blockchain_relayfee(const code& ec,
65-
rpc_interface::blockchain_relayfee) NOEXCEPT;
62+
void handle_blockchain_estimate_fee(const code& ec,
63+
rpc_interface::blockchain_estimate_fee, double number,
64+
const std::string& mode) NOEXCEPT;
65+
void handle_blockchain_relay_fee(const code& ec,
66+
rpc_interface::blockchain_relay_fee) NOEXCEPT;
6667
void handle_blockchain_scripthash_get_balance(const code& ec,
6768
rpc_interface::blockchain_scripthash_get_balance,
6869
const std::string& scripthash) NOEXCEPT;
@@ -72,8 +73,8 @@ class BCS_API protocol_electrum
7273
void handle_blockchain_scripthash_get_mempool(const code& ec,
7374
rpc_interface::blockchain_scripthash_get_mempool,
7475
const std::string& scripthash) NOEXCEPT;
75-
void handle_blockchain_scripthash_listunspent(const code& ec,
76-
rpc_interface::blockchain_scripthash_listunspent,
76+
void handle_blockchain_scripthash_list_unspent(const code& ec,
77+
rpc_interface::blockchain_scripthash_list_unspent,
7778
const std::string& scripthash) NOEXCEPT;
7879
void handle_blockchain_scripthash_subscribe(const code& ec,
7980
rpc_interface::blockchain_scripthash_subscribe,

0 commit comments

Comments
 (0)