aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.i18n.md2
-rw-r--r--README.md2
-rw-r--r--contrib/epee/include/misc_os_dependent.h4
-rw-r--r--src/cryptonote_basic/cryptonote_format_utils.cpp39
-rw-r--r--src/cryptonote_basic/cryptonote_format_utils.h1
-rw-r--r--src/cryptonote_basic/hardfork.h1
-rw-r--r--src/cryptonote_basic/miner.cpp16
-rw-r--r--src/simplewallet/simplewallet.cpp10
-rw-r--r--src/wallet/wallet2.cpp49
-rw-r--r--src/wallet/wallet2.h5
-rw-r--r--src/wallet/wallet_rpc_server.cpp5
-rw-r--r--src/wallet/wallet_rpc_server_commands_defs.h3
12 files changed, 85 insertions, 52 deletions
diff --git a/README.i18n.md b/README.i18n.md
index 65f87cda2..b0379bfb3 100644
--- a/README.i18n.md
+++ b/README.i18n.md
@@ -1,7 +1,7 @@
Monero daemon internationalization
==================================
-The Monero command line tools can be translated in various languages.
+The Monero command line tools can be translated in various languages. If you wish to contribute and need help/support, contact the [Monero Localization Workgroup on Taiga](https://taiga.getmonero.org/project/erciccione-monero-localization/) or come chat on `#monero-translations` (Freenode/IRC, riot/matrix, MatterMost)
In order to use the same translation workflow as the [Monero Core GUI](https://github.com/monero-project/monero-core), they use Qt Linguist translation files. However, to avoid the dependencies on Qt this normally implies, they use a custom loader to read those files at runtime.
diff --git a/README.md b/README.md
index 81db79575..9cb7594d1 100644
--- a/README.md
+++ b/README.md
@@ -166,7 +166,7 @@ library archives (`.a`).
| Dep | Min. version | Vendored | Debian/Ubuntu pkg | Arch pkg | Fedora | Optional | Purpose |
| ------------ | ------------- | -------- | ------------------ | ------------ | ----------------- | -------- | -------------- |
| GCC | 4.7.3 | NO | `build-essential` | `base-devel` | `gcc` | NO | |
-| CMake | 3.0.0 | NO | `cmake` | `cmake` | `cmake` | NO | |
+| CMake | 3.2.0 | NO | `cmake` | `cmake` | `cmake` | NO | |
| pkg-config | any | NO | `pkg-config` | `base-devel` | `pkgconf` | NO | |
| Boost | 1.58 | NO | `libboost-all-dev` | `boost` | `boost-devel` | NO | C++ libraries |
| OpenSSL | basically any | NO | `libssl-dev` | `openssl` | `openssl-devel` | NO | sha256 sum |
diff --git a/contrib/epee/include/misc_os_dependent.h b/contrib/epee/include/misc_os_dependent.h
index 99690b301..ffe575501 100644
--- a/contrib/epee/include/misc_os_dependent.h
+++ b/contrib/epee/include/misc_os_dependent.h
@@ -75,13 +75,13 @@ namespace misc_utils
clock_get_time(cclock, &mts);
mach_port_deallocate(mach_task_self(), cclock);
- return (mts.tv_sec * 1000000000) + (mts.tv_nsec);
+ return ((uint64_t)mts.tv_sec * 1000000000) + (mts.tv_nsec);
#else
struct timespec ts;
if(clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
return 0;
}
- return (ts.tv_sec * 1000000000) + (ts.tv_nsec);
+ return ((uint64_t)ts.tv_sec * 1000000000) + (ts.tv_nsec);
#endif
}
diff --git a/src/cryptonote_basic/cryptonote_format_utils.cpp b/src/cryptonote_basic/cryptonote_format_utils.cpp
index aab4f380c..c668ceae5 100644
--- a/src/cryptonote_basic/cryptonote_format_utils.cpp
+++ b/src/cryptonote_basic/cryptonote_format_utils.cpp
@@ -172,6 +172,45 @@ namespace cryptonote
return m;
}
//---------------------------------------------------------------
+ std::vector<crypto::public_key> get_subaddress_spend_public_keys(const cryptonote::account_keys &keys, uint32_t account, uint32_t begin, uint32_t end)
+ {
+ CHECK_AND_ASSERT_THROW_MES(begin <= end, "begin > end");
+
+ std::vector<crypto::public_key> pkeys;
+ pkeys.reserve(end - begin);
+ cryptonote::subaddress_index index = {account, begin};
+
+ ge_p3 p3;
+ ge_cached cached;
+ CHECK_AND_ASSERT_THROW_MES(ge_frombytes_vartime(&p3, (const unsigned char*)keys.m_account_address.m_spend_public_key.data) == 0,
+ "ge_frombytes_vartime failed to convert spend public key");
+ ge_p3_to_cached(&cached, &p3);
+
+ for (uint32_t idx = begin; idx < end; ++idx)
+ {
+ index.minor = idx;
+ if (index.is_zero())
+ {
+ pkeys.push_back(keys.m_account_address.m_spend_public_key);
+ continue;
+ }
+ const crypto::secret_key m = cryptonote::get_subaddress_secret_key(keys.m_view_secret_key, index);
+
+ // M = m*G
+ ge_scalarmult_base(&p3, (const unsigned char*)m.data);
+
+ // D = B + M
+ crypto::public_key D;
+ ge_p1p1 p1p1;
+ ge_add(&p1p1, &p3, &cached);
+ ge_p1p1_to_p3(&p3, &p1p1);
+ ge_p3_tobytes((unsigned char*)D.data, &p3);
+
+ pkeys.push_back(D);
+ }
+ return pkeys;
+ }
+ //---------------------------------------------------------------
bool generate_key_image_helper(const account_keys& ack, const std::unordered_map<crypto::public_key, subaddress_index>& subaddresses, const crypto::public_key& out_key, const crypto::public_key& tx_public_key, const std::vector<crypto::public_key>& additional_tx_public_keys, size_t real_output_index, keypair& in_ephemeral, crypto::key_image& ki)
{
crypto::key_derivation recv_derivation = AUTO_VAL_INIT(recv_derivation);
diff --git a/src/cryptonote_basic/cryptonote_format_utils.h b/src/cryptonote_basic/cryptonote_format_utils.h
index 29e180c41..07a3ac92a 100644
--- a/src/cryptonote_basic/cryptonote_format_utils.h
+++ b/src/cryptonote_basic/cryptonote_format_utils.h
@@ -93,6 +93,7 @@ namespace cryptonote
bool get_tx_fee(const transaction& tx, uint64_t & fee);
uint64_t get_tx_fee(const transaction& tx);
crypto::secret_key get_subaddress_secret_key(const crypto::secret_key& a, const subaddress_index& index);
+ std::vector<crypto::public_key> get_subaddress_spend_public_keys(const cryptonote::account_keys &keys, uint32_t account, uint32_t begin, uint32_t end);
bool generate_key_image_helper(const account_keys& ack, const std::unordered_map<crypto::public_key, subaddress_index>& subaddresses, const crypto::public_key& out_key, const crypto::public_key& tx_public_key, const std::vector<crypto::public_key>& additional_tx_public_keys, size_t real_output_index, keypair& in_ephemeral, crypto::key_image& ki);
bool generate_key_image_helper_precomp(const account_keys& ack, const crypto::public_key& out_key, const crypto::key_derivation& recv_derivation, size_t real_output_index, const subaddress_index& received_index, keypair& in_ephemeral, crypto::key_image& ki);
void get_blob_hash(const blobdata& blob, crypto::hash& res);
diff --git a/src/cryptonote_basic/hardfork.h b/src/cryptonote_basic/hardfork.h
index 1ec601660..ee5ec0596 100644
--- a/src/cryptonote_basic/hardfork.h
+++ b/src/cryptonote_basic/hardfork.h
@@ -79,7 +79,6 @@ namespace cryptonote
* returns true if no error, false otherwise
*
* @param version the major block version for the fork
- * @param voting_version the minor block version for the fork, used for voting
* @param height The height the hardfork takes effect
* @param time Approximate time of the hardfork (seconds since epoch)
*/
diff --git a/src/cryptonote_basic/miner.cpp b/src/cryptonote_basic/miner.cpp
index b322383a9..919872709 100644
--- a/src/cryptonote_basic/miner.cpp
+++ b/src/cryptonote_basic/miner.cpp
@@ -624,21 +624,15 @@ namespace cryptonote
continue; // if interrupted because stop called, loop should end ..
}
- boost::tribool battery_powered(on_battery_power());
- bool on_ac_power = false;
- if(indeterminate( battery_powered ))
+ bool on_ac_power = m_ignore_battery;
+ if(!m_ignore_battery)
{
- // name could be better, only ignores battery requirement if we failed
- // to get the status of the system
- if( m_ignore_battery )
+ boost::tribool battery_powered(on_battery_power());
+ if(!indeterminate( battery_powered ))
{
- on_ac_power = true;
+ on_ac_power = !battery_powered;
}
}
- else
- {
- on_ac_power = !battery_powered;
- }
if( m_is_background_mining_started )
{
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 150c6333c..aa8c66f7a 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -3194,14 +3194,6 @@ void simple_wallet::on_money_spent(uint64_t height, const crypto::hash &txid, co
//----------------------------------------------------------------------------------------------------
void simple_wallet::on_skip_transaction(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx)
{
- message_writer(console_color_red, true) << "\r" <<
- tr("Height ") << height << ", " <<
- tr("transaction ") << txid << ", " <<
- tr("unsupported transaction format");
- if (m_auto_refresh_refreshing)
- m_cmd_binder.print_prompt();
- else
- m_refresh_progress_reporter.update(height, true);
}
//----------------------------------------------------------------------------------------------------
bool simple_wallet::refresh_main(uint64_t start_height, bool reset, bool is_init)
@@ -4629,7 +4621,7 @@ bool simple_wallet::donate(const std::vector<std::string> &args_)
local_args.push_back(amount_str);
if (!payment_id_str.empty())
local_args.push_back(payment_id_str);
- message_writer() << tr("Donating ") << amount_str << " to The Monero Project (donate.getmonero.org/"<< MONERO_DONATION_ADDR <<").";
+ message_writer() << tr("Donating ") << amount_str << " to The Monero Project (donate.getmonero.org or "<< MONERO_DONATION_ADDR <<").";
transfer_new(local_args);
return true;
}
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index d97e53011..87577d2fd 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -888,14 +888,12 @@ void wallet2::expand_subaddresses(const cryptonote::subaddress_index& index)
cryptonote::subaddress_index index2;
for (index2.major = m_subaddress_labels.size(); index2.major < index.major + m_subaddress_lookahead_major; ++index2.major)
{
- for (index2.minor = 0; index2.minor < (index2.major == index.major ? index.minor : 0) + m_subaddress_lookahead_minor; ++index2.minor)
+ const uint32_t end = (index2.major == index.major ? index.minor : 0) + m_subaddress_lookahead_minor;
+ const std::vector<crypto::public_key> pkeys = cryptonote::get_subaddress_spend_public_keys(m_account.get_keys(), index2.major, 0, end);
+ for (index2.minor = 0; index2.minor < end; ++index2.minor)
{
- if (m_subaddresses_inv.count(index2) == 0)
- {
- crypto::public_key D = get_subaddress_spend_public_key(index2);
- m_subaddresses[D] = index2;
- m_subaddresses_inv[index2] = D;
- }
+ const crypto::public_key &D = pkeys[index2.minor];
+ m_subaddresses[D] = index2;
}
}
m_subaddress_labels.resize(index.major + 1, {"Untitled account"});
@@ -904,15 +902,14 @@ void wallet2::expand_subaddresses(const cryptonote::subaddress_index& index)
else if (m_subaddress_labels[index.major].size() <= index.minor)
{
// add new subaddresses
- cryptonote::subaddress_index index2 = index;
- for (index2.minor = m_subaddress_labels[index.major].size(); index2.minor < index.minor + m_subaddress_lookahead_minor; ++index2.minor)
+ const uint32_t end = index.minor + m_subaddress_lookahead_minor;
+ const uint32_t begin = m_subaddress_labels[index.major].size();
+ cryptonote::subaddress_index index2 = {index.major, begin};
+ const std::vector<crypto::public_key> pkeys = cryptonote::get_subaddress_spend_public_keys(m_account.get_keys(), index2.major, index2.minor, end);
+ for (; index2.minor < end; ++index2.minor)
{
- if (m_subaddresses_inv.count(index2) == 0)
- {
- crypto::public_key D = get_subaddress_spend_public_key(index2);
- m_subaddresses[D] = index2;
- m_subaddresses_inv[index2] = D;
- }
+ const crypto::public_key &D = pkeys[index2.minor - begin];
+ m_subaddresses[D] = index2;
}
m_subaddress_labels[index.major].resize(index.minor + 1);
}
@@ -1218,7 +1215,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
td.m_rct = false;
}
set_unspent(m_transfers.size()-1);
- if (!m_multisig)
+ if (!m_multisig && !m_watch_only)
m_key_images[td.m_key_image] = m_transfers.size()-1;
m_pub_keys[tx_scan_info[o].in_ephemeral.pub] = m_transfers.size()-1;
if (m_multisig)
@@ -1312,11 +1309,21 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
uint64_t amount = boost::get<cryptonote::txin_to_key>(in).amount;
if (amount > 0)
{
- THROW_WALLET_EXCEPTION_IF(amount != td.amount(), error::wallet_internal_error,
- std::string("Inconsistent amount in tx input: got ") + print_money(amount) +
- std::string(", expected ") + print_money(td.amount()));
+ if(amount != td.amount())
+ {
+ MERROR("Inconsistent amount in tx input: got " << print_money(amount) <<
+ ", expected " << print_money(td.amount()));
+ // this means:
+ // 1) the same output pub key was used as destination multiple times,
+ // 2) the wallet set the highest amount among them to transfer_details::m_amount, and
+ // 3) the wallet somehow spent that output with an amount smaller than the above amount, causing inconsistency
+ td.m_amount = amount;
+ }
+ }
+ else
+ {
+ amount = td.amount();
}
- amount = td.amount();
tx_money_spent_in_ins += amount;
if (subaddr_account && *subaddr_account != td.m_subaddr_index.major)
LOG_ERROR("spent funds are from different subaddress accounts; count of incoming/outgoing payments will be incorrect");
@@ -2342,7 +2349,6 @@ bool wallet2::clear()
m_address_book.clear();
m_local_bc_height = 1;
m_subaddresses.clear();
- m_subaddresses_inv.clear();
m_subaddress_labels.clear();
return true;
}
@@ -3184,7 +3190,6 @@ bool wallet2::finalize_multisig(const epee::wipeable_string &password, std::unor
}
m_subaddresses.clear();
- m_subaddresses_inv.clear();
m_subaddress_labels.clear();
add_subaddress_account(tr("Primary account"));
diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h
index f9995c2ee..28289842b 100644
--- a/src/wallet/wallet2.h
+++ b/src/wallet/wallet2.h
@@ -605,6 +605,7 @@ namespace tools
cryptonote::account_public_address get_subaddress(const cryptonote::subaddress_index& index) const;
cryptonote::account_public_address get_address() const { return get_subaddress({0,0}); }
crypto::public_key get_subaddress_spend_public_key(const cryptonote::subaddress_index& index) const;
+ std::vector<crypto::public_key> get_subaddress_spend_public_keys(uint32_t account, uint32_t begin, uint32_t end) const;
std::string get_subaddress_as_str(const cryptonote::subaddress_index& index) const;
std::string get_address_as_str() const { return get_subaddress_as_str({0, 0}); }
std::string get_integrated_address_as_str(const crypto::hash8& payment_id) const;
@@ -782,7 +783,8 @@ namespace tools
if (ver < 20)
return;
a & m_subaddresses;
- a & m_subaddresses_inv;
+ std::unordered_map<cryptonote::subaddress_index, crypto::public_key> dummy_subaddresses_inv;
+ a & dummy_subaddresses_inv;
a & m_subaddress_labels;
a & m_additional_tx_keys;
if(ver < 21)
@@ -1089,7 +1091,6 @@ namespace tools
std::unordered_map<crypto::public_key, size_t> m_pub_keys;
cryptonote::account_public_address m_account_public_address;
std::unordered_map<crypto::public_key, cryptonote::subaddress_index> m_subaddresses;
- std::unordered_map<cryptonote::subaddress_index, crypto::public_key> m_subaddresses_inv;
std::vector<std::vector<std::string>> m_subaddress_labels;
std::unordered_map<crypto::hash, std::string> m_tx_notes;
std::unordered_map<std::string, std::string> m_attributes;
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index 5c644983b..6d5419521 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -39,6 +39,7 @@ using namespace epee;
#include "wallet/wallet_args.h"
#include "common/command_line.h"
#include "common/i18n.h"
+#include "cryptonote_config.h"
#include "cryptonote_basic/cryptonote_format_utils.h"
#include "cryptonote_basic/account.h"
#include "multisig/multisig.h"
@@ -1803,11 +1804,11 @@ namespace tools
return false;
}
- uint64_t min_height = 0, max_height = (uint64_t)-1;
+ uint64_t min_height = 0, max_height = CRYPTONOTE_MAX_BLOCK_NUMBER;
if (req.filter_by_height)
{
min_height = req.min_height;
- max_height = req.max_height;
+ max_height = req.max_height <= max_height ? req.max_height : max_height;
}
if (req.in)
diff --git a/src/wallet/wallet_rpc_server_commands_defs.h b/src/wallet/wallet_rpc_server_commands_defs.h
index 82b6b78f9..e38cba5a5 100644
--- a/src/wallet/wallet_rpc_server_commands_defs.h
+++ b/src/wallet/wallet_rpc_server_commands_defs.h
@@ -29,6 +29,7 @@
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
#pragma once
+#include "cryptonote_config.h"
#include "cryptonote_protocol/cryptonote_protocol_defs.h"
#include "cryptonote_basic/cryptonote_basic.h"
#include "cryptonote_basic/subaddress_index.h"
@@ -1262,7 +1263,7 @@ namespace wallet_rpc
KV_SERIALIZE(pool);
KV_SERIALIZE(filter_by_height);
KV_SERIALIZE(min_height);
- KV_SERIALIZE(max_height);
+ KV_SERIALIZE_OPT(max_height, (uint64_t)CRYPTONOTE_MAX_BLOCK_NUMBER);
KV_SERIALIZE(account_index);
KV_SERIALIZE(subaddr_indices);
END_KV_SERIALIZE_MAP()