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

libbitcoin / libbitcoin-system / 23096907349

14 Mar 2026 09:39PM UTC coverage: 81.295% (-0.02%) from 81.31%
23096907349

Pull #1794

github

web-flow
Merge d42b2b41f into 7440479d4
Pull Request #1794: Refactor json serializers into their own files.

120 of 165 new or added lines in 11 files covered. (72.73%)

2 existing lines in 1 file now uncovered.

11000 of 13531 relevant lines covered (81.29%)

3502537.52 hits per line

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

76.19
/src/chain/json/header.cpp
1
/**
2
 * Copyright (c) 2011-2026 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 <bitcoin/system/chain/json/json.hpp>
20

21
#include <bitcoin/system/chain/header.hpp>
22
#include <bitcoin/system/define.hpp>
23
#include <bitcoin/system/hash/hash.hpp>
24

25
namespace libbitcoin {
26
namespace system {
27
namespace chain {
28

29
DEFINE_JSON_TO_TAG(header)
2✔
30
{
31
    return
2✔
32
    {
33
        value.at("version").to_number<uint32_t>(),
2✔
34
        decode_hash<hash_size>(value.at("previous").as_string()),
2✔
35
        decode_hash<hash_size>(value.at("merkle_root").as_string()),
2✔
36
        value.at("timestamp").to_number<uint32_t>(),
2✔
37
        value.at("bits").to_number<uint32_t>(),
2✔
38
        value.at("nonce").to_number<uint32_t>()
2✔
39
    };
8✔
40
}
41

42
DEFINE_JSON_FROM_TAG(header)
4✔
43
{
44
    value =
20✔
45
    {
46
        // hash is computed property
47
        { "hash", encode_hash(instance.hash()) },
4✔
48
        { "version", instance.version() },
49
        { "previous", encode_hash(instance.previous_block_hash()) },
8✔
50
        { "merkle_root", encode_hash(instance.merkle_root()) },
8✔
51
        { "timestamp", instance.timestamp() },
52
        { "bits", instance.bits() },
53
        { "nonce", instance.nonce() }
54
    };
4✔
55
}
4✔
56

NEW
57
DEFINE_JSON_TO_TAG(header::cptr)
×
58
{
NEW
59
    return to_shared(tag_invoke(to_tag<header>{}, value));
×
60
}
61

NEW
62
DEFINE_JSON_FROM_TAG(header::cptr)
×
63
{
NEW
64
    tag_invoke(from_tag{}, value, *instance);
×
NEW
65
}
×
66

67
} // namespace chain
68
} // namespace system
69
} // namespace libbitcoin
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc