From 43c0c7944dabef6940090a6efd47475c231767be Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Mon, 26 Sep 2022 21:57:24 +0200 Subject: [PATCH] inital code for submiting asset descriptor --- src/currency_core/currency_basic.h | 45 ++++++++++++++++++++++++++++-- src/wallet/wallet2.cpp | 18 ++++++++++++ src/wallet/wallet2.h | 3 +- 3 files changed, 63 insertions(+), 3 deletions(-) diff --git a/src/currency_core/currency_basic.h b/src/currency_core/currency_basic.h index af113532..77f7dee9 100644 --- a/src/currency_core/currency_basic.h +++ b/src/currency_core/currency_basic.h @@ -703,10 +703,48 @@ namespace currency FIELD(ticker) FIELD(full_name) FIELD(owner) - END_SERIALIZE() + END_SERIALIZE() + + + BEGIN_BOOST_SERIALIZATION() + BOOST_SERIALIZE(total_max_supply) + BOOST_SERIALIZE(current_supply) + BOOST_SERIALIZE(decimal_point) + BOOST_SERIALIZE(ticker) + BOOST_SERIALIZE(full_name) + BOOST_SERIALIZE(owner) + END_BOOST_SERIALIZATION() }; +#define ASSET_DESCRIPTOR_OPERATION_UNDEFINED 0 +#define ASSET_DESCRIPTOR_OPERATION_REGISTER 1 +#define ASSET_DESCRIPTOR_OPERATION_UPDATE 2 + + + struct asset_descriptor_operation + { + uint8_t operation_type = ASSET_DESCRIPTOR_OPERATION_UNDEFINED; + std::vector proof; + asset_descriptor_base descriptor; + + + BEGIN_VERSIONED_SERIALIZE() + FIELD(operation_type) + FIELD(proof) + FIELD(descriptor) + END_SERIALIZE() + + + BEGIN_BOOST_SERIALIZATION() + BOOST_SERIALIZE(operation_type) + BOOST_SERIALIZE(proof) + BOOST_SERIALIZE(descriptor) + END_BOOST_SERIALIZATION() + }; + + + struct extra_padding { @@ -775,7 +813,7 @@ namespace currency typedef boost::mpl::vector24< tx_service_attachment, tx_comment, tx_payer_old, tx_receiver_old, tx_derivation_hint, std::string, tx_crypto_checksum, etc_tx_time, etc_tx_details_unlock_time, etc_tx_details_expiration_time, etc_tx_details_flags, crypto::public_key, extra_attachment_info, extra_alias_entry_old, extra_user_data, extra_padding, etc_tx_flags16_t, etc_tx_details_unlock_time2, - tx_payer, tx_receiver, extra_alias_entry, zarcanum_tx_data_v1, zarcanum_outs_range_proof, zc_balance_proof + tx_payer, tx_receiver, extra_alias_entry, zarcanum_tx_data_v1, zarcanum_outs_range_proof, zc_balance_proof, asset_descriptor_operation > all_payload_types; typedef boost::make_variant_over::type payload_items_v; @@ -1102,6 +1140,9 @@ SET_VARIANT_TAGS(currency::zc_balance_proof, 46, "zc_balance_proof"); SET_VARIANT_TAGS(currency::open_asset_id, 47, "asset_id"); +SET_VARIANT_TAGS(currency::asset_descriptor_operation, 48, "asset_descriptor_base"); + + #undef SET_VARIANT_TAGS diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 4aa78072..cf8ad1b7 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -4121,6 +4121,24 @@ void wallet2::request_alias_registration(currency::extra_alias_entry& ai, curren destinations.push_back(tx_dest_alias_reward); transfer(destinations, 0, 0, fee, extra, attachments, get_current_split_strategy(), tx_dust_policy(DEFAULT_DUST_THRESHOLD), res_tx, CURRENCY_TO_KEY_OUT_RELAXED, false); +} +//---------------------------------------------------------------------------------------------------- +void wallet2::publish_new_asset(const asset_descriptor_base& asset_info, const std::vector& destinations) +{ + asset_descriptor_operation asset_reg_info = AUTO_VAL_INIT(asset_reg_info); + asset_reg_info.descriptor = asset_info; + asset_reg_info.operation_type = ASSET_DESCRIPTOR_OPERATION_REGISTER; + + + std::vector destinations_local = destinations; + std::vector extra; + std::vector attachments; + + extra.push_back(asset_reg_info); + + transfer(destinations, 0, 0, fee, extra, attachments, get_current_split_strategy(), tx_dust_policy(DEFAULT_DUST_THRESHOLD), res_tx, CURRENCY_TO_KEY_OUT_RELAXED, false); + + } //---------------------------------------------------------------------------------------------------- void wallet2::request_alias_update(currency::extra_alias_entry& ai, currency::transaction& res_tx, uint64_t fee, uint64_t reward) diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index f75b1e98..c6837a08 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -551,7 +551,8 @@ namespace tools void request_alias_registration(currency::extra_alias_entry& ai, currency::transaction& res_tx, uint64_t fee, uint64_t reward, const crypto::secret_key& authority_key = currency::null_skey); void request_alias_update(currency::extra_alias_entry& ai, currency::transaction& res_tx, uint64_t fee, uint64_t reward); bool check_available_sources(std::list& amounts); - + + void publish_new_asset(const asset_descriptor_base& asset_info, const std::vector& destinations); bool set_core_proxy(const std::shared_ptr& proxy); void set_pos_mint_packing_size(uint64_t new_size);