little bit of branding
This commit is contained in:
@@ -71,6 +71,7 @@ target_link_libraries(cryptonote_basic
|
||||
checkpoints
|
||||
cryptonote_format_utils_basic
|
||||
device
|
||||
oracle
|
||||
${Boost_DATE_TIME_LIBRARY}
|
||||
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
||||
${Boost_SERIALIZATION_LIBRARY}
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "serialization/debug_archive.h"
|
||||
#include "serialization/crypto.h"
|
||||
#include "serialization/keyvalue_serialization.h" // eepe named serialization
|
||||
#include "serialization/pricing_record.h"
|
||||
#include "cryptonote_config.h"
|
||||
#include "crypto/crypto.h"
|
||||
#include "crypto/hash.h"
|
||||
@@ -50,6 +51,7 @@
|
||||
#include "ringct/rctTypes.h"
|
||||
#include "device/device.hpp"
|
||||
#include "cryptonote_basic/fwd.h"
|
||||
#include "oracle/pricing_record.h"
|
||||
|
||||
namespace cryptonote
|
||||
{
|
||||
@@ -74,19 +76,10 @@ namespace cryptonote
|
||||
crypto::hash hash;
|
||||
};
|
||||
|
||||
// outputs <= HF_VERSION_VIEW_TAGS
|
||||
struct txout_to_key
|
||||
struct txout_fulmo_tagged_key
|
||||
{
|
||||
txout_to_key() { }
|
||||
txout_to_key(const crypto::public_key &_key) : key(_key) { }
|
||||
crypto::public_key key;
|
||||
};
|
||||
|
||||
// outputs >= HF_VERSION_VIEW_TAGS
|
||||
struct txout_to_tagged_key
|
||||
{
|
||||
txout_to_tagged_key() { }
|
||||
txout_to_tagged_key(const crypto::public_key &_key, const crypto::view_tag &_view_tag) : key(_key), view_tag(_view_tag) { }
|
||||
txout_fulmo_tagged_key() { }
|
||||
txout_fulmo_tagged_key(const crypto::public_key &_key, const crypto::view_tag &_view_tag, const std::string &_asset_type, const uint64_t _unlock_time) : key(_key), view_tag(_view_tag), asset_type(_asset_type), unlock_time(_unlock_time) { }
|
||||
crypto::public_key key;
|
||||
crypto::view_tag view_tag; // optimization to reduce scanning time
|
||||
std::string asset_type;
|
||||
@@ -139,7 +132,7 @@ namespace cryptonote
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
struct txin_to_key
|
||||
struct txin_fulmo_key
|
||||
{
|
||||
uint64_t amount;
|
||||
std::vector<uint64_t> key_offsets;
|
||||
@@ -155,9 +148,9 @@ namespace cryptonote
|
||||
};
|
||||
|
||||
|
||||
typedef boost::variant<txin_gen, txin_to_script, txin_to_scripthash, txin_to_key> txin_v;
|
||||
typedef boost::variant<txin_gen, txin_to_script, txin_to_scripthash, txin_fulmo_key> txin_v;
|
||||
|
||||
typedef boost::variant<txout_to_script, txout_to_scripthash, txout_to_key, txout_to_tagged_key> txout_target_v;
|
||||
typedef boost::variant<txout_to_script, txout_to_scripthash, txout_fulmo_tagged_key> txout_target_v;
|
||||
|
||||
//typedef std::pair<uint64_t, txout> out_t;
|
||||
struct tx_out
|
||||
@@ -185,6 +178,13 @@ namespace cryptonote
|
||||
std::vector<tx_out> vout;
|
||||
//extra
|
||||
std::vector<uint8_t> extra;
|
||||
// Block height of PR to use
|
||||
uint64_t pricing_record_height;
|
||||
// Circulating supply information
|
||||
uint64_t amount_burnt;
|
||||
uint64_t amount_minted;
|
||||
// Slippage tracking
|
||||
uint64_t amount_slippage;
|
||||
|
||||
BEGIN_SERIALIZE()
|
||||
VARINT_FIELD(version)
|
||||
@@ -193,6 +193,10 @@ namespace cryptonote
|
||||
FIELD(vin)
|
||||
FIELD(vout)
|
||||
FIELD(extra)
|
||||
VARINT_FIELD(pricing_record_height)
|
||||
VARINT_FIELD(amount_burnt)
|
||||
VARINT_FIELD(amount_minted)
|
||||
VARINT_FIELD(amount_slippage)
|
||||
END_SERIALIZE()
|
||||
|
||||
public:
|
||||
@@ -204,6 +208,10 @@ namespace cryptonote
|
||||
vin.clear();
|
||||
vout.clear();
|
||||
extra.clear();
|
||||
pricing_record_height = 0;
|
||||
amount_burnt = 0;
|
||||
amount_minted = 0;
|
||||
amount_slippage = 0;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -312,7 +320,7 @@ namespace cryptonote
|
||||
ar.tag("rctsig_prunable");
|
||||
ar.begin_object();
|
||||
r = rct_signatures.p.serialize_rctsig_prunable(ar, rct_signatures.type, vin.size(), vout.size(),
|
||||
vin.size() > 0 && vin[0].type() == typeid(txin_to_key) ? boost::get<txin_to_key>(vin[0]).key_offsets.size() - 1 : 0);
|
||||
vin.size() > 0 && vin[0].type() == typeid(txin_fulmo_key) ? boost::get<txin_fulmo_key>(vin[0]).key_offsets.size() - 1 : 0);
|
||||
if (!r || !ar.good()) return false;
|
||||
ar.end_object();
|
||||
}
|
||||
@@ -449,7 +457,7 @@ namespace cryptonote
|
||||
size_t operator()(const txin_gen& txin) const{return 0;}
|
||||
size_t operator()(const txin_to_script& txin) const{return 0;}
|
||||
size_t operator()(const txin_to_scripthash& txin) const{return 0;}
|
||||
size_t operator()(const txin_to_key& txin) const {return txin.key_offsets.size();}
|
||||
size_t operator()(const txin_fulmo_key& txin) const {return txin.key_offsets.size();}
|
||||
};
|
||||
|
||||
return boost::apply_visitor(txin_signature_size_visitor(), tx_in);
|
||||
@@ -467,6 +475,7 @@ namespace cryptonote
|
||||
uint64_t timestamp;
|
||||
crypto::hash prev_id;
|
||||
uint32_t nonce;
|
||||
oracle::pricing_record pricing_record;
|
||||
|
||||
BEGIN_SERIALIZE()
|
||||
VARINT_FIELD(major_version)
|
||||
@@ -474,6 +483,7 @@ namespace cryptonote
|
||||
VARINT_FIELD(timestamp)
|
||||
FIELD(prev_id)
|
||||
FIELD(nonce)
|
||||
FIELD(pricing_record)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
@@ -572,38 +582,38 @@ namespace std {
|
||||
};
|
||||
}
|
||||
|
||||
BLOB_SERIALIZER(cryptonote::txout_to_key);
|
||||
//BLOB_SERIALIZER(cryptonote::txout_to_key);
|
||||
BLOB_SERIALIZER(cryptonote::txout_to_scripthash);
|
||||
|
||||
VARIANT_TAG(binary_archive, cryptonote::txin_gen, 0xff);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txin_to_script, 0x0);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txin_to_scripthash, 0x1);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txin_to_key, 0x2);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txin_fulmo_key, 0x2);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txout_to_script, 0x0);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txout_to_scripthash, 0x1);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txout_to_key, 0x2);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txout_to_tagged_key, 0x3);
|
||||
//VARIANT_TAG(binary_archive, cryptonote::txout_to_key, 0x2);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txout_fulmo_tagged_key, 0x3);
|
||||
VARIANT_TAG(binary_archive, cryptonote::transaction, 0xcc);
|
||||
VARIANT_TAG(binary_archive, cryptonote::block, 0xbb);
|
||||
|
||||
VARIANT_TAG(json_archive, cryptonote::txin_gen, "gen");
|
||||
VARIANT_TAG(json_archive, cryptonote::txin_to_script, "script");
|
||||
VARIANT_TAG(json_archive, cryptonote::txin_to_scripthash, "scripthash");
|
||||
VARIANT_TAG(json_archive, cryptonote::txin_to_key, "key");
|
||||
VARIANT_TAG(json_archive, cryptonote::txin_fulmo_key, "key");
|
||||
VARIANT_TAG(json_archive, cryptonote::txout_to_script, "script");
|
||||
VARIANT_TAG(json_archive, cryptonote::txout_to_scripthash, "scripthash");
|
||||
VARIANT_TAG(json_archive, cryptonote::txout_to_key, "key");
|
||||
VARIANT_TAG(json_archive, cryptonote::txout_to_tagged_key, "tagged_key");
|
||||
//VARIANT_TAG(json_archive, cryptonote::txout_to_key, "key");
|
||||
VARIANT_TAG(json_archive, cryptonote::txout_fulmo_tagged_key, "tagged_key");
|
||||
VARIANT_TAG(json_archive, cryptonote::transaction, "tx");
|
||||
VARIANT_TAG(json_archive, cryptonote::block, "block");
|
||||
|
||||
VARIANT_TAG(debug_archive, cryptonote::txin_gen, "gen");
|
||||
VARIANT_TAG(debug_archive, cryptonote::txin_to_script, "script");
|
||||
VARIANT_TAG(debug_archive, cryptonote::txin_to_scripthash, "scripthash");
|
||||
VARIANT_TAG(debug_archive, cryptonote::txin_to_key, "key");
|
||||
VARIANT_TAG(debug_archive, cryptonote::txin_fulmo_key, "key");
|
||||
VARIANT_TAG(debug_archive, cryptonote::txout_to_script, "script");
|
||||
VARIANT_TAG(debug_archive, cryptonote::txout_to_scripthash, "scripthash");
|
||||
VARIANT_TAG(debug_archive, cryptonote::txout_to_key, "key");
|
||||
VARIANT_TAG(debug_archive, cryptonote::txout_to_tagged_key, "tagged_key");
|
||||
//VARIANT_TAG(debug_archive, cryptonote::txout_to_key, "key");
|
||||
VARIANT_TAG(debug_archive, cryptonote::txout_fulmo_tagged_key, "tagged_key");
|
||||
VARIANT_TAG(debug_archive, cryptonote::transaction, "tx");
|
||||
VARIANT_TAG(debug_archive, cryptonote::block, "block");
|
||||
|
||||
@@ -101,16 +101,12 @@ namespace boost
|
||||
|
||||
|
||||
template <class Archive>
|
||||
inline void serialize(Archive &a, cryptonote::txout_to_key &x, const boost::serialization::version_type ver)
|
||||
{
|
||||
a & x.key;
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
inline void serialize(Archive &a, cryptonote::txout_to_tagged_key &x, const boost::serialization::version_type ver)
|
||||
inline void serialize(Archive &a, cryptonote::txout_fulmo_tagged_key &x, const boost::serialization::version_type ver)
|
||||
{
|
||||
a & x.key;
|
||||
a & x.view_tag;
|
||||
a & x.asset_type;
|
||||
a & x.unlock_time;
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
@@ -143,11 +139,12 @@ namespace boost
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
inline void serialize(Archive &a, cryptonote::txin_to_key &x, const boost::serialization::version_type ver)
|
||||
inline void serialize(Archive &a, cryptonote::txin_fulmo_key &x, const boost::serialization::version_type ver)
|
||||
{
|
||||
a & x.amount;
|
||||
a & x.key_offsets;
|
||||
a & x.k_image;
|
||||
a & x.asset_type;
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
|
||||
@@ -464,7 +464,7 @@ namespace cryptonote
|
||||
CHECK_AND_ASSERT_MES(tx.rct_signatures.type == rct::RCTTypeBulletproof2 || tx.rct_signatures.type == rct::RCTTypeCLSAG || tx.rct_signatures.type == rct::RCTTypeBulletproofPlus,
|
||||
std::numeric_limits<uint64_t>::max(), "Unsupported rct_signatures type in get_pruned_transaction_weight");
|
||||
CHECK_AND_ASSERT_MES(!tx.vin.empty(), std::numeric_limits<uint64_t>::max(), "empty vin");
|
||||
CHECK_AND_ASSERT_MES(tx.vin[0].type() == typeid(cryptonote::txin_to_key), std::numeric_limits<uint64_t>::max(), "empty vin");
|
||||
CHECK_AND_ASSERT_MES(tx.vin[0].type() == typeid(cryptonote::txin_fulmo_key), std::numeric_limits<uint64_t>::max(), "empty vin");
|
||||
|
||||
// get pruned data size
|
||||
std::ostringstream s;
|
||||
@@ -484,7 +484,7 @@ namespace cryptonote
|
||||
weight += extra;
|
||||
|
||||
// calculate deterministic CLSAG/MLSAG data size
|
||||
const size_t ring_size = boost::get<cryptonote::txin_to_key>(tx.vin[0]).key_offsets.size();
|
||||
const size_t ring_size = boost::get<cryptonote::txin_fulmo_key>(tx.vin[0]).key_offsets.size();
|
||||
if (rct::is_rct_clsag(tx.rct_signatures.type))
|
||||
extra = tx.vin.size() * (ring_size + 2) * 32;
|
||||
else
|
||||
@@ -531,8 +531,8 @@ namespace cryptonote
|
||||
uint64_t amount_out = 0;
|
||||
for(auto& in: tx.vin)
|
||||
{
|
||||
CHECK_AND_ASSERT_MES(in.type() == typeid(txin_to_key), 0, "unexpected type id in transaction");
|
||||
amount_in += boost::get<txin_to_key>(in).amount;
|
||||
CHECK_AND_ASSERT_MES(in.type() == typeid(txin_fulmo_key), 0, "unexpected type id in transaction");
|
||||
amount_in += boost::get<txin_fulmo_key>(in).amount;
|
||||
}
|
||||
for(auto& o: tx.vout)
|
||||
amount_out += o.amount;
|
||||
@@ -824,7 +824,7 @@ namespace cryptonote
|
||||
money = 0;
|
||||
for(const auto& in: tx.vin)
|
||||
{
|
||||
CHECKED_GET_SPECIFIC_VARIANT(in, const txin_to_key, tokey_in, false);
|
||||
CHECKED_GET_SPECIFIC_VARIANT(in, const txin_fulmo_key, tokey_in, false);
|
||||
money += tokey_in.amount;
|
||||
}
|
||||
return true;
|
||||
@@ -841,8 +841,8 @@ namespace cryptonote
|
||||
{
|
||||
for(const auto& in: tx.vin)
|
||||
{
|
||||
CHECK_AND_ASSERT_MES(in.type() == typeid(txin_to_key), false, "wrong variant type: "
|
||||
<< in.type().name() << ", expected " << typeid(txin_to_key).name()
|
||||
CHECK_AND_ASSERT_MES(in.type() == typeid(txin_fulmo_key), false, "wrong variant type: "
|
||||
<< in.type().name() << ", expected " << typeid(txin_fulmo_key).name()
|
||||
<< ", in transaction id=" << get_transaction_hash(tx));
|
||||
|
||||
}
|
||||
@@ -878,7 +878,7 @@ namespace cryptonote
|
||||
uint64_t money = 0;
|
||||
for(const auto& in: tx.vin)
|
||||
{
|
||||
CHECKED_GET_SPECIFIC_VARIANT(in, const txin_to_key, tokey_in, false);
|
||||
CHECKED_GET_SPECIFIC_VARIANT(in, const txin_fulmo_key, tokey_in, false);
|
||||
if(money > tokey_in.amount + money)
|
||||
return false;
|
||||
money += tokey_in.amount;
|
||||
@@ -908,12 +908,12 @@ namespace cryptonote
|
||||
//---------------------------------------------------------------
|
||||
bool get_output_public_key(const cryptonote::tx_out& out, crypto::public_key& output_public_key)
|
||||
{
|
||||
// before HF_VERSION_VIEW_TAGS, outputs with public keys are of type txout_to_key
|
||||
// after HF_VERSION_VIEW_TAGS, outputs with public keys are of type txout_to_tagged_key
|
||||
if (out.target.type() == typeid(txout_to_key))
|
||||
output_public_key = boost::get< txout_to_key >(out.target).key;
|
||||
else if (out.target.type() == typeid(txout_to_tagged_key))
|
||||
output_public_key = boost::get< txout_to_tagged_key >(out.target).key;
|
||||
// before HF_VERSION_VIEW_TAGS, outputs with public keys are of type txout_fulmo_tagged_key
|
||||
// after HF_VERSION_VIEW_TAGS, outputs with public keys are of type txout_fulmo_tagged_key
|
||||
if (out.target.type() == typeid(txout_fulmo_tagged_key))
|
||||
output_public_key = boost::get< txout_fulmo_tagged_key >(out.target).key;
|
||||
else if (out.target.type() == typeid(txout_fulmo_tagged_key))
|
||||
output_public_key = boost::get< txout_fulmo_tagged_key >(out.target).key;
|
||||
else
|
||||
{
|
||||
LOG_ERROR("Unexpected output target type found: " << out.target.type().name());
|
||||
@@ -925,16 +925,16 @@ namespace cryptonote
|
||||
//---------------------------------------------------------------
|
||||
boost::optional<crypto::view_tag> get_output_view_tag(const cryptonote::tx_out& out)
|
||||
{
|
||||
return out.target.type() == typeid(txout_to_tagged_key)
|
||||
? boost::optional<crypto::view_tag>(boost::get< txout_to_tagged_key >(out.target).view_tag)
|
||||
return out.target.type() == typeid(txout_fulmo_tagged_key)
|
||||
? boost::optional<crypto::view_tag>(boost::get< txout_fulmo_tagged_key >(out.target).view_tag)
|
||||
: boost::optional<crypto::view_tag>();
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
bool get_output_asset_type(const cryptonote::tx_out& out, std::string& output_asset_type)
|
||||
{
|
||||
// after HF_VERSION_VIEW_TAGS, outputs with public keys are of type txout_to_tagged_key
|
||||
if (out.target.type() == typeid(txout_to_tagged_key))
|
||||
output_asset_type = boost::get< txout_to_tagged_key >(out.target).asset_type;
|
||||
// after HF_VERSION_VIEW_TAGS, outputs with public keys are of type txout_fulmo_tagged_key
|
||||
if (out.target.type() == typeid(txout_fulmo_tagged_key))
|
||||
output_asset_type = boost::get< txout_fulmo_tagged_key >(out.target).asset_type;
|
||||
else
|
||||
{
|
||||
LOG_ERROR("Unexpected output target type found: " << out.target.type().name());
|
||||
@@ -946,9 +946,9 @@ namespace cryptonote
|
||||
//---------------------------------------------------------------
|
||||
bool get_output_unlock_time(const cryptonote::tx_out& out, uint64_t& output_unlock_time)
|
||||
{
|
||||
// after HF_VERSION_VIEW_TAGS, outputs with public keys are of type txout_to_tagged_key
|
||||
if (out.target.type() == typeid(txout_to_tagged_key))
|
||||
output_unlock_time = boost::get< txout_to_tagged_key >(out.target).unlock_time;
|
||||
// after HF_VERSION_VIEW_TAGS, outputs with public keys are of type txout_fulmo_tagged_key
|
||||
if (out.target.type() == typeid(txout_fulmo_tagged_key))
|
||||
output_unlock_time = boost::get< txout_fulmo_tagged_key >(out.target).unlock_time;
|
||||
else
|
||||
{
|
||||
LOG_ERROR("Unexpected output target type found: " << out.target.type().name());
|
||||
@@ -972,7 +972,7 @@ namespace cryptonote
|
||||
out.amount = amount;
|
||||
if (use_view_tags)
|
||||
{
|
||||
txout_to_tagged_key ttk;
|
||||
txout_fulmo_tagged_key ttk;
|
||||
ttk.key = output_public_key;
|
||||
ttk.view_tag = view_tag;
|
||||
ttk.asset_type = asset_type;
|
||||
@@ -981,7 +981,7 @@ namespace cryptonote
|
||||
}
|
||||
else
|
||||
{
|
||||
txout_to_key tk;
|
||||
txout_fulmo_tagged_key tk;
|
||||
tk.key = output_public_key;
|
||||
out.target = tk;
|
||||
}
|
||||
@@ -991,30 +991,9 @@ namespace cryptonote
|
||||
{
|
||||
for (const auto &o: tx.vout)
|
||||
{
|
||||
if (hf_version > HF_VERSION_VIEW_TAGS)
|
||||
{
|
||||
// from v15, require outputs have view tags
|
||||
CHECK_AND_ASSERT_MES(o.target.type() == typeid(txout_to_tagged_key), false, "wrong variant type: "
|
||||
<< o.target.type().name() << ", expected txout_to_tagged_key in transaction id=" << get_transaction_hash(tx));
|
||||
}
|
||||
else if (hf_version < HF_VERSION_VIEW_TAGS)
|
||||
{
|
||||
// require outputs to be of type txout_to_key
|
||||
CHECK_AND_ASSERT_MES(o.target.type() == typeid(txout_to_key), false, "wrong variant type: "
|
||||
<< o.target.type().name() << ", expected txout_to_key in transaction id=" << get_transaction_hash(tx));
|
||||
}
|
||||
else //(hf_version == HF_VERSION_VIEW_TAGS)
|
||||
{
|
||||
// require outputs be of type txout_to_key OR txout_to_tagged_key
|
||||
// to allow grace period before requiring all to be txout_to_tagged_key
|
||||
CHECK_AND_ASSERT_MES(o.target.type() == typeid(txout_to_key) || o.target.type() == typeid(txout_to_tagged_key), false, "wrong variant type: "
|
||||
<< o.target.type().name() << ", expected txout_to_key or txout_to_tagged_key in transaction id=" << get_transaction_hash(tx));
|
||||
|
||||
// require all outputs in a tx be of the same type
|
||||
CHECK_AND_ASSERT_MES(o.target.type() == tx.vout[0].target.type(), false, "non-matching variant types: "
|
||||
<< o.target.type().name() << " and " << tx.vout[0].target.type().name() << ", "
|
||||
<< "expected matching variant types in transaction id=" << get_transaction_hash(tx));
|
||||
}
|
||||
// require outputs have view tags
|
||||
CHECK_AND_ASSERT_MES(o.target.type() == typeid(txout_fulmo_tagged_key), false, "wrong variant type: "
|
||||
<< o.target.type().name() << ", expected txout_fulmo_tagged_key in transaction id=" << get_transaction_hash(tx));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1316,7 +1295,7 @@ namespace cryptonote
|
||||
binary_archive<true> ba(ss);
|
||||
const size_t inputs = t.vin.size();
|
||||
const size_t outputs = t.vout.size();
|
||||
const size_t mixin = t.vin.empty() ? 0 : t.vin[0].type() == typeid(txin_to_key) ? boost::get<txin_to_key>(t.vin[0]).key_offsets.size() - 1 : 0;
|
||||
const size_t mixin = t.vin.empty() ? 0 : t.vin[0].type() == typeid(txin_fulmo_key) ? boost::get<txin_fulmo_key>(t.vin[0]).key_offsets.size() - 1 : 0;
|
||||
bool r = tt.rct_signatures.p.serialize_rctsig_prunable(ba, t.rct_signatures.type, inputs, outputs, mixin);
|
||||
CHECK_AND_ASSERT_MES(r, false, "Failed to serialize rct signatures prunable");
|
||||
cryptonote::get_blob_hash(ss.str(), res);
|
||||
|
||||
Reference in New Issue
Block a user