Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions include/bitcoin/bitcoin/utility/property_tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <vector>
#include <boost/property_tree/ptree.hpp>
#include <bitcoin/bitcoin/define.hpp>
#include <bitcoin/bitcoin/chain/block.hpp>
#include <bitcoin/bitcoin/chain/points_value.hpp>
#include <bitcoin/bitcoin/config/header.hpp>
#include <bitcoin/bitcoin/config/input.hpp>
Expand All @@ -42,6 +43,22 @@ class wrapper;
*/
typedef std::map<std::string, std::string> settings_list;

/**
* Generate a property list for a block.
* @param[in] block The block.
* @param[in] json Use json array formatting.
* @return A property list.
*/
BC_API pt::ptree property_list(const chain::block& block, bool json);

/**
* Generate a property tree for a block.
* @param[in] block The block.
* @param[in] json Use json array formatting.
* @return A property tree.
*/
BC_API pt::ptree property_tree(const chain::block& block, bool json);

/**
* Generate a property list for a block header.
* @param[in] header The header.
Expand All @@ -59,6 +76,7 @@ BC_API pt::ptree property_tree(const config::header& header);
/**
* Generate a property tree for a set of headers.
* @param[in] headers The set of headers.
* @param[in] json Use json array formatting.
* @return A property tree.
*/
BC_API pt::ptree property_tree(const std::vector<config::header>& headers,
Expand Down
17 changes: 17 additions & 0 deletions src/utility/property_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,23 @@ ptree property_tree(const std::vector<config::header>& headers, bool json)
return tree;
}

// block

ptree property_list(const chain::block& block, bool json)
{
ptree tree = property_list(block.header());
tree.add_child("transactions", property_tree_list_of_lists("transaction",
block.transactions(), json));
return tree;
}

ptree property_tree(const chain::block& block, bool json)
{
ptree tree;
tree.add_child("block", property_list(block, json));
return tree;
}

// inputs

ptree property_list(const chain::input& tx_input)
Expand Down