diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 1a1f1e8e..ed51ef76 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -2113,11 +2113,11 @@ bool simple_wallet::emit_asset(const std::vector &args) tx_destination_entry td = AUTO_VAL_INIT(td); td.addr.push_back(m_wallet->get_account().get_public_address()); td.amount = amount; - td.asset_id = asset_id; + td.asset_id = currency::null_pkey; std::vector destinations; destinations.push_back(td); currency::transaction result_tx = AUTO_VAL_INIT(result_tx); - m_wallet->emmit_asset(asset_id, destinations, result_tx); + m_wallet->emit_asset(asset_id, destinations, result_tx); success_msg_writer(true) << "Emitted " << get_transaction_hash(result_tx) << " (unconfirmed) : " << ENDL << "Asset ID: " << asset_id << ENDL diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 7b5d1f30..cc533644 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -4954,7 +4954,7 @@ void wallet2::deploy_new_asset(const currency::asset_descriptor_base& asset_info m_custom_assets[new_asset_id] = ado.descriptor; } //---------------------------------------------------------------------------------------------------- -void wallet2::emmit_asset(const crypto::public_key asset_id, std::vector& destinations, currency::transaction& result_tx) +void wallet2::emit_asset(const crypto::public_key asset_id, std::vector& destinations, currency::transaction& result_tx) { auto own_asset_entry_it = m_own_asset_descriptors.find(asset_id); @@ -4976,6 +4976,12 @@ void wallet2::emmit_asset(const crypto::public_key asset_id, std::vectorsecond.control_key; + for(auto& dst : ctp.dsts) + { + if (dst.asset_id == asset_id) + dst.asset_id = null_pkey; // emit operation requires null_pkey for emitting asset outputs, fix it ad-hoc here + } + finalized_tx ft = AUTO_VAL_INIT(ft); this->transfer(ctp, ft, true, nullptr); result_tx = ft.tx; diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 5ea7a30b..413adb97 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -394,7 +394,7 @@ namespace tools bool check_available_sources(std::list& amounts); 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 emmit_asset(const crypto::public_key asset_id, std::vector& destinations, currency::transaction& result_tx); + 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 transfer_asset_ownership(const crypto::public_key asset_id, const crypto::public_key& new_owner, currency::transaction& result_tx); diff --git a/tests/core_tests/multiassets_test.cpp b/tests/core_tests/multiassets_test.cpp index 28dda0e5..1a933292 100644 --- a/tests/core_tests/multiassets_test.cpp +++ b/tests/core_tests/multiassets_test.cpp @@ -142,9 +142,9 @@ bool multiassets_basic_test::c1(currency::core& c, size_t ev_index, const std::v CHECK_AND_ASSERT_MES(asset_info2.meta_info == asset_info.meta_info, false, "Failed to find needed asset in result balances"); - //test emmit function + //test emit function //use same destinations as we used before - miner_wlt->emmit_asset(asset_id, destinations, tx); + miner_wlt->emit_asset(asset_id, destinations, tx); r = mine_next_pow_blocks_in_playtime(miner_wlt->get_account().get_public_address(), c, CURRENCY_MINED_MONEY_UNLOCK_WINDOW); CHECK_AND_ASSERT_MES(r, false, "mine_next_pow_blocks_in_playtime failed"); @@ -252,13 +252,13 @@ bool multiassets_basic_test::c1(currency::core& c, size_t ev_index, const std::v //miner_wlt->refresh(); - // check emmit_asset() with modified 'current_supply' + // check emit_asset() with modified 'current_supply' miner_wlt->get_debug_events_dispatcher().SUBSCIRBE_DEBUG_EVENT([&](const wde_construct_tx_handle_asset_descriptor_operation_before_seal& o) { o.pado->descriptor.current_supply += 1000000; }); - //test emmit function but re-adjust current_supply to wrong amount - miner_wlt->emmit_asset(asset_id, destinations, tx); + //test emit function but re-adjust current_supply to wrong amount + miner_wlt->emit_asset(asset_id, destinations, tx); CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 1, false, "Unexpected number of txs in the pool: " << c.get_pool_transactions_count()); r = mine_next_pow_block_in_playtime(miner_wlt->get_account().get_public_address(), c); CHECK_AND_ASSERT_MES(!r, false, "block with a bad tx was unexpectedly mined"); @@ -305,7 +305,7 @@ bool multiassets_basic_test::c1(currency::core& c, size_t ev_index, const std::v uint64_t balance_alice_asset = alice_wlt->balance(asset_id); uint64_t balance_miner_asset = miner_wlt->balance(asset_id); - alice_wlt->emmit_asset(asset_id, destinations, tx); + alice_wlt->emit_asset(asset_id, destinations, tx); r = mine_next_pow_blocks_in_playtime(miner_wlt->get_account().get_public_address(), c, CURRENCY_MINED_MONEY_UNLOCK_WINDOW); CHECK_AND_ASSERT_MES(r, false, "mine_next_pow_blocks_in_playtime failed"); @@ -315,7 +315,7 @@ bool multiassets_basic_test::c1(currency::core& c, size_t ev_index, const std::v CHECK_AND_ASSERT_MES(miner_wlt->balance(asset_id) == balance_miner_asset + destinations[0].amount, false, "Miner balance wrong"); CHECK_AND_ASSERT_MES(alice_wlt->balance(asset_id) == balance_alice_asset + destinations[1].amount, false, "Alice balance wrong"); - //TODO: attempt to emmmit from old key, attempt to emmit from more then max supply + //TODO: attempt to emmmit from old key, attempt to emit from more then max supply return true; }