From ee84d41d3400d35545ee0b0a566445b04d158f20 Mon Sep 17 00:00:00 2001 From: Doyle Date: Fri, 15 Mar 2019 12:37:30 +1100 Subject: [PATCH] Update cryptonote utils for Loki hardfork 11, Infinite Staking --- src/cryptonote_core/cryptonote_basic.h | 40 ++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/src/cryptonote_core/cryptonote_basic.h b/src/cryptonote_core/cryptonote_basic.h index 80de4cf8..5f581219 100644 --- a/src/cryptonote_core/cryptonote_basic.h +++ b/src/cryptonote_core/cryptonote_basic.h @@ -137,6 +137,15 @@ namespace cryptonote END_SERIALIZE() }; + enum loki_version + { + loki_version_0 = 0, + loki_version_1, + loki_version_2, + loki_version_3_per_output_unlock_times, + loki_version_4_tx_types, + }; + class transaction_prefix { @@ -151,20 +160,45 @@ namespace cryptonote //extra std::vector extra; + // + // NOTE: Loki specific + // std::vector output_unlock_times; - bool is_deregister; + enum loki_type_t + { + loki_type_standard, + loki_type_deregister, + loki_type_key_image_unlock, + loki_type_count, + }; + + union + { + bool is_deregister; + uint16_t type; + }; BEGIN_SERIALIZE() VARINT_FIELD(version) - if (blob_type == BLOB_TYPE_CRYPTONOTE_LOKI) + if (version > loki_version_2 && blob_type == BLOB_TYPE_CRYPTONOTE_LOKI) { FIELD(output_unlock_times) - FIELD(is_deregister) + if (version == loki_version_3_per_output_unlock_times) + FIELD(is_deregister) } VARINT_FIELD(unlock_time) FIELD(vin) FIELD(vout) + if (blob_type == BLOB_TYPE_CRYPTONOTE_LOKI) + { + if (version >= loki_version_3_per_output_unlock_times && vout.size() != output_unlock_times.size()) return false; + } FIELD(extra) + if (blob_type == BLOB_TYPE_CRYPTONOTE_LOKI && version >= loki_version_4_tx_types) + { + VARINT_FIELD(type) + if (static_cast(type) >= loki_type_count) return false; + } END_SERIALIZE()