forked from lthn/blockchain
additional error handling for wallet2 and simplewallet
This commit is contained in:
parent
44ed820abe
commit
ba594dd5ac
2 changed files with 12 additions and 0 deletions
|
|
@ -1808,11 +1808,13 @@ bool simple_wallet::deploy_new_asset(const std::vector<std::string> &args)
|
|||
if (!args.size() || args.size() > 1)
|
||||
{
|
||||
fail_msg_writer() << "invalid arguments count: " << args.size() << ", expected 1";
|
||||
return true;
|
||||
}
|
||||
bool r = epee::serialization::load_t_from_json_file(adb, args[0]);
|
||||
if (!r)
|
||||
{
|
||||
fail_msg_writer() << "Failed to load json file with asset specification: " << args[0];
|
||||
return true;
|
||||
}
|
||||
tx_destination_entry td = AUTO_VAL_INIT(td);
|
||||
td.addr.push_back(m_wallet->get_account().get_public_address());
|
||||
|
|
@ -1842,6 +1844,7 @@ bool simple_wallet::add_custom_asset_id(const std::vector<std::string> &args)
|
|||
if (!args.size() || args.size() > 1)
|
||||
{
|
||||
fail_msg_writer() << "invalid arguments count: " << args.size() << ", expected 1";
|
||||
return true;
|
||||
}
|
||||
crypto::public_key asset_id = currency::null_pkey;
|
||||
if (!epee::string_tools::parse_tpod_from_hex_string(args[0], asset_id))
|
||||
|
|
@ -1877,6 +1880,7 @@ bool simple_wallet::generate_ionic_swap_proposal(const std::vector<std::string>
|
|||
if (args.size() != 2)
|
||||
{
|
||||
fail_msg_writer() << "invalid arguments count: " << args.size() << ", expected 1";
|
||||
return true;
|
||||
}
|
||||
|
||||
view::ionic_swap_proposal_info proposal_info = AUTO_VAL_INIT(proposal_info);
|
||||
|
|
@ -1884,6 +1888,7 @@ bool simple_wallet::generate_ionic_swap_proposal(const std::vector<std::string>
|
|||
if (!r)
|
||||
{
|
||||
fail_msg_writer() << "Failed to load json file with asset specification: " << args[0];
|
||||
return true;
|
||||
}
|
||||
currency::account_public_address destination_addr = AUTO_VAL_INIT(destination_addr);
|
||||
currency::payment_id_t integrated_payment_id;
|
||||
|
|
@ -1921,6 +1926,7 @@ bool simple_wallet::get_ionic_swap_proposal_info(const std::vector<std::string>
|
|||
if (args.size() != 1)
|
||||
{
|
||||
fail_msg_writer() << "invalid arguments count: " << args.size() << ", expected 1";
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string raw_proposal;
|
||||
|
|
@ -1953,6 +1959,7 @@ bool simple_wallet::accept_ionic_swap_proposal(const std::vector<std::string> &a
|
|||
if (args.size() != 1)
|
||||
{
|
||||
fail_msg_writer() << "invalid arguments count: " << args.size() << ", expected 1";
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string raw_proposal;
|
||||
|
|
@ -1983,6 +1990,7 @@ bool simple_wallet::remove_custom_asset_id(const std::vector<std::string> &args)
|
|||
if (!args.size() || args.size() > 1)
|
||||
{
|
||||
fail_msg_writer() << "invalid arguments count: " << args.size() << ", expected 1";
|
||||
return true;
|
||||
}
|
||||
crypto::public_key asset_id = currency::null_pkey;
|
||||
if (!epee::string_tools::parse_tpod_from_hex_string(args[0], asset_id))
|
||||
|
|
|
|||
|
|
@ -6712,6 +6712,10 @@ void wallet2::transfer(construct_tx_param& ctp,
|
|||
|
||||
check_and_throw_if_self_directed_tx_with_payment_id_requested(ctp);
|
||||
|
||||
bool asset_operation_requested = count_type_in_variant_container<asset_descriptor_operation>(ctp.extra) != 0;
|
||||
bool dont_have_zero_asset_ids_in_destinations = std::count_if(ctp.dsts.begin(), ctp.dsts.end(), [](const tx_destination_entry& de) { return de.asset_id == null_pkey; }) == 0;
|
||||
WLT_THROW_IF_FALSE_WALLET_CMN_ERR_EX(asset_operation_requested || dont_have_zero_asset_ids_in_destinations, "zero asset id is used errounesly (no asset operation was requested)");
|
||||
|
||||
if (ctp.crypt_address.spend_public_key == currency::null_pkey)
|
||||
{
|
||||
ctp.crypt_address = currency::get_crypt_address_from_destinations(m_account.get_keys(), ctp.dsts);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue