diff --git a/src/currency_core/currency_basic.h b/src/currency_core/currency_basic.h index 6165495a..52f25be8 100644 --- a/src/currency_core/currency_basic.h +++ b/src/currency_core/currency_basic.h @@ -696,6 +696,7 @@ namespace currency } }; +#define ASSET_DESCRIPTOR_BASE_HF5_VER 2 #define ASSET_DESCRIPTOR_BASE_LAST_VER 2 struct dummy diff --git a/src/currency_core/currency_format_utils.cpp b/src/currency_core/currency_format_utils.cpp index 5765e7c0..a6b19db1 100644 --- a/src/currency_core/currency_format_utils.cpp +++ b/src/currency_core/currency_format_utils.cpp @@ -2302,8 +2302,17 @@ namespace currency amount_of_burned_assets -= item.amount; } } - ado.opt_amount = amount_of_burned_assets; // TODO: support hidden supply -- sowle - + if (ado.version < ASSET_DESCRIPTOR_BASE_HF5_VER) + { + CHECK_AND_ASSERT_THROW_MES(ado.opt_descriptor.has_value(), "Internal error: opt_descriptor unset during ASSET_DESCRIPTOR_OPERATION_PUBLIC_BURN for version less then 2"); + ado.opt_descriptor->current_supply -= amount_of_burned_assets; + } + else + { + CHECK_AND_ASSERT_THROW_MES(!ado.opt_descriptor.has_value(), "Internal error: opt_descriptor unset during ASSET_DESCRIPTOR_OPERATION_PUBLIC_BURN for version less then 2"); + ado.opt_amount = amount_of_burned_assets; // TODO: support hidden supply -- sowle + } + gen_context.ao_amount_commitment = amount_of_burned_assets * gen_context.ao_asset_id_pt + gen_context.ao_amount_blinding_mask * crypto::c_point_G; ado.opt_amount_commitment = (crypto::c_scalar_1div8 * gen_context.ao_amount_commitment).to_public_key(); @@ -2329,7 +2338,16 @@ namespace currency item.asset_id = gen_context.ao_asset_id; } } - ado.opt_amount = amount_of_emitted_asset; // TODO: support hidden supply -- sowle + if (ado.version < ASSET_DESCRIPTOR_BASE_HF5_VER) + { + CHECK_AND_ASSERT_THROW_MES(ado.opt_descriptor.has_value(), "Internal error: opt_descriptor unset during ASSET_DESCRIPTOR_OPERATION_PUBLIC_BURN for version less then 2"); + ado.opt_descriptor->current_supply += amount_of_emitted_asset; + } + else + { + CHECK_AND_ASSERT_THROW_MES(!ado.opt_descriptor.has_value(), "Internal error: opt_descriptor unset during ASSET_DESCRIPTOR_OPERATION_PUBLIC_BURN for version less then 2"); + ado.opt_amount = amount_of_emitted_asset; // TODO: support hidden supply -- sowle + } gen_context.ao_amount_commitment = amount_of_emitted_asset * gen_context.ao_asset_id_pt + gen_context.ao_amount_blinding_mask * crypto::c_point_G; ado.opt_amount_commitment = (crypto::c_scalar_1div8 * gen_context.ao_amount_commitment).to_public_key(); @@ -2778,8 +2796,7 @@ namespace currency const asset_descriptor_operation* pado = get_type_in_variant_container(tx.extra); if (pado != nullptr) { - if ((pado->operation_type == ASSET_DESCRIPTOR_OPERATION_EMIT || pado->operation_type == ASSET_DESCRIPTOR_OPERATION_UPDATE) && - !pado->descriptor.owner_eth_pub_key.has_value()) + if ((pado->operation_type == ASSET_DESCRIPTOR_OPERATION_EMIT || pado->operation_type == ASSET_DESCRIPTOR_OPERATION_UPDATE) && (!ftp.ado_sign_thirdparty)) { asset_operation_ownership_proof aoop{}; r = crypto::generate_schnorr_sig(tx_prefix_hash, sender_account_keys.spend_secret_key, aoop.gss); diff --git a/src/currency_core/currency_format_utils.h b/src/currency_core/currency_format_utils.h index 2f4e1783..f96210a6 100644 --- a/src/currency_core/currency_format_utils.h +++ b/src/currency_core/currency_format_utils.h @@ -29,6 +29,7 @@ #include "currency_format_utils_transactions.h" #include "core_runtime_config.h" #include "wallet/wallet_public_structs_defs.h" +#include "wallet/wallet_public_structs_defs.h" #include "bc_attachments_helpers.h" #include "bc_payments_id_service.h" #include "bc_offers_service_basic.h" @@ -164,9 +165,11 @@ namespace currency uint64_t tx_version; uint64_t mode_separate_fee = 0; - epee::misc_utils::events_dispatcher* pevents_dispatcher; + epee::misc_utils::events_dispatcher* pevents_dispatcher = nullptr; tx_generation_context gen_context{}; // solely for consolidated txs + + bool ado_sign_thirdparty = false;//@#@ TODO: add to serialization map @zoidberg BEGIN_SERIALIZE_OBJECT() diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 0205a33c..26976ecb 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -5600,6 +5600,7 @@ void wallet2::emit_asset(const crypto::public_key& asset_id, const std::vectortransfer(ctp, ft, send_to_network, nullptr); @@ -7949,6 +7950,7 @@ bool wallet2::prepare_transaction(construct_tx_param& ctp, currency::finalize_tx ftp.flags = ctp.flags; ftp.multisig_id = ctp.multisig_id; ftp.spend_pub_key = m_account.get_public_address().spend_public_key; + ftp.ado_sign_thirdparty = ctp.ado_sign_thirdparty; /* TODO WLT_LOG_GREEN("[prepare_transaction]: get_needed_money_time: " << get_needed_money_time << " ms" diff --git a/src/wallet/wallet2_base.h b/src/wallet/wallet2_base.h index 649909e8..4c88dc58 100644 --- a/src/wallet/wallet2_base.h +++ b/src/wallet/wallet2_base.h @@ -229,6 +229,9 @@ namespace tools // misc std::string tx_meaning_for_logs; // used to correctly log things, e.g. "escrow" or "asset emission". uint32_t additional_transfer_flags_to_mark = 0; + + //ado + bool ado_sign_thirdparty = false; }; struct mode_separate_context