aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt117
-rw-r--r--src/common/CMakeLists.txt64
-rw-r--r--src/connectivity_tool/CMakeLists.txt45
-rw-r--r--src/crypto/CMakeLists.txt76
-rw-r--r--src/cryptonote_config.h7
-rw-r--r--src/cryptonote_core/CMakeLists.txt80
-rw-r--r--src/cryptonote_core/account.cpp2
-rw-r--r--src/cryptonote_core/cryptonote_format_utils.cpp2
-rw-r--r--src/cryptonote_core/tx_pool.cpp7
-rw-r--r--src/daemon/CMakeLists.txt78
-rw-r--r--src/miner/CMakeLists.txt55
-rw-r--r--src/mnemonics/CMakeLists.txt52
-rw-r--r--src/mnemonics/electrum-words.cpp4
-rw-r--r--src/rpc/CMakeLists.txt54
-rw-r--r--src/simplewallet/CMakeLists.txt58
-rw-r--r--src/simplewallet/simplewallet.cpp85
-rw-r--r--src/simplewallet/simplewallet.h5
-rw-r--r--src/version.cmake2
-rw-r--r--src/version.h.in2
-rw-r--r--src/wallet/CMakeLists.txt56
-rw-r--r--src/wallet/wallet2.cpp123
-rw-r--r--src/wallet/wallet2.h45
22 files changed, 918 insertions, 101 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index aec615eb2..43c5740af 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -28,59 +28,72 @@
#
# Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
-add_definitions(-DSTATICLIB)
-# miniupnp changed their static define
-add_definitions(-DMINIUPNP_STATICLIB)
+if (WIN32 OR STATIC)
+ add_definitions(-DSTATICLIB)
+ # miniupnp changed their static define
+ add_definitions(-DMINIUPNP_STATICLIB)
+endif ()
-file(GLOB_RECURSE COMMON common/*)
-file(GLOB_RECURSE CRYPTO crypto/*)
-file(GLOB_RECURSE CRYPTONOTE_CORE cryptonote_core/*)
-file(GLOB_RECURSE CRYPTONOTE_PROTOCOL cryptonote_protocol/*)
-file(GLOB_RECURSE DAEMON daemon/*)
-file(GLOB_RECURSE P2P p2p/*)
-file(GLOB_RECURSE RPC rpc/*)
-file(GLOB_RECURSE SIMPLEWALLET simplewallet/*)
-file(GLOB_RECURSE CONN_TOOL connectivity_tool/*)
-file(GLOB_RECURSE WALLET wallet/*)
-file(GLOB_RECURSE MINER miner/*)
-file(GLOB MNEMONICS mnemonics/*)
+function (bitmonero_private_headers group)
+ source_group("${group}\\Private"
+ FILES
+ ${ARGN})
+endfunction ()
-source_group(common FILES ${COMMON})
-source_group(crypto FILES ${CRYPTO})
-source_group(cryptonote_core FILES ${CRYPTONOTE_CORE})
-source_group(cryptonote_protocol FILES ${CRYPTONOTE_PROTOCOL})
-source_group(daemon FILES ${DAEMON})
-source_group(p2p FILES ${P2P})
-source_group(rpc FILES ${RPC})
-source_group(simplewallet FILES ${SIMPLEWALLET})
-source_group(connectivity-tool FILES ${CONN_TOOL})
-source_group(wallet FILES ${WALLET})
-source_group(simpleminer FILES ${MINER})
-source_group(mnemonics FILES ${MNEMONICS})
+function (bitmonero_install_headers subdir)
+ install(
+ FILES ${ARGN}
+ DESTINATION "include/${subdir}"
+ COMPONENT development)
+endfunction ()
-add_library(common ${COMMON})
-add_library(crypto ${CRYPTO})
-add_library(cryptonote_core ${CRYPTONOTE_CORE})
-add_library(mnemonics ${MNEMONICS})
-add_executable(daemon ${DAEMON} ${P2P} ${CRYPTONOTE_PROTOCOL})
-add_executable(connectivity_tool ${CONN_TOOL})
-add_executable(simpleminer ${MINER})
-target_link_libraries(daemon rpc cryptonote_core crypto common ${UNBOUND_LIBRARY} ${UPNP_LIBRARIES} ${Boost_LIBRARIES} ${EXTRA_LIBRARIES})
-target_link_libraries(connectivity_tool cryptonote_core crypto common ${UNBOUND_LIBRARY} ${Boost_LIBRARIES} ${EXTRA_LIBRARIES})
-target_link_libraries(simpleminer cryptonote_core crypto common ${UNBOUND_LIBRARY} ${Boost_LIBRARIES} ${EXTRA_LIBRARIES})
-add_library(rpc ${RPC})
-add_library(wallet ${WALLET})
-target_link_libraries(wallet mnemonics)
-add_executable(simplewallet ${SIMPLEWALLET} )
-target_link_libraries(simplewallet wallet rpc cryptonote_core crypto common mnemonics ${UNBOUND_LIBRARY} ${UPNP_LIBRARIES} ${Boost_LIBRARIES} ${EXTRA_LIBRARIES})
-add_dependencies(daemon version)
-add_dependencies(rpc version)
-add_dependencies(simplewallet version)
+function (bitmonero_add_executable name)
+ source_group("${name}"
+ FILES
+ ${ARGN})
-set_property(TARGET common crypto cryptonote_core rpc wallet PROPERTY FOLDER "libs")
-set_property(TARGET daemon simplewallet connectivity_tool simpleminer PROPERTY FOLDER "prog")
-if (STATIC)
- set_property(TARGET daemon simplewallet connectivity_tool simpleminer PROPERTY LINK_SEARCH_START_STATIC 1)
- set_property(TARGET daemon simplewallet connectivity_tool simpleminer PROPERTY LINK_SEARCH_END_STATIC 1)
-endif()
-set_property(TARGET daemon PROPERTY OUTPUT_NAME "bitmonerod")
+ add_executable("${name}"
+ ${ARGN})
+ target_link_libraries("${name}"
+ LINK_PRIVATE
+ ${EXTRA_LIBRARIES})
+ set_property(TARGET "${name}"
+ PROPERTY
+ FOLDER "prog")
+ set_property(TARGET "${name}"
+ PROPERTY
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
+
+ if (STATIC)
+ set_property(TARGET "${name}"
+ PROPERTY
+ LINK_SEARCH_START_STATIC 1)
+ set_property(TARGET "${name}"
+ PROPERTY
+ LINK_SEARCH_END_STATIC 1)
+ endif ()
+endfunction ()
+
+function (bitmonero_add_library name)
+ source_group("${name}"
+ FILES
+ ${ARGN})
+
+ add_library("${name}"
+ ${ARGN})
+ set_property(TARGET "${name}"
+ PROPERTY
+ FOLDER "libs")
+endfunction ()
+
+add_subdirectory(common)
+add_subdirectory(crypto)
+add_subdirectory(cryptonote_core)
+add_subdirectory(mnemonics)
+add_subdirectory(rpc)
+add_subdirectory(wallet)
+
+add_subdirectory(connectivity_tool)
+add_subdirectory(miner)
+add_subdirectory(simplewallet)
+add_subdirectory(daemon)
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
new file mode 100644
index 000000000..739c0adee
--- /dev/null
+++ b/src/common/CMakeLists.txt
@@ -0,0 +1,64 @@
+# Copyright (c) 2014, 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.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# 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.
+
+set(common_sources
+ base58.cpp
+ command_line.cpp
+ dns_utils.cpp
+ util.cpp)
+
+set(common_headers)
+
+set(common_private_headers
+ base58.h
+ boost_serialization_helper.h
+ command_line.h
+ dns_utils.h
+ int-util.h
+ pod-class.h
+ unordered_containers_boost_serialization.h
+ util.h
+ varint.h)
+
+bitmonero_private_headers(common
+ ${common_private_headers})
+bitmonero_add_library(common
+ ${common_sources}
+ ${common_headers}
+ ${common_private_headers})
+target_link_libraries(common
+ LINK_PRIVATE
+ crypto
+ ${UNBOUND_LIBRARY}
+ ${Boost_DATE_TIME_LIBRARY}
+ ${Boost_FILESYSTEM_LIBRARY}
+ ${Boost_SYSTEM_LIBRARY}
+ ${EXTRA_LIBRARIES})
+
+#bitmonero_install_headers(common
+# ${common_headers})
diff --git a/src/connectivity_tool/CMakeLists.txt b/src/connectivity_tool/CMakeLists.txt
new file mode 100644
index 000000000..b0178c70a
--- /dev/null
+++ b/src/connectivity_tool/CMakeLists.txt
@@ -0,0 +1,45 @@
+# Copyright (c) 2014, 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.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# 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.
+
+set(connectivity_tool_sources
+ conn_tool.cpp)
+
+set(connectivity_tool_private_headers)
+
+bitmonero_add_executable(connectivity_tool
+ ${connectivity_tool_sources}
+ ${connectivity_tool_private_headers})
+target_link_libraries(connectivity_tool
+ LINK_PRIVATE
+ cryptonote_core
+ crypto
+ common
+ ${CMAKE_THREAD_LIBS_INIT}
+ ${Boost_PROGRAM_OPTIONS_LIBRARY}
+ ${Boost_REGEX_LIBRARY}
+ ${Boost_SYSTEM_LIBRARY})
diff --git a/src/crypto/CMakeLists.txt b/src/crypto/CMakeLists.txt
new file mode 100644
index 000000000..4afcab9c8
--- /dev/null
+++ b/src/crypto/CMakeLists.txt
@@ -0,0 +1,76 @@
+# Copyright (c) 2014, 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.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# 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.
+
+set(crypto_sources
+ aesb.c
+ blake256.c
+ chacha8.c
+ crypto-ops-data.c
+ crypto-ops.c
+ crypto.cpp
+ groestl.c
+ hash-extra-blake.c
+ hash-extra-groestl.c
+ hash-extra-jh.c
+ hash-extra-skein.c
+ hash.c
+ jh.c
+ keccak.c
+ oaes_lib.c
+ random.c
+ skein.c
+ slow-hash.c
+ tree-hash.c)
+
+set(crypto_headers)
+
+set(crypto_private_headers
+ blake256.h
+ chacha8.h
+ crypto-ops.h
+ crypto.h
+ generic-ops.h
+ groestl.h
+ groestl_tables.h
+ hash-ops.h
+ hash.h
+ initializer.h
+ jh.h
+ keccak.h
+ oaes_config.h
+ oaes_lib.h
+ random.h
+ skein.h
+ skein_port.h)
+
+bitmonero_private_headers(crypto
+ ${crypto_private_headers})
+bitmonero_add_library(crypto
+ ${crypto_sources}
+ ${crypto_headers}
+ ${crypto_private_headers})
diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h
index 1ac8ab328..7864b974e 100644
--- a/src/cryptonote_config.h
+++ b/src/cryptonote_config.h
@@ -56,8 +56,11 @@
#define CRYPTONOTE_DISPLAY_DECIMAL_POINT 12
// COIN - number of smallest units in one coin
#define COIN ((uint64_t)1000000000000) // pow(10, 12)
-#define DEFAULT_FEE ((uint64_t)100000000000) // 5 * pow(10, 11)
+#define FEE_PER_KB ((uint64_t)10000000000) // pow(10, 10)
+
+// temporarily to allow backward compatibility during the switch to per-kb
+//#define MINING_ALLOWED_LEGACY_FEE ((uint64_t)100000000000) // pow(10, 11)
#define ORPHANED_BLOCKS_MAX_COUNT 100
@@ -114,7 +117,7 @@ namespace config
{
uint64_t const DEFAULT_FEE_ATOMIC_XMR_PER_KB = 500; // Just a placeholder! Change me!
uint8_t const FEE_CALCULATION_MAX_RETRIES = 10;
- uint64_t const DEFAULT_DUST_THRESHOLD = 5000000000; // 5 * 10^9
+ uint64_t const DEFAULT_DUST_THRESHOLD = ((uint64_t)10000000000); // pow(10, 10)
std::string const P2P_REMOTE_DEBUG_TRUSTED_PUB_KEY = "0000000000000000000000000000000000000000000000000000000000000000";
uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX = 18;
diff --git a/src/cryptonote_core/CMakeLists.txt b/src/cryptonote_core/CMakeLists.txt
new file mode 100644
index 000000000..3c2e097c1
--- /dev/null
+++ b/src/cryptonote_core/CMakeLists.txt
@@ -0,0 +1,80 @@
+# Copyright (c) 2014, 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.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# 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.
+
+set(cryptonote_core_sources
+ account.cpp
+ blockchain_storage.cpp
+ checkpoints.cpp
+ checkpoints_create.cpp
+ cryptonote_basic_impl.cpp
+ cryptonote_core.cpp
+ cryptonote_format_utils.cpp
+ difficulty.cpp
+ miner.cpp
+ tx_pool.cpp)
+
+set(cryptonote_core_headers)
+
+set(cryptonote_core_private_headers
+ account.h
+ account_boost_serialization.h
+ blockchain_storage.h
+ blockchain_storage_boost_serialization.h
+ checkpoints.h
+ checkpoints_create.h
+ connection_context.h
+ cryptonote_basic.h
+ cryptonote_basic_impl.h
+ cryptonote_boost_serialization.h
+ cryptonote_core.h
+ cryptonote_format_utils.h
+ cryptonote_stat_info.h
+ difficulty.h
+ miner.h
+ tx_extra.h
+ tx_pool.h
+ verification_context.h)
+
+bitmonero_private_headers(cryptonote_core
+ ${crypto_private_headers})
+bitmonero_add_library(cryptonote_core
+ ${cryptonote_core_sources}
+ ${cryptonote_core_headers}
+ ${cryptonote_core_private_headers})
+target_link_libraries(cryptonote_core
+ LINK_PUBLIC
+ common
+ crypto
+ ${Boost_DATE_TIME_LIBRARY}
+ ${Boost_PROGRAM_OPTIONS_LIBRARY}
+ ${Boost_SERIALIZATION_LIBRARY}
+ LINK_PRIVATE
+ ${Boost_FILESYSTEM_LIBRARY}
+ ${Boost_SYSTEM_LIBRARY}
+ ${Boost_THREAD_LIBRARY}
+ ${EXTRA_LIBRARIES})
diff --git a/src/cryptonote_core/account.cpp b/src/cryptonote_core/account.cpp
index 36043238d..9f6c91026 100644
--- a/src/cryptonote_core/account.cpp
+++ b/src/cryptonote_core/account.cpp
@@ -65,7 +65,7 @@ DISABLE_VS_WARNINGS(4244 4345)
// rng for generating second set of keys is hash of first rng. means only one set of electrum-style words needed for recovery
crypto::secret_key second;
- keccak((uint8_t *)&first, sizeof(crypto::secret_key), (uint8_t *)&second, sizeof(crypto::secret_key));
+ keccak((uint8_t *)&m_keys.m_spend_secret_key, sizeof(crypto::secret_key), (uint8_t *)&second, sizeof(crypto::secret_key));
generate_keys(m_keys.m_account_address.m_view_public_key, m_keys.m_view_secret_key, second, two_random ? false : true);
diff --git a/src/cryptonote_core/cryptonote_format_utils.cpp b/src/cryptonote_core/cryptonote_format_utils.cpp
index 33cad30c4..8c7b2fbaa 100644
--- a/src/cryptonote_core/cryptonote_format_utils.cpp
+++ b/src/cryptonote_core/cryptonote_format_utils.cpp
@@ -107,7 +107,7 @@ namespace cryptonote
block_reward += fee;
std::vector<uint64_t> out_amounts;
- decompose_amount_into_digits(block_reward, DEFAULT_FEE,
+ decompose_amount_into_digits(block_reward, ::config::DEFAULT_DUST_THRESHOLD,
[&out_amounts](uint64_t a_chunk) { out_amounts.push_back(a_chunk); },
[&out_amounts](uint64_t a_dust) { out_amounts.push_back(a_dust); });
diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp
index 81f932014..96c6ebed9 100644
--- a/src/cryptonote_core/tx_pool.cpp
+++ b/src/cryptonote_core/tx_pool.cpp
@@ -86,9 +86,12 @@ namespace cryptonote
}
uint64_t fee = inputs_amount - outputs_amount;
- if (!kept_by_block && fee < DEFAULT_FEE)
+ uint64_t needed_fee = blob_size / 1024;
+ needed_fee += (blob_size % 1024) ? 1 : 0;
+ needed_fee *= FEE_PER_KB;
+ if (!kept_by_block && fee < needed_fee /*&& fee < MINING_ALLOWED_LEGACY_FEE*/)
{
- LOG_PRINT_L1("transaction fee is not enough: " << print_money(fee) << ", minumim fee: " << print_money(DEFAULT_FEE));
+ LOG_PRINT_L1("transaction fee is not enough: " << print_money(fee) << ", minumim fee: " << print_money(needed_fee));
tvc.m_verifivation_failed = true;
return false;
}
diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt
new file mode 100644
index 000000000..adcc61c43
--- /dev/null
+++ b/src/daemon/CMakeLists.txt
@@ -0,0 +1,78 @@
+# Copyright (c) 2014, 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.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# 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.
+
+set(daemon_sources
+ daemon.cpp)
+
+set(daemon_headers)
+
+set(daemon_private_headers
+ daemon_commands_handler.h
+
+ # cryptonote_protocol
+ ../cryptonote_protocol/blobdatatype.h
+ ../cryptonote_protocol/cryptonote_protocol_defs.h
+ ../cryptonote_protocol/cryptonote_protocol_handler.h
+ ../cryptonote_protocol/cryptonote_protocol_handler.inl
+ ../cryptonote_protocol/cryptonote_protocol_handler_common.h
+
+ # p2p
+ ../p2p/net_node.h
+ ../p2p/net_node.inl
+ ../p2p/net_node_common.h
+ ../p2p/net_peerlist.h
+ ../p2p/net_peerlist_boost_serialization.h
+ ../p2p/p2p_protocol_defs.h
+ ../p2p/stdafx.h)
+
+bitmonero_private_headers(daemon
+ ${daemon_private_headers})
+bitmonero_add_executable(daemon
+ ${daemon_sources}
+ ${daemon_headers}
+ ${daemon_private_headers})
+target_link_libraries(daemon
+ LINK_PRIVATE
+ rpc
+ cryptonote_core
+ crypto
+ common
+ ${Boost_CHRONO_LIBRARY}
+ ${Boost_FILESYSTEM_LIBRARY}
+ ${Boost_PROGRAM_OPTIONS_LIBRARY}
+ ${Boost_REGEX_LIBRARY}
+ ${Boost_SYSTEM_LIBRARY}
+ ${Boost_THREAD_LIBRARY}
+ ${CMAKE_THREAD_LIBS_INIT}
+ ${UPNP_LIBRARIES}
+ ${EXTRA_LIBRARIES})
+add_dependencies(daemon
+ version)
+set_property(TARGET daemon
+ PROPERTY
+ OUTPUT_NAME "bitmonerod")
diff --git a/src/miner/CMakeLists.txt b/src/miner/CMakeLists.txt
new file mode 100644
index 000000000..83bda57cc
--- /dev/null
+++ b/src/miner/CMakeLists.txt
@@ -0,0 +1,55 @@
+# Copyright (c) 2014, 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.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# 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.
+
+set(simpleminer_sources
+ simpleminer.cpp)
+
+set(simpleminer_headers)
+
+set(simpleminer_private_headers
+ simpleminer.h
+ simpleminer_protocol_defs.h
+ target_helper.h)
+
+bitmonero_private_headers(simpleminer
+ ${simpleminer_private_headers})
+bitmonero_add_executable(simpleminer
+ ${simpleminer_sources}
+ ${simpleminer_headers}
+ ${simpleminer_private_headers})
+target_link_libraries(simpleminer
+ LINK_PRIVATE
+ cryptonote_core
+ common
+ ${Boost_FILESYSTEM_LIBRARY}
+ ${Boost_PROGRAM_OPTIONS_LIBRARY}
+ ${Boost_REGEX_LIBRARY}
+ ${Boost_SYSTEM_LIBRARY}
+ ${Boost_THREAD_LIBRARY}
+ ${CMAKE_THREAD_LIBS_INIT}
+ ${EXTRA_LIBRARIES})
diff --git a/src/mnemonics/CMakeLists.txt b/src/mnemonics/CMakeLists.txt
new file mode 100644
index 000000000..66ef4f3f1
--- /dev/null
+++ b/src/mnemonics/CMakeLists.txt
@@ -0,0 +1,52 @@
+# Copyright (c) 2014, 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.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# 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.
+
+set(mnemonics_sources
+ electrum-words.cpp)
+
+set(mnemonics_headers)
+
+set(mnemonics_private_headers
+ electrum-words.h
+ english.h
+ japanese.h
+ language_base.h
+ old_english.h
+ portuguese.h
+ singleton.h
+ spanish.h)
+
+bitmonero_private_headers(mnemonics
+ ${mnemonics_private_headers})
+bitmonero_add_library(mnemonics
+ ${mnemonics_sources}
+ ${mnemonics_headers}
+ ${mnemonics_private_headers})
+target_link_libraries(mnemonics
+ LINK_PRIVATE
+ ${Boost_SYSTEM_LIBRARY})
diff --git a/src/mnemonics/electrum-words.cpp b/src/mnemonics/electrum-words.cpp
index ffa82b21e..7258b8a15 100644
--- a/src/mnemonics/electrum-words.cpp
+++ b/src/mnemonics/electrum-words.cpp
@@ -255,7 +255,7 @@ namespace crypto
std::string wlist_copy = words;
if (seed.size() == seed_length/2)
{
- memcpy(dst.data, dst.data + 16, 16); // if electrum 12-word seed, duplicate
+ memcpy(dst.data+16, dst.data, 16); // if electrum 12-word seed, duplicate
wlist_copy += ' ';
wlist_copy += words;
}
@@ -328,7 +328,7 @@ namespace crypto
words.pop_back();
words += (' ' + words_store[create_checksum_index(words_store, language->get_unique_prefix_length())]);
- return false;
+ return true;
}
/*!
diff --git a/src/rpc/CMakeLists.txt b/src/rpc/CMakeLists.txt
new file mode 100644
index 000000000..5417a0ec1
--- /dev/null
+++ b/src/rpc/CMakeLists.txt
@@ -0,0 +1,54 @@
+# Copyright (c) 2014, 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.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# 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.
+
+set(rpc_sources
+ core_rpc_server.cpp)
+
+set(rpc_headers)
+
+set(rpc_private_headers
+ core_rpc_server.h
+ core_rpc_server_commands_defs.h
+ core_rpc_server_error_codes.h)
+
+bitmonero_private_headers(rpc
+ ${rpc_private_headers})
+bitmonero_add_library(rpc
+ ${rpc_sources}
+ ${rpc_headers}
+ ${rpc_private_headers})
+target_link_libraries(rpc
+ LINK_PRIVATE
+ cryptonote_core
+ ${Boost_CHRONO_LIBRARY}
+ ${Boost_REGEX_LIBRARY}
+ ${Boost_SYSTEM_LIBRARY}
+ ${Boost_THREAD_LIBRARY}
+ ${EXTRA_LIBRARIES})
+add_dependencies(rpc
+ version)
diff --git a/src/simplewallet/CMakeLists.txt b/src/simplewallet/CMakeLists.txt
new file mode 100644
index 000000000..14f877907
--- /dev/null
+++ b/src/simplewallet/CMakeLists.txt
@@ -0,0 +1,58 @@
+# Copyright (c) 2014, 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.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# 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.
+
+set(simplewallet_sources
+ simplewallet.cpp
+ password_container.cpp)
+
+set(simplewallet_headers)
+
+set(simplewallet_private_headers
+ simplewallet.h
+ password_container.h)
+
+bitmonero_private_headers(simplewallet
+ ${simplewallet_private_headers})
+bitmonero_add_executable(simplewallet
+ ${simplewallet_sources}
+ ${simplewallet_headers}
+ ${simplewallet_private_headers})
+target_link_libraries(simplewallet
+ LINK_PRIVATE
+ wallet
+ rpc
+ cryptonote_core
+ crypto
+ common
+ mnemonics
+ ${UNBOUND_LIBRARY}
+ ${UPNP_LIBRARIES}
+ ${CMAKE_THREAD_LIBS_INIT}
+ ${EXTRA_LIBRARIES})
+add_dependencies(simplewallet
+ version)
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 4cb9cff21..e1e2a198b 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -207,6 +207,13 @@ bool simple_wallet::viewkey(const std::vector<std::string> &args/* = std::vector
bool simple_wallet::seed(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
{
std::string electrum_words;
+
+ if (m_wallet->get_seed_language().empty())
+ {
+ std::string mnemonic_language = get_mnemonic_language();
+ m_wallet->set_seed_language(mnemonic_language);
+ }
+
bool success = m_wallet->get_seed(electrum_words);
if (success)
@@ -317,6 +324,21 @@ bool simple_wallet::ask_wallet_create_if_needed()
return r;
}
+
+/*!
+ * \brief Prints the seed with a nice message
+ * \param seed seed to print
+ */
+void simple_wallet::print_seed(std::string seed)
+{
+ success_msg_writer(true) << "\nPLEASE NOTE: the following 25 words can be used to recover access to your wallet. " <<
+ "Please write them down and store them somewhere safe and secure. Please do not store them in " <<
+ "your email or on file storage services outside of your immediate control.\n";
+ boost::replace_nth(seed, " ", 15, "\n");
+ boost::replace_nth(seed, " ", 7, "\n");
+ std::cout << seed << std::endl;
+}
+
//----------------------------------------------------------------------------------------------------
bool simple_wallet::init(const boost::program_options::variables_map& vm)
{
@@ -485,10 +507,28 @@ std::string simple_wallet::get_mnemonic_language()
bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string& password, const crypto::secret_key& recovery_key,
bool recover, bool two_random, bool testnet, const std::string &old_language)
{
+ bool was_deprecated_wallet = m_restore_deterministic_wallet && ((old_language == crypto::ElectrumWords::old_language_name) ||
+ crypto::ElectrumWords::get_is_old_style_seed(m_electrum_seed));
+
+ std::string mnemonic_language = old_language;
+ // Ask for seed language if it is not a wallet restore or if it was a deprecated wallet
+ // that was earlier used before this restore.
+ if (!m_restore_deterministic_wallet || was_deprecated_wallet)
+ {
+ if (was_deprecated_wallet)
+ {
+ // The user had used an older version of the wallet with old style mnemonics.
+ message_writer(epee::log_space::console_color_green, false) << "\nYou had been using " <<
+ "a deprecated version of the wallet. Please use the new seed that we provide.\n";
+ }
+ mnemonic_language = get_mnemonic_language();
+ }
+
m_wallet_file = wallet_file;
m_wallet.reset(new tools::wallet2(testnet));
m_wallet->callback(this);
+ m_wallet->set_seed_language(mnemonic_language);
crypto::secret_key recovery_val;
try
@@ -509,27 +549,7 @@ bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string
// convert rng value to electrum-style word list
std::string electrum_words;
- bool was_deprecated_wallet = (old_language == crypto::ElectrumWords::old_language_name) ||
- crypto::ElectrumWords::get_is_old_style_seed(m_electrum_seed);
-
- std::string mnemonic_language = old_language;
- // Ask for seed language if it is not a wallet restore or if it was a deprecated wallet
- // that was earlier used before this restore.
- if (!m_restore_deterministic_wallet || was_deprecated_wallet)
- {
- if (was_deprecated_wallet)
- {
- // The user had used an older version of the wallet with old style mnemonics.
- message_writer(epee::log_space::console_color_green, false) << "\nYou had been using " <<
- "a deprecated version of the wallet. Please use the new seed that we provide.\n";
- }
- mnemonic_language = get_mnemonic_language();
- }
crypto::ElectrumWords::bytes_to_words(recovery_val, electrum_words, mnemonic_language);
- m_wallet->set_seed_language(mnemonic_language);
-
- std::string print_electrum = "";
-
success_msg_writer() <<
"**********************************************************************\n" <<
@@ -543,10 +563,7 @@ bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string
if (!two_random)
{
- success_msg_writer(true) << "\nPLEASE NOTE: the following 25 words can be used to recover access to your wallet. Please write them down and store them somewhere safe and secure. Please do not store them in your email or on file storage services outside of your immediate control.\n";
- boost::replace_nth(electrum_words, " ", 15, "\n");
- boost::replace_nth(electrum_words, " ", 7, "\n");
- std::cout << electrum_words << std::endl;
+ print_seed(electrum_words);
}
success_msg_writer() << "**********************************************************************";
@@ -564,6 +581,21 @@ bool simple_wallet::open_wallet(const string &wallet_file, const std::string& pa
m_wallet->load(m_wallet_file, password);
message_writer(epee::log_space::console_color_white, true) << "Opened wallet: "
<< m_wallet->get_account().get_public_address_str(m_wallet->testnet());
+ // If the wallet file is deprecated, we should ask for mnemonic language again and store
+ // everything in the new format.
+ if (!m_non_deterministic && m_wallet->is_deprecated())
+ {
+ message_writer(epee::log_space::console_color_green, false) << "\nYou had been using " <<
+ "a deprecated version of the wallet. Please proceed to upgrade your wallet.\n";
+ std::string mnemonic_language = get_mnemonic_language();
+ m_wallet->set_seed_language(mnemonic_language);
+ m_wallet->rewrite(m_wallet_file, password);
+
+ // Display the seed
+ std::string seed;
+ m_wallet->get_seed(seed);
+ print_seed(seed);
+ }
}
catch (const std::exception& e)
{
@@ -1054,15 +1086,14 @@ bool simple_wallet::transfer(const std::vector<std::string> &args_)
try
{
// figure out what tx will be necessary
- auto ptx_vector = m_wallet->create_transactions(dsts, fake_outs_count, 0 /* unlock_time */, DEFAULT_FEE, extra);
+ auto ptx_vector = m_wallet->create_transactions(dsts, fake_outs_count, 0 /* unlock_time */, 0 /* unused fee arg*/, extra);
// if more than one tx necessary, prompt user to confirm
if (ptx_vector.size() > 1)
{
std::string prompt_str = "Your transaction needs to be split into ";
prompt_str += std::to_string(ptx_vector.size());
- prompt_str += " transactions. This will result in a fee of ";
- prompt_str += print_money(ptx_vector.size() * DEFAULT_FEE);
+ prompt_str += " transactions. This will result in a transaction fee being applied to each transaction";
prompt_str += ". Is this okay? (Y/Yes/N/No)";
std::string accepted = command_line::input_line(prompt_str);
if (accepted != "Y" && accepted != "y" && accepted != "Yes" && accepted != "yes")
diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h
index af6d4172a..ebc85ed17 100644
--- a/src/simplewallet/simplewallet.h
+++ b/src/simplewallet/simplewallet.h
@@ -101,6 +101,11 @@ namespace cryptonote
uint64_t get_daemon_blockchain_height(std::string& err);
bool try_connect_to_daemon();
bool ask_wallet_create_if_needed();
+ /*!
+ * \brief Prints the seed with a nice message
+ * \param seed seed to print
+ */
+ void print_seed(std::string seed);
/*!
* \brief Gets the word seed language from the user.
diff --git a/src/version.cmake b/src/version.cmake
index 2f3aa0b25..14ce8843d 100644
--- a/src/version.cmake
+++ b/src/version.cmake
@@ -68,7 +68,7 @@ else()
message(STATUS "The most recent tag was at ${TAGGEDCOMMIT}")
# Check if we're building that tagged commit or a different one
- if(${COMMIT} MATCHES ${TAGGEDCOMMIT})
+ if(COMMIT STREQUAL TAGGEDCOMMIT)
message(STATUS "You are building a tagged release")
set(VERSIONTAG "release")
else()
diff --git a/src/version.h.in b/src/version.h.in
index 9862431de..b6b24d5a0 100644
--- a/src/version.h.in
+++ b/src/version.h.in
@@ -1,3 +1,3 @@
#define MONERO_VERSION_TAG "@VERSIONTAG@"
-#define MONERO_VERSION "0.8.8.4"
+#define MONERO_VERSION "0.8.8.5"
#define MONERO_VERSION_FULL MONERO_VERSION "-" MONERO_VERSION_TAG
diff --git a/src/wallet/CMakeLists.txt b/src/wallet/CMakeLists.txt
new file mode 100644
index 000000000..af3ec0fb8
--- /dev/null
+++ b/src/wallet/CMakeLists.txt
@@ -0,0 +1,56 @@
+# Copyright (c) 2014, 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.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# 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.
+
+set(wallet_sources
+ wallet2.cpp
+ wallet_rpc_server.cpp)
+
+set(wallet_headers)
+
+set(wallet_private_headers
+ wallet2.h
+ wallet_errors.h
+ wallet_rpc_server.h
+ wallet_rpc_server_commands_defs.h
+ wallet_rpc_server_error_codes.h)
+
+bitmonero_private_headers(wallet
+ ${wallet_private_headers})
+bitmonero_add_library(wallet
+ ${wallet_sources}
+ ${wallet_headers}
+ ${wallet_private_headers})
+target_link_libraries(wallet
+ LINK_PUBLIC
+ cryptonote_core
+ mnemonics
+ LINK_PRIVATE
+ ${Boost_SERIALIZATION_LIBRARY}
+ ${Boost_SYSTEM_LIBRARY}
+ ${Boost_THREAD_LIBRARY}
+ ${EXTRA_LIBRARIES})
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 5af9a71bd..066b006b4 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -48,6 +48,9 @@ using namespace epee;
#include "cryptonote_protocol/blobdatatype.h"
#include "mnemonics/electrum-words.h"
#include "common/dns_utils.h"
+#include "rapidjson/document.h"
+#include "rapidjson/writer.h"
+#include "rapidjson/stringbuffer.h"
extern "C"
{
@@ -88,6 +91,12 @@ void wallet2::init(const std::string& daemon_address, uint64_t upper_transaction
//----------------------------------------------------------------------------------------------------
bool wallet2::get_seed(std::string& electrum_words)
{
+ if (seed_language.empty())
+ {
+ std::cout << "seed_language not set" << std::endl;
+ return false;
+ }
+
crypto::ElectrumWords::bytes_to_words(get_account().get_keys().m_spend_secret_key, electrum_words, seed_language);
crypto::secret_key second;
@@ -98,12 +107,27 @@ bool wallet2::get_seed(std::string& electrum_words)
return memcmp(second.data,get_account().get_keys().m_view_secret_key.data, sizeof(crypto::secret_key)) == 0;
}
/*!
+ * \brief Gets the seed language
+ */
+const std::string wallet2::get_seed_language()
+{
+ return seed_language;
+}
+/*!
* \brief Sets the seed language
+ * \param language Seed language to set to
*/
void wallet2::set_seed_language(const std::string &language)
{
seed_language = language;
}
+/*!
+ * \brief Tells if the wallet file is deprecated.
+ */
+bool wallet2::is_deprecated() const
+{
+ return is_old_file_format;
+}
//----------------------------------------------------------------------------------------------------
void wallet2::process_new_transaction(const cryptonote::transaction& tx, uint64_t height)
{
@@ -432,7 +456,13 @@ bool wallet2::clear()
m_local_bc_height = 1;
return true;
}
-//----------------------------------------------------------------------------------------------------
+
+/*!
+ * \brief Stores wallet information to wallet file.
+ * \param keys_file_name Name of wallet file
+ * \param password Password of wallet file
+ * \return Whether it was successful.
+ */
bool wallet2::store_keys(const std::string& keys_file_name, const std::string& password)
{
std::string account_data;
@@ -440,6 +470,22 @@ bool wallet2::store_keys(const std::string& keys_file_name, const std::string& p
CHECK_AND_ASSERT_MES(r, false, "failed to serialize wallet keys");
wallet2::keys_file_data keys_file_data = boost::value_initialized<wallet2::keys_file_data>();
+ // Create a JSON object with "key_data" and "seed_language" as keys.
+ rapidjson::Document json;
+ json.SetObject();
+ rapidjson::Value value(rapidjson::kStringType);
+ value.SetString(account_data.c_str(), account_data.length());
+ json.AddMember("key_data", value, json.GetAllocator());
+ value.SetString(seed_language.c_str(), seed_language.length());
+ json.AddMember("seed_language", value, json.GetAllocator());
+
+ // Serialize the JSON object
+ rapidjson::StringBuffer buffer;
+ rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
+ json.Accept(writer);
+ account_data = buffer.GetString();
+
+ // Encrypt the entire JSON object.
crypto::chacha8_key key;
crypto::generate_chacha8_key(password, key);
std::string cipher;
@@ -465,30 +511,60 @@ namespace
return r && expected_pub == pub;
}
}
-//----------------------------------------------------------------------------------------------------
+
+/*!
+ * \brief Load wallet information from wallet file.
+ * \param keys_file_name Name of wallet file
+ * \param password Password of wallet file
+ */
void wallet2::load_keys(const std::string& keys_file_name, const std::string& password)
{
wallet2::keys_file_data keys_file_data;
std::string buf;
bool r = epee::file_io_utils::load_file_to_string(keys_file_name, buf);
THROW_WALLET_EXCEPTION_IF(!r, error::file_read_error, keys_file_name);
+
+ // Decrypt the contents
r = ::serialization::parse_binary(buf, keys_file_data);
THROW_WALLET_EXCEPTION_IF(!r, error::wallet_internal_error, "internal error: failed to deserialize \"" + keys_file_name + '\"');
-
crypto::chacha8_key key;
crypto::generate_chacha8_key(password, key);
std::string account_data;
account_data.resize(keys_file_data.account_data.size());
crypto::chacha8(keys_file_data.account_data.data(), keys_file_data.account_data.size(), key, keys_file_data.iv, &account_data[0]);
+ // The contents should be JSON if the wallet follows the new format.
+ rapidjson::Document json;
+ if (json.Parse(account_data.c_str(), keys_file_data.account_data.size()).HasParseError())
+ {
+ is_old_file_format = true;
+ }
+ else
+ {
+ account_data = std::string(json["key_data"].GetString(), json["key_data"].GetString() +
+ json["key_data"].GetStringLength());
+ set_seed_language(std::string(json["seed_language"].GetString(), json["seed_language"].GetString() +
+ json["seed_language"].GetStringLength()));
+ }
+
const cryptonote::account_keys& keys = m_account.get_keys();
r = epee::serialization::load_t_from_binary(m_account, account_data);
r = r && verify_keys(keys.m_view_secret_key, keys.m_account_address.m_view_public_key);
r = r && verify_keys(keys.m_spend_secret_key, keys.m_account_address.m_spend_public_key);
THROW_WALLET_EXCEPTION_IF(!r, error::invalid_password);
}
-//----------------------------------------------------------------------------------------------------
-crypto::secret_key wallet2::generate(const std::string& wallet_, const std::string& password, const crypto::secret_key& recovery_param, bool recover, bool two_random)
+
+/*!
+ * \brief Generates a wallet or restores one.
+ * \param wallet_ Name of wallet file
+ * \param password Password of wallet file
+ * \param recovery_param If it is a restore, the recovery key
+ * \param recover Whether it is a restore
+ * \param two_random Whether it is a non-deterministic wallet
+ * \return The secret key of the generated wallet
+ */
+crypto::secret_key wallet2::generate(const std::string& wallet_, const std::string& password,
+ const crypto::secret_key& recovery_param, bool recover, bool two_random)
{
clear();
prepare_file_names(wallet_);
@@ -514,6 +590,22 @@ crypto::secret_key wallet2::generate(const std::string& wallet_, const std::stri
store();
return retval;
}
+
+/*!
+ * \brief Rewrites to the wallet file for wallet upgrade (doesn't generate key, assumes it's already there)
+ * \param wallet_name Name of wallet file (should exist)
+ * \param password Password for wallet file
+ */
+void wallet2::rewrite(const std::string& wallet_name, const std::string& password)
+{
+ prepare_file_names(wallet_name);
+ boost::system::error_code ignored_ec;
+ THROW_WALLET_EXCEPTION_IF(!boost::filesystem::exists(m_wallet_file, ignored_ec), error::file_not_found, m_wallet_file);
+ THROW_WALLET_EXCEPTION_IF(!boost::filesystem::exists(m_keys_file, ignored_ec), error::file_not_found, m_keys_file);
+ bool r = store_keys(m_keys_file, password);
+ THROW_WALLET_EXCEPTION_IF(!r, error::file_save_error, m_keys_file);
+ store();
+}
//----------------------------------------------------------------------------------------------------
void wallet2::wallet_exists(const std::string& file_path, bool& keys_file_exists, bool& wallet_file_exists)
{
@@ -764,7 +856,7 @@ void wallet2::add_unconfirmed_tx(const cryptonote::transaction& tx, uint64_t cha
void wallet2::transfer(const std::vector<cryptonote::tx_destination_entry>& dsts, size_t fake_outputs_count,
uint64_t unlock_time, uint64_t fee, const std::vector<uint8_t>& extra, cryptonote::transaction& tx, pending_tx& ptx)
{
- transfer(dsts, fake_outputs_count, unlock_time, fee, extra, detail::digit_split_strategy, tx_dust_policy(fee), tx, ptx);
+ transfer(dsts, fake_outputs_count, unlock_time, fee, extra, detail::digit_split_strategy, tx_dust_policy(::config::DEFAULT_DUST_THRESHOLD), tx, ptx);
}
//----------------------------------------------------------------------------------------------------
void wallet2::transfer(const std::vector<cryptonote::tx_destination_entry>& dsts, size_t fake_outputs_count,
@@ -930,7 +1022,7 @@ void wallet2::commit_tx(std::vector<pending_tx>& ptx_vector)
//
// this function will make multiple calls to wallet2::transfer if multiple
// transactions will be required
-std::vector<wallet2::pending_tx> wallet2::create_transactions(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, const uint64_t unlock_time, const uint64_t fee, const std::vector<uint8_t> extra)
+std::vector<wallet2::pending_tx> wallet2::create_transactions(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, const uint64_t unlock_time, const uint64_t fee_UNUSED, const std::vector<uint8_t> extra)
{
// failsafe split attempt counter
@@ -954,7 +1046,22 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions(std::vector<crypto
{
cryptonote::transaction tx;
pending_tx ptx;
- transfer(dst_vector, fake_outs_count, unlock_time, fee, extra, tx, ptx);
+
+ // loop until fee is met without increasing tx size to next KB boundary.
+ uint64_t needed_fee = 0;
+ do
+ {
+ transfer(dst_vector, fake_outs_count, unlock_time, needed_fee, extra, tx, ptx);
+ auto txBlob = t_serializable_object_to_blob(ptx.tx);
+ uint64_t txSize = txBlob.size();
+ uint64_t numKB = txSize / 1024;
+ if (txSize % 1024)
+ {
+ numKB++;
+ }
+ needed_fee = numKB * FEE_PER_KB;
+ } while (ptx.fee < needed_fee);
+
ptx_vector.push_back(ptx);
// mark transfers to be used as "spent"
diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h
index afa42c2d3..bcd7ce6f7 100644
--- a/src/wallet/wallet2.h
+++ b/src/wallet/wallet2.h
@@ -82,7 +82,7 @@ namespace tools
{
wallet2(const wallet2&) : m_run(true), m_callback(0), m_testnet(false) {};
public:
- wallet2(bool testnet = false) : m_run(true), m_callback(0), m_testnet(testnet) {};
+ wallet2(bool testnet = false) : m_run(true), m_callback(0), m_testnet(testnet), is_old_file_format(false) {};
struct transfer_details
{
uint64_t m_block_height;
@@ -133,7 +133,24 @@ namespace tools
END_SERIALIZE()
};
- crypto::secret_key generate(const std::string& wallet, const std::string& password, const crypto::secret_key& recovery_param = crypto::secret_key(), bool recover = false, bool two_random = false);
+ /*!
+ * \brief Generates a wallet or restores one.
+ * \param wallet_ Name of wallet file
+ * \param password Password of wallet file
+ * \param recovery_param If it is a restore, the recovery key
+ * \param recover Whether it is a restore
+ * \param two_random Whether it is a non-deterministic wallet
+ * \return The secret key of the generated wallet
+ */
+ crypto::secret_key generate(const std::string& wallet, const std::string& password,
+ const crypto::secret_key& recovery_param = crypto::secret_key(), bool recover = false,
+ bool two_random = false);
+ /*!
+ * \brief Rewrites to the wallet file for wallet upgrade (doesn't generate key, assumes it's already there)
+ * \param wallet_name Name of wallet file (should exist)
+ * \param password Password for wallet file
+ */
+ void rewrite(const std::string& wallet_name, const std::string& password);
void load(const std::string& wallet, const std::string& password);
void store();
cryptonote::account_base& get_account(){return m_account;}
@@ -153,9 +170,17 @@ namespace tools
bool get_seed(std::string& electrum_words);
/*!
+ * \brief Gets the seed language
+ */
+ const std::string get_seed_language();
+ /*!
* \brief Sets the seed language
*/
- void set_seed_language(const std::string &language);
+ void set_seed_language(const std::string &language);
+ /*!
+ * \brief Tells if the wallet file is deprecated.
+ */
+ bool is_deprecated() const;
void refresh();
void refresh(uint64_t start_height, size_t & blocks_fetched);
void refresh(uint64_t start_height, size_t & blocks_fetched, bool& received_money);
@@ -203,7 +228,18 @@ namespace tools
static std::string address_from_txt_record(const std::string& s);
private:
+ /*!
+ * \brief Stores wallet information to wallet file.
+ * \param keys_file_name Name of wallet file
+ * \param password Password of wallet file
+ * \return Whether it was successful.
+ */
bool store_keys(const std::string& keys_file_name, const std::string& password);
+ /*!
+ * \brief Load wallet information from wallet file.
+ * \param keys_file_name Name of wallet file
+ * \param password Password of wallet file
+ */
void load_keys(const std::string& keys_file_name, const std::string& password);
void process_new_transaction(const cryptonote::transaction& tx, uint64_t height);
void process_new_blockchain_entry(const cryptonote::block& b, cryptonote::block_complete_entry& bche, crypto::hash& bl_id, uint64_t height);
@@ -239,7 +275,8 @@ namespace tools
i_wallet2_callback* m_callback;
bool m_testnet;
- std::string seed_language;
+ std::string seed_language; /*!< Language of the mnemonics (seed). */
+ bool is_old_file_format; /*!< Whether the wallet file is of an old file format */
};
}
BOOST_CLASS_VERSION(tools::wallet2, 7)