• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

libbitcoin / libbitcoin-server / 45130211835

23 Nov 2026 07:19AM UTC coverage: 91.147% (-2.3%) from 93.468%
45130211835

push

github

web-flow
Merge pull request #1219 from evoskuil/master

Add embedded page and network smoke CI.

250 of 694 new or added lines in 15 files covered. (36.02%)

2 existing lines in 2 files now uncovered.

13652 of 14978 relevant lines covered (91.15%)

446.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.35
/src/server_node.cpp
1
/**
2
 * Copyright (c) 2011-2026 libbitcoin developers
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 <bitcoin/server/server_node.hpp>
20

21
#include <bitcoin/server/define.hpp>
22
#include <bitcoin/server/sessions/sessions.hpp>
23

24
namespace libbitcoin {
25
namespace server {
26

27
using namespace system;
28
using namespace database;
29
using namespace network;
30
using namespace node;
31
using namespace std::placeholders;
32

33
BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)
34

35
// net::strand() is safe to call from constructor (non-virtual).
36
server_node::server_node(query& query, const configuration& configuration,
1,806 ✔
37
    const logger& log) NOEXCEPT
1,806 ✔
38
  : full_node(query, configuration, log),
39
    config_(configuration)
1,806 ✔
40
{
41
}
1,806 ✔
42

43
server_node::~server_node() NOEXCEPT
1,806 ✔
44
{
45
}
1,806 ✔
46

47
// Properties.
48
// ----------------------------------------------------------------------------
49

50
const configuration& server_node::server_config() const NOEXCEPT
1 ✔
51
{
52
    return config_;
1 ✔
53
}
54

55
const settings& server_node::server_settings() const NOEXCEPT
1 ✔
56
{
57
    return config_.server;
1 ✔
58
}
59

60
// Sequences.
61
// ----------------------------------------------------------------------------
62

63
void server_node::run(result_handler&& handler) NOEXCEPT
1,804 ✔
64
{
65
    // Base (net) invokes do_run().
66
    full_node::run(std::move(handler));
1,804 ✔
67
}
1,804 ✔
68

69
void server_node::do_run(const result_handler& handler) NOEXCEPT
1,804 ✔
70
{
71
    BC_ASSERT(stranded());
1,804 ✔
72

73
    // Start services after node is running.
74
    full_node::do_run(std::bind(&server_node::start_admin, this, _1, handler));
1,804 ✔
75
}
1,804 ✔
76

77
void server_node::start_admin(const code& ec,
1,804 ✔
78
    const result_handler& handler) NOEXCEPT
79
{
80
    BC_ASSERT(stranded());
1,804 ✔
81

82
    if (ec)
1,804 ✔
83
    {
84
        handler(ec);
1 ✔
85
        return;
1 ✔
86
    }
87

88
    attach_admin_session()->start(
5,409 ✔
89
        std::bind(&server_node::start_native, this, _1, handler));
3,606 ✔
90
}
91

92
void server_node::start_native(const code& ec,
1,803 ✔
93
    const result_handler& handler) NOEXCEPT
94
{
95
    BC_ASSERT(stranded());
1,803 ✔
96

97
    if (ec)
1,803 ✔
98
    {
99
        handler(ec);
1 ✔
100
        return;
1 ✔
101
    }
102

103
    attach_native_session()->start(
5,406 ✔
104
        std::bind(&server_node::start_bitcoind, this, _1, handler));
3,604 ✔
105
}
106

107
void server_node::start_bitcoind(const code& ec,
1,802 ✔
108
    const result_handler& handler) NOEXCEPT
109
{
110
    BC_ASSERT(stranded());
1,802 ✔
111

112
    if (ec)
1,802 ✔
113
    {
114
        handler(ec);
1 ✔
115
        return;
1 ✔
116
    }
117

118
    attach_bitcoind_session()->start(
5,403 ✔
119
        std::bind(&server_node::start_btcd, this, _1, handler));
3,602 ✔
120
}
121

122
void server_node::start_btcd(const code& ec,
1,801 ✔
123
    const result_handler& handler) NOEXCEPT
124
{
125
    BC_ASSERT(stranded());
1,801 ✔
126

127
    if (ec)
1,801 ✔
128
    {
129
        handler(ec);
1 ✔
130
        return;
1 ✔
131
    }
132

133
    attach_btcd_session()->start(
5,400 ✔
134
        std::bind(&server_node::start_electrum, this, _1, handler));
3,600 ✔
135
}
136

137
void server_node::start_electrum(const code& ec,
1,800 ✔
138
    const result_handler& handler) NOEXCEPT
139
{
140
    BC_ASSERT(stranded());
1,800 ✔
141

142
    if (ec)
1,800 ✔
143
    {
144
        handler(ec);
1 ✔
145
        return;
1 ✔
146
    }
147

148
    attach_electrum_session()->start(
5,397 ✔
149
        std::bind(&server_node::start_sparrow, this, _1, handler));
3,598 ✔
150
}
151

152
void server_node::start_sparrow(const code& ec,
1,799 ✔
153
    const result_handler& handler) NOEXCEPT
154
{
155
    BC_ASSERT(stranded());
1,799 ✔
156

157
    if (ec)
1,799 ✔
158
    {
159
        handler(ec);
1 ✔
160
        return;
1 ✔
161
    }
162

163
    attach_sparrow_session()->start(
5,394 ✔
164
        std::bind(&server_node::start_esplora, this, _1, handler));
3,596 ✔
165
}
166

167
void server_node::start_esplora(const code& ec,
1,798 ✔
168
    const result_handler& handler) NOEXCEPT
169
{
170
    BC_ASSERT(stranded());
1,798 ✔
171

172
    if (ec)
1,798 ✔
173
    {
174
        handler(ec);
1 ✔
175
        return;
1 ✔
176
    }
177

178
    attach_esplora_session()->start(
5,391 ✔
179
        std::bind(&server_node::start_stratum_v1, this, _1, handler));
3,594 ✔
180
}
181

182
void server_node::start_stratum_v1(const code& ec,
1,797 ✔
183
    const result_handler& handler) NOEXCEPT
184
{
185
    BC_ASSERT(stranded());
1,797 ✔
186

187
    if (ec)
1,797 ✔
188
    {
189
        handler(ec);
1 ✔
190
        return;
1 ✔
191
    }
192

193
    const auto& stratum = config_.server.stratum_v1;
1,796 ✔
194
    const auto& wallet = config_.server.wallet;
195
    system::chain::script payout{};
1,796 ✔
196
    if (stratum.enabled() && !stratum.payout_address.empty() &&
1,796 ✔
NEW
197
        output_script(payout, stratum.payout_address, wallet.p2kh_prefix,
×
NEW
198
            wallet.p2sh_prefix, wallet.witness_prefix))
×
199
    {
NEW
200
        handler(network::error::invalid_configuration);
×
201
        return;
202
    }
203

204
    attach_stratum_v1_session()->start(
3,592 ✔
205
        std::bind(&server_node::start_stratum_v2, this, _1, handler));
3,592 ✔
206
}
1,796 ✔
207

208
void server_node::start_stratum_v2(const code& ec,
1,796 ✔
209
    const result_handler& handler) NOEXCEPT
210
{
211
    BC_ASSERT(stranded());
1,796 ✔
212

213
    if (ec)
1,796 ✔
214
    {
215
        handler(ec);
1 ✔
216
        return;
1 ✔
217
    }
218

219
    attach_stratum_v2_session()->start(
5,385 ✔
220
        std::bind(&server_node::start_zmq, this, _1, handler));
3,590 ✔
221
}
222

223
void server_node::start_zmq(const code& ec,
1,795 ✔
224
    const result_handler& handler) NOEXCEPT
225
{
226
    BC_ASSERT(stranded());
1,795 ✔
227

228
    if (ec)
1,795 ✔
229
    {
230
        handler(ec);
1 ✔
231
        return;
1 ✔
232
    }
233

234
    attach_zmq_session()->start(move_copy(handler));
1,794 ✔
235
}
236

237
// Session attachments.
238
// ----------------------------------------------------------------------------
239

240
session_admin::ptr server_node::attach_admin_session() NOEXCEPT
1,803 ✔
241
{
242
    return net::attach<session_admin>(*this, config_,
243
        config_.server.admin);
1,803 ✔
244
}
245

246
session_native::ptr server_node::attach_native_session() NOEXCEPT
1,802 ✔
247
{
248
    return net::attach<session_native>(*this, config_,
249
        config_.server.native);
1,802 ✔
250
}
251

252
session_bitcoind::ptr server_node::attach_bitcoind_session() NOEXCEPT
1,801 ✔
253
{
254
    return net::attach<session_bitcoind>(*this, config_,
255
        config_.server.bitcoind);
1,801 ✔
256
}
257

258
session_btcd::ptr server_node::attach_btcd_session() NOEXCEPT
1,800 ✔
259
{
260
    return net::attach<session_btcd>(*this, config_,
261
        config_.server.btcd);
1,800 ✔
262
}
263

264
session_electrum::ptr server_node::attach_electrum_session() NOEXCEPT
1,799 ✔
265
{
266
    return net::attach<session_electrum>(*this, config_,
267
        config_.server.electrum);
1,799 ✔
268
}
269

270
session_sparrow::ptr server_node::attach_sparrow_session() NOEXCEPT
1,798 ✔
271
{
272
    return net::attach<session_sparrow>(*this, config_,
273
        config_.server.sparrow);
1,798 ✔
274
}
275

276
session_esplora::ptr server_node::attach_esplora_session() NOEXCEPT
1,797 ✔
277
{
278
    return net::attach<session_esplora>(*this, config_,
279
        config_.server.esplora);
1,797 ✔
280
}
281

282
session_stratum_v1::ptr server_node::attach_stratum_v1_session() NOEXCEPT
1,796 ✔
283
{
284
    return net::attach<session_stratum_v1>(*this, config_,
285
        config_.server.stratum_v1);
1,796 ✔
286
}
287

288
session_stratum_v2::ptr server_node::attach_stratum_v2_session() NOEXCEPT
1,795 ✔
289
{
290
    return net::attach<session_stratum_v2>(*this, config_,
291
        config_.server.stratum_v2);
1,795 ✔
292
}
293

294
session_zmq::ptr
295
server_node::attach_zmq_session() NOEXCEPT
1,794 ✔
296
{
297
    return net::attach<session_zmq>(*this, config_,
298
        config_.server.zmq);
1,794 ✔
299
}
300

301
BC_POP_WARNING()
302

303
} // namespace server
304
} // namespace libbitcoin
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc