From c971c9846bb17c092efbdbac1bee259bad0ff41a Mon Sep 17 00:00:00 2001 From: Some Random Crypto Guy Date: Thu, 31 Oct 2024 11:23:46 +0000 Subject: [PATCH] updated to support N-out-TX operation of Salvium v0.6.x --- src/cryptonote_config.h | 1 + src/cryptonote_core/cryptonote_basic.h | 15 +++++++++++++-- src/cryptonote_core/cryptonote_format_utils.cpp | 6 +++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h index ca50a8f..26bf333 100644 --- a/src/cryptonote_config.h +++ b/src/cryptonote_config.h @@ -1,6 +1,7 @@ #pragma once #define CURRENT_TRANSACTION_VERSION 2 +#define HF_VERSION_ENABLE_N_OUTS 2 #define PRICING_RECORD_VALID_TIME_DIFF_FROM_BLOCK 120 // seconds diff --git a/src/cryptonote_core/cryptonote_basic.h b/src/cryptonote_core/cryptonote_basic.h index a99ac8c..5f1fe95 100644 --- a/src/cryptonote_core/cryptonote_basic.h +++ b/src/cryptonote_core/cryptonote_basic.h @@ -200,6 +200,10 @@ namespace cryptonote cryptonote::salvium_transaction_type type; // Return address crypto::public_key return_address; + // Return address list (must be at least 1 and at most BULLETPROOF_MAX_OUTPUTS-1 - the "-1" is for the change output) + std::vector return_address_list; + //return_address_change_mask + std::vector return_address_change_mask; // Return TX public key crypto::public_key return_pubkey; // Source asset type @@ -222,8 +226,13 @@ namespace cryptonote if (type != cryptonote::salvium_transaction_type::PROTOCOL) { VARINT_FIELD(amount_burnt) if (type != cryptonote::salvium_transaction_type::MINER) { - FIELD(return_address) - FIELD(return_pubkey) + if (type == cryptonote::transaction_type::TRANSFER && version >= TRANSACTION_VERSION_N_OUTS) { + FIELD(return_address_list) + FIELD(return_address_change_mask) + } else { + FIELD(return_address) + FIELD(return_pubkey) + } FIELD(source_asset_type) FIELD(destination_asset_type) VARINT_FIELD(amount_slippage_limit) @@ -332,6 +341,8 @@ namespace cryptonote // Salvium-specific fields type = cryptonote::salvium_transaction_type::UNSET; return_address = null_pkey; + return_address_list.clear(); + return_address_change_mask.clear(); return_pubkey = null_pkey; source_asset_type.clear(); destination_asset_type.clear(); diff --git a/src/cryptonote_core/cryptonote_format_utils.cpp b/src/cryptonote_core/cryptonote_format_utils.cpp index 4bbc3d0..336c19a 100644 --- a/src/cryptonote_core/cryptonote_format_utils.cpp +++ b/src/cryptonote_core/cryptonote_format_utils.cpp @@ -264,7 +264,11 @@ namespace cryptonote blob = t_serializable_object_to_blob(static_cast(b)); crypto::hash tree_root_hash = get_tx_tree_hash(b); blob.append(reinterpret_cast(&tree_root_hash), sizeof(tree_root_hash)); - blob.append(tools::get_varint_data(b.tx_hashes.size()+1)); + if (b.blob_type == BLOB_TYPE_CRYPTONOTE_SALVIUM) { + blob.append(tools::get_varint_data(b.tx_hashes.size() + (b.major_version >= HF_VERSION_ENABLE_N_OUTS ? 2 : 1))); + } else { + blob.append(tools::get_varint_data(b.tx_hashes.size() + 1)); + } return true; } //---------------------------------------------------------------