Skip to content

Commit

Permalink
Merge pull request monero-project#255 from stoffu/aeon-upstream-14
Browse files Browse the repository at this point in the history
Aeon upstream 14
  • Loading branch information
aeonix committed Jan 24, 2022
2 parents 923b05e + 4d2849c commit 35058fe
Show file tree
Hide file tree
Showing 20 changed files with 149 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/blockchain_db/blockchain_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ class BlockchainDB
/**
* @brief An empty constructor.
*/
BlockchainDB(): m_open(false) { }
BlockchainDB(): m_hardfork(NULL), m_open(false) { }

/**
* @brief An empty destructor.
Expand Down
2 changes: 1 addition & 1 deletion src/blockchain_db/lmdb/db_lmdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ void BlockchainLMDB::open(const std::string& filename, const int db_flags)
if (is_hdd_result)
{
if (is_hdd_result.value())
MCLOG_RED(el::Level::Warning, "global", "The blockchain is on a rotating drive: this will be very slow, use a SSD if possible");
MCLOG_RED(el::Level::Warning, "global", "The blockchain is on a rotating drive: this will be very slow, use an SSD if possible");
}

m_folder = filename;
Expand Down
1 change: 1 addition & 0 deletions src/cryptonote_basic/account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ DISABLE_VS_WARNINGS(4244 4345)
void account_base::set_null()
{
m_keys = account_keys();
m_creation_timestamp = 0;
}
//-----------------------------------------------------------------
void account_base::forget_spend_key()
Expand Down
2 changes: 1 addition & 1 deletion src/daemon/rpc_command_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ bool t_rpc_command_executor::show_status() {
% get_sync_percentage(ires)
% (ires.testnet ? "testnet" : ires.stagenet ? "stagenet" : "mainnet")
% bootstrap_msg
% (!has_mining_info ? "mining info unavailable" : mining_busy ? "syncing" : mres.active ? ( ( mres.is_background_mining_enabled ? "smart " : "" ) + std::string("mining at ") + get_mining_speed(mres.speed) ) : "not mining")
% (!has_mining_info ? "mining info unavailable" : mining_busy ? "syncing" : mres.active ? ( ( mres.is_background_mining_enabled ? "smart " : "" ) + std::string("mining at ") + get_mining_speed(mres.speed) + std::string(" to ") + mres.address ) : "not mining")
% get_mining_speed(cryptonote::difficulty_type(ires.wide_difficulty) / ires.target)
% (unsigned)hfres.version
% get_fork_extra_info(hfres.earliest_height, net_height, ires.target)
Expand Down
15 changes: 15 additions & 0 deletions src/device/device_io_hid.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright (c) 2017-2018, The Monero Project
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
Expand Down
16 changes: 10 additions & 6 deletions src/p2p/net_node.inl
Original file line number Diff line number Diff line change
Expand Up @@ -651,10 +651,14 @@ namespace nodetool
{
kill();
m_peerlist.deinit();
m_net_server.deinit_server();
// remove UPnP port mapping
if(!m_no_igd)
delete_upnp_port_mapping(m_listening_port);

if (!m_offline)
{
m_net_server.deinit_server();
// remove UPnP port mapping
if(!m_no_igd)
delete_upnp_port_mapping(m_listening_port);
}
return store_config();
}
//-----------------------------------------------------------------------------------
Expand Down Expand Up @@ -2045,7 +2049,7 @@ namespace nodetool
char lanAddress[64];
result = UPNP_GetValidIGD(deviceList, &urls, &igdData, lanAddress, sizeof lanAddress);
freeUPNPDevlist(deviceList);
if (result != 0) {
if (result > 0) {
if (result == 1) {
std::ostringstream portString;
portString << port;
Expand Down Expand Up @@ -2091,7 +2095,7 @@ namespace nodetool
char lanAddress[64];
result = UPNP_GetValidIGD(deviceList, &urls, &igdData, lanAddress, sizeof lanAddress);
freeUPNPDevlist(deviceList);
if (result != 0) {
if (result > 0) {
if (result == 1) {
std::ostringstream portString;
portString << port;
Expand Down
31 changes: 12 additions & 19 deletions src/rpc/core_rpc_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,23 +222,15 @@ namespace cryptonote
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
static cryptonote::blobdata get_pruned_tx_blob(cryptonote::transaction &tx)
{
std::stringstream ss;
binary_archive<true> ba(ss);
bool r = tx.serialize_base(ba);
CHECK_AND_ASSERT_MES(r, cryptonote::blobdata(), "Failed to serialize rct signatures base");
return ss.str();
}
//------------------------------------------------------------------------------------------------------------------------------
static cryptonote::blobdata get_pruned_tx_json(cryptonote::transaction &tx)
{
std::stringstream ss;
json_archive<true> ar(ss);
bool r = tx.serialize_base(ar);
CHECK_AND_ASSERT_MES(r, cryptonote::blobdata(), "Failed to serialize rct signatures base");
return ss.str();
}
class pruned_transaction {
transaction& tx;
public:
pruned_transaction(transaction& tx) : tx(tx) {}
BEGIN_SERIALIZE_OBJECT()
bool r = tx.serialize_base(ar);
if (!r) return false;
END_SERIALIZE()
};
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_get_blocks(const COMMAND_RPC_GET_BLOCKS_FAST::request& req, COMMAND_RPC_GET_BLOCKS_FAST::response& res)
{
Expand Down Expand Up @@ -574,10 +566,11 @@ namespace cryptonote

crypto::hash tx_hash = *vhi++;
e.tx_hash = *txhi++;
blobdata blob = req.prune ? get_pruned_tx_blob(tx) : t_serializable_object_to_blob(tx);
pruned_transaction pruned_tx{tx};
blobdata blob = req.prune ? t_serializable_object_to_blob(pruned_tx) : t_serializable_object_to_blob(tx);
e.as_hex = string_tools::buff_to_hex_nodelimer(blob);
if (req.decode_as_json)
e.as_json = req.prune ? get_pruned_tx_json(tx) : obj_to_json_str(tx);
e.as_json = req.prune ? obj_to_json_str(pruned_tx) : obj_to_json_str(tx);
e.in_pool = pool_tx_hashes.find(tx_hash) != pool_tx_hashes.end();
if (e.in_pool)
{
Expand Down
3 changes: 0 additions & 3 deletions src/rpc/core_rpc_server_commands_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -782,9 +782,6 @@ namespace cryptonote
std::string tx_as_hex;
bool do_not_relay;

request() {}
explicit request(const transaction &);

BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(tx_as_hex)
KV_SERIALIZE_OPT(do_not_relay, false)
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/daemon_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class classname \
// NOTE: when using a type with multiple template parameters,
// replace any comma in the template specifier with the macro
// above, or the preprocessor will eat the comma in a bad way.
#define RPC_MESSAGE_MEMBER(type, name) type name = type{}
#define RPC_MESSAGE_MEMBER(type, name) type name = {}


namespace cryptonote
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ namespace rpc
static const char* STATUS_BAD_REQUEST;
static const char* STATUS_BAD_JSON;

Message() : status(STATUS_OK) { }
Message() : status(STATUS_OK), rpc_version(0) { }

virtual ~Message() { }

Expand Down
10 changes: 9 additions & 1 deletion src/simplewallet/simplewallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2583,7 +2583,15 @@ simple_wallet::simple_wallet()
m_cmd_binder.set_handler("show_transfers",
boost::bind(&simple_wallet::show_transfers, this, _1),
tr("show_transfers [in|out|pending|failed|pool|coinbase] [index=<N1>[,<N2>,...]] [<min_height> [<max_height>]]"),
tr("Show the incoming/outgoing transfers within an optional height range."));
// Seemingly broken formatting to compensate for the backslash before the quotes.
tr("Show the incoming/outgoing transfers within an optional height range.\n\n"
"Output format:\n"
"In or Coinbase: Block Number, \"block\"|\"in\", Time, Amount, Transaction Hash, Payment ID, Subaddress Index, \"-\", Note\n"
"Out: Block Number, \"out\", Time, Amount*, Transaction Hash, Payment ID, Fee, Destinations, Input addresses**, \"-\", Note\n"
"Pool: \"pool\", \"in\", Time, Amount, Transaction Hash, Payment Id, Subaddress Index, \"-\", Note, Double Spend Note\n"
"Pending or Failed: \"failed\"|\"pending\", \"out\", Time, Amount*, Transaction Hash, Payment ID, Fee, Input addresses**, \"-\", Note\n\n"
"* Excluding change and fee.\n"
"** Set of address indices used as inputs in this transfer."));
m_cmd_binder.set_handler("export_transfers",
boost::bind(&simple_wallet::export_transfers, this, _1),
tr("export_transfers [in|out|all|pending|failed|coinbase] [index=<N1>[,<N2>,...]] [<min_height> [<max_height>]] [output=<filepath>]"),
Expand Down
26 changes: 24 additions & 2 deletions src/wallet/api/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ WalletImpl::WalletImpl(NetworkType nettype, uint64_t kdf_rounds)
, m_synchronized(false)
, m_rebuildWalletCache(false)
, m_is_connected(false)
, m_refreshShouldRescan(false)
{
m_wallet.reset(new tools::wallet2(static_cast<cryptonote::network_type>(nettype), kdf_rounds, true));
m_history.reset(new TransactionHistoryImpl(this));
Expand Down Expand Up @@ -1010,6 +1011,20 @@ void WalletImpl::refreshAsync()
m_refreshCV.notify_one();
}

bool WalletImpl::rescanBlockchain()
{
clearStatus();
m_refreshShouldRescan = true;
doRefresh();
return status() == Status_Ok;
}

void WalletImpl::rescanBlockchainAsync()
{
m_refreshShouldRescan = true;
refreshAsync();
}

void WalletImpl::setAutoRefreshInterval(int millis)
{
if (millis > MAX_REFRESH_INTERVAL_MILLIS) {
Expand Down Expand Up @@ -1984,6 +1999,7 @@ void WalletImpl::refreshThreadFunc()
LOG_PRINT_L3(__FUNCTION__ << ": refresh lock acquired...");
LOG_PRINT_L3(__FUNCTION__ << ": m_refreshEnabled: " << m_refreshEnabled);
LOG_PRINT_L3(__FUNCTION__ << ": m_status: " << status());
LOG_PRINT_L3(__FUNCTION__ << ": m_refreshShouldRescan: " << m_refreshShouldRescan);
if (m_refreshEnabled) {
LOG_PRINT_L3(__FUNCTION__ << ": refreshing...");
doRefresh();
Expand All @@ -1994,12 +2010,16 @@ void WalletImpl::refreshThreadFunc()

void WalletImpl::doRefresh()
{
bool rescan = m_refreshShouldRescan.exchange(false);
// synchronizing async and sync refresh calls
boost::lock_guard<boost::mutex> guarg(m_refreshMutex2);
try {
do try {
LOG_PRINT_L3(__FUNCTION__ << ": doRefresh, rescan = "<<rescan);
// Syncing daemon and refreshing wallet simultaneously is very resource intensive.
// Disable refresh if wallet is disconnected or daemon isn't synced.
if (m_wallet->light_wallet() || daemonSynced()) {
if(rescan)
m_wallet->rescan_blockchain(false);
m_wallet->refresh(trustedDaemon());
if (!m_synchronized) {
m_synchronized = true;
Expand All @@ -2016,7 +2036,9 @@ void WalletImpl::doRefresh()
}
} catch (const std::exception &e) {
setStatusError(e.what());
}
break;
}while(!rescan && (rescan=m_refreshShouldRescan.exchange(false))); // repeat if not rescanned and rescan was requested

if (m_wallet2Callback->getListener()) {
m_wallet2Callback->getListener()->refreshed();
}
Expand Down
3 changes: 3 additions & 0 deletions src/wallet/api/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ class WalletImpl : public Wallet
bool synchronized() const override;
bool refresh() override;
void refreshAsync() override;
bool rescanBlockchain() override;
void rescanBlockchainAsync() override;
void setAutoRefreshInterval(int millis) override;
int autoRefreshInterval() const override;
void setRefreshFromBlockHeight(uint64_t refresh_from_block_height) override;
Expand Down Expand Up @@ -232,6 +234,7 @@ class WalletImpl : public Wallet
std::atomic<bool> m_refreshEnabled;
std::atomic<bool> m_refreshThreadDone;
std::atomic<int> m_refreshIntervalMillis;
std::atomic<bool> m_refreshShouldRescan;
// synchronizing refresh loop;
boost::mutex m_refreshMutex;

Expand Down
11 changes: 11 additions & 0 deletions src/wallet/api/wallet2_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,17 @@ struct Wallet
*/
virtual void refreshAsync() = 0;

