1
0
Fork 0
forked from lthn/blockchain

Multiple fixes here and there, mostly fixing compilation problems

This commit is contained in:
cryptozoidberg 2023-04-18 16:55:00 +02:00
parent ac4a62a5c9
commit 44e22b611d
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC
13 changed files with 51 additions and 45 deletions

View file

@ -56,8 +56,8 @@ namespace currency
const static crypto::key_derivation null_derivation = AUTO_VAL_INIT(null_derivation);
const static crypto::hash gdefault_genesis = epee::string_tools::hex_to_pod<crypto::hash>("CC608F59F8080E2FBFE3C8C80EB6E6A953D47CF2D6AEBD345BADA3A1CAB99852");
const static crypto::hash ffff_hash = epee::string_tools::hex_to_pod<crypto::hash>("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
const static crypto::public_key ffff_pkey = epee::string_tools::hex_to_pod<crypto::public_key>("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // TODO @#@# consider getting rid of this
//const static crypto::hash ffff_hash = epee::string_tools::hex_to_pod<crypto::hash>("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
//const static crypto::public_key ffff_pkey = epee::string_tools::hex_to_pod<crypto::public_key>("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // TODO @#@# consider getting rid of this
// TODO: rewtire the following to a normal aggregate initialization once we move to C++17 -- sowle
const static crypto::public_key native_coin_asset_id = reinterpret_cast<const crypto::public_key&>(static_cast<const crypto::ec_scalar&>(crypto::ec_scalar{'\xd6', '\x32', '\x9b', '\x5b', '\x1f', '\x7c', '\x08', '\x05', '\xb5', '\xc3', '\x45', '\xf4', '\x95', '\x75', '\x54', '\x00', '\x2a', '\x2f', '\x55', '\x78', '\x45', '\xf6', '\x4d', '\x76', '\x45', '\xda', '\xe0', '\xe0', '\x51', '\xa6', '\x49', '\x8a'})); // == crypto::c_point_H, checked in crypto_constants

View file

@ -2241,7 +2241,7 @@ namespace currency
uint64_t amount_of_emitted_asset = 0;
for (auto& item : shuffled_dsts)
{
if (item.asset_id == currency::ffff_pkey)
if (item.asset_id == currency::null_pkey)
{
item.asset_id = gen_context.ao_asset_id; // set calculated asset_id to the asset's outputs, if this asset is being emitted within this tx
amount_of_emitted_asset += item.amount;

View file

@ -1819,7 +1819,7 @@ bool simple_wallet::deploy_new_asset(const std::vector<std::string> &args)
tx_destination_entry td = AUTO_VAL_INIT(td);
td.addr.push_back(m_wallet->get_account().get_public_address());
td.amount = adb.current_supply;
td.asset_id = currency::ffff_pkey;
td.asset_id = currency::null_pkey;
std::vector<currency::tx_destination_entry> destinations;
destinations.push_back(td);
currency::transaction result_tx = AUTO_VAL_INIT(result_tx);

View file

@ -5535,7 +5535,7 @@ assets_selection_context wallet2::get_needed_money(uint64_t fee, const std::vect
amounts_map[currency::native_coin_asset_id].needed_amount = fee;
for(auto& dt : dsts)
{
if(dt.asset_id == currency::ffff_pkey)
if(dt.asset_id == currency::null_pkey)
continue; //this destination for emmition only
THROW_IF_TRUE_WALLET_EX(0 == dt.amount, error::zero_destination);
@ -6181,7 +6181,7 @@ void wallet2::prepare_tx_destinations(const assets_selection_context& needed_mon
{
// special case for asset minting destinations
for (auto& dst : dsts)
if (dst.asset_id == currency::ffff_pkey)
if (dst.asset_id == currency::null_pkey)
final_destinations.emplace_back(dst.amount, dst.addr, dst.asset_id);
// if there's not ehough destinations items (i.e. outputs), split the last one

View file

@ -1192,6 +1192,7 @@ namespace wallet_public
END_KV_SERIALIZE_MAP()
};
struct ionic_swap_proposal_info
{
std::vector<asset_funds> from;
@ -1242,12 +1243,12 @@ namespace wallet_public
struct create_ionic_swap_proposal_request
{
uint64_t wallet_id;
ionic_swap_proposal_info proposal;
ionic_swap_proposal_info proposal_info;
std::string destination_add;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(wallet_id)
KV_SERIALIZE(proposal)
KV_SERIALIZE(proposal_info)
KV_SERIALIZE(destination_add)
END_KV_SERIALIZE_MAP()
};
@ -1515,6 +1516,10 @@ namespace wallet_public
}
}
bool operator==(const asset_funds& lhs, const asset_funds& rhs)
{
return lhs.amount == rhs.amount && lhs.asset_id == rhs.asset_id;
}
} // namespace wallet_rpc
} // namespace tools

View file

@ -948,15 +948,15 @@ namespace tools
return false;
}
currency::transaction tx_template = AUTO_VAL_INIT(tx_template);
bool r = get_wallet()->create_ionic_swap_proposal(req.proposal, destination_addr, tx_template);
wallet_public::ionic_swap_proposal proposal = AUTO_VAL_INIT(proposal);
bool r = get_wallet()->create_ionic_swap_proposal(req.proposal, destination_addr, proposal);
if (!r)
{
er.code = WALLET_RPC_ERROR_CODE_WRONG_ARGUMENT;
er.message = "WALLET_RPC_ERROR_CODE_WRONG_ARGUMENT - Error creating proposal";
return false;
}
res.hex_raw_proposal = epee::string_tools::buff_to_hex_nodelimer(t_serializable_object_to_blob(tx_template));
res.hex_raw_proposal = epee::string_tools::buff_to_hex_nodelimer(t_serializable_object_to_blob(proposal));
return true;
}
//------------------------------------------------------------------------------------------------------------------------------

View file

@ -876,17 +876,17 @@ std::string wallets_manager::get_fav_offers(const std::list<bc_services::offer_i
#endif
}
std::string wallets_manager::create_ionic_swap_proposal(uint64_t wallet_id, const tools::wallet_public::create_ionic_swap_proposal_request& proposal, std::string& result_proposal_hex)
std::string wallets_manager::create_ionic_swap_proposal(uint64_t wallet_id, const tools::wallet_public::create_ionic_swap_proposal_request& proposal_req, std::string& result_proposal_hex)
{
GET_WALLET_OPT_BY_ID(wallet_id, wo);
try {
currency::account_public_address dest_account = AUTO_VAL_INIT(dest_account);
if (!currency::get_account_address_from_str(dest_account, proposal.destination_add))
if (!currency::get_account_address_from_str(dest_account, proposal_req.destination_add))
{
return API_RETURN_CODE_BAD_ARG;
}
tools::wallet_public ionic_swap_proposal proposal = AUTO_VAL_INIT(proposal);
bool r = wo.w->get()->create_ionic_swap_proposal(proposal.proposal, dest_account, proposal);
tools::wallet_public::ionic_swap_proposal proposal = AUTO_VAL_INIT(proposal);
bool r = wo.w->get()->create_ionic_swap_proposal(proposal_req.proposal_info, dest_account, proposal);
if (!r)
{
return API_RETURN_CODE_FAIL;

View file

@ -81,7 +81,7 @@ bool hard_fork_2_tx_payer_in_wallet::c1(currency::core& c, size_t ev_index, cons
CHECK_AND_ASSERT_MES(refresh_wallet_and_check_balance("", "Bob", bob_wlt, MK_TEST_COINS(12)), false, "");
// wallet RPC server
tools::wallet_rpc_server miner_wlt_rpc(*miner_wlt);
tools::wallet_rpc_server miner_wlt_rpc(miner_wlt);
epee::json_rpc::error je;
tools::wallet_rpc_server::connection_context ctx;
@ -161,7 +161,7 @@ bool hard_fork_2_tx_payer_in_wallet::c1(currency::core& c, size_t ev_index, cons
bob_wlt->callback(std::make_shared<tools::i_wallet2_callback>()); // clear callback
// Before HF2: Bob (auditable address) -> Alice with payer info requested (should NOT put tx_payer or tx_payer_old)
tools::wallet_rpc_server bob_wlt_rpc(*bob_wlt);
tools::wallet_rpc_server bob_wlt_rpc(bob_wlt);
tools::wallet_public::COMMAND_RPC_TRANSFER::request req_c = AUTO_VAL_INIT(req_c);
req_c.destinations.push_back(tools::wallet_public::transfer_destination{ MK_TEST_COINS(1), m_accounts[ALICE_ACC_IDX].get_public_address_str() });
req_c.fee = TESTS_DEFAULT_FEE;
@ -328,7 +328,7 @@ bool hard_fork_2_tx_receiver_in_wallet::c1(currency::core& c, size_t ev_index, c
CHECK_AND_ASSERT_MES(refresh_wallet_and_check_balance("", "Bob", bob_wlt, 0), false, "");
// wallet RPC server
tools::wallet_rpc_server alice_wlt_rpc(*alice_wlt);
tools::wallet_rpc_server alice_wlt_rpc(alice_wlt);
epee::json_rpc::error je;
tools::wallet_rpc_server::connection_context ctx;

View file

@ -31,9 +31,9 @@ bool ionic_swap_basic_test::generate(std::vector<test_event_entry>& events) cons
{
uint64_t ts = test_core_time::get_time();
m_accounts.resize(TOTAL_ACCS_COUNT);
account_base& miner_acc = m_accounts[MINER_ACC_IDX]; miner_acc.generate(); miner_acc.set_createtime(ts);
account_base& alice_acc = m_accounts[ALICE_ACC_IDX]; alice_acc.generate(); alice_acc.set_createtime(ts);
account_base& bob_acc = m_accounts[BOB_ACC_IDX]; bob_acc.generate(); bob_acc.set_createtime(ts);
currency::account_base& miner_acc = m_accounts[MINER_ACC_IDX]; miner_acc.generate(); miner_acc.set_createtime(ts);
currency::account_base& alice_acc = m_accounts[ALICE_ACC_IDX]; alice_acc.generate(); alice_acc.set_createtime(ts);
currency::account_base& bob_acc = m_accounts[BOB_ACC_IDX]; bob_acc.generate(); bob_acc.set_createtime(ts);
//account_base& carol_acc = m_accounts[CAROL_ACC_IDX]; carol_acc.generate(); carol_acc.set_createtime(ts);
MAKE_GENESIS_BLOCK(events, blk_0, miner_acc, ts);
@ -45,7 +45,7 @@ bool ionic_swap_basic_test::generate(std::vector<test_event_entry>& events) cons
return true;
}
bool zarcanum_basic_test::c1(currency::core& c, size_t ev_index, const std::vector<test_event_entry>& events)
bool ionic_swap_basic_test::c1(currency::core& c, size_t ev_index, const std::vector<test_event_entry>& events)
{
bool r = false;
std::shared_ptr<tools::wallet2> miner_wlt = init_playtime_test_wallet(events, c, MINER_ACC_IDX);
@ -58,13 +58,13 @@ bool zarcanum_basic_test::c1(currency::core& c, size_t ev_index, const std::vect
CHECK_AND_ASSERT_MES(!c.get_blockchain_storage().is_hardfork_active(ZANO_HARDFORK_04_ZARCANUM), false, "ZANO_HARDFORK_04_ZARCANUM is active");
account_base alice_acc;
currency::account_base alice_acc;
alice_acc.generate();
std::shared_ptr<tools::wallet2> alice_wlt = init_playtime_test_wallet(events, c, alice_acc);
alice_wlt->get_account().set_createtime(0);
miner_wlt->refresh();
asset_descriptor_base adb = AUTO_VAL_INIT(adb);
currency::asset_descriptor_base adb = AUTO_VAL_INIT(adb);
adb.total_max_supply = 1000000000000000000; //1M coins
adb.full_name = "Test coins";
adb.ticker = "TCT";
@ -73,17 +73,17 @@ bool zarcanum_basic_test::c1(currency::core& c, size_t ev_index, const std::vect
std::vector<currency::tx_destination_entry> destinations(2);
destinations[0].addr.push_back(miner_wlt->get_account().get_public_address());
destinations[0].amount = AMOUNT_ASSETS_TO_TRANSFER_MULTIASSETS_BASIC;
destinations[0].asset_id = currency::ffff_hash;
destinations[0].asset_id = currency::null_pkey;
destinations[1].addr.push_back(alice_wlt->get_account().get_public_address());
destinations[1].amount = AMOUNT_ASSETS_TO_TRANSFER_MULTIASSETS_BASIC;
destinations[1].asset_id = currency::ffff_hash;
destinations[1].asset_id = currency::null_pkey;
LOG_PRINT_MAGENTA("destinations[0].asset_id:" << destinations[0].asset_id, LOG_LEVEL_0);
LOG_PRINT_MAGENTA("destinations[1].asset_id:" << destinations[1].asset_id, LOG_LEVEL_0);
LOG_PRINT_MAGENTA("currency::ffff_hash:" << currency::ffff_hash, LOG_LEVEL_0);
LOG_PRINT_MAGENTA("currency::null_pkey:" << currency::null_pkey, LOG_LEVEL_0);
currency::transaction tx = AUTO_VAL_INIT(tx);
crypto::hash asset_id = currency::null_hash;
crypto::public_key asset_id = currency::null_pkey;
miner_wlt->publish_new_asset(adb, destinations, tx, asset_id);
LOG_PRINT_L0("Published new asset: " << asset_id << ", tx_id: " << currency::get_transaction_hash(tx));
@ -94,11 +94,11 @@ bool zarcanum_basic_test::c1(currency::core& c, size_t ev_index, const std::vect
miner_wlt->refresh();
alice_wlt->refresh();
uint64_t mined = 0;
std::unordered_map<crypto::hash, tools::wallet_public::asset_balance_entry_base> balances;
std::unordered_map<crypto::public_key, tools::wallet_public::asset_balance_entry_base> balances;
miner_wlt->balance(balances, mined);
auto it_asset = balances.find(asset_id);
auto it_native = balances.find(currency::null_hash);
auto it_native = balances.find(currency::native_coin_asset_id);
CHECK_AND_ASSERT_MES(it_asset != balances.end() && it_native != balances.end(), false, "Failed to find needed asset in result balances");
@ -111,7 +111,7 @@ bool zarcanum_basic_test::c1(currency::core& c, size_t ev_index, const std::vect
alice_wlt->balance(balances, mined);
it_asset = balances.find(asset_id);
it_native = balances.find(currency::null_hash);
it_native = balances.find(currency::native_coin_asset_id);
CHECK_AND_ASSERT_MES(it_asset != balances.end(), false, "Failed to find needed asset in result balances");
CHECK_AND_ASSERT_MES(it_native == balances.end(), false, "Failed to find needed asset in result balances");
@ -128,11 +128,11 @@ bool zarcanum_basic_test::c1(currency::core& c, size_t ev_index, const std::vect
proposal_details.from.push_back(view::asset_funds{ asset_id , assets_to_exchange });
proposal_details.to.push_back(view::asset_funds{ currency::null_pkey , native_tokens_to_exchange });
currency::transaction tx_template = AUTO_VAL_INIT(tx_template);
alice_wlt->create_ionic_swap_proposal(proposal_details, miner_wlt->get_account().get_public_address(), tx_template);
tools::wallet_public::ionic_swap_proposal proposal = AUTO_VAL_INIT(proposal);
alice_wlt->create_ionic_swap_proposal(proposal_details, miner_wlt->get_account().get_public_address(), proposal);
view::ionic_swap_proposal_info proposal_decoded_info;
miner_wlt->get_ionic_swap_proposal_info(tx_template, proposal_decoded_info);
miner_wlt->get_ionic_swap_proposal_info(proposal, proposal_decoded_info);
//Validate proposal
if (proposal_decoded_info.from != proposal_details.from || proposal_decoded_info.to != proposal_details.to)
@ -141,7 +141,7 @@ bool zarcanum_basic_test::c1(currency::core& c, size_t ev_index, const std::vect
}
currency::transaction res_tx = AUTO_VAL_INIT(res_tx);
r = miner_wlt->accept_ionic_swap_proposal(tx_template, res_tx);
r = miner_wlt->accept_ionic_swap_proposal(proposal, res_tx);
CHECK_AND_ASSERT_MES(r, false, "Failed to accept ionic proposal");
r = mine_next_pow_blocks_in_playtime(miner_wlt->get_account().get_public_address(), c, CURRENCY_MINED_MONEY_UNLOCK_WINDOW);
@ -155,7 +155,7 @@ bool zarcanum_basic_test::c1(currency::core& c, size_t ev_index, const std::vect
alice_wlt->balance(balances, mined);
it_asset = balances.find(asset_id);
it_native = balances.find(currency::null_hash);
it_native = balances.find(currency::native_coin_asset_id);
CHECK_AND_ASSERT_MES(it_asset != balances.end(), false, "Failed to find needed asset in result balances");
CHECK_AND_ASSERT_MES(it_native->second.total == native_tokens_to_exchange, false, "Failed to find needed asset in result balances");

View file

@ -111,7 +111,7 @@ bool isolate_auditable_and_proof::c1(currency::core& c, size_t ev_index, const s
epee::json_rpc::error je;
tools::wallet_rpc_server::connection_context ctx;
tools::wallet_rpc_server miner_wlt_rpc(*auditable_test_instance);
tools::wallet_rpc_server miner_wlt_rpc(auditable_test_instance);
tools::wallet_public::COMMAND_RPC_GET_RECENT_TXS_AND_INFO::request req = AUTO_VAL_INIT(req);
tools::wallet_public::COMMAND_RPC_GET_RECENT_TXS_AND_INFO::response res = AUTO_VAL_INIT(res);
req.count = 100;

View file

@ -70,14 +70,14 @@ bool multiassets_basic_test::c1(currency::core& c, size_t ev_index, const std::v
std::vector<currency::tx_destination_entry> destinations(2);
destinations[0].addr.push_back(miner_wlt->get_account().get_public_address());
destinations[0].amount = AMOUNT_ASSETS_TO_TRANSFER_MULTIASSETS_BASIC;
destinations[0].asset_id = currency::ffff_pkey;
destinations[0].asset_id = currency::null_pkey;
destinations[1].addr.push_back(alice_wlt->get_account().get_public_address());
destinations[1].amount = AMOUNT_ASSETS_TO_TRANSFER_MULTIASSETS_BASIC;
destinations[1].asset_id = currency::ffff_pkey;
destinations[1].asset_id = currency::null_pkey;
LOG_PRINT_MAGENTA("destinations[0].asset_id:" << destinations[0].asset_id, LOG_LEVEL_0);
LOG_PRINT_MAGENTA("destinations[1].asset_id:" << destinations[1].asset_id, LOG_LEVEL_0);
LOG_PRINT_MAGENTA("currency::ffff_pkey: " << currency::ffff_pkey, LOG_LEVEL_0);
LOG_PRINT_MAGENTA("currency::null_pkey: " << currency::null_pkey, LOG_LEVEL_0);
currency::transaction tx = AUTO_VAL_INIT(tx);
crypto::public_key asset_id = currency::null_pkey;

View file

@ -66,8 +66,9 @@ void transfer_multisig(tools::wallet2& w,
ftp.tx_version = tx_version;
w.prepare_transaction(ctp, ftp, tx);
tools::mode_separate_context emode_separate = AUTO_VAL_INIT(emode_separate);
emode_separate.tx_for_mode_separate = tx;
w.prepare_transaction(ctp, ftp, emode_separate);
crypto::secret_key sk = AUTO_VAL_INIT(sk);
w.finalize_transaction(ftp, tx, sk, false);

View file

@ -28,7 +28,7 @@ bool wallet_rpc_integrated_address::generate(std::vector<test_event_entry>& even
CREATE_TEST_WALLET(miner_wlt, miner_acc, blk_0);
// wallet RPC server
tools::wallet_rpc_server miner_wlt_rpc(*miner_wlt);
tools::wallet_rpc_server miner_wlt_rpc(miner_wlt);
epee::json_rpc::error je;
tools::wallet_rpc_server::connection_context ctx;
@ -110,7 +110,7 @@ bool wallet_rpc_integrated_address_transfer::c1(currency::core& c, size_t ev_ind
std::string alice_integrated_address = get_account_address_and_payment_id_as_str(m_accounts[ALICE_ACC_IDX].get_public_address(), payment_id);
// wallet RPC server
tools::wallet_rpc_server miner_wlt_rpc(*miner_wlt);
tools::wallet_rpc_server miner_wlt_rpc(miner_wlt);
epee::json_rpc::error je;
tools::wallet_rpc_server::connection_context ctx;
@ -226,7 +226,7 @@ bool wallet_rpc_transfer::c1(currency::core& c, size_t ev_index, const std::vect
miner_wlt->refresh();
// wallet RPC server
tools::wallet_rpc_server miner_wlt_rpc(*miner_wlt);
tools::wallet_rpc_server miner_wlt_rpc(miner_wlt);
epee::json_rpc::error je;
tools::wallet_rpc_server::connection_context ctx;