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

libbitcoin / libbitcoin-server / 44136105574

17 Nov 2026 05:21PM UTC coverage: 95.201%. Remained the same
44136105574

push

github

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

Read node witness in the ws configuration test.

12478 of 13107 relevant lines covered (95.2%)

435.64 hits per line

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

98.89
/src/protocols/native/protocol_native_configuration.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/protocols/protocol_native.hpp>
20

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

24
namespace libbitcoin {
25
namespace server {
26

27
using namespace std::placeholders;
28

29
#define CLASS protocol_native
30

31
BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)
32

33
bool protocol_native::handle_get_configuration(const code& ec,
252 ✔
34
    interface::configuration, uint8_t, uint8_t media) NOEXCEPT
35
{
36
    if (stopped(ec))
252 ✔
37
        return false;
38

39
    if (media != json)
8 ✔
40
    {
41
        send_not_acceptable();
2 ✔
42
        return true;
2 ✔
43
    }
44

45
    using namespace system;
46
    using selection = config::selection;
47
    const auto chain = selection::to_word(system_settings().genesis_network);
6 ✔
48
    const auto& query = archive();
6 ✔
49
    const auto& node = node_settings();
6 ✔
50
    const auto& peer = network_settings();
6 ✔
51
    const auto& fork = system_settings().forks;
6 ✔
52
    const auto& wallet = server_settings().wallet;
6 ✔
53
    const auto silent = query.silent_enabled() ?
6 ✔
54
        json::value(query.silent_start_height()) : json::value(nullptr);
6 ✔
55

56
    send_json(json::object
30 ✔
57
    {
58
        { "store", json::object
12 ✔
59
            {
60
                { "address", query.address_enabled() },
6 ✔
61
                { "filter", query.filter_enabled() },
6 ✔
62
                { "silent", silent },
63
                { "turbo", database_settings().turbo },
6 ✔
64
                { "pruned", get_pruned_height() }
6 ✔
65
            }
66
        },
67
        { "node", json::object
12 ✔
68
            {
69
                { "network", std::string{ chain } },
6 ✔
70
                { "limited", node.limited_blocks },
6 ✔
71
                { "blocks", node.provide_blocks },
6 ✔
72
                { "witness", node.provide_witness },
6 ✔
73
                { "filters", node.provide_filters },
6 ✔
74
                { "privacy", node.provide_privacy }
6 ✔
75
            }
12 ✔
76
        },
77
        { "wallet", json::object
6 ✔
78
            {
79
                { "p2kh", uint8_t{ wallet.p2kh_prefix } },
6 ✔
80
                { "p2sh", uint8_t{ wallet.p2sh_prefix } },
6 ✔
81
                { "wif", uint8_t{ wallet.wif_prefix } },
12 ✔
82
                { "witness", wallet.witness_prefix },
6 ✔
83
                { "silent", wallet.silent_prefix },
6 ✔
84
                { "hd_private", wallet.hd_private_prefix },
6 ✔
85
                { "hd_public", wallet.hd_public_prefix }
6 ✔
86
            }
87
        },
88
        { "network", json::object
12 ✔
89
            {
90
                { "relay", peer.enable_relay },
6 ✔
91
                { "alert", peer.enable_alert },
6 ✔
92
                { "reject", peer.enable_reject },
6 ✔
93
                { "compact", peer.enable_compact },
6 ✔
94
                { "address", peer.enable_address },
6 ✔
95
                { "witness_tx", peer.enable_witness_tx },
6 ✔
96
                { "memory_pool", peer.enable_memory_pool },
6 ✔
97
                { "not_found", peer.enable_not_found },
6 ✔
98
                { "protocol_maximum", peer.protocol_maximum },
6 ✔
99
                { "protocol_minimum", peer.protocol_minimum }
6 ✔
100
            }
101
        },
102
        { "forks", json::object
12 ✔
103
            {
104
                { "bip16", fork.bip16 },
6 ✔
105
                { "bip90", fork.bip90 },
6 ✔
106
                { "bip30", fork.bip30 },
6 ✔
107
                { "bip42", fork.bip42 },
6 ✔
108
                { "bip34", fork.bip34 },
6 ✔
109
                { "bip65", fork.bip65 },
6 ✔
110
                { "bip66", fork.bip66 },
6 ✔
111
                { "bip68", fork.bip68 },
6 ✔
112
                { "bip112", fork.bip112 },
6 ✔
113
                { "bip113", fork.bip113 },
6 ✔
114
                { "bip141", fork.bip141 },
6 ✔
115
                { "bip143", fork.bip143 },
6 ✔
116
                { "bip147", fork.bip147 },
6 ✔
117
                { "bip341", fork.bip341 },
6 ✔
118
                { "bip342", fork.bip342 },
6 ✔
119
                { "bip54_timewarp", fork.bip54_timewarp },
6 ✔
120
                { "bip54_timespan", fork.bip54_timespan },
6 ✔
121
                { "bip54_sigops", fork.bip54_sigops },
6 ✔
122
                { "bip54_txsize", fork.bip54_txsize },
6 ✔
123
                { "bip54_coinbase", fork.bip54_coinbase },
6 ✔
124
                { "retarget", fork.retarget },
6 ✔
125
                { "difficult", fork.difficult },
6 ✔
126
                { "time_warp_patch", fork.time_warp_patch },
6 ✔
127
                { "block_storm_patch", fork.block_storm_patch },
6 ✔
128
                { "signet", fork.signet },
6 ✔
129
                { "ltc_time_warp_patch", fork.ltc_time_warp_patch },
6 ✔
130
                { "ltc_retarget_overflow_patch", fork.ltc_retarget_overflow_patch },
6 ✔
131
                { "ltc_scrypt_proof_of_work", fork.ltc_scrypt_proof_of_work }
6 ✔
132
            }
133
        }
134
    });
135
    return true;
136
}
6 ✔
137

138
// utility
139
// ----------------------------------------------------------------------------
140

141
size_t protocol_native::get_pruned_height() NOEXCEPT
6 ✔
142
{
143
    if (!node_settings().limited_blocks)
6 ✔
144
        return {};
145

146
    const auto& system_ = system_settings();
1 ✔
147
    const auto milestone = get_active_height(system_.milestone.hash());
1 ✔
148
    const auto checkpoint = get_active_height(system_.top_checkpoint().hash());
1 ✔
149
    return std::max(milestone, checkpoint);
1 ✔
150
}
151

152
size_t protocol_native::get_active_height(
2 ✔
153
    const system::hash_digest& hash) NOEXCEPT
154
{
155
    const auto& query = archive();
2 ✔
156
    const auto link = query.to_header(hash);
2 ✔
157
    system::chain::context ctx{};
2 ✔
158

159
    // This uses candidate header vs. confirmed block so that stripping will
160
    // show at heights below top checkpoint and milestone while still syncing.
161
    // This can result in a weak branch milestone block implying a pruned
162
    // height that doesn't confirm (ok), which can't happen for checkpoints.
163
    // This can be mitigated by setting stripped on the object when it's a
164
    // milestone or checked object and pruning is enabled. Pruning can be
165
    // enabled after storage of non-stripped blocks, which does not strip them.
166
    // This will return false is bip141 is not active by the milestone.
167
    return query.get_context(ctx, link) && 
2 ✔
168
        ctx.is_enabled(system::chain::bip141_rule) && 
×
169
        query.is_candidate_header(link) ? ctx.height : zero;
4 ✔
170
}
2 ✔
171

172
BC_POP_WARNING()
173

174
} // namespace server
175
} // 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