/**
* @brief rescanBlockchain - rescans the wallet, updating transactions from daemon
* @return - true if refreshed successfully;
*/
virtual bool rescanBlockchain() = 0;

/**
* @brief rescanBlockchainAsync - rescans wallet asynchronously, starting from genesys
*/
virtual void rescanBlockchainAsync() = 0;

/**
* @brief setAutoRefreshInterval - setup interval for automatic refresh.
* @param seconds - interval in millis. if zero or less than zero - automatic refresh disabled;
Expand Down
4 changes: 4 additions & 0 deletions src/wallet/wallet2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,7 @@ wallet_keys_unlocker::~wallet_keys_unlocker()
wallet2::wallet2(network_type nettype, uint64_t kdf_rounds, bool unattended):
m_multisig_rescan_info(NULL),
m_multisig_rescan_k(NULL),
m_upper_transaction_weight_limit(0),
m_run(true),
m_callback(0),
m_trusted_daemon(false),
Expand Down Expand Up @@ -846,6 +847,9 @@ wallet2::wallet2(network_type nettype, uint64_t kdf_rounds, bool unattended):
m_is_initialized(false),
m_kdf_rounds(kdf_rounds),
is_old_file_format(false),
m_watch_only(false),
m_multisig(false),
m_multisig_threshold(0),
m_node_rpc_proxy(m_http_client, m_daemon_rpc_mutex),
m_subaddress_lookahead_major(SUBADDRESS_LOOKAHEAD_MAJOR),
m_subaddress_lookahead_minor(SUBADDRESS_LOOKAHEAD_MINOR),
Expand Down
16 changes: 15 additions & 1 deletion tests/unit_tests/notify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#ifdef __GLIBC__
#include <sys/stat.h>
#endif

#include "gtest/gtest.h"

#include <boost/filesystem.hpp>
Expand All @@ -37,12 +41,22 @@

TEST(notify, works)
{
#ifdef __GLIBC__
mode_t prevmode = umask(077);
#endif
char name_template[] = "/tmp/monero-notify-unit-test-XXXXXX";
int fd = mkstemp(name_template);
#ifdef __GLIBC__
umask(prevmode);
#endif
ASSERT_TRUE(fd >= 0);
close(fd);

const std::string spec = epee::string_tools::get_current_module_folder() + "/test_notifier " + name_template + " %s";
const std::string spec = epee::string_tools::get_current_module_folder() + "/test_notifier"
#ifdef _WIN32
+ ".exe"
#endif
+ " " + name_template + " %s";

tools::Notify notify(spec.c_str());
notify.notify("%s", "1111111111111111111111111111111111111111111111111111111111111111", NULL);
Expand Down
11 changes: 10 additions & 1 deletion translations/monero.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1727,7 +1727,16 @@ Otherwise, you prove the reserve of the smallest possible amount above &lt;amoun
</message>
<message>
<location filename="../src/simplewallet/simplewallet.cpp" line="2432"/>
<source>Show the incoming/outgoing transfers within an optional height range.</source>
<source>Show the incoming/outgoing transfers within an optional height range.

Output format:
In or Coinbase: Block Number, &quot;block&quot;|&quot;in&quot;, Time, Amount, Transaction Hash, Payment ID, Subaddress Index, &quot;-&quot;, Note\
Out: Block Number, &quot;out&quot;, Time, Amount*, Transaction Hash, Payment ID, Fee, Destinations, Input addresses**, &quot;-&quot;, Note
Pool: &quot;pool&quot;, &quot;in&quot;, Time, Amount, Transaction Hash, Payment Id, Subaddress Index, &quot;-&quot;, Note, Double Spend Note\
Pending or Failed: &quot;failed&quot;|&quot;pending&quot;, &quot;out&quot;, Time, Amount*, Transaction Hash, Payment ID, Fee, Input addresses**, &quot;-&quot;, Note

* Excluding change and fee.
** Set of address indices used as inputs in this transfer.</source>
<translation type="unfinished"></translation>
</message>
<message>
Expand Down
11 changes: 10 additions & 1 deletion translations/monero_fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,16 @@ Sinon, vous prouvez le plus petit solde supérieur à &lt;montant&gt; dans votre
</message>
<message>
<location filename="../src/simplewallet/simplewallet.cpp" line="2432"/>
<source>Show the incoming/outgoing transfers within an optional height range.</source>
<source>Show the incoming/outgoing transfers within an optional height range.

Output format:
In or Coinbase: Block Number, &quot;block&quot;|&quot;in&quot;, Time, Amount, Transaction Hash, Payment ID, Subaddress Index, &quot;-&quot;, Note\
Out: Block Number, &quot;out&quot;, Time, Amount*, Transaction Hash, Payment ID, Fee, Destinations, Input addresses**, &quot;-&quot;, Note
Pool: &quot;pool&quot;, &quot;in&quot;, Time, Amount, Transaction Hash, Payment Id, Subaddress Index, &quot;-&quot;, Note, Double Spend Note\
Pending or Failed: &quot;failed&quot;|&quot;pending&quot;, &quot;out&quot;, Time, Amount*, Transaction Hash, Payment ID, Fee, Input addresses**, &quot;-&quot;, Note

* Excluding change and fee.
** Set of address indices used as inputs in this transfer.</source>
<translation>Afficher les transferts entrants/sortants dans un interval de hauteurs facultatif.</translation>
</message>
<message>
Expand Down
11 changes: 10 additions & 1 deletion translations/monero_it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1702,7 +1702,16 @@ Otherwise, you prove the reserve of the smallest possible amount above &lt;amoun
</message>
<message>
<location filename="../src/simplewallet/simplewallet.cpp" line="1758"/>
<source>Show the incoming/outgoing transfers within an optional height range.</source>
<source>Show the incoming/outgoing transfers within an optional height range.

Output format:
In or Coinbase: Block Number, &quot;block&quot;|&quot;in&quot;, Time, Amount, Transaction Hash, Payment ID, Subaddress Index, &quot;-&quot;, Note\
Out: Block Number, &quot;out&quot;, Time, Amount*, Transaction Hash, Payment ID, Fee, Destinations, Input addresses**, &quot;-&quot;, Note
Pool: &quot;pool&quot;, &quot;in&quot;, Time, Amount, Transaction Hash, Payment Id, Subaddress Index, &quot;-&quot;, Note, Double Spend Note\
Pending or Failed: &quot;failed&quot;|&quot;pending&quot;, &quot;out&quot;, Time, Amount*, Transaction Hash, Payment ID, Fee, Input addresses**, &quot;-&quot;, Note

* Excluding change and fee.
** Set of address indices used as inputs in this transfer.</source>
<translation type="unfinished"></translation>
</message>
<message>
Expand Down

0 comments on commit 35058fe

Please sign in to comment.