aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cryptonote_core/cryptonote_format_utils.cpp1
-rw-r--r--src/cryptonote_core/cryptonote_format_utils.h4
-rw-r--r--src/simplewallet/simplewallet.cpp82
-rw-r--r--src/simplewallet/simplewallet.h2
-rw-r--r--src/wallet/api/wallet.cpp5
-rw-r--r--src/wallet/api/wallet.h1
-rw-r--r--src/wallet/wallet2.cpp81
-rw-r--r--src/wallet/wallet2.h26
-rw-r--r--src/wallet/wallet2_api.h6
9 files changed, 180 insertions, 28 deletions
diff --git a/src/cryptonote_core/cryptonote_format_utils.cpp b/src/cryptonote_core/cryptonote_format_utils.cpp
index 234422e3d..d88f66e3b 100644
--- a/src/cryptonote_core/cryptonote_format_utils.cpp
+++ b/src/cryptonote_core/cryptonote_format_utils.cpp
@@ -480,6 +480,7 @@ namespace cryptonote
tx.extra = extra;
keypair txkey = keypair::generate();
+ remove_field_from_tx_extra(tx.extra, typeid(tx_extra_pub_key));
add_tx_pub_key_to_extra(tx, txkey.pub);
tx_key = txkey.sec;
diff --git a/src/cryptonote_core/cryptonote_format_utils.h b/src/cryptonote_core/cryptonote_format_utils.h
index d5dd6494d..9f9ed8625 100644
--- a/src/cryptonote_core/cryptonote_format_utils.h
+++ b/src/cryptonote_core/cryptonote_format_utils.h
@@ -93,9 +93,9 @@ namespace cryptonote
bool construct_tx_and_get_tx_key(const account_keys& sender_account_keys, const std::vector<tx_source_entry>& sources, const std::vector<tx_destination_entry>& destinations, std::vector<uint8_t> extra, transaction& tx, uint64_t unlock_time, crypto::secret_key &tx_key, bool rct = false);
template<typename T>
- bool find_tx_extra_field_by_type(const std::vector<tx_extra_field>& tx_extra_fields, T& field)
+ bool find_tx_extra_field_by_type(const std::vector<tx_extra_field>& tx_extra_fields, T& field, size_t index = 0)
{
- auto it = std::find_if(tx_extra_fields.begin(), tx_extra_fields.end(), [](const tx_extra_field& f) { return typeid(T) == f.type(); });
+ auto it = std::find_if(tx_extra_fields.begin(), tx_extra_fields.end(), [&index](const tx_extra_field& f) { return typeid(T) == f.type() && !index--; });
if(tx_extra_fields.end() == it)
return false;
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 3190c0496..515fc5b22 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -280,7 +280,8 @@ std::string simple_wallet::get_commands_str()
bool simple_wallet::viewkey(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
{
// don't log
- std::cout << string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_view_secret_key) << std::endl;
+ std::cout << "secret: " << string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_view_secret_key) << std::endl;
+ std::cout << "public: " << string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_account_address.m_view_public_key) << std::endl;
return true;
}
@@ -288,7 +289,8 @@ bool simple_wallet::viewkey(const std::vector<std::string> &args/* = std::vector
bool simple_wallet::spendkey(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
{
// don't log
- std::cout << string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_spend_secret_key) << std::endl;
+ std::cout << "secret: " << string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_spend_secret_key) << std::endl;
+ std::cout << "public: " << string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_account_address.m_spend_public_key) << std::endl;
return true;
}
@@ -1738,18 +1740,23 @@ bool simple_wallet::show_incoming_transfers(const std::vector<std::string>& args
bool filter = false;
bool available = false;
- if (!args.empty())
+ bool verbose = false;
+ for (const auto &arg: args)
{
- if (args[0] == "available")
+ if (arg == "available")
{
filter = true;
available = true;
}
- else if (args[0] == "unavailable")
+ else if (arg == "unavailable")
{
filter = true;
available = false;
}
+ else if (arg == "verbose")
+ {
+ verbose = true;
+ }
}
tools::wallet2::transfer_container transfers;
@@ -1762,17 +1769,24 @@ bool simple_wallet::show_incoming_transfers(const std::vector<std::string>& args
{
if (!transfers_found)
{
- message_writer() << boost::format("%21s%8s%12s%8s%16s%68s") % tr("amount") % tr("spent") % tr("unlocked") % tr("ringct") % tr("global index") % tr("tx id");
+ std::string verbose_string;
+ if (verbose)
+ verbose_string = (boost::format("%68s%68s") % tr("pubkey") % tr("key image")).str();
+ message_writer() << boost::format("%21s%8s%12s%8s%16s%68s%s") % tr("amount") % tr("spent") % tr("unlocked") % tr("ringct") % tr("global index") % tr("tx id") % verbose_string;
transfers_found = true;
}
+ std::string verbose_string;
+ if (verbose)
+ verbose_string = (boost::format("%68s%68s") % td.get_public_key() % (td.m_key_image_known ? epee::string_tools::pod_to_hex(td.m_key_image) : std::string('?', 64))).str();
message_writer(td.m_spent ? epee::log_space::console_color_magenta : epee::log_space::console_color_green, false) <<
- boost::format("%21s%8s%12s%8s%16u%68s") %
+ boost::format("%21s%8s%12s%8s%16u%68s%s") %
print_money(td.amount()) %
(td.m_spent ? tr("T") : tr("F")) %
(m_wallet->is_transfer_unlocked(td) ? tr("unlocked") : tr("locked")) %
(td.is_rct() ? tr("RingCT") : tr("-")) %
td.m_global_output_index %
- td.m_txid;
+ td.m_txid %
+ verbose_string;
}
}
@@ -2163,12 +2177,16 @@ bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::stri
// if more than one tx necessary, prompt user to confirm
if (m_wallet->always_confirm_transfers() || ptx_vector.size() > 1)
{
+ uint64_t total_sent = 0;
uint64_t total_fee = 0;
uint64_t dust_not_in_fee = 0;
uint64_t dust_in_fee = 0;
for (size_t n = 0; n < ptx_vector.size(); ++n)
{
total_fee += ptx_vector[n].fee;
+ for (auto i: ptx_vector[n].selected_transfers)
+ total_sent += m_wallet->get_transfer_details(i).amount();
+ total_sent -= ptx_vector[n].change_dts.amount + ptx_vector[n].fee;
if (ptx_vector[n].dust_added_to_fee)
dust_in_fee += ptx_vector[n].dust;
@@ -2177,6 +2195,7 @@ bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::stri
}
std::stringstream prompt;
+ prompt << boost::format(tr("Sending %s. ")) % print_money(total_sent);
if (ptx_vector.size() > 1)
{
prompt << boost::format(tr("Your transaction needs to be split into %llu transactions. "
@@ -2760,7 +2779,7 @@ bool simple_wallet::sweep_all(const std::vector<std::string> &args_)
return true;
}
//----------------------------------------------------------------------------------------------------
-bool simple_wallet::accept_loaded_tx(const std::function<size_t()> get_num_txes, const std::function<const tools::wallet2::tx_construction_data&(size_t)> &get_tx)
+bool simple_wallet::accept_loaded_tx(const std::function<size_t()> get_num_txes, const std::function<const tools::wallet2::tx_construction_data&(size_t)> &get_tx, const std::string &extra_message)
{
// gather info to ask the user
uint64_t amount = 0, amount_to_dests = 0, change = 0;
@@ -2801,7 +2820,12 @@ bool simple_wallet::accept_loaded_tx(const std::function<size_t()> get_num_txes,
fail_msg_writer() << tr("Claimed change is larger than payment to the change address");
return false;
}
- change = cd.change_dts.amount;
+ if (memcmp(&cd.change_dts.addr, &get_tx(0).change_dts.addr, sizeof(cd.change_dts.addr)))
+ {
+ fail_msg_writer() << tr("Change does to more than one address");
+ return false;
+ }
+ change += cd.change_dts.amount;
it->second -= cd.change_dts.amount;
if (it->second == 0)
dests.erase(get_account_address_as_str(m_wallet->testnet(), cd.change_dts.addr));
@@ -2818,20 +2842,35 @@ bool simple_wallet::accept_loaded_tx(const std::function<size_t()> get_num_txes,
if (dest_string.empty())
dest_string = tr("with no destinations");
+ std::string change_string;
+ if (change > 0)
+ {
+ std::string address = get_account_address_as_str(m_wallet->testnet(), get_tx(0).change_dts.addr);
+ change_string += (boost::format(tr("%s change to %s")) % print_money(change) % address).str();
+ }
+ else
+ change_string += tr("no change");
+
uint64_t fee = amount - amount_to_dests;
- std::string prompt_str = (boost::format(tr("Loaded %lu transactions, for %s, fee %s, change %s, %s, with min mixin %lu. Is this okay? (Y/Yes/N/No)")) % (unsigned long)get_num_txes() % print_money(amount) % print_money(fee) % print_money(change) % dest_string % (unsigned long)min_mixin).str();
+ std::string prompt_str = (boost::format(tr("Loaded %lu transactions, for %s, fee %s, %s, %s, with min mixin %lu. %sIs this okay? (Y/Yes/N/No)")) % (unsigned long)get_num_txes() % print_money(amount) % print_money(fee) % dest_string % change_string % (unsigned long)min_mixin % extra_message).str();
std::string accepted = command_line::input_line(prompt_str);
return is_it_true(accepted);
}
//----------------------------------------------------------------------------------------------------
bool simple_wallet::accept_loaded_tx(const tools::wallet2::unsigned_tx_set &txs)
{
- return accept_loaded_tx([&txs](){return txs.txes.size();}, [&txs](size_t n)->const tools::wallet2::tx_construction_data&{return txs.txes[n];});
+ std::string extra_message;
+ if (!txs.transfers.empty())
+ extra_message = (boost::format("%u outputs to import. ") % (unsigned)txs.transfers.size()).str();
+ return accept_loaded_tx([&txs](){return txs.txes.size();}, [&txs](size_t n)->const tools::wallet2::tx_construction_data&{return txs.txes[n];}, extra_message);
}
//----------------------------------------------------------------------------------------------------
bool simple_wallet::accept_loaded_tx(const tools::wallet2::signed_tx_set &txs)
{
- return accept_loaded_tx([&txs](){return txs.ptx.size();}, [&txs](size_t n)->const tools::wallet2::tx_construction_data&{return txs.ptx[n].construction_data;});
+ std::string extra_message;
+ if (!txs.key_images.empty())
+ extra_message = (boost::format("%u key images to import. ") % (unsigned)txs.key_images.size()).str();
+ return accept_loaded_tx([&txs](){return txs.ptx.size();}, [&txs](size_t n)->const tools::wallet2::tx_construction_data&{return txs.ptx[n].construction_data;}, extra_message);
}
//----------------------------------------------------------------------------------------------------
bool simple_wallet::sign_transfer(const std::vector<std::string> &args_)
@@ -2842,9 +2881,10 @@ bool simple_wallet::sign_transfer(const std::vector<std::string> &args_)
return true;
}
+ std::vector<tools::wallet2::pending_tx> ptx;
try
{
- bool r = m_wallet->sign_tx("unsigned_monero_tx", "signed_monero_tx", [&](const tools::wallet2::unsigned_tx_set &tx){ return accept_loaded_tx(tx); });
+ bool r = m_wallet->sign_tx("unsigned_monero_tx", "signed_monero_tx", ptx, [&](const tools::wallet2::unsigned_tx_set &tx){ return accept_loaded_tx(tx); });
if (!r)
{
fail_msg_writer() << tr("Failed to sign transaction");
@@ -2857,7 +2897,14 @@ bool simple_wallet::sign_transfer(const std::vector<std::string> &args_)
return true;
}
- success_msg_writer(true) << tr("Transaction successfully signed to file: ") << "signed_monero_tx";
+ std::string txids_as_text;
+ for (const auto &t: ptx)
+ {
+ if (!txids_as_text.empty())
+ txids_as_text += (", ");
+ txids_as_text += epee::string_tools::pod_to_hex(get_transaction_hash(t.tx));
+ }
+ success_msg_writer(true) << tr("Transaction successfully signed to file ") << "signed_monero_tx" << ", txid " << txids_as_text;
return true;
}
//----------------------------------------------------------------------------------------------------
@@ -2879,12 +2926,16 @@ bool simple_wallet::submit_transfer(const std::vector<std::string> &args_)
// if more than one tx necessary, prompt user to confirm
if (m_wallet->always_confirm_transfers())
{
+ uint64_t total_sent = 0;
uint64_t total_fee = 0;
uint64_t dust_not_in_fee = 0;
uint64_t dust_in_fee = 0;
for (size_t n = 0; n < ptx_vector.size(); ++n)
{
total_fee += ptx_vector[n].fee;
+ for (auto i: ptx_vector[n].selected_transfers)
+ total_sent += m_wallet->get_transfer_details(i).amount();
+ total_sent -= ptx_vector[n].change_dts.amount + ptx_vector[n].fee;
if (ptx_vector[n].dust_added_to_fee)
dust_in_fee += ptx_vector[n].dust;
@@ -2893,6 +2944,7 @@ bool simple_wallet::submit_transfer(const std::vector<std::string> &args_)
}
std::stringstream prompt;
+ prompt << boost::format(tr("Sending %s. ")) % print_money(total_sent);
if (ptx_vector.size() > 1)
{
prompt << boost::format(tr("Your transaction needs to be split into %llu transactions. "
diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h
index 4fe1b0417..0d83f429b 100644
--- a/src/simplewallet/simplewallet.h
+++ b/src/simplewallet/simplewallet.h
@@ -155,7 +155,7 @@ namespace cryptonote
uint64_t get_daemon_blockchain_height(std::string& err);
bool try_connect_to_daemon(bool silent = false);
bool ask_wallet_create_if_needed();
- bool accept_loaded_tx(const std::function<size_t()> get_num_txes, const std::function<const tools::wallet2::tx_construction_data&(size_t)> &get_tx);
+ bool accept_loaded_tx(const std::function<size_t()> get_num_txes, const std::function<const tools::wallet2::tx_construction_data&(size_t)> &get_tx, const std::string &extra_message = std::string());
bool accept_loaded_tx(const tools::wallet2::unsigned_tx_set &txs);
bool accept_loaded_tx(const tools::wallet2::signed_tx_set &txs);
bool get_address_from_str(const std::string &str, cryptonote::account_public_address &address, bool &has_payment_id, crypto::hash8 &payment_id);
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp
index 134ea601c..d21d8b900 100644
--- a/src/wallet/api/wallet.cpp
+++ b/src/wallet/api/wallet.cpp
@@ -469,7 +469,10 @@ uint64_t WalletImpl::blockChainHeight() const
{
return m_wallet->get_blockchain_current_height();
}
-
+uint64_t WalletImpl::approximateBlockChainHeight() const
+{
+ return m_wallet->get_approximate_blockchain_height();
+}
uint64_t WalletImpl::daemonBlockChainHeight() const
{
std::string err;
diff --git a/src/wallet/api/wallet.h b/src/wallet/api/wallet.h
index 372d6efd7..02a46da8c 100644
--- a/src/wallet/api/wallet.h
+++ b/src/wallet/api/wallet.h
@@ -76,6 +76,7 @@ public:
uint64_t balance() const;
uint64_t unlockedBalance() const;
uint64_t blockChainHeight() const;
+ uint64_t approximateBlockChainHeight() const;
uint64_t daemonBlockChainHeight() const;
uint64_t daemonBlockChainTargetHeight() const;
bool synchronized() const;
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 02346e0eb..15a134257 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -631,11 +631,16 @@ void wallet2::process_new_transaction(const cryptonote::transaction& tx, const s
}
// Don't try to extract tx public key if tx has no ouputs
- if (!tx.vout.empty())
+ size_t pk_index = 0;
+ while (!tx.vout.empty())
{
+ // if tx.vout is not empty, we loop through all tx pubkeys
+
tx_extra_pub_key pub_key_field;
- if(!find_tx_extra_field_by_type(tx_extra_fields, pub_key_field))
+ if(!find_tx_extra_field_by_type(tx_extra_fields, pub_key_field, pk_index++))
{
+ if (pk_index > 1)
+ break;
LOG_PRINT_L0("Public key wasn't found in the transaction extra. Skipping transaction " << txid());
if(0 != m_callback)
m_callback->on_skip_transaction(height, tx);
@@ -2004,6 +2009,19 @@ crypto::secret_key wallet2::generate(const std::string& wallet_, const std::stri
m_account_public_address = m_account.get_keys().m_account_address;
m_watch_only = false;
+ if(m_refresh_from_block_height == 0 && !recover){
+ // Wallets created offline don't know blockchain height.
+ // Set blockchain height calculated from current date/time
+ // -1 month for fluctuations in block time and machine date/time setup.
+ // avg seconds per block
+ const int seconds_per_block = DIFFICULTY_TARGET_V2;
+ // ~num blocks per month
+ const uint64_t blocks_per_month = 60*60*24*30/seconds_per_block;
+ uint64_t approx_blockchain_height = get_approximate_blockchain_height();
+ if(approx_blockchain_height > 0) {
+ m_refresh_from_block_height = approx_blockchain_height - blocks_per_month;
+ }
+ }
bool r = store_keys(m_keys_file, password, false);
THROW_WALLET_EXCEPTION_IF(!r, error::file_save_error, m_keys_file);
@@ -2948,6 +2966,7 @@ bool wallet2::save_tx(const std::vector<pending_tx>& ptx_vector, const std::stri
unsigned_tx_set txs;
for (auto &tx: ptx_vector)
txs.txes.push_back(tx.construction_data);
+ txs.transfers = m_transfers;
std::string s = obj_to_json_str(txs);
if (s.empty())
return false;
@@ -2958,7 +2977,7 @@ bool wallet2::save_tx(const std::vector<pending_tx>& ptx_vector, const std::stri
return epee::file_io_utils::save_string_to_file(filename, std::string(UNSIGNED_TX_PREFIX) + s);
}
//----------------------------------------------------------------------------------------------------
-bool wallet2::sign_tx(const std::string &unsigned_filename, const std::string &signed_filename, std::function<bool(const unsigned_tx_set&)> accept_func)
+bool wallet2::sign_tx(const std::string &unsigned_filename, const std::string &signed_filename, std::vector<wallet2::pending_tx> &txs, std::function<bool(const unsigned_tx_set&)> accept_func)
{
std::string s;
boost::system::error_code errcode;
@@ -2993,6 +3012,8 @@ bool wallet2::sign_tx(const std::string &unsigned_filename, const std::string &s
return false;
}
+ import_outputs(exported_txs.transfers);
+
// sign the transactions
signed_tx_set signed_txes;
for (size_t n = 0; n < exported_txs.txes.size(); ++n)
@@ -3038,6 +3059,17 @@ bool wallet2::sign_tx(const std::string &unsigned_filename, const std::string &s
ptx.tx_key = rct::rct2sk(rct::identity()); // don't send it back to the untrusted view wallet
ptx.dests = sd.splitted_dsts;
ptx.construction_data = sd;
+
+ txs.push_back(ptx);
+ }
+
+ // add key images
+ signed_txes.key_images.resize(m_transfers.size());
+ for (size_t i = 0; i < m_transfers.size(); ++i)
+ {
+ if (!m_transfers[i].m_key_image_known)
+ LOG_PRINT_L0("WARNING: key image not known in signing wallet at index " << i);
+ signed_txes.key_images[i] = m_transfers[i].m_key_image;
}
s = obj_to_json_str(signed_txes);
@@ -3087,6 +3119,23 @@ bool wallet2::load_tx(const std::string &signed_filename, std::vector<tools::wal
return false;
}
+ // import key images
+ if (signed_txs.key_images.size() > m_transfers.size())
+ {
+ LOG_PRINT_L1("More key images returned that we know outputs for");
+ return false;
+ }
+ for (size_t i = 0; i < signed_txs.key_images.size(); ++i)
+ {
+ transfer_details &td = m_transfers[i];
+ if (td.m_key_image_known && td.m_key_image != signed_txs.key_images[i])
+ LOG_PRINT_L0("WARNING: imported key image differs from previously known key image at index " << i << ": trusting imported one");
+ td.m_key_image = signed_txs.key_images[i];
+ m_key_images[m_transfers[i].m_key_image] = i;
+ td.m_key_image_known = true;
+ m_pub_keys[m_transfers[i].get_public_key()] = i;
+ }
+
ptx = signed_txs.ptx;
return true;
@@ -4578,6 +4627,21 @@ uint64_t wallet2::get_daemon_blockchain_target_height(string &err)
return resp_t.result.target_height;
}
+uint64_t wallet2::get_approximate_blockchain_height() const
+{
+ if (m_testnet) return 0;
+ // time of v2 fork
+ const time_t fork_time = 1458748658;
+ // v2 fork block
+ const uint64_t fork_block = 1009827;
+ // avg seconds per block
+ const int seconds_per_block = DIFFICULTY_TARGET_V2;
+ // Calculated blockchain height
+ uint64_t approx_blockchain_height = fork_block + (time(NULL) - fork_time)/seconds_per_block;
+ LOG_PRINT_L2("Calculated blockchain height: " << approx_blockchain_height);
+ return approx_blockchain_height;
+}
+
void wallet2::set_tx_note(const crypto::hash &txid, const std::string &note)
{
m_tx_notes[txid] = note;
@@ -4717,6 +4781,7 @@ uint64_t wallet2::import_key_images(const std::vector<std::pair<crypto::key_imag
for (size_t n = 0; n < signed_key_images.size(); ++n)
{
m_transfers[n].m_key_image = signed_key_images[n].first;
+ m_key_images[m_transfers[n].m_key_image] = n;
m_transfers[n].m_key_image_known = true;
}
@@ -4777,17 +4842,19 @@ size_t wallet2::import_outputs(const std::vector<tools::wallet2::transfer_detail
std::vector<tx_extra_field> tx_extra_fields;
tx_extra_pub_key pub_key_field;
- THROW_WALLET_EXCEPTION_IF(td.m_tx.vout.empty(), error::wallet_internal_error, "tx with no outputs at index " + i);
+ THROW_WALLET_EXCEPTION_IF(td.m_tx.vout.empty(), error::wallet_internal_error, "tx with no outputs at index " + boost::lexical_cast<std::string>(i));
THROW_WALLET_EXCEPTION_IF(!parse_tx_extra(td.m_tx.extra, tx_extra_fields), error::wallet_internal_error,
- "Transaction extra has unsupported format at index " + i);
+ "Transaction extra has unsupported format at index " + boost::lexical_cast<std::string>(i));
THROW_WALLET_EXCEPTION_IF(!find_tx_extra_field_by_type(tx_extra_fields, pub_key_field), error::wallet_internal_error,
- "Public key wasn't found in the transaction extra at index " + i);
+ "Public key wasn't found in the transaction extra at index " + boost::lexical_cast<std::string>(i));
cryptonote::generate_key_image_helper(m_account.get_keys(), pub_key_field.pub_key, td.m_internal_output_index, in_ephemeral, td.m_key_image);
td.m_key_image_known = true;
THROW_WALLET_EXCEPTION_IF(in_ephemeral.pub != boost::get<cryptonote::txout_to_key>(td.m_tx.vout[td.m_internal_output_index].target).key,
- error::wallet_internal_error, "key_image generated ephemeral public key not matched with output_key at index " + i);
+ error::wallet_internal_error, "key_image generated ephemeral public key not matched with output_key at index " + boost::lexical_cast<std::string>(i));
+ m_key_images[td.m_key_image] = m_transfers.size();
+ m_pub_keys[td.get_public_key()] = m_transfers.size();
m_transfers.push_back(td);
}
diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h
index 417e754a5..6168873d5 100644
--- a/src/wallet/wallet2.h
+++ b/src/wallet/wallet2.h
@@ -133,6 +133,21 @@ namespace tools
bool is_rct() const { return m_rct; }
uint64_t amount() const { return m_amount; }
const crypto::public_key &get_public_key() const { return boost::get<const cryptonote::txout_to_key>(m_tx.vout[m_internal_output_index].target).key; }
+
+ BEGIN_SERIALIZE_OBJECT()
+ FIELD(m_block_height)
+ FIELD(m_tx)
+ FIELD(m_txid)
+ FIELD(m_internal_output_index)
+ FIELD(m_global_output_index)
+ FIELD(m_spent)
+ FIELD(m_spent_height)
+ FIELD(m_key_image)
+ FIELD(m_mask)
+ FIELD(m_amount)
+ FIELD(m_rct)
+ FIELD(m_key_image_known)
+ END_SERIALIZE()
};
struct payment_details
@@ -226,16 +241,20 @@ namespace tools
struct unsigned_tx_set
{
std::vector<tx_construction_data> txes;
+ wallet2::transfer_container transfers;
BEGIN_SERIALIZE_OBJECT()
FIELD(txes)
+ FIELD(transfers)
END_SERIALIZE()
};
struct signed_tx_set
{
std::vector<pending_tx> ptx;
+ std::vector<crypto::key_image> key_images;
BEGIN_SERIALIZE_OBJECT()
FIELD(ptx)
+ FIELD(key_images)
END_SERIALIZE()
};
@@ -377,7 +396,7 @@ namespace tools
void commit_tx(pending_tx& ptx_vector);
void commit_tx(std::vector<pending_tx>& ptx_vector);
bool save_tx(const std::vector<pending_tx>& ptx_vector, const std::string &filename);
- bool sign_tx(const std::string &unsigned_filename, const std::string &signed_filename, std::function<bool(const unsigned_tx_set&)> accept_func = NULL);
+ bool sign_tx(const std::string &unsigned_filename, const std::string &signed_filename, std::vector<wallet2::pending_tx> &ptx, std::function<bool(const unsigned_tx_set&)> accept_func = NULL);
bool load_tx(const std::string &signed_filename, std::vector<tools::wallet2::pending_tx> &ptx, std::function<bool(const signed_tx_set&)> accept_func = NULL);
std::vector<pending_tx> create_transactions(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t> extra, bool trusted_daemon);
std::vector<wallet2::pending_tx> create_transactions_2(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t> extra, bool trusted_daemon);
@@ -492,7 +511,10 @@ namespace tools
std::string get_daemon_address() const;
uint64_t get_daemon_blockchain_height(std::string& err);
uint64_t get_daemon_blockchain_target_height(std::string& err);
-
+ /*!
+ * \brief Calculates the approximate blockchain height from current date/time.
+ */
+ uint64_t get_approximate_blockchain_height() const;
std::vector<size_t> select_available_outputs_from_histogram(uint64_t count, bool atleast, bool unlocked, bool trusted_daemon);
std::vector<size_t> select_available_outputs(const std::function<bool(const transfer_details &td)> &f);
std::vector<size_t> select_available_unmixable_outputs(bool trusted_daemon);
diff --git a/src/wallet/wallet2_api.h b/src/wallet/wallet2_api.h
index 6fe15d1e3..e624ffa69 100644
--- a/src/wallet/wallet2_api.h
+++ b/src/wallet/wallet2_api.h
@@ -282,6 +282,12 @@ struct Wallet
virtual uint64_t blockChainHeight() const = 0;
/**
+ * @brief approximateBlockChainHeight - returns approximate blockchain height calculated from date/time
+ * @return
+ */
+ virtual uint64_t approximateBlockChainHeight() const = 0;
+
+ /**
* @brief daemonBlockChainHeight - returns daemon blockchain height
* @return 0 - in case error communicating with the daemon.
* status() will return Status_Error and errorString() will return verbose error description