diff --git a/builds/msvc-140/bitcoin/bitcoin.vcxproj b/builds/msvc-140/bitcoin/bitcoin.vcxproj
index ade9b8d18..30ad9c4d2 100644
--- a/builds/msvc-140/bitcoin/bitcoin.vcxproj
+++ b/builds/msvc-140/bitcoin/bitcoin.vcxproj
@@ -32,6 +32,7 @@
+
@@ -166,6 +167,7 @@
+
@@ -357,6 +359,7 @@
+
diff --git a/builds/msvc-140/bitcoin/bitcoin.vcxproj.filters b/builds/msvc-140/bitcoin/bitcoin.vcxproj.filters
index d790a3178..97c6102f4 100644
--- a/builds/msvc-140/bitcoin/bitcoin.vcxproj.filters
+++ b/builds/msvc-140/bitcoin/bitcoin.vcxproj.filters
@@ -578,6 +578,9 @@
Source Files\chain\attachment\asset
+
+ Source Files\chain
+
@@ -1147,6 +1150,9 @@
Header Files\chain\attachment\asset
+
+ Header Files
+
@@ -1203,5 +1209,8 @@
Header Files\impl\utility
+
+ Header Files\impl
+
\ No newline at end of file
diff --git a/include/metaverse/bitcoin/base_primary.hpp b/include/metaverse/bitcoin/base_primary.hpp
new file mode 100644
index 000000000..91435de71
--- /dev/null
+++ b/include/metaverse/bitcoin/base_primary.hpp
@@ -0,0 +1,82 @@
+/**
+ * Copyright (c) 2011-2015 metaverse developers (see AUTHORS)
+ *
+ * This file is part of mvs-node.
+ *
+ * metaverse is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License with
+ * additional permissions to the one published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option)
+ * any later version. For more information see LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+#ifndef MVS_BASE_PRIMARY_HPP
+#define MVS_BASE_PRIMARY_HPP
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace libbitcoin {
+
+template
+class base_primary
+{
+public:
+ T& Instance();
+ const T& Instance() const;
+ //
+ template
+ static T factory_from_data(const data_chunk &data, Args... args);
+
+ template
+ static T factory_from_data(std::istream& stream, Args... args);
+
+ template
+ static T factory_from_data(reader& source, Args... args);
+
+ template
+ bool from_data(const data_chunk& data, Args... args);
+
+ template
+ bool from_data(std::istream& stream, Args... args);
+
+ template
+ bool from_data(reader& source, Args... args);
+
+ data_chunk to_data() const;
+
+ template::type,
+ typename std::enable_if< (!std::is_base_of::value
+ && !std::is_base_of::value )>::type* = nullptr, typename... Args>
+ data_chunk to_data(T1_&& t , Args... args) const;
+
+ template
+ void to_data(std::ostream& stream, Args... args) const;
+
+ template
+ void to_data(writer& sink, Args... args) const;
+
+private:
+ base_primary(){}
+ friend T;
+};
+
+
+
+} // namespace libbitcoin
+
+#include
+
+#endif
+
diff --git a/include/metaverse/bitcoin/chain/attachment/account/account.hpp b/include/metaverse/bitcoin/chain/attachment/account/account.hpp
index 2f238499f..b68538c04 100644
--- a/include/metaverse/bitcoin/chain/attachment/account/account.hpp
+++ b/include/metaverse/bitcoin/chain/attachment/account/account.hpp
@@ -29,6 +29,7 @@
#include
#include
#include
+#include
namespace libbitcoin {
namespace chain {
@@ -119,23 +120,17 @@ class BC_API account_multisig
};
class BC_API account
+ : public base_primary
{
public:
account();
account(const std::string& name, const std::string& mnemonic, const hash_digest& passwd,
uint32_t hd_index, uint8_t priority, uint8_t status, uint8_t type);
- static account factory_from_data(const data_chunk& data);
- static account factory_from_data(std::istream& stream);
- static account factory_from_data(reader& source);
static uint64_t satoshi_fixed_size();
- bool from_data(const data_chunk& data);
- bool from_data(std::istream& stream);
- bool from_data(reader& source);
- data_chunk to_data() const;
- void to_data(std::ostream& stream) const;
- void to_data(writer& sink) const;
+ bool from_data_t(reader& source);
+ void to_data_t(writer& sink) const;
bool is_valid() const;
void reset();
diff --git a/include/metaverse/bitcoin/chain/attachment/account/account_address.hpp b/include/metaverse/bitcoin/chain/attachment/account/account_address.hpp
index 3fae7c7c5..c9bf69775 100644
--- a/include/metaverse/bitcoin/chain/attachment/account/account_address.hpp
+++ b/include/metaverse/bitcoin/chain/attachment/account/account_address.hpp
@@ -28,6 +28,7 @@
#include
#include
#include
+#include
namespace libbitcoin {
namespace chain {
@@ -50,7 +51,8 @@ enum account_address_status : uint8_t
stealth_addr = 3 // stealth address
};
-class BC_API account_address
+class BC_API account_address
+ : public base_primary
{
public:
typedef std::vector list;
@@ -59,17 +61,10 @@ class BC_API account_address
const std::string& pub_key, uint32_t hd_index, uint64_t balance,
const std::string& alias, const std::string& address, uint8_t status);
account_address(const account_address& other);
- static account_address factory_from_data(const data_chunk& data);
- static account_address factory_from_data(std::istream& stream);
- static account_address factory_from_data(reader& source);
static uint64_t satoshi_fixed_size();
- bool from_data(const data_chunk& data);
- bool from_data(std::istream& stream);
- bool from_data(reader& source);
- data_chunk to_data() const;
- void to_data(std::ostream& stream) const;
- void to_data(writer& sink) const;
+ bool from_data_t(reader& source);
+ void to_data_t(writer& sink) const;
#ifdef MVS_DEBUG
std::string to_string() ;
#endif
diff --git a/include/metaverse/bitcoin/chain/attachment/asset/asset.hpp b/include/metaverse/bitcoin/chain/attachment/asset/asset.hpp
index 8033bedb7..b7873fbf0 100644
--- a/include/metaverse/bitcoin/chain/attachment/asset/asset.hpp
+++ b/include/metaverse/bitcoin/chain/attachment/asset/asset.hpp
@@ -31,6 +31,7 @@
#include
#include
#include
+#include
using namespace libbitcoin::chain;
@@ -43,6 +44,7 @@ namespace libbitcoin {
namespace chain {
class BC_API asset
+ : public base_primary
{
public:
enum class asset_status : uint32_t
@@ -56,17 +58,10 @@ class BC_API asset
asset();
asset(uint32_t status, const asset_detail& detail);
asset(uint32_t status, const asset_transfer& detail);
- static asset factory_from_data(const data_chunk& data);
- static asset factory_from_data(std::istream& stream);
- static asset factory_from_data(reader& source);
static uint64_t satoshi_fixed_size();
- bool from_data(const data_chunk& data);
- bool from_data(std::istream& stream);
- bool from_data(reader& source);
- data_chunk to_data() const;
- void to_data(std::ostream& stream) const;
- void to_data(writer& sink) const;
+ bool from_data_t(reader& source);
+ void to_data_t(writer& sink) const;
std::string to_string() const;
bool is_valid_type() const;
bool is_valid() const;
diff --git a/include/metaverse/bitcoin/chain/attachment/asset/asset_cert.hpp b/include/metaverse/bitcoin/chain/attachment/asset/asset_cert.hpp
index 863cd3493..1b9d7784d 100644
--- a/include/metaverse/bitcoin/chain/attachment/asset/asset_cert.hpp
+++ b/include/metaverse/bitcoin/chain/attachment/asset/asset_cert.hpp
@@ -25,6 +25,7 @@
#include
#include
#include
+#include
#define ASSET_CERT_STATUS2UINT32(kd) (static_cast::type>(kd))
@@ -59,6 +60,7 @@ namespace asset_cert_ns {
}
class BC_API asset_cert
+ : public base_primary
{
public:
typedef std::vector list;
@@ -79,16 +81,8 @@ class BC_API asset_cert
bool is_valid() const;
bool operator< (const asset_cert& other) const;
- static asset_cert factory_from_data(const data_chunk& data);
- static asset_cert factory_from_data(std::istream& stream);
- static asset_cert factory_from_data(reader& source);
-
- bool from_data(const data_chunk& data);
- bool from_data(std::istream& stream);
- bool from_data(reader& source);
- data_chunk to_data() const;
- void to_data(std::ostream& stream) const;
- void to_data(writer& sink) const;
+ bool from_data_t(reader& source);
+ void to_data_t(writer& sink) const;
std::string to_string() const;
uint64_t serialized_size() const;
diff --git a/include/metaverse/bitcoin/chain/attachment/asset/asset_detail.hpp b/include/metaverse/bitcoin/chain/attachment/asset/asset_detail.hpp
index 531902482..95f331f82 100644
--- a/include/metaverse/bitcoin/chain/attachment/asset/asset_detail.hpp
+++ b/include/metaverse/bitcoin/chain/attachment/asset/asset_detail.hpp
@@ -28,6 +28,7 @@
#include
#include
#include
+#include
#include "asset_cert.hpp"
namespace libbitcoin {
@@ -48,6 +49,7 @@ BC_CONSTEXPR size_t ASSET_DETAIL_FIX_SIZE = ASSET_DETAIL_SYMBOL_FIX_SIZE
+ ASSET_DETAIL_DESCRIPTION_FIX_SIZE;
class BC_API asset_detail
+ : public base_primary
{
public:
typedef std::vector list;
@@ -61,16 +63,9 @@ class BC_API asset_detail
uint8_t decimal_number, uint8_t threshold, const std::string& issuer,
const std::string& address, const std::string& description);
- static asset_detail factory_from_data(const data_chunk& data);
- static asset_detail factory_from_data(std::istream& stream);
- static asset_detail factory_from_data(reader& source);
static uint64_t satoshi_fixed_size();
- bool from_data(const data_chunk& data);
- bool from_data(std::istream& stream);
- bool from_data(reader& source);
- data_chunk to_data() const;
- void to_data(std::ostream& stream) const;
- void to_data(writer& sink) const;
+ bool from_data_t(reader& source);
+ void to_data_t(writer& sink) const;
bool operator< (const asset_detail& other) const;
std::string to_string() const;
diff --git a/include/metaverse/bitcoin/chain/attachment/asset/asset_mit.hpp b/include/metaverse/bitcoin/chain/attachment/asset/asset_mit.hpp
index 527af30c6..b473ebe93 100644
--- a/include/metaverse/bitcoin/chain/attachment/asset/asset_mit.hpp
+++ b/include/metaverse/bitcoin/chain/attachment/asset/asset_mit.hpp
@@ -27,6 +27,7 @@
#include
#include
#include
+#include
#define MIT_STATUS2UINT32(kd) (static_cast::type>(kd))
@@ -54,6 +55,7 @@ BC_CONSTEXPR size_t ASSET_MIT_TRANSFER_FIX_SIZE = (
BC_CONSTEXPR size_t ASSET_MIT_INFO_FIX_SIZE = 4 + 4 + 64 + ASSET_MIT_TRANSFER_FIX_SIZE;
class BC_API asset_mit
+ : public base_primary
{
public:
typedef std::vector list;
@@ -74,17 +76,9 @@ class BC_API asset_mit
bool is_valid() const;
bool operator< (const asset_mit& other) const;
- static asset_mit factory_from_data(const data_chunk& data);
- static asset_mit factory_from_data(std::istream& stream);
- static asset_mit factory_from_data(reader& source);
-
- bool from_data(const data_chunk& data);
- bool from_data(std::istream& stream);
- bool from_data(reader& source);
+ bool from_data_t(reader& source);
+ void to_data_t(writer& sink) const;
data_chunk to_short_data() const;
- data_chunk to_data() const;
- void to_data(std::ostream& stream) const;
- void to_data(writer& sink) const;
std::string to_string() const;
uint64_t serialized_size() const;
diff --git a/include/metaverse/bitcoin/chain/attachment/asset/asset_transfer.hpp b/include/metaverse/bitcoin/chain/attachment/asset/asset_transfer.hpp
index c9efd8f0c..178a56582 100644
--- a/include/metaverse/bitcoin/chain/attachment/asset/asset_transfer.hpp
+++ b/include/metaverse/bitcoin/chain/attachment/asset/asset_transfer.hpp
@@ -29,7 +29,7 @@
#include
#include
#include
-#include
+#include
namespace libbitcoin {
namespace chain {
@@ -81,21 +81,15 @@ struct asset_deposited_balance {
};
class BC_API asset_transfer
+ : public base_primary
{
public:
asset_transfer();
asset_transfer(const std::string& symbol, uint64_t quantity);
- static asset_transfer factory_from_data(const data_chunk& data);
- static asset_transfer factory_from_data(std::istream& stream);
- static asset_transfer factory_from_data(reader& source);
static uint64_t satoshi_fixed_size();
- bool from_data(const data_chunk& data);
- bool from_data(std::istream& stream);
- bool from_data(reader& source);
- data_chunk to_data() const;
- void to_data(std::ostream& stream) const;
- void to_data(writer& sink) const;
+ bool from_data_t(reader& source);
+ void to_data_t(writer& sink) const;
std::string to_string() const;
diff --git a/include/metaverse/bitcoin/chain/attachment/asset/blockchain_asset.hpp b/include/metaverse/bitcoin/chain/attachment/asset/blockchain_asset.hpp
index c49f30bdf..6eaec05bf 100644
--- a/include/metaverse/bitcoin/chain/attachment/asset/blockchain_asset.hpp
+++ b/include/metaverse/bitcoin/chain/attachment/asset/blockchain_asset.hpp
@@ -23,33 +23,29 @@
#include
#include
#include
+#include
#include
#include
#include
#include
#include
+#include
namespace libbitcoin {
namespace chain {
class BC_API blockchain_asset
+ : public base_primary
{
public:
typedef std::vector list;
blockchain_asset();
blockchain_asset(uint32_t version, const output_point& tx_point,
uint64_t height, const asset_detail& asset);
- static blockchain_asset factory_from_data(const data_chunk& data);
- static blockchain_asset factory_from_data(std::istream& stream);
- static blockchain_asset factory_from_data(reader& source);
static uint64_t satoshi_fixed_size();
- bool from_data(const data_chunk& data);
- bool from_data(std::istream& stream);
- bool from_data(reader& source);
- data_chunk to_data() const;
- void to_data(std::ostream& stream) const;
- void to_data(writer& sink) const;
+ bool from_data_t(reader& source);
+ void to_data_t(writer& sink) const;
#ifdef MVS_DEBUG
std::string to_string() const;
diff --git a/include/metaverse/bitcoin/chain/attachment/attachment.hpp b/include/metaverse/bitcoin/chain/attachment/attachment.hpp
index 21f02ef39..d5dafb4b1 100644
--- a/include/metaverse/bitcoin/chain/attachment/attachment.hpp
+++ b/include/metaverse/bitcoin/chain/attachment/attachment.hpp
@@ -34,6 +34,7 @@
#include
#include
#include
+#include
using namespace libbitcoin::chain;
#define TYPE2UINT32(kd) (static_cast::type>(kd))
@@ -53,6 +54,7 @@ namespace libbitcoin {
namespace chain {
class BC_API attachment
+ : public base_primary
{
public:
@@ -86,17 +88,10 @@ class BC_API attachment
: type(type), version(version), attach(attach_data)
{}
- static attachment factory_from_data(const data_chunk& data);
- static attachment factory_from_data(std::istream& stream);
- static attachment factory_from_data(reader& source);
static uint64_t satoshi_fixed_size();
- bool from_data(const data_chunk& data);
- bool from_data(std::istream& stream);
- bool from_data(reader& source);
- data_chunk to_data() const;
- void to_data(std::ostream& stream) const;
- void to_data(writer& sink) const;
+ bool from_data_t(reader& source);
+ void to_data_t(writer& sink) const;
std::string to_string() const;
bool is_valid() const;
bool is_valid_type() const;
diff --git a/include/metaverse/bitcoin/chain/attachment/did/blockchain_did.hpp b/include/metaverse/bitcoin/chain/attachment/did/blockchain_did.hpp
index 8d487de01..c98f47ce8 100644
--- a/include/metaverse/bitcoin/chain/attachment/did/blockchain_did.hpp
+++ b/include/metaverse/bitcoin/chain/attachment/did/blockchain_did.hpp
@@ -23,16 +23,19 @@
#include
#include
#include
+#include
#include
#include
#include
#include
#include
+#include
namespace libbitcoin {
namespace chain {
class BC_API blockchain_did
+ : public base_primary
{
public:
enum did_address_type: uint32_t
@@ -45,17 +48,10 @@ class BC_API blockchain_did
blockchain_did();
blockchain_did( uint32_t version, const output_point& tx_point,
uint64_t height, uint32_t status, const did_detail& did);
- static blockchain_did factory_from_data(const data_chunk& data);
- static blockchain_did factory_from_data(std::istream& stream);
- static blockchain_did factory_from_data(reader& source);
static uint64_t satoshi_fixed_size();
- bool from_data(const data_chunk& data);
- bool from_data(std::istream& stream);
- bool from_data(reader& source);
- data_chunk to_data() const;
- void to_data(std::ostream& stream) const;
- void to_data(writer& sink) const;
+ bool from_data_t(reader& source);
+ void to_data_t(writer& sink) const;
#ifdef MVS_DEBUG
std::string to_string() const;
diff --git a/include/metaverse/bitcoin/chain/attachment/did/did.hpp b/include/metaverse/bitcoin/chain/attachment/did/did.hpp
index 5b22073cd..3a7811d8f 100644
--- a/include/metaverse/bitcoin/chain/attachment/did/did.hpp
+++ b/include/metaverse/bitcoin/chain/attachment/did/did.hpp
@@ -30,6 +30,7 @@
#include
#include
#include
+#include
using namespace libbitcoin::chain;
@@ -42,6 +43,7 @@ namespace libbitcoin {
namespace chain {
class BC_API did
+ : public base_primary
{
public:
enum class did_status : uint32_t
@@ -53,17 +55,10 @@ class BC_API did
did();
did(uint32_t status, const did_detail& detail);
- static did factory_from_data(const data_chunk& data);
- static did factory_from_data(std::istream& stream);
- static did factory_from_data(reader& source);
static uint64_t satoshi_fixed_size();
- bool from_data(const data_chunk& data);
- bool from_data(std::istream& stream);
- bool from_data(reader& source);
- data_chunk to_data() const;
- void to_data(std::ostream& stream) const;
- void to_data(writer& sink) const;
+ bool from_data_t(reader& source);
+ void to_data_t(writer& sink) const;
std::string to_string() const;
bool is_valid_type() const;
bool is_valid() const;
diff --git a/include/metaverse/bitcoin/chain/attachment/did/did_detail.hpp b/include/metaverse/bitcoin/chain/attachment/did/did_detail.hpp
index 8ec98f72d..0158b419d 100644
--- a/include/metaverse/bitcoin/chain/attachment/did/did_detail.hpp
+++ b/include/metaverse/bitcoin/chain/attachment/did/did_detail.hpp
@@ -28,6 +28,7 @@
#include
#include
#include
+#include
namespace libbitcoin {
namespace chain {
@@ -39,6 +40,7 @@ BC_CONSTEXPR size_t DID_DETAIL_FIX_SIZE = DID_DETAIL_SYMBOL_FIX_SIZE
+ DID_DETAIL_ADDRESS_FIX_SIZE;
class BC_API did_detail
+ : public base_primary
{
public:
typedef std::vector list;
@@ -53,17 +55,10 @@ class BC_API did_detail
did_detail();
did_detail(const std::string& symbol, const std::string& address);
- static did_detail factory_from_data(const data_chunk& data);
- static did_detail factory_from_data(std::istream& stream);
- static did_detail factory_from_data(reader& source);
static uint64_t satoshi_fixed_size();
static std::string get_blackhole_did_symbol();
- bool from_data(const data_chunk& data);
- bool from_data(std::istream& stream);
- bool from_data(reader& source);
- data_chunk to_data() const;
- void to_data(std::ostream& stream) const;
- void to_data(writer& sink) const;
+ bool from_data_t(reader& source);
+ void to_data_t(writer& sink) const;
bool operator< (const did_detail& other) const;
std::string to_string() const;
diff --git a/include/metaverse/bitcoin/chain/attachment/etp/etp.hpp b/include/metaverse/bitcoin/chain/attachment/etp/etp.hpp
index 7e46f0cb9..5d47fce57 100644
--- a/include/metaverse/bitcoin/chain/attachment/etp/etp.hpp
+++ b/include/metaverse/bitcoin/chain/attachment/etp/etp.hpp
@@ -27,6 +27,7 @@
#include
#include
#include
+#include
namespace libbitcoin {
namespace chain {
@@ -34,21 +35,15 @@ namespace chain {
BC_CONSTEXPR size_t ETP_FIX_SIZE = 8;
class BC_API etp
+ : public base_primary
{
public:
etp();
etp(uint64_t value);
- static etp factory_from_data(const data_chunk& data);
- static etp factory_from_data(std::istream& stream);
- static etp factory_from_data(reader& source);
static uint64_t satoshi_fixed_size();
- bool from_data(const data_chunk& data);
- bool from_data(std::istream& stream);
- bool from_data(reader& source);
- data_chunk to_data() const;
- void to_data(std::ostream& stream) const;
- void to_data(writer& sink) const;
+ bool from_data_t(reader& source);
+ void to_data_t(writer& sink) const;
std::string to_string() const;
bool is_valid() const;
void reset();
diff --git a/include/metaverse/bitcoin/chain/attachment/etp/etp_award.hpp b/include/metaverse/bitcoin/chain/attachment/etp/etp_award.hpp
index 758cfb8a4..14dc4e466 100644
--- a/include/metaverse/bitcoin/chain/attachment/etp/etp_award.hpp
+++ b/include/metaverse/bitcoin/chain/attachment/etp/etp_award.hpp
@@ -27,6 +27,7 @@
#include
#include
#include
+#include
namespace libbitcoin {
namespace chain {
@@ -34,21 +35,15 @@ namespace chain {
BC_CONSTEXPR size_t ETP_AWARD_FIX_SIZE = 8;
class BC_API etp_award
+ : public base_primary
{
public:
etp_award();
etp_award(uint64_t height);
- static etp_award factory_from_data(const data_chunk& data);
- static etp_award factory_from_data(std::istream& stream);
- static etp_award factory_from_data(reader& source);
static uint64_t satoshi_fixed_size();
- bool from_data(const data_chunk& data);
- bool from_data(std::istream& stream);
- bool from_data(reader& source);
- data_chunk to_data() const;
- void to_data(std::ostream& stream) const;
- void to_data(writer& sink) const;
+ bool from_data_t(reader& source);
+ void to_data_t(writer& sink) const;
std::string to_string() const;
bool is_valid() const;
void reset();
diff --git a/include/metaverse/bitcoin/chain/attachment/message/message.hpp b/include/metaverse/bitcoin/chain/attachment/message/message.hpp
index 1c7eee6c8..c3aae7469 100644
--- a/include/metaverse/bitcoin/chain/attachment/message/message.hpp
+++ b/include/metaverse/bitcoin/chain/attachment/message/message.hpp
@@ -27,29 +27,24 @@
#include
#include
#include
+#include
namespace libbitcoin {
namespace chain {
BC_CONSTEXPR size_t BLOCKCHAIN_MESSAGE_FIX_SIZE = 256;
class BC_API blockchain_message
+ : public base_primary
{
public:
//BC_CONSTEXPR static size_t blockchain_message_FIX_SIZE = 64;
blockchain_message();
blockchain_message(std::string content);
- static blockchain_message factory_from_data(const data_chunk& data);
- static blockchain_message factory_from_data(std::istream& stream);
- static blockchain_message factory_from_data(reader& source);
static uint64_t satoshi_fixed_size();
- bool from_data(const data_chunk& data);
- bool from_data(std::istream& stream);
- bool from_data(reader& source);
- data_chunk to_data() const;
- void to_data(std::ostream& stream) const;
- void to_data(writer& sink) const;
+ bool from_data_t(reader& source);
+ void to_data_t(writer& sink) const;
std::string to_string() const;
bool is_valid() const;
void reset();
diff --git a/include/metaverse/bitcoin/chain/block.hpp b/include/metaverse/bitcoin/chain/block.hpp
index 738784aa7..0950dd9dd 100644
--- a/include/metaverse/bitcoin/chain/block.hpp
+++ b/include/metaverse/bitcoin/chain/block.hpp
@@ -32,11 +32,13 @@
#include
#include
#include
+#include
namespace libbitcoin {
namespace chain {
class BC_API block
+ : public base_primary
{
public:
typedef std::vector list;
@@ -44,12 +46,6 @@ class BC_API block
typedef std::vector ptr_list;
typedef std::vector indexes;
- static block factory_from_data(const data_chunk& data,
- bool with_transaction_count = true);
- static block factory_from_data(std::istream& stream,
- bool with_transaction_count = true);
- static block factory_from_data(reader& source,
- bool with_transaction_count = true);
static hash_digest generate_merkle_root(
const transaction::list& transactions);
static block genesis_mainnet();
@@ -68,12 +64,8 @@ class BC_API block
block& operator=(block&& other);
void operator=(const block&) = delete;
- bool from_data(const data_chunk& data, bool with_transaction_count = true);
- bool from_data(std::istream& stream, bool with_transaction_count = true);
- bool from_data(reader& source, bool with_transaction_count = true);
- data_chunk to_data(bool with_transaction_count = true) const;
- void to_data(std::ostream& stream, bool with_transaction_count = true) const;
- void to_data(writer& sink, bool with_transaction_count = true) const;
+ bool from_data_t(reader& source, bool with_transaction_count = true);
+ void to_data_t(writer& sink, bool with_transaction_count = true) const;
bool is_valid() const;
void reset();
uint64_t serialized_size(bool with_transaction_count = true) const;
diff --git a/include/metaverse/bitcoin/chain/business_data.hpp b/include/metaverse/bitcoin/chain/business_data.hpp
index 4d6ad2292..6dd606668 100644
--- a/include/metaverse/bitcoin/chain/business_data.hpp
+++ b/include/metaverse/bitcoin/chain/business_data.hpp
@@ -26,6 +26,9 @@
#include
#include
#include
+#include
+#include
+#include
#include
#include
#include
@@ -34,6 +37,7 @@
#include
#include
#include
+#include
#define KIND2UINT16(kd) (static_cast::type>(kd))
// 0 -- unspent 1 -- confirmed 2 -- local asset not issued
@@ -68,6 +72,7 @@ enum business_status : uint8_t
};
class BC_API business_data
+ : public base_primary
{
public:
typedef boost::variant<
@@ -80,17 +85,10 @@ class BC_API business_data
blockchain_message,
did_detail> business_data_type;
- static business_data factory_from_data(const data_chunk& data);
- static business_data factory_from_data(std::istream& stream);
- static business_data factory_from_data(reader& source);
static uint64_t satoshi_fixed_size();
- bool from_data(const data_chunk& data);
- bool from_data(std::istream& stream);
- bool from_data(reader& source);
- data_chunk to_data() ;
- void to_data(std::ostream& stream) ;
- void to_data(writer& sink);
+ bool from_data_t(reader& source);
+ void to_data_t(writer& sink);
#if MVS_DEBUG
std::string to_string() ;
#endif
diff --git a/include/metaverse/bitcoin/chain/header.hpp b/include/metaverse/bitcoin/chain/header.hpp
index 70a6b6234..308287f08 100644
--- a/include/metaverse/bitcoin/chain/header.hpp
+++ b/include/metaverse/bitcoin/chain/header.hpp
@@ -39,6 +39,7 @@
#include
#include
#include
+#include
namespace libbitcoin {
using bigint = boost::multiprecision::number>;
@@ -49,20 +50,15 @@ namespace libbitcoin {
namespace chain {
class BC_API header
+ : public base_primary
{
public:
typedef std::vector list;
typedef std::shared_ptr ptr;
typedef std::vector ptr_list;
- static header factory_from_data(const data_chunk& data,
- bool with_transaction_count = true);
- static header factory_from_data(std::istream& stream,
- bool with_transaction_count = true);
- static header factory_from_data(reader& source,
- bool with_transaction_count = true);
static uint64_t satoshi_fixed_size_without_transaction_count();
-
+
header();
header(const header& other);
header(uint32_t version, const hash_digest& previous_block_hash,
@@ -80,12 +76,8 @@ class BC_API header
// TODO: eliminate blockchain transaction copies and then delete this.
header& operator=(const header& other) /*= delete*/;
- bool from_data(const data_chunk& data, bool with_transaction_count = true);
- bool from_data(std::istream& stream, bool with_transaction_count = true);
- bool from_data(reader& source, bool with_transaction_count = true);
- data_chunk to_data(bool with_transaction_count = true) const;
- void to_data(std::ostream& stream, bool with_transaction_count = true) const;
- void to_data(writer& sink, bool with_transaction_count = true) const;
+ bool from_data_t(reader& source, bool with_transaction_count = true);
+ void to_data_t(writer& sink, bool with_transaction_count = true) const;
hash_digest hash() const;
bool is_valid() const;
void reset();
diff --git a/include/metaverse/bitcoin/chain/history.hpp b/include/metaverse/bitcoin/chain/history.hpp
index 5dc8fed45..9118755a0 100644
--- a/include/metaverse/bitcoin/chain/history.hpp
+++ b/include/metaverse/bitcoin/chain/history.hpp
@@ -25,6 +25,7 @@
#include
#include
#include
+#include
namespace libbitcoin {
namespace chain {
diff --git a/include/metaverse/bitcoin/chain/input.hpp b/include/metaverse/bitcoin/chain/input.hpp
index b3f440406..bbcd44ac7 100644
--- a/include/metaverse/bitcoin/chain/input.hpp
+++ b/include/metaverse/bitcoin/chain/input.hpp
@@ -24,36 +24,46 @@
#include
#include
#include
+#include
#include
#include
#include
#include
#include
#include
+#include
namespace libbitcoin {
namespace chain {
class BC_API input
+ : public base_primary
{
public:
typedef std::vector list;
- static input factory_from_data(const data_chunk& data);
- static input factory_from_data(std::istream& stream);
- static input factory_from_data(reader& source);
+
+ input();
+ input(input&& other);
+ input(const input& other);
+
+ input(output_point&& previous_output, chain::script&& script, uint32_t sequence);
+ input(const output_point& previous_output, const chain::script& script, const uint32_t& sequence);
+
+ input& operator=(input&& other);
+ input& operator=(const input& other);
+
static uint64_t satoshi_fixed_size();
- bool from_data(const data_chunk& data);
- bool from_data(std::istream& stream);
- bool from_data(reader& source);
- data_chunk to_data() const;
- void to_data(std::ostream& stream) const;
- void to_data(writer& sink) const;
+ bool from_data_t(reader& source);
+ void to_data_t(writer& sink) const;
std::string to_string(uint32_t flags) const;
bool is_valid() const;
void reset();
+
bool is_final() const;
+ bool is_locked(size_t block_height, uint32_t median_time_past) const;
+
uint64_t serialized_size() const;
std::string get_script_address() const;
diff --git a/include/metaverse/bitcoin/chain/output.hpp b/include/metaverse/bitcoin/chain/output.hpp
index 410997977..b3c1f56c1 100644
--- a/include/metaverse/bitcoin/chain/output.hpp
+++ b/include/metaverse/bitcoin/chain/output.hpp
@@ -32,6 +32,7 @@
#include
#include // added for asset issue/transfer
#include
+#include
// forward declaration
namespace libbitcoin {
@@ -44,23 +45,25 @@ namespace libbitcoin {
namespace chain {
class BC_API output
+ : public base_primary