1
0
Fork 0
forked from lthn/blockchain

merged from zarcanum

This commit is contained in:
cryptozoidberg 2022-12-16 15:40:24 +01:00
commit a9eba1d728
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC
14 changed files with 129 additions and 83 deletions

View file

@ -31,7 +31,7 @@
#include <boost/thread.hpp>
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include "net/http_server_cp2.h"
#include "net/http_server_handlers_map2.h"

View file

@ -1,4 +1,4 @@
// Copyright (c) 2019 Zano Project
// Copyright (c) 2019-2022 Zano Project
// Note: class udp_blocking_client is a slightly modified version of an example
// taken from https://www.boost.org/doc/libs/1_53_0/doc/html/boost_asio/example/timeouts/blocking_udp_client.cpp
@ -13,7 +13,7 @@
#include <boost/asio/deadline_timer.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/ip/udp.hpp>
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/array.hpp>
#include <epee/include/misc_log_ex.h>

View file

@ -408,7 +408,7 @@ bool generate_genesis(const std::string& path_config, uint64_t premine_split_amo
ss.str("");
ss.clear();
std::cout << ENDL << "PROOF PHRASE: " << gcp.proof_string << ENDL;
construct_miner_tx(0, 0, 0, 0, 0, destinations, bl.miner_tx, TRANSACTION_VERSION_PRE_HF4, gcp.proof_string, CURRENCY_MINER_TX_MAX_OUTS);
// construct_miner_tx(0, 0, 0, 0, 0, destinations, bl.miner_tx, TRANSACTION_VERSION_PRE_HF4, gcp.proof_string, CURRENCY_MINER_TX_MAX_OUTS); <-- temporarily commented out; this overload needs to be re-implemented -- sowle
currency::blobdata txb = tx_to_blob(bl.miner_tx);
//self validate block

View file

@ -1988,7 +1988,7 @@ namespace currency
{
if (summary_outs_money > summary_inputs_money)
{
LOG_ERROR("Transaction inputs money (" << summary_inputs_money << ") less than outputs money (" << summary_outs_money << ")");
LOG_ERROR("Transaction inputs money (" << print_money_brief(summary_inputs_money) << ") is less than outputs money (" << print_money_brief(summary_outs_money) << ")");
return false;
}
}

View file

@ -67,13 +67,18 @@ namespace currency
if (found)
{
found = true;
const boost::multiprecision::uint256_t d_mp = lhs / (crypto::c_zarcanum_z_coeff_mp * this->stake_amount) + 1;
const boost::multiprecision::uint256_t ba = d_mp * crypto::c_zarcanum_z_coeff_mp * this->stake_amount - lhs;
const boost::multiprecision::uint256_t l_div_z_D = this->z_l_div_z_D / crypto::c_zarcanum_z_coeff_mp;
LOG_PRINT_GREEN("Found Zarcanum kernel: amount: " << currency::print_money_brief(this->stake_amount) << /* ", gindex: " << td.m_global_output_index << */ ENDL
<< "difficulty: " << this->basic_diff << ENDL
<< "kernel info: " << ENDL
<< print_stake_kernel_info(this->sk)
<< "kernel_hash: " << this->kernel_hash << ENDL
<< "lhs: " << lhs << ENDL
<< "rhs: " << rhs
<< "lhs: 0x" << crypto::scalar_t(lhs).to_string_as_hex_number() << " = 0x" << std::hex << d_mp << " * 2^64 * " << this->stake_amount << " - 0x" << std::hex << ba << ENDL
<< "rhs: 0x" << crypto::scalar_t(rhs).to_string_as_hex_number() << ENDL
<< "d: 0x" << std::hex << d_mp << ENDL
<< "l / floor(z * D): 0x" << std::hex << l_div_z_D
, LOG_LEVEL_0);
}

View file

@ -6,7 +6,7 @@
#pragma once
#include <boost/thread.hpp>
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <boost/foreach.hpp>
#include <boost/bimap.hpp>
#include <boost/multi_index_container.hpp>

View file

@ -1242,4 +1242,4 @@ namespace currency
#undef LOG_DEFAULT_CHANNEL
#define LOG_DEFAULT_CHANNEL NULL
#define LOG_DEFAULT_CHANNEL NULL

View file

@ -223,9 +223,9 @@ simple_wallet::simple_wallet()
m_cmd_binder.set_handler("sign_transfer", boost::bind(&simple_wallet::sign_transfer, this,ph::_1), "sign_transfer <unsgined_tx_file> <signed_tx_file> - sign unsigned tx from a watch-only wallet");
m_cmd_binder.set_handler("submit_transfer", boost::bind(&simple_wallet::submit_transfer, this,ph::_1), "submit_transfer <signed_tx_file> - broadcast signed tx");
m_cmd_binder.set_handler("export_history", boost::bind(&simple_wallet::submit_transfer, this,ph::_1), "Export transaction history in CSV file");
m_cmd_binder.set_handler("tor_enable", boost::bind(&simple_wallet::tor_enable, this, _1), "Enable relaying transactions over TOR network(enabled by default)");
m_cmd_binder.set_handler("tor_disable", boost::bind(&simple_wallet::tor_disable, this, _1), "Enable relaying transactions over TOR network(enabled by default)");
m_cmd_binder.set_handler("deploy_new_asset", boost::bind(&simple_wallet::deploy_new_asset, this, _1), "Deploys new asset in the network, with current wallet as a maintainer");
m_cmd_binder.set_handler("tor_enable", boost::bind(&simple_wallet::tor_enable, this, ph::_1), "Enable relaying transactions over TOR network(enabled by default)");
m_cmd_binder.set_handler("tor_disable", boost::bind(&simple_wallet::tor_disable, this, ph::_1), "Enable relaying transactions over TOR network(enabled by default)");
m_cmd_binder.set_handler("deploy_new_asset", boost::bind(&simple_wallet::deploy_new_asset, this, ph::_1), "Deploys new asset in the network, with current wallet as a maintainer");
m_cmd_binder.set_handler("add_custom_asset_id", boost::bind(&simple_wallet::add_custom_asset_id, this, _1), "Approve asset id to be recognized in the wallet and returned in balances");
m_cmd_binder.set_handler("remove_custom_asset_id", boost::bind(&simple_wallet::remove_custom_asset_id, this, _1), "Cancel previously made approval for asset id");
@ -1942,9 +1942,7 @@ bool simple_wallet::sweep_below(const std::vector<std::string> &args)
uint64_t amount_total = 0, amount_swept = 0;
currency::transaction result_tx = AUTO_VAL_INIT(result_tx);
std::string filename = "zano_tx_unsigned";
m_wallet->sweep_below(fake_outs_count, addr, amount, payment_id, fee, outs_total, amount_total, outs_swept, &result_tx, &filename);
if (!get_inputs_money_amount(result_tx, amount_swept))
LOG_ERROR("get_inputs_money_amount failed, tx: " << obj_to_json_str(result_tx));
m_wallet->sweep_below(fake_outs_count, addr, amount, payment_id, fee, outs_total, amount_total, outs_swept, amount_swept, &result_tx, &filename);
success_msg_writer(false) << outs_swept << " outputs (" << print_money_brief(amount_swept) << " coins) of " << outs_total << " total (" << print_money_brief(amount_total)
<< ") below the specified limit of " << print_money_brief(amount) << " were successfully swept";

View file

@ -951,14 +951,14 @@ namespace
bool r = params_array != nullptr && ps.get_next_value(params_array, rate_submit_id_str);
CHECK_AND_ASSERT_MES(r, false, "Incorrect parameters");
struct { uint64_t low, high; } rate_128 = { 0 };
CHECK_AND_ASSERT_MES(pod_from_net_format_reverse(rate_str, rate_128, true), false, "Can't parse rate from " << rate_str);
CHECK_AND_ASSERT_MES(rate_128.high == 0, false, "rate overflow, rate str: " << rate_str);
struct { uint64_t low, high, higher, highest; } rate_256 = { 0 }; // this will allow any length of data from 64 to 256 bits (helpful for odd miners)
CHECK_AND_ASSERT_MES(pod_from_net_format_reverse(rate_str, rate_256, true), false, "Can't parse rate from " << rate_str);
CHECK_AND_ASSERT_MES(rate_256.high == 0 && rate_256.higher == 0 && rate_256.highest == 0, false, "rate overflow, rate str: " << rate_str);
crypto::hash rate_submit_id = null_hash;
CHECK_AND_ASSERT_MES(pod_from_net_format(rate_submit_id_str, rate_submit_id), false, "Can't parse rate_submit_id from " << rate_submit_id_str);
m_last_reported_hashrate = rate_128.low;
return m_config.handle_submit_hashrate(this, rate_128.low, rate_submit_id);
m_last_reported_hashrate = rate_256.low;
return m_config.handle_submit_hashrate(this, rate_256.low, rate_submit_id);
}
bool handle_method_eth_submitWork(const jsonrpc_id_t& id, epee::serialization::portable_storage& ps, epee::serialization::portable_storage::hsection params_section)

