diff --git a/include/bitcoin/bitcoin/utility/property_tree.hpp b/include/bitcoin/bitcoin/utility/property_tree.hpp index dc9c81d26a..df5abc5a30 100644 --- a/include/bitcoin/bitcoin/utility/property_tree.hpp +++ b/include/bitcoin/bitcoin/utility/property_tree.hpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -42,6 +43,22 @@ class wrapper; */ typedef std::map 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. @@ -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& headers, diff --git a/src/utility/property_tree.cpp b/src/utility/property_tree.cpp index c4983ba92b..cdf12f64a5 100644 --- a/src/utility/property_tree.cpp +++ b/src/utility/property_tree.cpp @@ -86,6 +86,23 @@ ptree property_tree(const std::vector& 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)