diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index f7078763..3d1a1fc8 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -5543,7 +5543,7 @@ void wallet2::transfer_asset_ownership(const crypto::public_key& asset_id, const result_tx = ft.tx; } //---------------------------------------------------------------------------------------------------- -void wallet2::burn_asset(const crypto::public_key& asset_id, uint64_t amount_to_burn, currency::finalized_tx& ft) +void wallet2::burn_asset(const crypto::public_key& asset_id, uint64_t amount_to_burn, currency::finalized_tx& ft, const std::vector& service_entries, const std::string& address_to_point/* = const std::string()*/, uint64_t native_amount_to_point/* = 0*/) { currency::asset_descriptor_base last_adb{}; bool r = this->daemon_get_asset_info(asset_id, last_adb); @@ -5565,14 +5565,30 @@ void wallet2::burn_asset(const crypto::public_key& asset_id, uint64_t amount_to_ ctp.need_at_least_1_zc = true; ctp.dsts.push_back(dst_to_burn); ctp.tx_meaning_for_logs = "asset burn"; + if (service_entries.size()) + { + //put it to extra + ctp.extra.insert(ctp.extra.end(), service_entries.begin(), service_entries.end()); + } + if (address_to_point.size()) + { + currency::account_public_address addr = AUTO_VAL_INIT(addr); + bool r = currency::get_account_address_from_str(addr, address_to_point); + CHECK_AND_ASSERT_THROW_MES(r, "WRONG_ADDRESS"); + currency::tx_destination_entry dst_to_point = AUTO_VAL_INIT(dst_to_point); + dst_to_point.asset_id = native_coin_asset_id; + dst_to_point.amount = native_amount_to_point; + dst_to_point.addr.push_back(addr); + ctp.dsts.push_back(dst_to_point); + } this->transfer(ctp, ft, true, nullptr); } //---------------------------------------------------------------------------------------------------- -void wallet2::burn_asset(const crypto::public_key& asset_id, uint64_t amount_to_burn, currency::transaction& result_tx) +void wallet2::burn_asset(const crypto::public_key& asset_id, uint64_t amount_to_burn, currency::transaction& result_tx, const std::vector& service_entries, const std::string& address_to_point/* = const std::string()*/, uint64_t native_amount_to_point /*= 0*/) { finalized_tx ft{}; - burn_asset(asset_id, amount_to_burn, ft); + burn_asset(asset_id, amount_to_burn, ft, service_entries, address_to_point, native_amount_to_point); result_tx = ft.tx; } //---------------------------------------------------------------------------------------------------- diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index c454480a..d8fd661f 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -422,13 +422,13 @@ namespace tools void deploy_new_asset(const currency::asset_descriptor_base& asset_info, const std::vector& destinations, currency::transaction& result_tx, crypto::public_key& new_asset_id); void emit_asset(const crypto::public_key& asset_id, std::vector& destinations, currency::transaction& result_tx); void update_asset(const crypto::public_key& asset_id, const currency::asset_descriptor_base new_descriptor, currency::transaction& result_tx); - void burn_asset(const crypto::public_key& asset_id, uint64_t amount_to_burn, currency::transaction& result_tx); + void burn_asset(const crypto::public_key& asset_id, uint64_t amount_to_burn, currency::transaction& result_tx, const std::vector& service_entries = std::vector(), const std::string& address_to_point = std::string(), uint64_t native_amount_to_point = 0); void transfer_asset_ownership(const crypto::public_key& asset_id, const currency::asset_owner_pub_key_v& new_owner_v, currency::transaction& result_tx); void deploy_new_asset(const currency::asset_descriptor_base& asset_info, const std::vector& destinations, currency::finalized_tx& ft, crypto::public_key& new_asset_id); void emit_asset(const crypto::public_key& asset_id, const std::vector& destinations, currency::finalized_tx& ft); void update_asset(const crypto::public_key& asset_id, const currency::asset_descriptor_base& new_descriptor, currency::finalized_tx& ft); - void burn_asset(const crypto::public_key& asset_id, uint64_t amount_to_burn, currency::finalized_tx& ft); + void burn_asset(const crypto::public_key& asset_id, uint64_t amount_to_burn, currency::finalized_tx& ft, const std::vector& service_entries = std::vector(), const std::string& address_to_point = std::string(), uint64_t native_amount_to_point = 0); void transfer_asset_ownership(const crypto::public_key& asset_id, const currency::asset_owner_pub_key_v& new_owner_v, currency::finalized_tx& ft); bool daemon_get_asset_info(const crypto::public_key& asset_id, currency::asset_descriptor_base& adb); @@ -960,7 +960,7 @@ private: uint64_t m_last_known_daemon_height = 0; - //this needed to access wallets state in coretests, for creating abnormal blocks and tranmsactions + //this needed to access wallets state in coretests, for creating abnormal blocks and transactions friend class test_generator; }; // class wallet2 diff --git a/src/wallet/wallet_public_structs_defs.h b/src/wallet/wallet_public_structs_defs.h index b6d78d46..ba276a0a 100644 --- a/src/wallet/wallet_public_structs_defs.h +++ b/src/wallet/wallet_public_structs_defs.h @@ -153,8 +153,8 @@ namespace wallet_public std::vector service_entries; std::vector remote_addresses; //optional std::vector remote_aliases; //optional, describe only if there only one remote address - std::vector subtransfers; + boost::optional data_for_external_signing; //not included in streaming serialization uint64_t fee = 0; @@ -2087,12 +2087,19 @@ namespace wallet_public struct request { - crypto::public_key asset_id; - uint64_t burn_amount; + crypto::public_key asset_id = currency::null_pkey; + uint64_t burn_amount = 0; + //optional params + std::string point_tx_to_address; + uint64_t native_amount = 0; + std::vector service_entries; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE_POD_AS_HEX_STRING(asset_id) DOC_DSCR("Id of the asset to burn") DOC_EXMP("40fa6db923728b38962718c61b4dc3af1acaa1967479c73703e260dc3609c58d") DOC_END KV_SERIALIZE(burn_amount) DOC_DSCR("Amount to burn") DOC_EXMP(10000000) DOC_END + KV_SERIALIZE(point_tx_to_address) DOC_DSCR("Optional, if we need this transaction to be seen by particular wallet") DOC_EXMP("ZxBvJDuQjMG9R2j4WnYUhBYNrwZPwuyXrC7FHdVmWqaESgowDvgfWtiXeNGu8Px9B24pkmjsA39fzSSiEQG1ekB225ZnrMTBp") DOC_END + KV_SERIALIZE(native_amount) DOC_DSCR("Optional, if we need this transaction to be seen by particular wallet") DOC_EXMP(0) DOC_END + KV_SERIALIZE(service_entries) DOC_DSCR("Optional, if we need to include service entries for burn transaction") DOC_EXMP_AUTO(1) DOC_END END_KV_SERIALIZE_MAP() }; diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 069e6856..305bd6d4 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -1388,7 +1388,7 @@ namespace tools WALLET_RPC_BEGIN_TRY_ENTRY(); currency::finalized_tx ft{}; - w.get_wallet()->burn_asset(req.asset_id, req.burn_amount, ft); + w.get_wallet()->burn_asset(req.asset_id, req.burn_amount, ft, req.service_entries, req.point_tx_to_address, req.native_amount); res.tx_id = ft.tx_id; return true;