View file

@ -499,7 +499,7 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t
uint64_t max_out_unlock_time = 0;
std::vector<wallet_out_info> outs;
uint64_t tx_money_got_in_outs = 0;
uint64_t tx_money_got_in_outs = 0; // TODO: @#@# correctly calculate tx_money_got_in_outs for post-HF4
crypto::public_key tx_pub_key = null_pkey;
bool r = parse_and_validate_tx_extra(tx, tx_pub_key);
THROW_IF_TRUE_WALLET_EX(!r, error::tx_extra_parse_error, tx);
@ -5021,7 +5021,6 @@ bool wallet2::prepare_tx_sources(size_t fake_outputs_count, std::vector<currency
//size_t real_index = src.outputs.size() ? (rand() % src.outputs.size() ):0;
tx_output_entry real_oe = AUTO_VAL_INIT(real_oe);
real_oe.out_reference = td.m_global_output_index; // TODO: use ref_by_id when neccessary
//@#@
VARIANT_SWITCH_BEGIN(td.m_ptx_wallet_info->m_tx.vout[td.m_internal_output_index]);
VARIANT_CASE_CONST(tx_out_bare, o)
{
@ -5509,23 +5508,25 @@ bool wallet2::is_transfer_able_to_go(const transfer_details& td, uint64_t fake_o
{
if (!td.is_spendable())
return false;
VARIANT_SWITCH_BEGIN(td.m_ptx_wallet_info->m_tx.vout[td.m_internal_output_index]);
VARIANT_CASE_CONST(tx_out_bare, o);
const tx_out_v &out_v = td.m_ptx_wallet_info->m_tx.vout[td.m_internal_output_index];
uint8_t mix_attr = CURRENCY_TO_KEY_OUT_RELAXED;
if (get_mix_attr_from_tx_out_v(out_v, mix_attr))
{
if (!currency::is_mixattr_applicable_for_fake_outs_counter(mix_attr, fake_outputs_count))
return false;
}
VARIANT_SWITCH_BEGIN(out_v);
VARIANT_CASE_CONST(tx_out_bare, o);
if (o.target.type() == typeid(txout_htlc))
{
if (fake_outputs_count != 0)
return false;
}
else
{
if (!currency::is_mixattr_applicable_for_fake_outs_counter(boost::get<currency::txout_to_key>(o.target).mix_attr, fake_outputs_count))
return false;
}
}
VARIANT_CASE_CONST(tx_out_zarcanum, o);
//@#@
VARIANT_SWITCH_END();
return true;
}
//----------------------------------------------------------------------------------------------------
@ -5758,6 +5759,9 @@ void wallet2::print_source_entry(std::stringstream& output, const currency::tx_s
<< ", real_output: " << src.real_output
<< ", real_output_in_tx_index: " << src.real_output_in_tx_index
<< ", indexes: " << ss.str();
if (src.asset_id != currency::null_hash)
output << ", asset_id: " << print16(src.asset_id);
}
//----------------------------------------------------------------------------------------------------
bool wallet2::get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key) const
@ -5785,15 +5789,25 @@ void wallet2::prepare_tx_destinations(const assets_selection_context& needed_mon
prepare_tx_destinations(el.second.needed_amount, el.second.found_amount, destination_split_strategy_id, dust_policy, dsts, final_destinations, el.first);
}
if (is_in_hardfork_zone(ZANO_HARDFORK_04_ZARCANUM) && final_destinations.size() < CURRENCY_TX_MIN_ALLOWED_OUTS)
if (is_in_hardfork_zone(ZANO_HARDFORK_04_ZARCANUM))
{
// special case for asset minting destinations
for (auto& dst : dsts)
if (dst.asset_id == currency::ffff_hash)
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
tx_destination_entry de = final_destinations.back();
final_destinations.pop_back();
size_t items_to_be_added = CURRENCY_TX_MIN_ALLOWED_OUTS - final_destinations.size();
decompose_amount_randomly(de.amount, [&](uint64_t amount){ de.amount = amount; final_destinations.push_back(de); }, items_to_be_added);
WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(final_destinations.size() == CURRENCY_TX_MIN_ALLOWED_OUTS,
"can't get necessary number of outputs using decompose_amount_randomly(), got " << final_destinations.size() << " while mininum is " << CURRENCY_TX_MIN_ALLOWED_OUTS);
if (final_destinations.size() > 0 && final_destinations.size() < CURRENCY_TX_MIN_ALLOWED_OUTS)
{
tx_destination_entry de = final_destinations.back();
final_destinations.pop_back();
size_t items_to_be_added = CURRENCY_TX_MIN_ALLOWED_OUTS - final_destinations.size();
// TODO: consider allowing to set them somewhere
size_t num_digits_to_keep = CURRENCY_TX_OUTS_RND_SPLIT_DIGITS_TO_KEEP;
decompose_amount_randomly(de.amount, [&](uint64_t amount){ de.amount = amount; final_destinations.push_back(de); }, items_to_be_added, num_digits_to_keep);
WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(final_destinations.size() == CURRENCY_TX_MIN_ALLOWED_OUTS,
"can't get necessary number of outputs using decompose_amount_randomly(), got " << final_destinations.size() << " while mininum is " << CURRENCY_TX_MIN_ALLOWED_OUTS);
}
}
}
//----------------------------------------------------------------------------------------------------
@ -5802,34 +5816,39 @@ void wallet2::prepare_tx_destinations(uint64_t needed_money,
detail::split_strategy_id_t destination_split_strategy_id,
const tx_dust_policy& dust_policy,
const std::vector<currency::tx_destination_entry>& dsts,
std::vector<currency::tx_destination_entry>& final_detinations, const crypto::hash& asset_id)
std::vector<currency::tx_destination_entry>& final_destinations, const crypto::hash& asset_id)
{
currency::tx_destination_entry change_dts = AUTO_VAL_INIT(change_dts);
if (needed_money < found_money)
{
change_dts.addr.push_back(m_account.get_keys().account_address);
change_dts.amount = found_money - needed_money;
change_dts.asset_id = asset_id;
}
WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(found_money >= needed_money, "needed_money==" << needed_money << " < found_money==" << found_money);
if (asset_id != currency::null_hash)
if (is_in_hardfork_zone(ZANO_HARDFORK_04_ZARCANUM))
{
if (change_dts.amount)
for(auto& dst : dsts)
{
final_detinations.push_back(change_dts);
if (dst.asset_id == asset_id)
final_destinations.emplace_back(dst.amount, dst.addr, dst.asset_id);
}
return;
if (found_money > needed_money)
final_destinations.emplace_back(found_money - needed_money, m_account.get_public_address(), asset_id); // returning back the change
}
uint64_t dust = 0;
bool r = detail::apply_split_strategy_by_id(destination_split_strategy_id, dsts, change_dts, dust_policy.dust_threshold, final_detinations, dust, WALLET_MAX_ALLOWED_OUTPUT_AMOUNT);
WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(r, "invalid split strategy id: " << destination_split_strategy_id);
WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(dust_policy.dust_threshold >= dust, "invalid dust value: dust = " << dust << ", dust_threshold = " << dust_policy.dust_threshold);
if (0 != dust && !dust_policy.add_to_fee)
else
{
final_detinations.push_back(currency::tx_destination_entry(dust, dust_policy.addr_for_dust));
final_detinations.back().asset_id = asset_id;
// pre-HF4
WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(asset_id == currency::null_hash, "assets are not allowed prior to HF4");
currency::tx_destination_entry change_dts = AUTO_VAL_INIT(change_dts);
if (needed_money < found_money)
{
change_dts.addr.push_back(m_account.get_keys().account_address);
change_dts.amount = found_money - needed_money;
}
uint64_t dust = 0;
bool r = detail::apply_split_strategy_by_id(destination_split_strategy_id, dsts, change_dts, dust_policy.dust_threshold, final_destinations, dust, WALLET_MAX_ALLOWED_OUTPUT_AMOUNT);
WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(r, "invalid split strategy id: " << destination_split_strategy_id);
WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(dust_policy.dust_threshold >= dust, "invalid dust value: dust = " << dust << ", dust_threshold = " << dust_policy.dust_threshold);
if (0 != dust && !dust_policy.add_to_fee)
{
final_destinations.emplace_back(dust, dust_policy.addr_for_dust);
}
}
}
//----------------------------------------------------------------------------------------------------
@ -6154,7 +6173,7 @@ void wallet2::transfer(construct_tx_param& ctp,
}
//----------------------------------------------------------------------------------------------------
void wallet2::sweep_below(size_t fake_outs_count, const currency::account_public_address& destination_addr, uint64_t threshold_amount, const currency::payment_id_t& payment_id,
uint64_t fee, size_t& outs_total, uint64_t& amount_total, size_t& outs_swept, currency::transaction* p_result_tx /* = nullptr */, std::string* p_filename_or_unsigned_tx_blob_str /* = nullptr */)
uint64_t fee, size_t& outs_total, uint64_t& amount_total, size_t& outs_swept, uint64_t& amount_swept, currency::transaction* p_result_tx /* = nullptr */, std::string* p_filename_or_unsigned_tx_blob_str /* = nullptr */)
{
static const size_t estimated_bytes_per_input = 78;
const size_t estimated_max_inputs = static_cast<size_t>(CURRENCY_MAX_TRANSACTION_BLOB_SIZE / (estimated_bytes_per_input * (fake_outs_count + 1.5))); // estimated number of maximum tx inputs under the tx size limit
@ -6164,6 +6183,7 @@ void wallet2::sweep_below(size_t fake_outs_count, const currency::account_public
outs_total = 0;
amount_total = 0;
outs_swept = 0;
amount_swept = 0;
std::vector<uint64_t> selected_transfers;
selected_transfers.reserve(m_transfers.size());
@ -6198,10 +6218,11 @@ void wallet2::sweep_below(size_t fake_outs_count, const currency::account_public
if (fake_outs_count > 0)
{
COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::request req = AUTO_VAL_INIT(req);
req.height_upper_limit = m_last_pow_block_h;
req.use_forced_mix_outs = false;
req.decoys_count = fake_outs_count + 1;
for (uint64_t i : selected_transfers)
req.amounts.push_back(m_transfers[i].amount());
req.amounts.push_back(m_transfers[i].is_zc() ? 0 : m_transfers[i].m_amount);
r = m_core_proxy->call_COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS(req, rpc_get_random_outs_resp);
@ -6268,16 +6289,14 @@ void wallet2::sweep_below(size_t fake_outs_count, const currency::account_public
{
if (td.m_global_output_index == daemon_oe.global_amount_index)
continue;
tx_output_entry oe = AUTO_VAL_INIT(oe);
oe.out_reference = daemon_oe.global_amount_index;
oe.stealth_address = daemon_oe.stealth_address;
src.outputs.push_back(oe);
src.outputs.emplace_back(daemon_oe.global_amount_index, daemon_oe.stealth_address, daemon_oe.concealing_point, daemon_oe.amount_commitment);
if (src.outputs.size() >= fake_outs_count)
break;
}
}
// insert real output into src.outputs
// TODO: bad design, we need to get rid of code duplicates below -- sowle
auto it_to_insert = std::find_if(src.outputs.begin(), src.outputs.end(), [&](const tx_output_entry& a)
{
if (a.out_reference.type().hash_code() == typeid(uint64_t).hash_code())
@ -6285,17 +6304,32 @@ void wallet2::sweep_below(size_t fake_outs_count, const currency::account_public
return false; // TODO: implement deterministics real output placement in case there're ref_by_id outs
});
tx_output_entry real_oe = AUTO_VAL_INIT(real_oe);
real_oe.out_reference = td.m_global_output_index;
//@#@
if(td.m_ptx_wallet_info->m_tx.vout[td.m_internal_output_index].type() != typeid(tx_out_bare))
continue;
const tx_out_bare& out_b = boost::get<tx_out_bare>(td.m_ptx_wallet_info->m_tx.vout[td.m_internal_output_index]);
real_oe.stealth_address = boost::get<txout_to_key>(out_b.target).key;
auto inserted_it = src.outputs.insert(it_to_insert, real_oe);
txout_ref_v out_reference = td.m_global_output_index; // TODO: use ref_by_id when neccessary
std::vector<tx_output_entry>::iterator interted_it = src.outputs.end();
VARIANT_SWITCH_BEGIN(td.m_ptx_wallet_info->m_tx.vout[td.m_internal_output_index]);
VARIANT_CASE_CONST(tx_out_bare, o)
{
VARIANT_SWITCH_BEGIN(o.target);
VARIANT_CASE_CONST(txout_to_key, o)
interted_it = src.outputs.emplace(it_to_insert, out_reference, o.key);
VARIANT_CASE_CONST(txout_htlc, htlc)
interted_it = src.outputs.emplace(it_to_insert, out_reference, htlc.pkey_refund);
VARIANT_CASE_OTHER()
{
WLT_THROW_IF_FALSE_WITH_CODE(false,
"Internal error: unexpected type of target: " << o.target.type().name(),
API_RETURN_CODE_INTERNAL_ERROR);
}
VARIANT_SWITCH_END();
}
VARIANT_CASE_CONST(tx_out_zarcanum, o);
interted_it = src.outputs.emplace(it_to_insert, out_reference, o.stealth_address, o.concealing_point, o.amount_commitment);
WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(td.m_opt_blinding_mask, "m_opt_blinding_mask is null, transfer index: " << tr_index << ", amount: " << print_money_brief(td.amount()));
src.real_out_amount_blinding_mask = *td.m_opt_blinding_mask;
VARIANT_SWITCH_END();
src.real_out_tx_key = get_tx_pub_key_from_extra(td.m_ptx_wallet_info->m_tx);
src.real_output = inserted_it - src.outputs.begin();
src.real_output = interted_it - src.outputs.begin();
src.real_output_in_tx_index = td.m_internal_output_index;
//detail::print_source_entry(src);
}
if (amount_swept <= fee)
@ -6324,7 +6358,6 @@ void wallet2::sweep_below(size_t fake_outs_count, const currency::account_public
};
size_t st_index_upper_boundary = std::min(selected_transfers.size(), estimated_max_inputs);
uint64_t amount_swept = 0;
try_construct_result_t res = try_construct_tx(st_index_upper_boundary, ftp, amount_swept);
WLT_THROW_IF_FALSE_WALLET_CMN_ERR_EX(res != rc_too_few_outputs, st_index_upper_boundary << " biggest unspent outputs have total amount of " << print_money_brief(amount_swept)

View file

@ -714,7 +714,7 @@ namespace tools
void submit_transfer_files(const std::string& signed_tx_file, currency::transaction& tx);
void sweep_below(size_t fake_outs_count, const currency::account_public_address& destination_addr, uint64_t threshold_amount, const currency::payment_id_t& payment_id,
uint64_t fee, size_t& outs_total, uint64_t& amount_total, size_t& outs_swept, currency::transaction* p_result_tx = nullptr, std::string* p_filename_or_unsigned_tx_blob_str = nullptr);
uint64_t fee, size_t& outs_total, uint64_t& amount_total, size_t& outs_swept, uint64_t& amount_swept, currency::transaction* p_result_tx = nullptr, std::string* p_filename_or_unsigned_tx_blob_str = nullptr);
bool get_transfer_address(const std::string& adr_str, currency::account_public_address& addr, std::string& payment_id);
inline uint64_t get_blockchain_current_size() const {

View file

@ -438,8 +438,19 @@ namespace tools
for (size_t i = 0; i < m_sources.size(); ++i)
{
const currency::tx_source_entry& src = m_sources[i];
ss << "\n source " << i << ":";
ss << "\n amount: " << currency::print_money(src.amount);
ss << "\n " << i << ": ";
ss << " amount: " << std::setw(21) << currency::print_money(src.amount);
ss << (src.is_zarcanum() ? " ZC " : " old ");
ss << " asset_id: " << src.asset_id;
for (size_t j = 0; j < src.outputs.size(); ++j)
{
const currency::tx_source_entry::output_entry& out = src.outputs[j];
if (out.out_reference.type() == typeid(uint64_t))
ss << "\n ref #" << j << ": " << boost::get<uint64_t>(out.out_reference);
else
ss << "\n ref #" << j << ": ref by id";
}
// It's not good, if logs will contain such much data
//ss << "\n real_output: " << src.real_output;
//ss << "\n real_output_in_tx_index: " << src.real_output_in_tx_index;
@ -462,7 +473,7 @@ namespace tools
{
ss << currency::get_account_address_as_str(a) << ";";
}
ss << " anount: " << currency::print_money(dst.amount);
ss << " amount: " << std::setw(21) << currency::print_money(dst.amount);
ss << " asset_id: " << dst.asset_id;
}

View file

@ -620,9 +620,8 @@ namespace tools
uint64_t amount_total = 0, amount_swept = 0;
std::string unsigned_tx_blob_str;
m_wallet.sweep_below(req.mixin, addr, req.amount, payment_id, req.fee, outs_total, amount_total, outs_swept, &tx, &unsigned_tx_blob_str);
m_wallet.sweep_below(req.mixin, addr, req.amount, payment_id, req.fee, outs_total, amount_total, outs_swept, amount_swept, &tx, &unsigned_tx_blob_str);
get_inputs_money_amount(tx, amount_swept);
res.amount_swept = amount_swept;
res.amount_total = amount_total;
res.outs_swept = outs_swept;

View file

@ -306,7 +306,7 @@ void run_emulation(const std::string& path)
perform_simulation_for_function(timestamp_to_hashrate, current_index, blocks, result_blocks, \
[&](std::vector<uint64_t>& timestamps, std::vector<currency::wide_difficulty_type>& cumulative_difficulties, size_t target_seconds) \
{ \
return func_name(timestamps, cumulative_difficulties, target_seconds); \
return func_name(timestamps, cumulative_difficulties, target_seconds, DIFFICULTY_POW_STARTER); \
}); \
current_index+=2;