aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--CMakeLists_IOS.txt2
-rw-r--r--LICENSE2
-rw-r--r--Makefile6
-rw-r--r--README.md25
-rw-r--r--cmake/32-bit-toolchain.cmake2
-rw-r--r--cmake/64-bit-toolchain.cmake2
-rw-r--r--cmake/CheckTrezor.cmake17
-rw-r--r--cmake/FindUnbound.cmake2
-rw-r--r--cmake/GenVersion.cmake2
-rw-r--r--cmake/Version.cmake2
-rw-r--r--cmake/test-libusb-version.c2
-rw-r--r--cmake/test-protobuf.cpp2
-rw-r--r--cmake/test-static-assert.c2
-rw-r--r--cmake/test-static-assert.cpp2
-rw-r--r--contrib/CMakeLists.txt2
-rw-r--r--contrib/epee/CMakeLists.txt2
-rw-r--r--contrib/epee/include/hex.h2
-rw-r--r--contrib/epee/include/int-util.h2
-rw-r--r--contrib/epee/include/memwipe.h2
-rw-r--r--contrib/epee/include/net/connection_basic.hpp2
-rw-r--r--contrib/epee/include/net/http_auth.h2
-rw-r--r--contrib/epee/include/net/net_ssl.h1
-rw-r--r--contrib/epee/include/net/network_throttle-detail.hpp2
-rw-r--r--contrib/epee/include/net/network_throttle.hpp2
-rw-r--r--contrib/epee/include/span.h2
-rw-r--r--contrib/epee/include/wipeable_string.h2
-rw-r--r--contrib/epee/src/CMakeLists.txt2
-rw-r--r--contrib/epee/src/connection_basic.cpp2
-rw-r--r--contrib/epee/src/hex.cpp2
-rw-r--r--contrib/epee/src/http_auth.cpp2
-rw-r--r--contrib/epee/src/memwipe.c2
-rw-r--r--contrib/epee/src/net_ssl.cpp51
-rw-r--r--contrib/epee/src/network_throttle-detail.cpp2
-rw-r--r--contrib/epee/src/network_throttle.cpp2
-rw-r--r--contrib/epee/src/wipeable_string.cpp2
-rw-r--r--external/CMakeLists.txt2
-rw-r--r--external/db_drivers/CMakeLists.txt2
-rw-r--r--external/db_drivers/liblmdb/CMakeLists.txt2
-rw-r--r--external/easylogging++/CMakeLists.txt2
m---------external/unbound0
-rw-r--r--include/INode.h2
-rw-r--r--include/IWallet.h2
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/blockchain_db/CMakeLists.txt2
-rw-r--r--src/blockchain_db/berkeleydb/db_bdb.cpp2
-rw-r--r--src/blockchain_db/berkeleydb/db_bdb.h2
-rw-r--r--src/blockchain_db/blockchain_db.cpp2
-rw-r--r--src/blockchain_db/blockchain_db.h2
-rw-r--r--src/blockchain_db/db_types.h2
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.cpp2
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.h2
-rw-r--r--src/blockchain_db/testdb.h2
-rw-r--r--src/blockchain_utilities/CMakeLists.txt2
-rw-r--r--src/blockchain_utilities/README.md2
-rw-r--r--src/blockchain_utilities/blockchain_ancestry.cpp2
-rw-r--r--src/blockchain_utilities/blockchain_blackball.cpp2
-rw-r--r--src/blockchain_utilities/blockchain_depth.cpp2
-rw-r--r--src/blockchain_utilities/blockchain_export.cpp2
-rw-r--r--src/blockchain_utilities/blockchain_import.cpp2
-rw-r--r--src/blockchain_utilities/blockchain_prune_known_spent_data.cpp2
-rw-r--r--src/blockchain_utilities/blockchain_stats.cpp2
-rw-r--r--src/blockchain_utilities/blockchain_usage.cpp2
-rw-r--r--src/blockchain_utilities/blockchain_utilities.h2
-rw-r--r--src/blockchain_utilities/blocksdat_file.cpp2
-rw-r--r--src/blockchain_utilities/blocksdat_file.h2
-rw-r--r--src/blockchain_utilities/bootstrap_file.cpp2
-rw-r--r--src/blockchain_utilities/bootstrap_file.h2
-rw-r--r--src/blockchain_utilities/bootstrap_serialization.h2
-rw-r--r--src/blocks/CMakeLists.txt2
-rw-r--r--src/blocks/checkpoints.datbin208420 -> 221956 bytes
-rw-r--r--src/checkpoints/CMakeLists.txt2
-rw-r--r--src/checkpoints/checkpoints.cpp3
-rw-r--r--src/checkpoints/checkpoints.h2
-rw-r--r--src/common/CMakeLists.txt2
-rw-r--r--src/common/aligned.c2
-rw-r--r--src/common/apply_permutation.h2
-rw-r--r--src/common/base58.cpp2
-rw-r--r--src/common/base58.h2
-rw-r--r--src/common/boost_serialization_helper.h2
-rw-r--r--src/common/command_line.cpp2
-rw-r--r--src/common/command_line.h2
-rw-r--r--src/common/common_fwd.h2
-rw-r--r--src/common/dns_utils.cpp10
-rw-r--r--src/common/dns_utils.h2
-rw-r--r--src/common/download.cpp2
-rw-r--r--src/common/download.h2
-rw-r--r--src/common/http_connection.h2
-rw-r--r--src/common/i18n.cpp2
-rw-r--r--src/common/i18n.h2
-rw-r--r--src/common/json_util.h2
-rw-r--r--src/common/password.cpp2
-rw-r--r--src/common/password.h2
-rw-r--r--src/common/perf_timer.cpp2
-rw-r--r--src/common/perf_timer.h2
-rw-r--r--src/common/pod-class.h2
-rw-r--r--src/common/rpc_client.h2
-rw-r--r--src/common/scoped_message_writer.h2
-rw-r--r--src/common/sfinae_helpers.h2
-rw-r--r--src/common/spawn.cpp4
-rw-r--r--src/common/stack_trace.cpp2
-rw-r--r--src/common/stack_trace.h2
-rw-r--r--src/common/threadpool.cpp2
-rw-r--r--src/common/threadpool.h2
-rw-r--r--src/common/timings.cc2
-rw-r--r--src/common/unordered_containers_boost_serialization.h2
-rw-r--r--src/common/updates.cpp2
-rw-r--r--src/common/updates.h2
-rw-r--r--src/common/util.cpp2
-rw-r--r--src/common/util.h2
-rw-r--r--src/common/varint.h2
-rw-r--r--src/crypto/CMakeLists.txt2
-rw-r--r--src/crypto/blake256.c2
-rw-r--r--src/crypto/blake256.h2
-rw-r--r--src/crypto/chacha.h2
-rw-r--r--src/crypto/crypto-ops-data.c2
-rw-r--r--src/crypto/crypto-ops.c2
-rw-r--r--src/crypto/crypto-ops.h2
-rw-r--r--src/crypto/crypto.cpp2
-rw-r--r--src/crypto/crypto.h2
-rw-r--r--src/crypto/crypto_ops_builder/README.md2
-rw-r--r--src/crypto/crypto_ops_builder/crypto-ops-data.c2
-rw-r--r--src/crypto/crypto_ops_builder/crypto-ops-old.c2
-rw-r--r--src/crypto/crypto_ops_builder/crypto-ops.h2
-rw-r--r--src/crypto/crypto_ops_builder/ref10CommentedCombined/MakeCryptoOps.py2
-rw-r--r--src/crypto/crypto_ops_builder/ref10CommentedCombined/crypto-ops.h2
-rw-r--r--src/crypto/generic-ops.h2
-rw-r--r--src/crypto/groestl.h2
-rw-r--r--src/crypto/groestl_tables.h2
-rw-r--r--src/crypto/hash-extra-blake.c2
-rw-r--r--src/crypto/hash-extra-groestl.c2
-rw-r--r--src/crypto/hash-extra-jh.c2
-rw-r--r--src/crypto/hash-extra-skein.c2
-rw-r--r--src/crypto/hash-ops.h2
-rw-r--r--src/crypto/hash.c2
-rw-r--r--src/crypto/hash.h2
-rw-r--r--src/crypto/initializer.h2
-rw-r--r--src/crypto/random.c2
-rw-r--r--src/crypto/random.h2
-rw-r--r--src/crypto/skein_port.h2
-rw-r--r--src/crypto/slow-hash.c2
-rw-r--r--src/crypto/tree-hash.c16
-rw-r--r--src/cryptonote_basic/CMakeLists.txt2
-rw-r--r--src/cryptonote_basic/account.cpp2
-rw-r--r--src/cryptonote_basic/account.h2
-rw-r--r--src/cryptonote_basic/account_boost_serialization.h2
-rw-r--r--src/cryptonote_basic/blobdatatype.h2
-rw-r--r--src/cryptonote_basic/connection_context.h6
-rw-r--r--src/cryptonote_basic/cryptonote_basic.h2
-rw-r--r--src/cryptonote_basic/cryptonote_basic_impl.cpp2
-rw-r--r--src/cryptonote_basic/cryptonote_basic_impl.h2
-rw-r--r--src/cryptonote_basic/cryptonote_boost_serialization.h2
-rw-r--r--src/cryptonote_basic/cryptonote_format_utils.cpp3
-rw-r--r--src/cryptonote_basic/cryptonote_format_utils.h2
-rw-r--r--src/cryptonote_basic/cryptonote_stat_info.h2
-rw-r--r--src/cryptonote_basic/difficulty.cpp2
-rw-r--r--src/cryptonote_basic/difficulty.h2
-rw-r--r--src/cryptonote_basic/hardfork.cpp2
-rw-r--r--src/cryptonote_basic/hardfork.h2
-rw-r--r--src/cryptonote_basic/miner.cpp11
-rw-r--r--src/cryptonote_basic/miner.h6
-rw-r--r--src/cryptonote_basic/subaddress_index.h2
-rw-r--r--src/cryptonote_basic/tx_extra.h2
-rw-r--r--src/cryptonote_basic/verification_context.h2
-rw-r--r--src/cryptonote_config.h2
-rw-r--r--src/cryptonote_core/CMakeLists.txt2
-rw-r--r--src/cryptonote_core/blockchain.cpp8
-rw-r--r--src/cryptonote_core/blockchain.h2
-rw-r--r--src/cryptonote_core/blockchain_storage_boost_serialization.h2
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp2
-rw-r--r--src/cryptonote_core/cryptonote_core.h2
-rw-r--r--src/cryptonote_core/cryptonote_tx_utils.cpp2
-rw-r--r--src/cryptonote_core/cryptonote_tx_utils.h2
-rw-r--r--src/cryptonote_core/tx_pool.cpp2
-rw-r--r--src/cryptonote_core/tx_pool.h2
-rw-r--r--src/cryptonote_protocol/CMakeLists.txt2
-rw-r--r--src/cryptonote_protocol/block_queue.cpp2
-rw-r--r--src/cryptonote_protocol/block_queue.h2
-rw-r--r--src/cryptonote_protocol/cryptonote_protocol_defs.h4
-rw-r--r--src/cryptonote_protocol/cryptonote_protocol_handler-base.cpp2
-rw-r--r--src/cryptonote_protocol/cryptonote_protocol_handler.h2
-rw-r--r--src/cryptonote_protocol/cryptonote_protocol_handler.inl3
-rw-r--r--src/cryptonote_protocol/cryptonote_protocol_handler_common.h2
-rw-r--r--src/daemon/CMakeLists.txt2
-rw-r--r--src/daemon/command_line_args.h8
-rw-r--r--src/daemon/command_parser_executor.cpp7
-rw-r--r--src/daemon/command_parser_executor.h4
-rw-r--r--src/daemon/command_server.cpp7
-rw-r--r--src/daemon/command_server.h2
-rw-r--r--src/daemon/core.h2
-rw-r--r--src/daemon/daemon.cpp14
-rw-r--r--src/daemon/daemon.h6
-rw-r--r--src/daemon/executor.cpp8
-rw-r--r--src/daemon/executor.h9
-rw-r--r--src/daemon/main.cpp57
-rw-r--r--src/daemon/p2p.h2
-rw-r--r--src/daemon/protocol.h2
-rw-r--r--src/daemon/rpc.h2
-rw-r--r--src/daemon/rpc_command_executor.cpp82
-rw-r--r--src/daemon/rpc_command_executor.h4
-rw-r--r--src/daemonizer/CMakeLists.txt2
-rw-r--r--src/daemonizer/daemonizer.h2
-rw-r--r--src/daemonizer/posix_daemonizer.inl2
-rw-r--r--src/daemonizer/posix_fork.h2
-rw-r--r--src/daemonizer/windows_daemonizer.inl2
-rw-r--r--src/daemonizer/windows_service.cpp2
-rw-r--r--src/daemonizer/windows_service.h2
-rw-r--r--src/daemonizer/windows_service_runner.h2
-rw-r--r--src/debug_utilities/CMakeLists.txt2
-rw-r--r--src/debug_utilities/cn_deserialize.cpp2
-rw-r--r--src/debug_utilities/object_sizes.cpp2
-rw-r--r--src/device/CMakeLists.txt2
-rw-r--r--src/device/device.cpp2
-rw-r--r--src/device/device.hpp2
-rw-r--r--src/device/device_cold.hpp2
-rw-r--r--src/device/device_default.cpp2
-rw-r--r--src/device/device_default.hpp2
-rw-r--r--src/device/device_io.hpp2
-rw-r--r--src/device/device_io_hid.cpp2
-rw-r--r--src/device/device_io_hid.hpp2
-rw-r--r--src/device/device_ledger.cpp2
-rw-r--r--src/device/device_ledger.hpp2
-rw-r--r--src/device/log.cpp2
-rw-r--r--src/device/log.hpp2
-rw-r--r--src/device_trezor/CMakeLists.txt8
-rw-r--r--src/device_trezor/device_trezor.cpp19
-rw-r--r--src/device_trezor/device_trezor.hpp2
-rw-r--r--src/device_trezor/device_trezor_base.cpp118
-rw-r--r--src/device_trezor/device_trezor_base.hpp55
-rw-r--r--src/device_trezor/trezor.hpp2
-rw-r--r--src/device_trezor/trezor/debug_link.cpp90
-rw-r--r--src/device_trezor/trezor/debug_link.hpp93
-rw-r--r--src/device_trezor/trezor/exceptions.hpp2
-rw-r--r--src/device_trezor/trezor/messages_map.cpp13
-rw-r--r--src/device_trezor/trezor/messages_map.hpp8
-rw-r--r--src/device_trezor/trezor/protocol.cpp2
-rw-r--r--src/device_trezor/trezor/protocol.hpp2
-rw-r--r--src/device_trezor/trezor/tools/build_protob.py10
-rw-r--r--src/device_trezor/trezor/transport.cpp152
-rw-r--r--src/device_trezor/trezor/transport.hpp21
-rw-r--r--src/device_trezor/trezor/trezor_defs.hpp2
-rw-r--r--src/gen_multisig/CMakeLists.txt2
-rw-r--r--src/gen_multisig/gen_multisig.cpp2
-rw-r--r--src/mnemonics/CMakeLists.txt2
-rw-r--r--src/mnemonics/chinese_simplified.h2
-rw-r--r--src/mnemonics/dutch.h2
-rw-r--r--src/mnemonics/electrum-words.cpp2
-rw-r--r--src/mnemonics/electrum-words.h2
-rw-r--r--src/mnemonics/english.h2
-rw-r--r--src/mnemonics/english_old.h2
-rw-r--r--src/mnemonics/esperanto.h2
-rw-r--r--src/mnemonics/french.h2
-rw-r--r--src/mnemonics/german.h2
-rw-r--r--src/mnemonics/italian.h2
-rw-r--r--src/mnemonics/japanese.h2
-rw-r--r--src/mnemonics/language_base.h2
-rw-r--r--src/mnemonics/lojban.h2
-rw-r--r--src/mnemonics/portuguese.h2
-rw-r--r--src/mnemonics/russian.h2
-rw-r--r--src/mnemonics/singleton.h2
-rw-r--r--src/mnemonics/spanish.h2
-rw-r--r--src/multisig/CMakeLists.txt2
-rw-r--r--src/multisig/multisig.cpp2
-rw-r--r--src/multisig/multisig.h2
-rw-r--r--src/p2p/CMakeLists.txt2
-rw-r--r--src/p2p/net_node.cpp2
-rw-r--r--src/p2p/net_node.h10
-rw-r--r--src/p2p/net_node.inl13
-rw-r--r--src/p2p/net_node_common.h2
-rw-r--r--src/p2p/net_peerlist.h7
-rw-r--r--src/p2p/net_peerlist_boost_serialization.h11
-rw-r--r--src/p2p/p2p_protocol_defs.h20
-rw-r--r--src/p2p/stdafx.h2
-rw-r--r--src/platform/mingw/alloca.h2
-rw-r--r--src/platform/msc/alloca.h2
-rw-r--r--src/platform/msc/inline_c.h2
-rw-r--r--src/platform/msc/stdbool.h2
-rw-r--r--src/platform/msc/sys/param.h2
-rw-r--r--src/ringct/CMakeLists.txt2
-rw-r--r--src/ringct/bulletproofs.cc2
-rw-r--r--src/ringct/bulletproofs.h2
-rw-r--r--src/ringct/rctCryptoOps.c2
-rw-r--r--src/ringct/rctCryptoOps.h2
-rw-r--r--src/rpc/CMakeLists.txt2
-rw-r--r--src/rpc/core_rpc_server.cpp42
-rw-r--r--src/rpc/core_rpc_server.h3
-rw-r--r--src/rpc/core_rpc_server_commands_defs.h28
-rw-r--r--src/rpc/core_rpc_server_error_codes.h2
-rw-r--r--src/rpc/daemon_handler.cpp2
-rw-r--r--src/rpc/daemon_handler.h2
-rw-r--r--src/rpc/daemon_messages.cpp2
-rw-r--r--src/rpc/daemon_messages.h2
-rw-r--r--src/rpc/daemon_rpc_version.h2
-rw-r--r--src/rpc/instanciations.cpp2
-rw-r--r--src/rpc/message.cpp2
-rw-r--r--src/rpc/message.h2
-rw-r--r--src/rpc/message_data_structs.h3
-rw-r--r--src/rpc/rpc_args.cpp2
-rw-r--r--src/rpc/rpc_args.h2
-rw-r--r--src/rpc/rpc_handler.h2
-rw-r--r--src/rpc/zmq_server.cpp2
-rw-r--r--src/rpc/zmq_server.h2
-rw-r--r--src/serialization/CMakeLists.txt2
-rw-r--r--src/serialization/binary_archive.h2
-rw-r--r--src/serialization/binary_utils.h2
-rw-r--r--src/serialization/container.h2
-rw-r--r--src/serialization/crypto.h2
-rw-r--r--src/serialization/debug_archive.h2
-rw-r--r--src/serialization/deque.h2
-rw-r--r--src/serialization/json_archive.h2
-rw-r--r--src/serialization/json_object.cpp6
-rw-r--r--src/serialization/json_object.h2
-rw-r--r--src/serialization/json_utils.h2
-rw-r--r--src/serialization/list.h2
-rw-r--r--src/serialization/pair.h2
-rw-r--r--src/serialization/serialization.h2
-rw-r--r--src/serialization/set.h2
-rw-r--r--src/serialization/string.h2
-rw-r--r--src/serialization/unordered_set.h2
-rw-r--r--src/serialization/variant.h2
-rw-r--r--src/serialization/vector.h2
-rw-r--r--src/simplewallet/CMakeLists.txt2
-rw-r--r--src/simplewallet/simplewallet.cpp2
-rw-r--r--src/simplewallet/simplewallet.h2
-rw-r--r--src/version.cpp.in4
-rw-r--r--src/wallet/CMakeLists.txt2
-rw-r--r--src/wallet/api/CMakeLists.txt2
-rw-r--r--src/wallet/api/address_book.cpp2
-rw-r--r--src/wallet/api/address_book.h2
-rw-r--r--src/wallet/api/pending_transaction.cpp2
-rw-r--r--src/wallet/api/pending_transaction.h2
-rw-r--r--src/wallet/api/subaddress.cpp2
-rw-r--r--src/wallet/api/subaddress.h2
-rw-r--r--src/wallet/api/subaddress_account.cpp2
-rw-r--r--src/wallet/api/subaddress_account.h2
-rw-r--r--src/wallet/api/transaction_history.cpp2
-rw-r--r--src/wallet/api/transaction_history.h2
-rw-r--r--src/wallet/api/transaction_info.cpp2
-rw-r--r--src/wallet/api/transaction_info.h2
-rw-r--r--src/wallet/api/unsigned_transaction.cpp2
-rw-r--r--src/wallet/api/unsigned_transaction.h2
-rw-r--r--src/wallet/api/utils.cpp2
-rw-r--r--src/wallet/api/wallet.cpp2
-rw-r--r--src/wallet/api/wallet.h2
-rw-r--r--src/wallet/api/wallet2_api.h2
-rw-r--r--src/wallet/api/wallet_manager.cpp2
-rw-r--r--src/wallet/api/wallet_manager.h2
-rw-r--r--src/wallet/node_rpc_proxy.cpp2
-rw-r--r--src/wallet/node_rpc_proxy.h2
-rw-r--r--src/wallet/wallet2.cpp24
-rw-r--r--src/wallet/wallet2.h4
-rw-r--r--src/wallet/wallet_args.cpp2
-rw-r--r--src/wallet/wallet_args.h2
-rw-r--r--src/wallet/wallet_errors.h25
-rw-r--r--src/wallet/wallet_rpc_server.cpp171
-rw-r--r--src/wallet/wallet_rpc_server.h4
-rw-r--r--src/wallet/wallet_rpc_server_commands_defs.h35
-rw-r--r--src/wallet/wallet_rpc_server_error_codes.h2
-rw-r--r--tests/CMakeLists.txt6
-rw-r--r--tests/core_proxy/CMakeLists.txt2
-rw-r--r--tests/core_proxy/core_proxy.cpp2
-rw-r--r--tests/core_proxy/core_proxy.h2
-rw-r--r--tests/core_tests/CMakeLists.txt9
-rw-r--r--tests/core_tests/block_reward.cpp2
-rw-r--r--tests/core_tests/block_reward.h2
-rw-r--r--tests/core_tests/block_validation.cpp2
-rw-r--r--tests/core_tests/block_validation.h2
-rw-r--r--tests/core_tests/bulletproofs.cpp2
-rw-r--r--tests/core_tests/bulletproofs.h2
-rw-r--r--tests/core_tests/chain_split_1.cpp2
-rw-r--r--tests/core_tests/chain_split_1.h2
-rw-r--r--tests/core_tests/chain_switch_1.cpp2
-rw-r--r--tests/core_tests/chain_switch_1.h2
-rw-r--r--tests/core_tests/chaingen.cpp624
-rw-r--r--tests/core_tests/chaingen.h463
-rw-r--r--tests/core_tests/chaingen001.cpp2
-rw-r--r--tests/core_tests/chaingen_main.cpp2
-rw-r--r--tests/core_tests/chaingen_tests_list.h2
-rw-r--r--tests/core_tests/double_spend.cpp2
-rw-r--r--tests/core_tests/double_spend.h2
-rw-r--r--tests/core_tests/double_spend.inl2
-rw-r--r--tests/core_tests/integer_overflow.cpp2
-rw-r--r--tests/core_tests/integer_overflow.h2
-rw-r--r--tests/core_tests/multisig.cpp2
-rw-r--r--tests/core_tests/multisig.h2
-rw-r--r--tests/core_tests/rct.cpp2
-rw-r--r--tests/core_tests/rct.h2
-rw-r--r--tests/core_tests/ring_signature_1.cpp2
-rw-r--r--tests/core_tests/ring_signature_1.h2
-rw-r--r--tests/core_tests/transaction_tests.cpp2
-rw-r--r--tests/core_tests/transaction_tests.h2
-rw-r--r--tests/core_tests/tx_validation.cpp2
-rw-r--r--tests/core_tests/tx_validation.h2
-rw-r--r--tests/core_tests/v2_tests.cpp2
-rw-r--r--tests/core_tests/v2_tests.h2
-rw-r--r--tests/core_tests/wallet_tools.cpp287
-rw-r--r--tests/core_tests/wallet_tools.h86
-rw-r--r--tests/crypto/CMakeLists.txt2
-rw-r--r--tests/crypto/crypto-ops-data.c2
-rw-r--r--tests/crypto/crypto-ops.c2
-rw-r--r--tests/crypto/crypto-tests.h2
-rw-r--r--tests/crypto/crypto.cpp2
-rw-r--r--tests/crypto/hash.c2
-rw-r--r--tests/crypto/main.cpp2
-rw-r--r--tests/crypto/random.c2
-rw-r--r--tests/cryptolib.pl2
-rw-r--r--tests/cryptotest.pl2
-rw-r--r--tests/daemon_tests/CMakeLists.txt2
-rw-r--r--tests/daemon_tests/transfers.cpp2
-rw-r--r--tests/difficulty/CMakeLists.txt2
-rw-r--r--tests/difficulty/difficulty.cpp2
-rwxr-xr-xtests/difficulty/generate-data2
-rw-r--r--tests/functional_tests/CMakeLists.txt2
-rw-r--r--tests/functional_tests/main.cpp2
-rw-r--r--tests/functional_tests/transactions_flow_test.cpp2
-rw-r--r--tests/functional_tests/transactions_flow_test.h2
-rw-r--r--tests/functional_tests/transactions_generation_from_blockchain.cpp2
-rw-r--r--tests/functional_tests/transactions_generation_from_blockchain.h2
-rw-r--r--tests/fuzz/CMakeLists.txt2
-rw-r--r--tests/fuzz/base58.cpp2
-rw-r--r--tests/fuzz/block.cpp2
-rw-r--r--tests/fuzz/bulletproof.cpp2
-rw-r--r--tests/fuzz/cold-outputs.cpp2
-rw-r--r--tests/fuzz/cold-transaction.cpp2
-rw-r--r--tests/fuzz/fuzzer.cpp2
-rw-r--r--tests/fuzz/fuzzer.h2
-rw-r--r--tests/fuzz/http-client.cpp2
-rw-r--r--tests/fuzz/levin.cpp2
-rw-r--r--tests/fuzz/load_from_binary.cpp2
-rw-r--r--tests/fuzz/load_from_json.cpp2
-rw-r--r--tests/fuzz/parse_url.cpp2
-rw-r--r--tests/fuzz/signature.cpp2
-rw-r--r--tests/fuzz/transaction.cpp2
-rw-r--r--tests/hash-target.cpp2
-rw-r--r--tests/hash/CMakeLists.txt2
-rw-r--r--tests/hash/main.cpp2
-rw-r--r--tests/io.h2
-rw-r--r--tests/libwallet_api_tests/CMakeLists.txt2
-rw-r--r--tests/libwallet_api_tests/main.cpp2
-rw-r--r--tests/net_load_tests/CMakeLists.txt2
-rw-r--r--tests/net_load_tests/clt.cpp2
-rw-r--r--tests/net_load_tests/net_load_tests.h2
-rw-r--r--tests/net_load_tests/srv.cpp2
-rw-r--r--tests/performance_tests/CMakeLists.txt2
-rw-r--r--tests/performance_tests/bulletproof.h2
-rw-r--r--tests/performance_tests/check_tx_signature.h2
-rw-r--r--tests/performance_tests/cn_fast_hash.h2
-rw-r--r--tests/performance_tests/cn_slow_hash.h2
-rw-r--r--tests/performance_tests/construct_tx.h2
-rw-r--r--tests/performance_tests/crypto_ops.h2
-rw-r--r--tests/performance_tests/derive_public_key.h2
-rw-r--r--tests/performance_tests/derive_secret_key.h2
-rw-r--r--tests/performance_tests/equality.h2
-rw-r--r--tests/performance_tests/ge_frombytes_vartime.h2
-rw-r--r--tests/performance_tests/ge_tobytes.h2
-rw-r--r--tests/performance_tests/generate_key_derivation.h2
-rw-r--r--tests/performance_tests/generate_key_image.h2
-rw-r--r--tests/performance_tests/generate_key_image_helper.h2
-rw-r--r--tests/performance_tests/generate_keypair.h2
-rw-r--r--tests/performance_tests/is_out_to_acc.h2
-rw-r--r--tests/performance_tests/main.cpp2
-rw-r--r--tests/performance_tests/multi_tx_test_base.h2
-rw-r--r--tests/performance_tests/performance_tests.h2
-rw-r--r--tests/performance_tests/performance_utils.h6
-rw-r--r--tests/performance_tests/range_proof.h2
-rw-r--r--tests/performance_tests/rct_mlsag.h2
-rw-r--r--tests/performance_tests/sc_reduce32.h2
-rw-r--r--tests/performance_tests/signature.h2
-rw-r--r--tests/performance_tests/single_tx_test_base.h2
-rw-r--r--tests/performance_tests/subaddress_expand.h2
-rw-r--r--tests/trezor/CMakeLists.txt63
-rw-r--r--tests/trezor/trezor_tests.cpp1409
-rw-r--r--tests/trezor/trezor_tests.h248
-rw-r--r--tests/unit_tests/CMakeLists.txt2
-rw-r--r--tests/unit_tests/account.cpp2
-rw-r--r--tests/unit_tests/address_from_url.cpp2
-rw-r--r--tests/unit_tests/apply_permutation.cpp2
-rw-r--r--tests/unit_tests/ban.cpp2
-rw-r--r--tests/unit_tests/base58.cpp2
-rw-r--r--tests/unit_tests/block_queue.cpp2
-rw-r--r--tests/unit_tests/block_reward.cpp2
-rw-r--r--tests/unit_tests/blockchain_db.cpp2
-rw-r--r--tests/unit_tests/bulletproofs.cpp2
-rw-r--r--tests/unit_tests/canonical_amounts.cpp2
-rw-r--r--tests/unit_tests/chacha.cpp2
-rw-r--r--tests/unit_tests/checkpoints.cpp2
-rw-r--r--tests/unit_tests/command_line.cpp2
-rw-r--r--tests/unit_tests/crypto.cpp2
-rw-r--r--tests/unit_tests/decompose_amount_into_digits.cpp2
-rw-r--r--tests/unit_tests/dns_resolver.cpp2
-rw-r--r--tests/unit_tests/epee_boosted_tcp_server.cpp2
-rw-r--r--tests/unit_tests/epee_levin_protocol_handler_async.cpp2
-rw-r--r--tests/unit_tests/epee_utils.cpp2
-rw-r--r--tests/unit_tests/fee.cpp2
-rw-r--r--tests/unit_tests/get_xtype_from_string.cpp2
-rw-r--r--tests/unit_tests/hardfork.cpp2
-rw-r--r--tests/unit_tests/hashchain.cpp2
-rw-r--r--tests/unit_tests/http.cpp2
-rw-r--r--tests/unit_tests/logging.cpp2
-rw-r--r--tests/unit_tests/main.cpp2
-rw-r--r--tests/unit_tests/memwipe.cpp2
-rw-r--r--tests/unit_tests/mnemonics.cpp2
-rw-r--r--tests/unit_tests/mul_div.cpp2
-rw-r--r--tests/unit_tests/multisig.cpp2
-rw-r--r--tests/unit_tests/output_selection.cpp2
-rw-r--r--tests/unit_tests/parse_amount.cpp2
-rw-r--r--tests/unit_tests/ringct.cpp2
-rw-r--r--tests/unit_tests/serialization.cpp2
-rw-r--r--tests/unit_tests/sha256.cpp2
-rw-r--r--tests/unit_tests/slow_memmem.cpp2
-rw-r--r--tests/unit_tests/subaddress.cpp2
-rw-r--r--tests/unit_tests/test_peerlist.cpp2
-rw-r--r--tests/unit_tests/test_protocol_pack.cpp2
-rw-r--r--tests/unit_tests/test_tx_utils.cpp2
-rw-r--r--tests/unit_tests/unbound.cpp2
-rw-r--r--tests/unit_tests/unit_tests_utils.h2
-rw-r--r--tests/unit_tests/uri.cpp2
-rw-r--r--tests/unit_tests/varint.cpp2
-rw-r--r--tests/unit_tests/vercmp.cpp2
-rw-r--r--translations/CMakeLists.txt2
-rw-r--r--translations/generate_translations_header.c2
-rw-r--r--utils/build_scripts/windows.bat2
-rw-r--r--utils/munin_plugins/alt_blocks_count2
-rw-r--r--utils/munin_plugins/difficulty2
-rw-r--r--utils/munin_plugins/grey_peerlist_size2
-rw-r--r--utils/munin_plugins/height2
-rw-r--r--utils/munin_plugins/incoming_connections_count2
-rw-r--r--utils/munin_plugins/outgoing_connections_count2
-rw-r--r--utils/munin_plugins/tx_count2
-rw-r--r--utils/munin_plugins/tx_pool_size2
-rw-r--r--utils/munin_plugins/white_peerlist_size2
531 files changed, 4693 insertions, 813 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 191cc8966..b2d47706b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/CMakeLists_IOS.txt b/CMakeLists_IOS.txt
index 9273af19f..3b7eacc8a 100644
--- a/CMakeLists_IOS.txt
+++ b/CMakeLists_IOS.txt
@@ -1,4 +1,4 @@
-# Portions Copyright (c) 2017-2018, The Monero Project
+# Portions Copyright (c) 2017-2019, The Monero Project
# This file is based off of the https://code.google.com/archive/p/ios-cmake/
# It has been altered for Monero iOS development
#
diff --git a/LICENSE b/LICENSE
index 733f09f23..f48fcda87 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2014-2018, The Monero Project
+Copyright (c) 2014-2019, The Monero Project
All rights reserved.
diff --git a/Makefile b/Makefile
index f21038b74..1fd310915 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
@@ -63,6 +63,10 @@ debug-test:
mkdir -p $(builddir)/debug
cd $(builddir)/debug && cmake -D BUILD_TESTS=ON -D CMAKE_BUILD_TYPE=Debug $(topdir) && $(MAKE) && $(MAKE) ARGS="-E libwallet_api_tests" test
+debug-test-trezor:
+ mkdir -p $(builddir)/debug
+ cd $(builddir)/debug && cmake -D BUILD_TESTS=ON -D TREZOR_DEBUG=ON -D CMAKE_BUILD_TYPE=Debug $(topdir) && $(MAKE) && $(MAKE) ARGS="-E libwallet_api_tests" test
+
debug-all:
mkdir -p $(builddir)/debug
cd $(builddir)/debug && cmake -D BUILD_TESTS=ON -D BUILD_SHARED_LIBS=OFF -D CMAKE_BUILD_TYPE=Debug $(topdir) && $(MAKE)
diff --git a/README.md b/README.md
index 9ec880621..35b2f701a 100644
--- a/README.md
+++ b/README.md
@@ -47,9 +47,9 @@ These builds are of the master branch, which is used for active development and
| Ubuntu 16.04 | amd64 | [![Ubuntu 16.04 amd64](https://build.getmonero.org/png?builder=monero-static-ubuntu-amd64)](https://build.getmonero.org/builders/monero-static-ubuntu-amd64)
| Ubuntu 16.04 | armv7 | [![Ubuntu 16.04 armv7](https://build.getmonero.org/png?builder=monero-static-ubuntu-arm7)](https://build.getmonero.org/builders/monero-static-ubuntu-arm7)
| Debian Stable | armv8 | [![Debian armv8](https://build.getmonero.org/png?builder=monero-static-debian-armv8)](https://build.getmonero.org/builders/monero-static-debian-armv8)
-| OSX 10.11 | amd64 | [![OSX 10.11 amd64](https://build.getmonero.org/png?builder=monero-static-osx-10.11)](https://build.getmonero.org/builders/monero-static-osx-10.11)
-| OSX 10.12 | amd64 | [![OSX 10.12 amd64](https://build.getmonero.org/png?builder=monero-static-osx-10.12)](https://build.getmonero.org/builders/monero-static-osx-10.12)
-| OSX 10.13 | amd64 | [![OSX 10.13 amd64](https://build.getmonero.org/png?builder=monero-static-osx-10.13)](https://build.getmonero.org/builders/monero-static-osx-10.13)
+| macOS 10.11 | amd64 | [![macOS 10.11 amd64](https://build.getmonero.org/png?builder=monero-static-osx-10.11)](https://build.getmonero.org/builders/monero-static-osx-10.11)
+| macOS 10.12 | amd64 | [![macOS 10.12 amd64](https://build.getmonero.org/png?builder=monero-static-osx-10.12)](https://build.getmonero.org/builders/monero-static-osx-10.12)
+| macOS 10.13 | amd64 | [![macOS 10.13 amd64](https://build.getmonero.org/png?builder=monero-static-osx-10.13)](https://build.getmonero.org/builders/monero-static-osx-10.13)
| FreeBSD 11 | amd64 | [![FreeBSD 11 amd64](https://build.getmonero.org/png?builder=monero-static-freebsd64)](https://build.getmonero.org/builders/monero-static-freebsd64)
| DragonFly BSD 4.6 | amd64 | [![DragonFly BSD amd64](https://build.getmonero.org/png?builder=monero-static-dragonflybsd-amd64)](https://build.getmonero.org/builders/monero-static-dragonflybsd-amd64)
| Windows (MSYS2/MinGW) | i686 | [![Windows (MSYS2/MinGW) i686](https://build.getmonero.org/png?builder=monero-static-win32)](https://build.getmonero.org/builders/monero-static-win32)
@@ -125,7 +125,8 @@ Dates are provided in the format YYYY-MM-DD.
| 1546000 | 2018-04-06 | v7 | v0.12.0.0 | v0.12.3.0 | Cryptonight variant 1, ringsize >= 7, sorted inputs
| 1685555 | 2018-10-18 | v8 | v0.13.0.0 | v0.13.0.4 | max transaction size at half the penalty free block size, bulletproofs enabled, cryptonight variant 2, fixed ringsize [11](https://youtu.be/KOO5S4vxi0o)
| 1686275 | 2018-10-19 | v9 | v0.13.0.0 | v0.13.0.4 | bulletproofs required
-| XXXXXXX | 2019-04-XX | XX | XXXXXXXXX | XXXXXXXXX | X
+| 1788000 | 2019-03-09 | v10 | v0.14.0.0 | v0.14.0.2 | Cryptonight-R PoW, new block weight algorithm, slightly more efficient RingCT format
+| 1788720 | 2019-03-10 | v11 | v0.14.0.0 | v0.14.0.2 | forbid old RingCT transaction format
X's indicate that these details have not been determined as of commit date.
@@ -193,13 +194,13 @@ If you already have a repo cloned, initialize and update:
Monero uses the CMake build system and a top-level [Makefile](Makefile) that
invokes cmake commands as needed.
-#### On Linux and OS X
+#### On Linux and macOS
* Install the dependencies
* Change to the root of the source code directory, change to the most recent release branch, and build:
cd monero
- git checkout release-v0.13
+ git checkout release-v0.14
make
*Optional*: If your machine has several cores and enough memory, enable
@@ -207,7 +208,7 @@ invokes cmake commands as needed.
this to be worthwhile, the machine should have one core and about 2GB of RAM
available per thread.
- *Note*: If cmake can not find zmq.hpp file on OS X, installing `zmq.hpp` from
+ *Note*: If cmake can not find zmq.hpp file on macOS, installing `zmq.hpp` from
https://github.com/zeromq/cppzmq to `/usr/local/include` should fix that error.
*Note*: The instructions above will compile the most stable release of the
@@ -259,11 +260,11 @@ Tested on a Raspberry Pi Zero with a clean install of minimal Raspbian Stretch (
```
* If using an external hard disk without an external power supply, ensure it gets enough power to avoid hardware issues when syncing, by adding the line "max_usb_current=1" to /boot/config.txt
-* Clone monero and checkout most recent release version:
+* Clone monero and checkout the most recent release version:
```
git clone https://github.com/monero-project/monero.git
cd monero
- git checkout tags/release-v0.13
+ git checkout tags/v0.14.1.0
```
* Build:
```
@@ -360,9 +361,9 @@ application.
cd monero
-* If you would like a specific [version/tag](https://github.com/monero-project/monero/tags), do a git checkout for that version. eg. 'release-0.13'. If you dont care about the version and just want binaries from master, skip this step:
-
- git checkout release-v0.13
+* If you would like a specific [version/tag](https://github.com/monero-project/monero/tags), do a git checkout for that version. eg. 'v0.14.1.0'. If you dont care about the version and just want binaries from master, skip this step:
+
+ git checkout v0.14.1.0
* If you are on a 64-bit system, run:
diff --git a/cmake/32-bit-toolchain.cmake b/cmake/32-bit-toolchain.cmake
index 253523e66..2d53adf06 100644
--- a/cmake/32-bit-toolchain.cmake
+++ b/cmake/32-bit-toolchain.cmake
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/cmake/64-bit-toolchain.cmake b/cmake/64-bit-toolchain.cmake
index b4b528347..7c56eef95 100644
--- a/cmake/64-bit-toolchain.cmake
+++ b/cmake/64-bit-toolchain.cmake
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/cmake/CheckTrezor.cmake b/cmake/CheckTrezor.cmake
index 71214363d..6aabdda36 100644
--- a/cmake/CheckTrezor.cmake
+++ b/cmake/CheckTrezor.cmake
@@ -1,6 +1,8 @@
OPTION(USE_DEVICE_TREZOR "Trezor support compilation" ON)
OPTION(USE_DEVICE_TREZOR_LIBUSB "Trezor LibUSB compilation" ON)
OPTION(USE_DEVICE_TREZOR_UDP_RELEASE "Trezor UdpTransport in release mode" OFF)
+OPTION(USE_DEVICE_TREZOR_DEBUG "Trezor Debugging enabled" OFF)
+OPTION(TREZOR_DEBUG "Main trezor debugging switch" OFF)
# Helper function to fix cmake < 3.6.0 FindProtobuf variables
function(_trezor_protobuf_fix_vars)
@@ -53,6 +55,14 @@ if (USE_DEVICE_TREZOR)
set(Protobuf_FOUND 1) # override found if all rquired info was provided by variables
endif()
+ if(TREZOR_DEBUG)
+ set(USE_DEVICE_TREZOR_DEBUG 1)
+ endif()
+
+ # Compile debugging support (for tests)
+ if (USE_DEVICE_TREZOR_DEBUG)
+ add_definitions(-DWITH_TREZOR_DEBUGGING=1)
+ endif()
else()
message(STATUS "Trezor support disabled by USE_DEVICE_TREZOR")
endif()
@@ -106,7 +116,12 @@ endif()
if(Protobuf_FOUND AND USE_DEVICE_TREZOR AND TREZOR_PYTHON AND Protobuf_COMPILE_TEST_PASSED)
set(ENV{PROTOBUF_INCLUDE_DIRS} "${Protobuf_INCLUDE_DIR}")
set(ENV{PROTOBUF_PROTOC_EXECUTABLE} "${Protobuf_PROTOC_EXECUTABLE}")
- execute_process(COMMAND ${TREZOR_PYTHON} tools/build_protob.py WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../src/device_trezor/trezor RESULT_VARIABLE RET OUTPUT_VARIABLE OUT ERROR_VARIABLE ERR)
+ set(TREZOR_PROTOBUF_PARAMS "")
+ if (USE_DEVICE_TREZOR_DEBUG)
+ set(TREZOR_PROTOBUF_PARAMS "--debug")
+ endif()
+
+ execute_process(COMMAND ${TREZOR_PYTHON} tools/build_protob.py ${TREZOR_PROTOBUF_PARAMS} WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../src/device_trezor/trezor RESULT_VARIABLE RET OUTPUT_VARIABLE OUT ERROR_VARIABLE ERR)
if(RET)
message(WARNING "Trezor protobuf messages could not be regenerated (err=${RET}, python ${PYTHON})."
"OUT: ${OUT}, ERR: ${ERR}."
diff --git a/cmake/FindUnbound.cmake b/cmake/FindUnbound.cmake
index a392d59ca..e3eb3d67e 100644
--- a/cmake/FindUnbound.cmake
+++ b/cmake/FindUnbound.cmake
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are
diff --git a/cmake/GenVersion.cmake b/cmake/GenVersion.cmake
index 289115175..1ea5b209c 100644
--- a/cmake/GenVersion.cmake
+++ b/cmake/GenVersion.cmake
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/cmake/Version.cmake b/cmake/Version.cmake
index 3677e80d7..632c1431c 100644
--- a/cmake/Version.cmake
+++ b/cmake/Version.cmake
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/cmake/test-libusb-version.c b/cmake/test-libusb-version.c
index 309e4ad27..b80191b58 100644
--- a/cmake/test-libusb-version.c
+++ b/cmake/test-libusb-version.c
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/cmake/test-protobuf.cpp b/cmake/test-protobuf.cpp
index 532df7cbe..0a1ca82be 100644
--- a/cmake/test-protobuf.cpp
+++ b/cmake/test-protobuf.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/cmake/test-static-assert.c b/cmake/test-static-assert.c
index 28a80a972..2e6c84839 100644
--- a/cmake/test-static-assert.c
+++ b/cmake/test-static-assert.c
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/cmake/test-static-assert.cpp b/cmake/test-static-assert.cpp
index 28a80a972..2e6c84839 100644
--- a/cmake/test-static-assert.cpp
+++ b/cmake/test-static-assert.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt
index 3bebbe0d2..0db645ce9 100644
--- a/contrib/CMakeLists.txt
+++ b/contrib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/contrib/epee/CMakeLists.txt b/contrib/epee/CMakeLists.txt
index 035b24b36..a2c636304 100644
--- a/contrib/epee/CMakeLists.txt
+++ b/contrib/epee/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/contrib/epee/include/hex.h b/contrib/epee/include/hex.h
index 250432173..6e720f128 100644
--- a/contrib/epee/include/hex.h
+++ b/contrib/epee/include/hex.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/contrib/epee/include/int-util.h b/contrib/epee/include/int-util.h
index 3bcc085e2..0ed6505ff 100644
--- a/contrib/epee/include/int-util.h
+++ b/contrib/epee/include/int-util.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/contrib/epee/include/memwipe.h b/contrib/epee/include/memwipe.h
index 0d8f491b7..d586608cb 100644
--- a/contrib/epee/include/memwipe.h
+++ b/contrib/epee/include/memwipe.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/contrib/epee/include/net/connection_basic.hpp b/contrib/epee/include/net/connection_basic.hpp
index 328f9afbf..feedc6895 100644
--- a/contrib/epee/include/net/connection_basic.hpp
+++ b/contrib/epee/include/net/connection_basic.hpp
@@ -8,7 +8,7 @@
// ! (how ever if in some wonderful juristdictions that is not the case, then why not make another sub-class withat that members and licence it as epee part)
// ! Working on above premise, IF this is valid in your juristdictions, then consider this code as released as:
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/contrib/epee/include/net/http_auth.h b/contrib/epee/include/net/http_auth.h
index 4324c41fd..00b9750b7 100644
--- a/contrib/epee/include/net/http_auth.h
+++ b/contrib/epee/include/net/http_auth.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/contrib/epee/include/net/net_ssl.h b/contrib/epee/include/net/net_ssl.h
index ca53d3667..f7b102164 100644
--- a/contrib/epee/include/net/net_ssl.h
+++ b/contrib/epee/include/net/net_ssl.h
@@ -59,7 +59,6 @@ namespace net_utils
bool is_ssl(const unsigned char *data, size_t len);
ssl_context_t create_ssl_context(const std::pair<std::string, std::string> &private_key_and_certificate_path, std::list<std::string> allowed_certificates, std::vector<std::vector<uint8_t>> allowed_fingerprints, bool allow_any_cert);
void use_ssl_certificate(ssl_context_t &ssl_context, const std::pair<std::string, std::string> &private_key_and_certificate_path);
- bool create_ssl_certificate(std::string &pkey_buffer, std::string &cert_buffer);
bool is_certificate_allowed(boost::asio::ssl::verify_context &ctx, const ssl_context_t &ssl_context);
bool ssl_handshake(boost::asio::ssl::stream<boost::asio::ip::tcp::socket> &socket, boost::asio::ssl::stream_base::handshake_type type, const epee::net_utils::ssl_context_t &ssl_context);
bool ssl_support_from_string(ssl_support_t &ssl, boost::string_ref s);
diff --git a/contrib/epee/include/net/network_throttle-detail.hpp b/contrib/epee/include/net/network_throttle-detail.hpp
index 9d12291f4..d7f2cc37a 100644
--- a/contrib/epee/include/net/network_throttle-detail.hpp
+++ b/contrib/epee/include/net/network_throttle-detail.hpp
@@ -2,7 +2,7 @@
/// @author rfree (current maintainer in monero.cc project)
/// @brief implementaion for throttling of connection (count and rate-limit speed etc)
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/contrib/epee/include/net/network_throttle.hpp b/contrib/epee/include/net/network_throttle.hpp
index 7df79a908..5092241a4 100644
--- a/contrib/epee/include/net/network_throttle.hpp
+++ b/contrib/epee/include/net/network_throttle.hpp
@@ -2,7 +2,7 @@
/// @author rfree (current maintainer in monero.cc project)
/// @brief interface for throttling of connection (count and rate-limit speed etc)
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/contrib/epee/include/span.h b/contrib/epee/include/span.h
index cfb5b1a17..19720ea8b 100644
--- a/contrib/epee/include/span.h
+++ b/contrib/epee/include/span.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/contrib/epee/include/wipeable_string.h b/contrib/epee/include/wipeable_string.h
index 31854fe2e..f0e526b92 100644
--- a/contrib/epee/include/wipeable_string.h
+++ b/contrib/epee/include/wipeable_string.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/contrib/epee/src/CMakeLists.txt b/contrib/epee/src/CMakeLists.txt
index e913211ea..0787a9d08 100644
--- a/contrib/epee/src/CMakeLists.txt
+++ b/contrib/epee/src/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/contrib/epee/src/connection_basic.cpp b/contrib/epee/src/connection_basic.cpp
index 377fb3452..83db171d8 100644
--- a/contrib/epee/src/connection_basic.cpp
+++ b/contrib/epee/src/connection_basic.cpp
@@ -2,7 +2,7 @@
/// @author rfree (current maintainer in monero.cc project)
/// @brief base for connection, contains e.g. the ratelimit hooks
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/contrib/epee/src/hex.cpp b/contrib/epee/src/hex.cpp
index 8421dcae9..558983f7e 100644
--- a/contrib/epee/src/hex.cpp
+++ b/contrib/epee/src/hex.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/contrib/epee/src/http_auth.cpp b/contrib/epee/src/http_auth.cpp
index dc968d971..289069daa 100644
--- a/contrib/epee/src/http_auth.cpp
+++ b/contrib/epee/src/http_auth.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/contrib/epee/src/memwipe.c b/contrib/epee/src/memwipe.c
index c2a26c392..ad1ef510d 100644
--- a/contrib/epee/src/memwipe.c
+++ b/contrib/epee/src/memwipe.c
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/contrib/epee/src/net_ssl.cpp b/contrib/epee/src/net_ssl.cpp
index 9a62dd3c2..eb0b0ad65 100644
--- a/contrib/epee/src/net_ssl.cpp
+++ b/contrib/epee/src/net_ssl.cpp
@@ -74,22 +74,23 @@ bool create_ssl_certificate(EVP_PKEY *&pkey, X509 *&cert)
{
MGINFO("Generating SSL certificate");
pkey = EVP_PKEY_new();
- openssl_pkey pkey_deleter{pkey};
if (!pkey)
{
MERROR("Failed to create new private key");
return false;
}
+
+ openssl_pkey pkey_deleter{pkey};
RSA *rsa = RSA_generate_key(4096, RSA_F4, NULL, NULL);
if (!rsa)
{
MERROR("Error generating RSA private key");
return false;
}
- if (EVP_PKEY_assign_RSA(pkey, rsa) <= 0)
+ if (EVP_PKEY_assign_RSA(pkey, rsa) <= 0) // The RSA will be automatically freed when the EVP_PKEY structure is freed.
{
- RSA_free(rsa);
MERROR("Error assigning RSA private key");
+ RSA_free(rsa);
return false;
}
@@ -117,43 +118,10 @@ bool create_ssl_certificate(EVP_PKEY *&pkey, X509 *&cert)
X509_free(cert);
return false;
}
+ (void)pkey_deleter.release();
return true;
}
-bool create_ssl_certificate(std::string &pkey_buffer, std::string &cert_buffer)
-{
- EVP_PKEY *pkey;
- X509 *cert;
- if (!create_ssl_certificate(pkey, cert))
- return false;
- BIO *bio_pkey = BIO_new(BIO_s_mem()), *bio_cert = BIO_new(BIO_s_mem());
- openssl_bio bio_pkey_deleter{bio_pkey};
- bool success = PEM_write_bio_PrivateKey(bio_pkey, pkey, NULL, NULL, 0, NULL, NULL) && PEM_write_bio_X509(bio_cert, cert);
- X509_free(cert);
- if (!success)
- {
- MERROR("Failed to write cert and/or pkey: " << ERR_get_error());
- return false;
- }
- BUF_MEM *buf = NULL;
- BIO_get_mem_ptr(bio_pkey, &buf);
- if (!buf || !buf->data || !buf->length)
- {
- MERROR("Failed to write pkey: " << ERR_get_error());
- return false;
- }
- pkey_buffer = std::string(buf->data, buf->length);
- buf = NULL;
- BIO_get_mem_ptr(bio_cert, &buf);
- if (!buf || !buf->data || !buf->length)
- {
- MERROR("Failed to write cert: " << ERR_get_error());
- return false;
- }
- cert_buffer = std::string(buf->data, buf->length);
- return success;
-}
-
ssl_context_t create_ssl_context(const std::pair<std::string, std::string> &private_key_and_certificate_path, std::list<std::string> allowed_certificates, std::vector<std::vector<uint8_t>> allowed_fingerprints, bool allow_any_cert)
{
ssl_context_t ssl_context{boost::asio::ssl::context(boost::asio::ssl::context::tlsv12), std::move(allowed_certificates), std::move(allowed_fingerprints)};
@@ -190,10 +158,13 @@ ssl_context_t create_ssl_context(const std::pair<std::string, std::string> &priv
CHECK_AND_ASSERT_THROW_MES(private_key_and_certificate_path.first.empty() == private_key_and_certificate_path.second.empty(), "private key and certificate must be either both given or both empty");
if (private_key_and_certificate_path.second.empty())
{
- std::string pkey, cert;
+ EVP_PKEY *pkey;
+ X509 *cert;
CHECK_AND_ASSERT_THROW_MES(create_ssl_certificate(pkey, cert), "Failed to create certificate");
- ssl_context.context.use_private_key(boost::asio::buffer(pkey), boost::asio::ssl::context::pem);
- ssl_context.context.use_certificate(boost::asio::buffer(cert), boost::asio::ssl::context::pem);
+ CHECK_AND_ASSERT_THROW_MES(SSL_CTX_use_certificate(ctx, cert), "Failed to use generated certificate");
+ // don't free the cert, the CTX owns it now
+ CHECK_AND_ASSERT_THROW_MES(SSL_CTX_use_PrivateKey(ctx, pkey), "Failed to use generated private key");
+ EVP_PKEY_free(pkey);
}
else
{
diff --git a/contrib/epee/src/network_throttle-detail.cpp b/contrib/epee/src/network_throttle-detail.cpp
index 0b42402bd..f89e7aec0 100644
--- a/contrib/epee/src/network_throttle-detail.cpp
+++ b/contrib/epee/src/network_throttle-detail.cpp
@@ -2,7 +2,7 @@
/// @author rfree (current maintainer in monero.cc project)
/// @brief implementaion for throttling of connection (count and rate-limit speed etc)
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/contrib/epee/src/network_throttle.cpp b/contrib/epee/src/network_throttle.cpp
index 167738855..f4f0b2c46 100644
--- a/contrib/epee/src/network_throttle.cpp
+++ b/contrib/epee/src/network_throttle.cpp
@@ -26,7 +26,7 @@ Throttling work by:
*/
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/contrib/epee/src/wipeable_string.cpp b/contrib/epee/src/wipeable_string.cpp
index 69f92e106..3a6ee5dac 100644
--- a/contrib/epee/src/wipeable_string.cpp
+++ b/contrib/epee/src/wipeable_string.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt
index 7553f87ea..bc4344b34 100644
--- a/external/CMakeLists.txt
+++ b/external/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/external/db_drivers/CMakeLists.txt b/external/db_drivers/CMakeLists.txt
index d537ec029..04776c475 100644
--- a/external/db_drivers/CMakeLists.txt
+++ b/external/db_drivers/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/external/db_drivers/liblmdb/CMakeLists.txt b/external/db_drivers/liblmdb/CMakeLists.txt
index 2e8822f54..562ebb1eb 100644
--- a/external/db_drivers/liblmdb/CMakeLists.txt
+++ b/external/db_drivers/liblmdb/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/external/easylogging++/CMakeLists.txt b/external/easylogging++/CMakeLists.txt
index 78795d54b..8287024c2 100644
--- a/external/easylogging++/CMakeLists.txt
+++ b/external/easylogging++/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/external/unbound b/external/unbound
-Subproject 7f23967954736dcaa366806b9eaba7e2bdfede1
+Subproject 0f6c0579d66b65f86066e30e7876105ba2775ef
diff --git a/include/INode.h b/include/INode.h
index 21be0b2f3..0d896ca69 100644
--- a/include/INode.h
+++ b/include/INode.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/include/IWallet.h b/include/IWallet.h
index 98110a9d6..98362895d 100644
--- a/include/IWallet.h
+++ b/include/IWallet.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f1454b48e..2ae72ee81 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/src/blockchain_db/CMakeLists.txt b/src/blockchain_db/CMakeLists.txt
index 277f4458e..db161fa5e 100644
--- a/src/blockchain_db/CMakeLists.txt
+++ b/src/blockchain_db/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/src/blockchain_db/berkeleydb/db_bdb.cpp b/src/blockchain_db/berkeleydb/db_bdb.cpp
index 60a7326f8..3eb24494f 100644
--- a/src/blockchain_db/berkeleydb/db_bdb.cpp
+++ b/src/blockchain_db/berkeleydb/db_bdb.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
diff --git a/src/blockchain_db/berkeleydb/db_bdb.h b/src/blockchain_db/berkeleydb/db_bdb.h
index e80adae9e..04a33d7c6 100644
--- a/src/blockchain_db/berkeleydb/db_bdb.h
+++ b/src/blockchain_db/berkeleydb/db_bdb.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
diff --git a/src/blockchain_db/blockchain_db.cpp b/src/blockchain_db/blockchain_db.cpp
index 754c3c2da..d772bf4bb 100644
--- a/src/blockchain_db/blockchain_db.cpp
+++ b/src/blockchain_db/blockchain_db.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/blockchain_db/blockchain_db.h b/src/blockchain_db/blockchain_db.h
index ed13de5b5..313e716e0 100644
--- a/src/blockchain_db/blockchain_db.h
+++ b/src/blockchain_db/blockchain_db.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/blockchain_db/db_types.h b/src/blockchain_db/db_types.h
index b8c7fa3e3..04cadbb10 100644
--- a/src/blockchain_db/db_types.h
+++ b/src/blockchain_db/db_types.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp
index e2db5e04e..becffed16 100644
--- a/src/blockchain_db/lmdb/db_lmdb.cpp
+++ b/src/blockchain_db/lmdb/db_lmdb.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
diff --git a/src/blockchain_db/lmdb/db_lmdb.h b/src/blockchain_db/lmdb/db_lmdb.h
index 82016c17a..7a04c5f0c 100644
--- a/src/blockchain_db/lmdb/db_lmdb.h
+++ b/src/blockchain_db/lmdb/db_lmdb.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
diff --git a/src/blockchain_db/testdb.h b/src/blockchain_db/testdb.h
index ac1849b5f..eb9c3e45a 100644
--- a/src/blockchain_db/testdb.h
+++ b/src/blockchain_db/testdb.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/blockchain_utilities/CMakeLists.txt b/src/blockchain_utilities/CMakeLists.txt
index df74eb695..0ba7ee86c 100644
--- a/src/blockchain_utilities/CMakeLists.txt
+++ b/src/blockchain_utilities/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/src/blockchain_utilities/README.md b/src/blockchain_utilities/README.md
index 5d968cd75..ad5963f27 100644
--- a/src/blockchain_utilities/README.md
+++ b/src/blockchain_utilities/README.md
@@ -1,6 +1,6 @@
# Monero Blockchain Utilities
-Copyright (c) 2014-2018, The Monero Project
+Copyright (c) 2014-2019, The Monero Project
## Introduction
diff --git a/src/blockchain_utilities/blockchain_ancestry.cpp b/src/blockchain_utilities/blockchain_ancestry.cpp
index a64ce160a..a6ee0573f 100644
--- a/src/blockchain_utilities/blockchain_ancestry.cpp
+++ b/src/blockchain_utilities/blockchain_ancestry.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/blockchain_utilities/blockchain_blackball.cpp b/src/blockchain_utilities/blockchain_blackball.cpp
index 8b007e901..6ff184041 100644
--- a/src/blockchain_utilities/blockchain_blackball.cpp
+++ b/src/blockchain_utilities/blockchain_blackball.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/blockchain_utilities/blockchain_depth.cpp b/src/blockchain_utilities/blockchain_depth.cpp
index 8060b0de4..8be83ee67 100644
--- a/src/blockchain_utilities/blockchain_depth.cpp
+++ b/src/blockchain_utilities/blockchain_depth.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/blockchain_utilities/blockchain_export.cpp b/src/blockchain_utilities/blockchain_export.cpp
index 5c5bc7f69..fa1243c1f 100644
--- a/src/blockchain_utilities/blockchain_export.cpp
+++ b/src/blockchain_utilities/blockchain_export.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/blockchain_utilities/blockchain_import.cpp b/src/blockchain_utilities/blockchain_import.cpp
index d7a88f935..e4efdc3cb 100644
--- a/src/blockchain_utilities/blockchain_import.cpp
+++ b/src/blockchain_utilities/blockchain_import.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/blockchain_utilities/blockchain_prune_known_spent_data.cpp b/src/blockchain_utilities/blockchain_prune_known_spent_data.cpp
index f6136c1ba..2d49b6ecd 100644
--- a/src/blockchain_utilities/blockchain_prune_known_spent_data.cpp
+++ b/src/blockchain_utilities/blockchain_prune_known_spent_data.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/blockchain_utilities/blockchain_stats.cpp b/src/blockchain_utilities/blockchain_stats.cpp
index aae8f333b..4cc84bf4a 100644
--- a/src/blockchain_utilities/blockchain_stats.cpp
+++ b/src/blockchain_utilities/blockchain_stats.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/blockchain_utilities/blockchain_usage.cpp b/src/blockchain_utilities/blockchain_usage.cpp
index 38a0b2648..bd73350b3 100644
--- a/src/blockchain_utilities/blockchain_usage.cpp
+++ b/src/blockchain_utilities/blockchain_usage.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/blockchain_utilities/blockchain_utilities.h b/src/blockchain_utilities/blockchain_utilities.h
index e690305c4..78487b995 100644
--- a/src/blockchain_utilities/blockchain_utilities.h
+++ b/src/blockchain_utilities/blockchain_utilities.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/blockchain_utilities/blocksdat_file.cpp b/src/blockchain_utilities/blocksdat_file.cpp
index 45ef33acb..f56ff5f94 100644
--- a/src/blockchain_utilities/blocksdat_file.cpp
+++ b/src/blockchain_utilities/blocksdat_file.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/blockchain_utilities/blocksdat_file.h b/src/blockchain_utilities/blocksdat_file.h
index 70a1f30a7..315713424 100644
--- a/src/blockchain_utilities/blocksdat_file.h
+++ b/src/blockchain_utilities/blocksdat_file.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/blockchain_utilities/bootstrap_file.cpp b/src/blockchain_utilities/bootstrap_file.cpp
index a8c46d661..fb9a24f5d 100644
--- a/src/blockchain_utilities/bootstrap_file.cpp
+++ b/src/blockchain_utilities/bootstrap_file.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/blockchain_utilities/bootstrap_file.h b/src/blockchain_utilities/bootstrap_file.h
index 187db0938..5fb2cf366 100644
--- a/src/blockchain_utilities/bootstrap_file.h
+++ b/src/blockchain_utilities/bootstrap_file.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/blockchain_utilities/bootstrap_serialization.h b/src/blockchain_utilities/bootstrap_serialization.h
index 278a7b40f..554c6d56e 100644
--- a/src/blockchain_utilities/bootstrap_serialization.h
+++ b/src/blockchain_utilities/bootstrap_serialization.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/blocks/CMakeLists.txt b/src/blocks/CMakeLists.txt
index ff48af6dc..0b7b02fee 100644
--- a/src/blocks/CMakeLists.txt
+++ b/src/blocks/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/src/blocks/checkpoints.dat b/src/blocks/checkpoints.dat
index 03e2cd2a8..adc433522 100644
--- a/src/blocks/checkpoints.dat
+++ b/src/blocks/checkpoints.dat
Binary files differ
diff --git a/src/checkpoints/CMakeLists.txt b/src/checkpoints/CMakeLists.txt
index 715006522..d324f518e 100644
--- a/src/checkpoints/CMakeLists.txt
+++ b/src/checkpoints/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/src/checkpoints/checkpoints.cpp b/src/checkpoints/checkpoints.cpp
index 96f575b2d..e31b96646 100644
--- a/src/checkpoints/checkpoints.cpp
+++ b/src/checkpoints/checkpoints.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -208,6 +208,7 @@ namespace cryptonote
ADD_CHECKPOINT(1530000, "01759bce497ec38e63c78b1038892169203bb78f87e488172f6b854fcd63ba7e");
ADD_CHECKPOINT(1579000, "7d0d7a2346373afd41ed1e744a939fc5d474a7dbaa257be5c6fff4009e789241");
ADD_CHECKPOINT(1668900, "ac2dcaf3d2f58ffcf8391639f0f1ebafcb8eac43c49479c7c37f611868d07568");
+ ADD_CHECKPOINT(1775600, "1c6e01c661dc22cab939e79ec6a5272190624ce8356d2f7b958e4f9a57fdb05e");
return true;
}
diff --git a/src/checkpoints/checkpoints.h b/src/checkpoints/checkpoints.h
index ad2b44d1a..a55b94bf0 100644
--- a/src/checkpoints/checkpoints.h
+++ b/src/checkpoints/checkpoints.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index bcf9cbce7..f06737b31 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/src/common/aligned.c b/src/common/aligned.c
index 763dfd0e7..6982409f7 100644
--- a/src/common/aligned.c
+++ b/src/common/aligned.c
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/apply_permutation.h b/src/common/apply_permutation.h
index ff346bab1..a4b2c8b78 100644
--- a/src/common/apply_permutation.h
+++ b/src/common/apply_permutation.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/base58.cpp b/src/common/base58.cpp
index 3562af486..ac1bf4b29 100644
--- a/src/common/base58.cpp
+++ b/src/common/base58.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/base58.h b/src/common/base58.h
index 69611859d..6bf2c3bb7 100644
--- a/src/common/base58.h
+++ b/src/common/base58.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/boost_serialization_helper.h b/src/common/boost_serialization_helper.h
index 3f5c623f8..2280f3312 100644
--- a/src/common/boost_serialization_helper.h
+++ b/src/common/boost_serialization_helper.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/command_line.cpp b/src/common/command_line.cpp
index 35135ea18..cae744ea5 100644
--- a/src/common/command_line.cpp
+++ b/src/common/command_line.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/command_line.h b/src/common/command_line.h
index 3a869bb26..b5e3d94a7 100644
--- a/src/common/command_line.h
+++ b/src/common/command_line.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/common_fwd.h b/src/common/common_fwd.h
index 2924d9cbe..7eaa6cdee 100644
--- a/src/common/common_fwd.h
+++ b/src/common/common_fwd.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/dns_utils.cpp b/src/common/dns_utils.cpp
index 417b5b4ac..58227dfa7 100644
--- a/src/common/dns_utils.cpp
+++ b/src/common/dns_utils.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -514,12 +514,12 @@ bool load_txt_records_from_dns(std::vector<std::string> &good_records, const std
if (!avail[cur_index])
{
records[cur_index].clear();
- LOG_PRINT_L2("DNSSEC not available for checkpoint update at URL: " << url << ", skipping.");
+ LOG_PRINT_L2("DNSSEC not available for hostname: " << url << ", skipping.");
}
if (!valid[cur_index])
{
records[cur_index].clear();
- LOG_PRINT_L2("DNSSEC validation failed for checkpoint update at URL: " << url << ", skipping.");
+ LOG_PRINT_L2("DNSSEC validation failed for hostname: " << url << ", skipping.");
}
cur_index++;
@@ -541,7 +541,7 @@ bool load_txt_records_from_dns(std::vector<std::string> &good_records, const std
if (num_valid_records < 2)
{
- LOG_PRINT_L0("WARNING: no two valid MoneroPulse DNS checkpoint records were received");
+ LOG_PRINT_L0("WARNING: no two valid DNS TXT records were received");
return false;
}
@@ -563,7 +563,7 @@ bool load_txt_records_from_dns(std::vector<std::string> &good_records, const std
if (good_records_index < 0)
{
- LOG_PRINT_L0("WARNING: no two MoneroPulse DNS checkpoint records matched");
+ LOG_PRINT_L0("WARNING: no two DNS TXT records matched");
return false;
}
diff --git a/src/common/dns_utils.h b/src/common/dns_utils.h
index 3a6ef68a1..a6bc7463a 100644
--- a/src/common/dns_utils.h
+++ b/src/common/dns_utils.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/download.cpp b/src/common/download.cpp
index 7c38cfa5b..f07d6798d 100644
--- a/src/common/download.cpp
+++ b/src/common/download.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/download.h b/src/common/download.h
index 3097394bc..f8656a59c 100644
--- a/src/common/download.h
+++ b/src/common/download.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/http_connection.h b/src/common/http_connection.h
index 554dd832b..6b4294802 100644
--- a/src/common/http_connection.h
+++ b/src/common/http_connection.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/i18n.cpp b/src/common/i18n.cpp
index a32875945..9ac347263 100644
--- a/src/common/i18n.cpp
+++ b/src/common/i18n.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/i18n.h b/src/common/i18n.h
index d21d00275..82a07410d 100644
--- a/src/common/i18n.h
+++ b/src/common/i18n.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/json_util.h b/src/common/json_util.h
index c320c3956..96f4b90e6 100644
--- a/src/common/json_util.h
+++ b/src/common/json_util.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2016-2018, The Monero Project
+// Copyright (c) 2016-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/password.cpp b/src/common/password.cpp
index 5f5cb800a..03d13db42 100644
--- a/src/common/password.cpp
+++ b/src/common/password.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/password.h b/src/common/password.h
index beb98283b..2837c70f3 100644
--- a/src/common/password.h
+++ b/src/common/password.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/perf_timer.cpp b/src/common/perf_timer.cpp
index 3e1357833..dda498088 100644
--- a/src/common/perf_timer.cpp
+++ b/src/common/perf_timer.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2016-2018, The Monero Project
+// Copyright (c) 2016-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/perf_timer.h b/src/common/perf_timer.h
index 5203da205..717391623 100644
--- a/src/common/perf_timer.h
+++ b/src/common/perf_timer.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2016-2018, The Monero Project
+// Copyright (c) 2016-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/pod-class.h b/src/common/pod-class.h
index 5f6709eef..200647590 100644
--- a/src/common/pod-class.h
+++ b/src/common/pod-class.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/rpc_client.h b/src/common/rpc_client.h
index 9665966ae..cb5f79da8 100644
--- a/src/common/rpc_client.h
+++ b/src/common/rpc_client.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/scoped_message_writer.h b/src/common/scoped_message_writer.h
index 42f439ad8..546377392 100644
--- a/src/common/scoped_message_writer.h
+++ b/src/common/scoped_message_writer.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/sfinae_helpers.h b/src/common/sfinae_helpers.h
index fa5052a2e..e9a98bb63 100644
--- a/src/common/sfinae_helpers.h
+++ b/src/common/sfinae_helpers.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2016-2018, The Monero Project
+// Copyright (c) 2016-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/spawn.cpp b/src/common/spawn.cpp
index e03552f8c..9a7e75d41 100644
--- a/src/common/spawn.cpp
+++ b/src/common/spawn.cpp
@@ -91,7 +91,7 @@ int spawn(const char *filename, const std::vector<std::string>& args, bool wait)
MINFO("Child exited with " << exitCode);
return static_cast<int>(exitCode);
#else
- char **argv = (char**)alloca(sizeof(char*) * (args.size() + 1));
+ std::vector<char*> argv(args.size() + 1);
for (size_t n = 0; n < args.size(); ++n)
argv[n] = (char*)args[n].c_str();
argv[args.size()] = NULL;
@@ -109,7 +109,7 @@ int spawn(const char *filename, const std::vector<std::string>& args, bool wait)
tools::closefrom(3);
close(0);
char *envp[] = {NULL};
- execve(filename, argv, envp);
+ execve(filename, argv.data(), envp);
MERROR("Failed to execve: " << strerror(errno));
return -1;
}
diff --git a/src/common/stack_trace.cpp b/src/common/stack_trace.cpp
index 141621427..8d4f8c6f1 100644
--- a/src/common/stack_trace.cpp
+++ b/src/common/stack_trace.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2016-2018, The Monero Project
+// Copyright (c) 2016-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/stack_trace.h b/src/common/stack_trace.h
index 272fb89ae..ae6573885 100644
--- a/src/common/stack_trace.h
+++ b/src/common/stack_trace.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2016-2018, The Monero Project
+// Copyright (c) 2016-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/threadpool.cpp b/src/common/threadpool.cpp
index cbf7163c5..2748c798c 100644
--- a/src/common/threadpool.cpp
+++ b/src/common/threadpool.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/threadpool.h b/src/common/threadpool.h
index a43e38a76..5e490ee7d 100644
--- a/src/common/threadpool.h
+++ b/src/common/threadpool.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/timings.cc b/src/common/timings.cc
index cb8deff2a..612ac2cc6 100644
--- a/src/common/timings.cc
+++ b/src/common/timings.cc
@@ -1,5 +1,5 @@
#include <string.h>
-#include <error.h>
+#include <errno.h>
#include <time.h>
#include <algorithm>
#include <boost/algorithm/string.hpp>
diff --git a/src/common/unordered_containers_boost_serialization.h b/src/common/unordered_containers_boost_serialization.h
index d78dc6a30..74e2c3f81 100644
--- a/src/common/unordered_containers_boost_serialization.h
+++ b/src/common/unordered_containers_boost_serialization.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/updates.cpp b/src/common/updates.cpp
index 9f12f8dbc..0bc6ff63c 100644
--- a/src/common/updates.cpp
+++ b/src/common/updates.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/updates.h b/src/common/updates.h
index 6ec22f183..8fda6d207 100644
--- a/src/common/updates.h
+++ b/src/common/updates.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/util.cpp b/src/common/util.cpp
index 28745eea4..80b8a9e81 100644
--- a/src/common/util.cpp
+++ b/src/common/util.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/util.h b/src/common/util.h
index d5aca15d1..ef2305bf4 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/varint.h b/src/common/varint.h
index 904255afc..a0d79be28 100644
--- a/src/common/varint.h
+++ b/src/common/varint.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/CMakeLists.txt b/src/crypto/CMakeLists.txt
index 6e774b8d5..84f002929 100644
--- a/src/crypto/CMakeLists.txt
+++ b/src/crypto/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/src/crypto/blake256.c b/src/crypto/blake256.c
index 6ef7d4207..1e305b3a6 100644
--- a/src/crypto/blake256.c
+++ b/src/crypto/blake256.c
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/blake256.h b/src/crypto/blake256.h
index 073772289..309dbf3ec 100644
--- a/src/crypto/blake256.h
+++ b/src/crypto/blake256.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/chacha.h b/src/crypto/chacha.h
index 0610f7051..a39823e5a 100644
--- a/src/crypto/chacha.h
+++ b/src/crypto/chacha.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/crypto-ops-data.c b/src/crypto/crypto-ops-data.c
index 1f77513ca..c9530bb2a 100644
--- a/src/crypto/crypto-ops-data.c
+++ b/src/crypto/crypto-ops-data.c
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/crypto-ops.c b/src/crypto/crypto-ops.c
index 09296d6f9..5a3d994a6 100644
--- a/src/crypto/crypto-ops.c
+++ b/src/crypto/crypto-ops.c
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/crypto-ops.h b/src/crypto/crypto-ops.h
index 2910dafd4..7137437bc 100644
--- a/src/crypto/crypto-ops.h
+++ b/src/crypto/crypto-ops.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/crypto.cpp b/src/crypto/crypto.cpp
index ddf072f68..3f06c4f3f 100644
--- a/src/crypto/crypto.cpp
+++ b/src/crypto/crypto.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/crypto.h b/src/crypto/crypto.h
index f22df1230..22b182ab0 100644
--- a/src/crypto/crypto.h
+++ b/src/crypto/crypto.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/crypto_ops_builder/README.md b/src/crypto/crypto_ops_builder/README.md
index 326d2ca6e..4bb95cc4a 100644
--- a/src/crypto/crypto_ops_builder/README.md
+++ b/src/crypto/crypto_ops_builder/README.md
@@ -1,6 +1,6 @@
# Monero
-Copyright (c) 2014-2018, The Monero Project
+Copyright (c) 2014-2019, The Monero Project
## Crypto Ops Builder
diff --git a/src/crypto/crypto_ops_builder/crypto-ops-data.c b/src/crypto/crypto_ops_builder/crypto-ops-data.c
index 127e3e17b..45e9923b1 100644
--- a/src/crypto/crypto_ops_builder/crypto-ops-data.c
+++ b/src/crypto/crypto_ops_builder/crypto-ops-data.c
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/crypto_ops_builder/crypto-ops-old.c b/src/crypto/crypto_ops_builder/crypto-ops-old.c
index 9097bf95b..89c2ced6e 100644
--- a/src/crypto/crypto_ops_builder/crypto-ops-old.c
+++ b/src/crypto/crypto_ops_builder/crypto-ops-old.c
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/crypto_ops_builder/crypto-ops.h b/src/crypto/crypto_ops_builder/crypto-ops.h
index 9337b56b7..b4fcfca9c 100644
--- a/src/crypto/crypto_ops_builder/crypto-ops.h
+++ b/src/crypto/crypto_ops_builder/crypto-ops.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/crypto_ops_builder/ref10CommentedCombined/MakeCryptoOps.py b/src/crypto/crypto_ops_builder/ref10CommentedCombined/MakeCryptoOps.py
index 0ed97d5f4..dfba583f7 100644
--- a/src/crypto/crypto_ops_builder/ref10CommentedCombined/MakeCryptoOps.py
+++ b/src/crypto/crypto_ops_builder/ref10CommentedCombined/MakeCryptoOps.py
@@ -15,7 +15,7 @@ print("maybe someone smart can replace the sed with perl..")
a = ""
license = textwrap.dedent("""\
- // Copyright (c) 2014-2018, The Monero Project
+ // Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/crypto_ops_builder/ref10CommentedCombined/crypto-ops.h b/src/crypto/crypto_ops_builder/ref10CommentedCombined/crypto-ops.h
index c06af035f..f62ff441d 100644
--- a/src/crypto/crypto_ops_builder/ref10CommentedCombined/crypto-ops.h
+++ b/src/crypto/crypto_ops_builder/ref10CommentedCombined/crypto-ops.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/generic-ops.h b/src/crypto/generic-ops.h
index 42b98706e..d06726638 100644
--- a/src/crypto/generic-ops.h
+++ b/src/crypto/generic-ops.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/groestl.h b/src/crypto/groestl.h
index 19837f309..6628947dd 100644
--- a/src/crypto/groestl.h
+++ b/src/crypto/groestl.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/groestl_tables.h b/src/crypto/groestl_tables.h
index 12472dced..ca0c4fca6 100644
--- a/src/crypto/groestl_tables.h
+++ b/src/crypto/groestl_tables.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/hash-extra-blake.c b/src/crypto/hash-extra-blake.c
index d33103c97..9bada96f3 100644
--- a/src/crypto/hash-extra-blake.c
+++ b/src/crypto/hash-extra-blake.c
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/hash-extra-groestl.c b/src/crypto/hash-extra-groestl.c
index 228853a44..57866bf9d 100644
--- a/src/crypto/hash-extra-groestl.c
+++ b/src/crypto/hash-extra-groestl.c
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/hash-extra-jh.c b/src/crypto/hash-extra-jh.c
index e765a18f3..0dbac4fb5 100644
--- a/src/crypto/hash-extra-jh.c
+++ b/src/crypto/hash-extra-jh.c
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/hash-extra-skein.c b/src/crypto/hash-extra-skein.c
index 06d8f87cc..78f48609f 100644
--- a/src/crypto/hash-extra-skein.c
+++ b/src/crypto/hash-extra-skein.c
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/hash-ops.h b/src/crypto/hash-ops.h
index ba7ece0f5..859c810bd 100644
--- a/src/crypto/hash-ops.h
+++ b/src/crypto/hash-ops.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/hash.c b/src/crypto/hash.c
index 43ce32957..b66f3b010 100644
--- a/src/crypto/hash.c
+++ b/src/crypto/hash.c
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/hash.h b/src/crypto/hash.h
index 165fe6bb0..17071923d 100644
--- a/src/crypto/hash.h
+++ b/src/crypto/hash.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/initializer.h b/src/crypto/initializer.h
index 107988d2b..75d80f054 100644
--- a/src/crypto/initializer.h
+++ b/src/crypto/initializer.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/random.c b/src/crypto/random.c
index 9e1a70a2d..74b202661 100644
--- a/src/crypto/random.c
+++ b/src/crypto/random.c
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/random.h b/src/crypto/random.h
index 6468136cc..ccb9f4853 100644
--- a/src/crypto/random.h
+++ b/src/crypto/random.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/skein_port.h b/src/crypto/skein_port.h
index 8a1640e57..1ec07a4d1 100644
--- a/src/crypto/skein_port.h
+++ b/src/crypto/skein_port.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/slow-hash.c b/src/crypto/slow-hash.c
index 6bdc1b28c..9dc6f5038 100644
--- a/src/crypto/slow-hash.c
+++ b/src/crypto/slow-hash.c
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/crypto/tree-hash.c b/src/crypto/tree-hash.c
index b2dc3ffb2..7802fb67f 100644
--- a/src/crypto/tree-hash.c
+++ b/src/crypto/tree-hash.c
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -34,15 +34,6 @@
#include "hash-ops.h"
-#ifdef _MSC_VER
-#include <malloc.h>
-#elif !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__) \
- && !defined(__NetBSD__)
- #include <alloca.h>
-#else
- #include <stdlib.h>
-#endif
-
/***
* Round to power of two, for count>=3 and for count being not too large (as reasonable for tree hash calculations)
*/
@@ -91,9 +82,8 @@ void tree_hash(const char (*hashes)[HASH_SIZE], size_t count, char *root_hash) {
size_t cnt = tree_hash_cnt( count );
- char (*ints)[HASH_SIZE];
- size_t ints_size = cnt * HASH_SIZE;
- ints = alloca(ints_size); memset( ints , 0 , ints_size); // allocate, and zero out as extra protection for using uninitialized mem
+ char ints[cnt][HASH_SIZE];
+ memset(ints, 0 , sizeof(ints)); // zero out as extra protection for using uninitialized mem
memcpy(ints, hashes, (2 * cnt - count) * HASH_SIZE);
diff --git a/src/cryptonote_basic/CMakeLists.txt b/src/cryptonote_basic/CMakeLists.txt
index 21445959d..5bb56e083 100644
--- a/src/cryptonote_basic/CMakeLists.txt
+++ b/src/cryptonote_basic/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/src/cryptonote_basic/account.cpp b/src/cryptonote_basic/account.cpp
index edbc2c561..a9aec163b 100644
--- a/src/cryptonote_basic/account.cpp
+++ b/src/cryptonote_basic/account.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_basic/account.h b/src/cryptonote_basic/account.h
index 021f84029..abf751b6e 100644
--- a/src/cryptonote_basic/account.h
+++ b/src/cryptonote_basic/account.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_basic/account_boost_serialization.h b/src/cryptonote_basic/account_boost_serialization.h
index 7379d787f..320a960dc 100644
--- a/src/cryptonote_basic/account_boost_serialization.h
+++ b/src/cryptonote_basic/account_boost_serialization.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_basic/blobdatatype.h b/src/cryptonote_basic/blobdatatype.h
index 82484c0a8..20f6b2421 100644
--- a/src/cryptonote_basic/blobdatatype.h
+++ b/src/cryptonote_basic/blobdatatype.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_basic/connection_context.h b/src/cryptonote_basic/connection_context.h
index 112c13049..96398a90b 100644
--- a/src/cryptonote_basic/connection_context.h
+++ b/src/cryptonote_basic/connection_context.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -40,7 +40,8 @@ namespace cryptonote
struct cryptonote_connection_context: public epee::net_utils::connection_context_base
{
cryptonote_connection_context(): m_state(state_before_handshake), m_remote_blockchain_height(0), m_last_response_height(0),
- m_last_request_time(boost::date_time::not_a_date_time), m_callback_request_count(0), m_last_known_hash(crypto::null_hash), m_pruning_seed(0), m_anchor(false) {}
+ m_last_request_time(boost::date_time::not_a_date_time), m_callback_request_count(0),
+ m_last_known_hash(crypto::null_hash), m_pruning_seed(0), m_rpc_port(0), m_anchor(false) {}
enum state
{
@@ -60,6 +61,7 @@ namespace cryptonote
epee::copyable_atomic m_callback_request_count; //in debug purpose: problem with double callback rise
crypto::hash m_last_known_hash;
uint32_t m_pruning_seed;
+ uint16_t m_rpc_port;
bool m_anchor;
//size_t m_score; TODO: add score calculations
};
diff --git a/src/cryptonote_basic/cryptonote_basic.h b/src/cryptonote_basic/cryptonote_basic.h
index 172a99e84..03caafbb0 100644
--- a/src/cryptonote_basic/cryptonote_basic.h
+++ b/src/cryptonote_basic/cryptonote_basic.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_basic/cryptonote_basic_impl.cpp b/src/cryptonote_basic/cryptonote_basic_impl.cpp
index 23a5bd5bd..e336cc1d1 100644
--- a/src/cryptonote_basic/cryptonote_basic_impl.cpp
+++ b/src/cryptonote_basic/cryptonote_basic_impl.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_basic/cryptonote_basic_impl.h b/src/cryptonote_basic/cryptonote_basic_impl.h
index 0b8131a7a..036273f0e 100644
--- a/src/cryptonote_basic/cryptonote_basic_impl.h
+++ b/src/cryptonote_basic/cryptonote_basic_impl.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_basic/cryptonote_boost_serialization.h b/src/cryptonote_basic/cryptonote_boost_serialization.h
index d1e321994..4ce9f3eeb 100644
--- a/src/cryptonote_basic/cryptonote_boost_serialization.h
+++ b/src/cryptonote_basic/cryptonote_boost_serialization.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_basic/cryptonote_format_utils.cpp b/src/cryptonote_basic/cryptonote_format_utils.cpp
index f4e7c9d36..f40464bd1 100644
--- a/src/cryptonote_basic/cryptonote_format_utils.cpp
+++ b/src/cryptonote_basic/cryptonote_format_utils.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -396,6 +396,7 @@ namespace cryptonote
for (const auto &bp: rv.p.bulletproofs)
nlr += bp.L.size() * 2;
const size_t bp_size = 32 * (9 + nlr);
+ CHECK_AND_ASSERT_THROW_MES_L1(n_outputs <= BULLETPROOF_MAX_OUTPUTS, "maximum number of outputs is " + std::to_string(BULLETPROOF_MAX_OUTPUTS) + " per transaction");
CHECK_AND_ASSERT_THROW_MES_L1(bp_base * n_padded_outputs >= bp_size, "Invalid bulletproof clawback");
const uint64_t bp_clawback = (bp_base * n_padded_outputs - bp_size) * 4 / 5;
CHECK_AND_ASSERT_THROW_MES_L1(bp_clawback <= std::numeric_limits<uint64_t>::max() - blob_size, "Weight overflow");
diff --git a/src/cryptonote_basic/cryptonote_format_utils.h b/src/cryptonote_basic/cryptonote_format_utils.h
index 92dbdbff0..40a9907be 100644
--- a/src/cryptonote_basic/cryptonote_format_utils.h
+++ b/src/cryptonote_basic/cryptonote_format_utils.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_basic/cryptonote_stat_info.h b/src/cryptonote_basic/cryptonote_stat_info.h
index a09fa850b..4cc1bc764 100644
--- a/src/cryptonote_basic/cryptonote_stat_info.h
+++ b/src/cryptonote_basic/cryptonote_stat_info.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_basic/difficulty.cpp b/src/cryptonote_basic/difficulty.cpp
index 55e3e93b3..89b748a83 100644
--- a/src/cryptonote_basic/difficulty.cpp
+++ b/src/cryptonote_basic/difficulty.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_basic/difficulty.h b/src/cryptonote_basic/difficulty.h
index b06538467..8da355b22 100644
--- a/src/cryptonote_basic/difficulty.h
+++ b/src/cryptonote_basic/difficulty.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_basic/hardfork.cpp b/src/cryptonote_basic/hardfork.cpp
index d1d836fcb..ebfe45f37 100644
--- a/src/cryptonote_basic/hardfork.cpp
+++ b/src/cryptonote_basic/hardfork.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_basic/hardfork.h b/src/cryptonote_basic/hardfork.h
index a3fc25dfa..123978b12 100644
--- a/src/cryptonote_basic/hardfork.h
+++ b/src/cryptonote_basic/hardfork.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_basic/miner.cpp b/src/cryptonote_basic/miner.cpp
index 3a51c6ea4..6628c8448 100644
--- a/src/cryptonote_basic/miner.cpp
+++ b/src/cryptonote_basic/miner.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -119,7 +119,8 @@ namespace cryptonote
m_min_idle_seconds(BACKGROUND_MINING_DEFAULT_MIN_IDLE_INTERVAL_IN_SECONDS),
m_idle_threshold(BACKGROUND_MINING_DEFAULT_IDLE_THRESHOLD_PERCENTAGE),
m_mining_target(BACKGROUND_MINING_DEFAULT_MINING_TARGET_PERCENTAGE),
- m_miner_extra_sleep(BACKGROUND_MINING_DEFAULT_MINER_EXTRA_SLEEP_MILLIS)
+ m_miner_extra_sleep(BACKGROUND_MINING_DEFAULT_MINER_EXTRA_SLEEP_MILLIS),
+ m_block_reward(0)
{
}
@@ -130,12 +131,13 @@ namespace cryptonote
catch (...) { /* ignore */ }
}
//-----------------------------------------------------------------------------------------------------
- bool miner::set_block_template(const block& bl, const difficulty_type& di, uint64_t height)
+ bool miner::set_block_template(const block& bl, const difficulty_type& di, uint64_t height, uint64_t block_reward)
{
CRITICAL_REGION_LOCAL(m_template_lock);
m_template = bl;
m_diffic = di;
m_height = height;
+ m_block_reward = block_reward;
++m_template_no;
m_starter_nonce = crypto::rand<uint32_t>();
return true;
@@ -167,7 +169,7 @@ namespace cryptonote
LOG_ERROR("Failed to get_block_template(), stopping mining");
return false;
}
- set_block_template(bl, di, height);
+ set_block_template(bl, di, height, expected_reward);
return true;
}
//-----------------------------------------------------------------------------------------------------
@@ -359,6 +361,7 @@ namespace cryptonote
//-----------------------------------------------------------------------------------------------------
bool miner::start(const account_public_address& adr, size_t threads_count, const boost::thread::attributes& attrs, bool do_background, bool ignore_battery)
{
+ m_block_reward = 0;
m_mine_address = adr;
m_threads_total = static_cast<uint32_t>(threads_count);
if (threads_count == 0)
diff --git a/src/cryptonote_basic/miner.h b/src/cryptonote_basic/miner.h
index d4cdb2363..08b1bd7f1 100644
--- a/src/cryptonote_basic/miner.h
+++ b/src/cryptonote_basic/miner.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -61,7 +61,7 @@ namespace cryptonote
~miner();
bool init(const boost::program_options::variables_map& vm, network_type nettype);
static void init_options(boost::program_options::options_description& desc);
- bool set_block_template(const block& bl, const difficulty_type& diffic, uint64_t height);
+ bool set_block_template(const block& bl, const difficulty_type& diffic, uint64_t height, uint64_t block_reward);
bool on_block_chain_update();
bool start(const account_public_address& adr, size_t threads_count, const boost::thread::attributes& attrs, bool do_background = false, bool ignore_battery = false);
uint64_t get_speed() const;
@@ -85,6 +85,7 @@ namespace cryptonote
bool set_idle_threshold(uint8_t idle_threshold);
uint8_t get_mining_target() const;
bool set_mining_target(uint8_t mining_target);
+ uint64_t get_block_reward() const { return m_block_reward; }
static constexpr uint8_t BACKGROUND_MINING_DEFAULT_IDLE_THRESHOLD_PERCENTAGE = 90;
static constexpr uint8_t BACKGROUND_MINING_MIN_IDLE_THRESHOLD_PERCENTAGE = 50;
@@ -169,5 +170,6 @@ namespace cryptonote
static bool get_process_time(uint64_t& total_time);
static uint8_t get_percent_of_total(uint64_t some_time, uint64_t total_time);
static boost::logic::tribool on_battery_power();
+ std::atomic<uint64_t> m_block_reward;
};
}
diff --git a/src/cryptonote_basic/subaddress_index.h b/src/cryptonote_basic/subaddress_index.h
index 9b71448f9..99933e229 100644
--- a/src/cryptonote_basic/subaddress_index.h
+++ b/src/cryptonote_basic/subaddress_index.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_basic/tx_extra.h b/src/cryptonote_basic/tx_extra.h
index 009e35ebe..ecb4c6040 100644
--- a/src/cryptonote_basic/tx_extra.h
+++ b/src/cryptonote_basic/tx_extra.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_basic/verification_context.h b/src/cryptonote_basic/verification_context.h
index 8d2b633a2..36b63f254 100644
--- a/src/cryptonote_basic/verification_context.h
+++ b/src/cryptonote_basic/verification_context.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h
index 956cc76aa..9beafe7c5 100644
--- a/src/cryptonote_config.h
+++ b/src/cryptonote_config.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_core/CMakeLists.txt b/src/cryptonote_core/CMakeLists.txt
index 231489fdb..fb96de226 100644
--- a/src/cryptonote_core/CMakeLists.txt
+++ b/src/cryptonote_core/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index 2c1b9d447..3e903cd12 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -3514,7 +3514,7 @@ leave:
// validate proof_of_work versus difficulty target
if(!check_hash(proof_of_work, current_diffic))
{
- MERROR_VER("Block with id: " << id << std::endl << "does not have enough proof of work: " << proof_of_work << std::endl << "unexpected difficulty: " << current_diffic);
+ MERROR_VER("Block with id: " << id << std::endl << "does not have enough proof of work: " << proof_of_work << " at height " << blockchain_height << ", unexpected difficulty: " << current_diffic);
bvc.m_verifivation_failed = true;
goto leave;
}
@@ -4328,7 +4328,7 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::vector<block_complete
unsigned nblocks = batches;
if (i < extra)
++nblocks;
- tpool.submit(&waiter, boost::bind(&Blockchain::block_longhash_worker, this, thread_height, epee::span<const block>(&blocks[i], nblocks), std::ref(maps[i])), true);
+ tpool.submit(&waiter, boost::bind(&Blockchain::block_longhash_worker, this, thread_height, epee::span<const block>(&blocks[thread_height - height], nblocks), std::ref(maps[i])), true);
thread_height += nblocks;
}
@@ -4705,7 +4705,7 @@ void Blockchain::cancel()
}
#if defined(PER_BLOCK_CHECKPOINT)
-static const char expected_block_hashes_hash[] = "954cb2bbfa2fe6f74b2cdd22a1a4c767aea249ad47ad4f7c9445f0f03260f511";
+static const char expected_block_hashes_hash[] = "570ce2357b08fadac6058e34f95c5e08323f9325de260d07b091a281a948a7b0";
void Blockchain::load_compiled_in_block_hashes(const GetCheckpointsCallback& get_checkpoints)
{
if (get_checkpoints == nullptr || !m_fast_sync)
diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h
index 9d928e386..4744defc5 100644
--- a/src/cryptonote_core/blockchain.h
+++ b/src/cryptonote_core/blockchain.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_core/blockchain_storage_boost_serialization.h b/src/cryptonote_core/blockchain_storage_boost_serialization.h
index f4f9f20ca..cfeb5acfc 100644
--- a/src/cryptonote_core/blockchain_storage_boost_serialization.h
+++ b/src/cryptonote_core/blockchain_storage_boost_serialization.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index 6639db620..58acdb6bb 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h
index 6d0ff098d..356265dd6 100644
--- a/src/cryptonote_core/cryptonote_core.h
+++ b/src/cryptonote_core/cryptonote_core.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_core/cryptonote_tx_utils.cpp b/src/cryptonote_core/cryptonote_tx_utils.cpp
index c138c7854..854f3d1c5 100644
--- a/src/cryptonote_core/cryptonote_tx_utils.cpp
+++ b/src/cryptonote_core/cryptonote_tx_utils.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_core/cryptonote_tx_utils.h b/src/cryptonote_core/cryptonote_tx_utils.h
index ad3297951..cb1561c2d 100644
--- a/src/cryptonote_core/cryptonote_tx_utils.h
+++ b/src/cryptonote_core/cryptonote_tx_utils.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp
index c2cc93530..c1cbe2acd 100644
--- a/src/cryptonote_core/tx_pool.cpp
+++ b/src/cryptonote_core/tx_pool.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_core/tx_pool.h b/src/cryptonote_core/tx_pool.h
index 7a8af8799..877f2b82f 100644
--- a/src/cryptonote_core/tx_pool.h
+++ b/src/cryptonote_core/tx_pool.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_protocol/CMakeLists.txt b/src/cryptonote_protocol/CMakeLists.txt
index 1189ccf22..bfcf42767 100644
--- a/src/cryptonote_protocol/CMakeLists.txt
+++ b/src/cryptonote_protocol/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/src/cryptonote_protocol/block_queue.cpp b/src/cryptonote_protocol/block_queue.cpp
index 716b0c8ba..b4f9daa74 100644
--- a/src/cryptonote_protocol/block_queue.cpp
+++ b/src/cryptonote_protocol/block_queue.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_protocol/block_queue.h b/src/cryptonote_protocol/block_queue.h
index c7d3af7ac..1bef01d67 100644
--- a/src/cryptonote_protocol/block_queue.h
+++ b/src/cryptonote_protocol/block_queue.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_protocol/cryptonote_protocol_defs.h b/src/cryptonote_protocol/cryptonote_protocol_defs.h
index 23846dbf8..d582e3e9c 100644
--- a/src/cryptonote_protocol/cryptonote_protocol_defs.h
+++ b/src/cryptonote_protocol/cryptonote_protocol_defs.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -54,6 +54,7 @@ namespace cryptonote
std::string host;
std::string ip;
std::string port;
+ uint16_t rpc_port;
std::string peer_id;
@@ -89,6 +90,7 @@ namespace cryptonote
KV_SERIALIZE(host)
KV_SERIALIZE(ip)
KV_SERIALIZE(port)
+ KV_SERIALIZE(rpc_port)
KV_SERIALIZE(peer_id)
KV_SERIALIZE(recv_count)
KV_SERIALIZE(recv_idle_time)
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler-base.cpp b/src/cryptonote_protocol/cryptonote_protocol_handler-base.cpp
index 6d9ad9028..225418980 100644
--- a/src/cryptonote_protocol/cryptonote_protocol_handler-base.cpp
+++ b/src/cryptonote_protocol/cryptonote_protocol_handler-base.cpp
@@ -2,7 +2,7 @@
/// @author rfree (current maintainer in monero.cc project)
/// @brief This is the place to implement our handlers for protocol network actions, e.g. for ratelimit for download-requests
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.h b/src/cryptonote_protocol/cryptonote_protocol_handler.h
index efd986b53..fc7db629c 100644
--- a/src/cryptonote_protocol/cryptonote_protocol_handler.h
+++ b/src/cryptonote_protocol/cryptonote_protocol_handler.h
@@ -2,7 +2,7 @@
/// @author rfree (current maintainer/user in monero.cc project - most of code is from CryptoNote)
/// @brief This is the original cryptonote protocol network-events handler, modified by us
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
index c8b43fb91..2317aee84 100644
--- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl
+++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
@@ -2,7 +2,7 @@
/// @author rfree (current maintainer/user in monero.cc project - most of code is from CryptoNote)
/// @brief This is the original cryptonote protocol network-events handler, modified by us
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -231,6 +231,7 @@ namespace cryptonote
cnx.ip = cnx.host;
cnx.port = std::to_string(cntxt.m_remote_address.as<epee::net_utils::ipv4_network_address>().port());
}
+ cnx.rpc_port = cntxt.m_rpc_port;
std::stringstream peer_id_str;
peer_id_str << std::hex << std::setw(16) << peer_id;
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler_common.h b/src/cryptonote_protocol/cryptonote_protocol_handler_common.h
index 2b9f201ec..a67178c52 100644
--- a/src/cryptonote_protocol/cryptonote_protocol_handler_common.h
+++ b/src/cryptonote_protocol/cryptonote_protocol_handler_common.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt
index 117790455..d9bfd9a20 100644
--- a/src/daemon/CMakeLists.txt
+++ b/src/daemon/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/src/daemon/command_line_args.h b/src/daemon/command_line_args.h
index cba71bf3b..32fdca5ea 100644
--- a/src/daemon/command_line_args.h
+++ b/src/daemon/command_line_args.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -96,6 +96,12 @@ namespace daemon_args
, 0
};
+ const command_line::arg_descriptor<bool> arg_public_node = {
+ "public-node"
+ , "Allow other users to use the node as a remote (restricted RPC mode, view-only commands) and advertise it over P2P"
+ , false
+ };
+
const command_line::arg_descriptor<std::string> arg_zmq_rpc_bind_ip = {
"zmq-rpc-bind-ip"
, "IP for ZMQ RPC server to listen on"
diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp
index 00d004970..b324ab99d 100644
--- a/src/daemon/command_parser_executor.cpp
+++ b/src/daemon/command_parser_executor.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -411,6 +411,11 @@ bool t_command_parser_executor::stop_mining(const std::vector<std::string>& args
return m_executor.stop_mining();
}
+bool t_command_parser_executor::mining_status(const std::vector<std::string>& args)
+{
+ return m_executor.mining_status();
+}
+
bool t_command_parser_executor::stop_daemon(const std::vector<std::string>& args)
{
if (!args.empty()) return false;
diff --git a/src/daemon/command_parser_executor.h b/src/daemon/command_parser_executor.h
index 5b8927908..bec6e4522 100644
--- a/src/daemon/command_parser_executor.h
+++ b/src/daemon/command_parser_executor.h
@@ -6,7 +6,7 @@
*/
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -97,6 +97,8 @@ public:
bool stop_mining(const std::vector<std::string>& args);
+ bool mining_status(const std::vector<std::string>& args);
+
bool stop_daemon(const std::vector<std::string>& args);
bool print_status(const std::vector<std::string>& args);
diff --git a/src/daemon/command_server.cpp b/src/daemon/command_server.cpp
index 3e19bb42f..94e4a8bf1 100644
--- a/src/daemon/command_server.cpp
+++ b/src/daemon/command_server.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -113,6 +113,11 @@ t_command_server::t_command_server(
, "Stop mining."
);
m_command_lookup.set_handler(
+ "mining_status"
+ , std::bind(&t_command_parser_executor::mining_status, &m_parser, p::_1)
+ , "Show current mining status."
+ );
+ m_command_lookup.set_handler(
"print_pool"
, std::bind(&t_command_parser_executor::print_transaction_pool_long, &m_parser, p::_1)
, "Print the transaction pool using a long format."
diff --git a/src/daemon/command_server.h b/src/daemon/command_server.h
index aff74da45..c8e77f551 100644
--- a/src/daemon/command_server.h
+++ b/src/daemon/command_server.h
@@ -9,7 +9,7 @@ Passing RPC commands:
*/
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/daemon/core.h b/src/daemon/core.h
index c15d8d236..91dbb7a4b 100644
--- a/src/daemon/core.h
+++ b/src/daemon/core.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp
index 88fba8372..3d1d893ea 100644
--- a/src/daemon/daemon.cpp
+++ b/src/daemon/daemon.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -96,9 +96,11 @@ void t_daemon::init_options(boost::program_options::options_description & option
}
t_daemon::t_daemon(
- boost::program_options::variables_map const & vm
+ boost::program_options::variables_map const & vm,
+ uint16_t public_rpc_port
)
- : mp_internals{new t_internals{vm}}
+ : mp_internals{new t_internals{vm}},
+ public_rpc_port(public_rpc_port)
{
zmq_rpc_bind_port = command_line::get_arg(vm, daemon_args::arg_zmq_rpc_bind_port);
zmq_rpc_bind_address = command_line::get_arg(vm, daemon_args::arg_zmq_rpc_bind_ip);
@@ -186,6 +188,12 @@ bool t_daemon::run(bool interactive)
MINFO(std::string("ZMQ server started at ") + zmq_rpc_bind_address
+ ":" + zmq_rpc_bind_port + ".");
+ if (public_rpc_port > 0)
+ {
+ MGINFO("Public RPC port " << public_rpc_port << " will be advertised to other peers over P2P");
+ mp_internals->p2p.get().set_rpc_port(public_rpc_port);
+ }
+
mp_internals->p2p.run(); // blocks until p2p goes down
if (rpc_commands)
diff --git a/src/daemon/daemon.h b/src/daemon/daemon.h
index 1e356ef5f..d44173177 100644
--- a/src/daemon/daemon.h
+++ b/src/daemon/daemon.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -43,11 +43,13 @@ private:
void stop_p2p();
private:
std::unique_ptr<t_internals> mp_internals;
+ uint16_t public_rpc_port;
std::string zmq_rpc_bind_address;
std::string zmq_rpc_bind_port;
public:
t_daemon(
- boost::program_options::variables_map const & vm
+ boost::program_options::variables_map const & vm,
+ uint16_t public_rpc_port = 0
);
t_daemon(t_daemon && other);
t_daemon & operator=(t_daemon && other);
diff --git a/src/daemon/executor.cpp b/src/daemon/executor.cpp
index fbc7d04fd..3719a253d 100644
--- a/src/daemon/executor.cpp
+++ b/src/daemon/executor.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -59,21 +59,21 @@ namespace daemonize
)
{
LOG_PRINT_L0("Monero '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ") Daemonised");
- return t_daemon{vm};
+ return t_daemon{vm, public_rpc_port};
}
bool t_executor::run_non_interactive(
boost::program_options::variables_map const & vm
)
{
- return t_daemon{vm}.run(false);
+ return t_daemon{vm, public_rpc_port}.run(false);
}
bool t_executor::run_interactive(
boost::program_options::variables_map const & vm
)
{
- return t_daemon{vm}.run(true);
+ return t_daemon{vm, public_rpc_port}.run(true);
}
}
diff --git a/src/daemon/executor.h b/src/daemon/executor.h
index 79d70567a..61e4e1bbf 100644
--- a/src/daemon/executor.h
+++ b/src/daemon/executor.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -45,6 +45,10 @@ namespace daemonize
static std::string const NAME;
+ t_executor(uint16_t public_rpc_port = 0) : public_rpc_port(public_rpc_port)
+ {
+ }
+
static void init_options(
boost::program_options::options_description & configurable_options
);
@@ -62,5 +66,8 @@ namespace daemonize
bool run_interactive(
boost::program_options::variables_map const & vm
);
+
+ private:
+ uint16_t public_rpc_port;
};
}
diff --git a/src/daemon/main.cpp b/src/daemon/main.cpp
index 35017d9ef..c3ac24b70 100644
--- a/src/daemon/main.cpp
+++ b/src/daemon/main.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -39,6 +39,7 @@
#include "daemon/executor.h"
#include "daemonizer/daemonizer.h"
#include "misc_log_ex.h"
+#include "net/parse.h"
#include "p2p/net_node.h"
#include "rpc/core_rpc_server.h"
#include "rpc/rpc_args.h"
@@ -56,6 +57,57 @@
namespace po = boost::program_options;
namespace bf = boost::filesystem;
+uint16_t parse_public_rpc_port(const po::variables_map &vm)
+{
+ const auto &public_node_arg = daemon_args::arg_public_node;
+ const bool public_node = command_line::get_arg(vm, public_node_arg);
+ if (!public_node)
+ {
+ return 0;
+ }
+
+ std::string rpc_port_str;
+ const auto &restricted_rpc_port = cryptonote::core_rpc_server::arg_rpc_restricted_bind_port;
+ if (!command_line::is_arg_defaulted(vm, restricted_rpc_port))
+ {
+ rpc_port_str = command_line::get_arg(vm, restricted_rpc_port);;
+ }
+ else if (command_line::get_arg(vm, cryptonote::core_rpc_server::arg_restricted_rpc))
+ {
+ rpc_port_str = command_line::get_arg(vm, cryptonote::core_rpc_server::arg_rpc_bind_port);
+ }
+ else
+ {
+ throw std::runtime_error("restricted RPC mode is required");
+ }
+
+ uint16_t rpc_port;
+ if (!string_tools::get_xtype_from_string(rpc_port, rpc_port_str))
+ {
+ throw std::runtime_error("invalid RPC port " + rpc_port_str);
+ }
+
+ const auto rpc_bind_address = command_line::get_arg(vm, cryptonote::rpc_args::descriptors().rpc_bind_ip);
+ const auto address = net::get_network_address(rpc_bind_address, rpc_port);
+ if (!address) {
+ throw std::runtime_error("failed to parse RPC bind address");
+ }
+ if (address->get_zone() != epee::net_utils::zone::public_)
+ {
+ throw std::runtime_error(std::string(zone_to_string(address->get_zone()))
+ + " network zone is not supported, please check RPC server bind address");
+ }
+
+ if (address->is_loopback() || address->is_local())
+ {
+ MLOG_RED(el::Level::Warning, "--" << public_node_arg.name
+ << " is enabled, but RPC server " << address->str()
+ << " may be unreachable from outside, please check RPC server bind address");
+ }
+
+ return rpc_port;
+}
+
int main(int argc, char const * argv[])
{
try {
@@ -86,6 +138,7 @@ int main(int argc, char const * argv[])
command_line::add_arg(core_settings, daemon_args::arg_max_log_file_size);
command_line::add_arg(core_settings, daemon_args::arg_max_log_files);
command_line::add_arg(core_settings, daemon_args::arg_max_concurrency);
+ command_line::add_arg(core_settings, daemon_args::arg_public_node);
command_line::add_arg(core_settings, daemon_args::arg_zmq_rpc_bind_ip);
command_line::add_arg(core_settings, daemon_args::arg_zmq_rpc_bind_port);
@@ -288,7 +341,7 @@ int main(int argc, char const * argv[])
MINFO("Moving from main() into the daemonize now.");
- return daemonizer::daemonize(argc, argv, daemonize::t_executor{}, vm) ? 0 : 1;
+ return daemonizer::daemonize(argc, argv, daemonize::t_executor{parse_public_rpc_port(vm)}, vm) ? 0 : 1;
}
catch (std::exception const & ex)
{
diff --git a/src/daemon/p2p.h b/src/daemon/p2p.h
index 0f01c746d..267b99c89 100644
--- a/src/daemon/p2p.h
+++ b/src/daemon/p2p.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/daemon/protocol.h b/src/daemon/protocol.h
index fd1d1b638..51a2bce1f 100644
--- a/src/daemon/protocol.h
+++ b/src/daemon/protocol.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/daemon/rpc.h b/src/daemon/rpc.h
index 37dffc097..213593aa7 100644
--- a/src/daemon/rpc.h
+++ b/src/daemon/rpc.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp
index 0a35dcef9..4ee67f571 100644
--- a/src/daemon/rpc_command_executor.cpp
+++ b/src/daemon/rpc_command_executor.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -61,8 +61,9 @@ namespace {
peer_id_str >> id_str;
epee::string_tools::xtype_to_string(peer.port, port_str);
std::string addr_str = ip_str + ":" + port_str;
+ std::string rpc_port = peer.rpc_port ? std::to_string(peer.rpc_port) : "-";
std::string pruning_seed = epee::string_tools::to_string_hex(peer.pruning_seed);
- tools::msg_writer() << boost::format("%-10s %-25s %-25s %-4s %s") % prefix % id_str % addr_str % pruning_seed % elapsed;
+ tools::msg_writer() << boost::format("%-10s %-25s %-25s %-5s %-4s %s") % prefix % id_str % addr_str % rpc_port % pruning_seed % elapsed;
}
void print_block_header(cryptonote::block_header_response const & header)
@@ -462,7 +463,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) + std::string(" to ") + mres.address ) : "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)) : "not mining")
% get_mining_speed(ires.difficulty / ires.target)
% (unsigned)hfres.version
% get_fork_extra_info(hfres.earliest_height, net_height, ires.target)
@@ -487,6 +488,81 @@ bool t_rpc_command_executor::show_status() {
return true;
}
+bool t_rpc_command_executor::mining_status() {
+ cryptonote::COMMAND_RPC_MINING_STATUS::request mreq;
+ cryptonote::COMMAND_RPC_MINING_STATUS::response mres;
+ epee::json_rpc::error error_resp;
+ bool has_mining_info = true;
+
+ std::string fail_message = "Problem fetching info";
+
+ bool mining_busy = false;
+ if (m_is_rpc)
+ {
+ // mining info is only available non unrestricted RPC mode
+ has_mining_info = m_rpc_client->rpc_request(mreq, mres, "/mining_status", fail_message.c_str());
+ }
+ else
+ {
+ if (!m_rpc_server->on_mining_status(mreq, mres))
+ {
+ tools::fail_msg_writer() << fail_message.c_str();
+ return true;
+ }
+
+ if (mres.status == CORE_RPC_STATUS_BUSY)
+ {
+ mining_busy = true;
+ }
+ else if (mres.status != CORE_RPC_STATUS_OK)
+ {
+ tools::fail_msg_writer() << make_error(fail_message, mres.status);
+ return true;
+ }
+ }
+
+ if (!has_mining_info)
+ {
+ tools::fail_msg_writer() << "Mining info unavailable";
+ return true;
+ }
+
+ if (mining_busy || !mres.active)
+ {
+ tools::msg_writer() << "Not currently mining";
+ }
+ else
+ {
+ tools::msg_writer() << "Mining at " << get_mining_speed(mres.speed) << " with " << mres.threads_count << " threads";
+ }
+
+ if (mres.active || mres.is_background_mining_enabled)
+ {
+ tools::msg_writer() << "PoW algorithm: " << mres.pow_algorithm;
+ tools::msg_writer() << "Mining address: " << mres.address;
+ }
+
+ if (mres.is_background_mining_enabled)
+ {
+ tools::msg_writer() << "Smart mining enabled:";
+ tools::msg_writer() << " Target: " << (unsigned)mres.bg_target << "% CPU";
+ tools::msg_writer() << " Idle threshold: " << (unsigned)mres.bg_idle_threshold << "% CPU";
+ tools::msg_writer() << " Min idle time: " << (unsigned)mres.bg_min_idle_seconds << " seconds";
+ tools::msg_writer() << " Ignore battery: " << (mres.bg_ignore_battery ? "yes" : "no");
+ }
+
+ if (!mining_busy && mres.active)
+ {
+ uint64_t daily = 86400ull / mres.block_target * mres.block_reward;
+ uint64_t monthly = 86400ull / mres.block_target * 30.5 * mres.block_reward;
+ uint64_t yearly = 86400ull / mres.block_target * 356 * mres.block_reward;
+ tools::msg_writer() << "Expected: " << cryptonote::print_money(daily) << " monero daily, "
+ << cryptonote::print_money(monthly) << " monero monthly, " << cryptonote::print_money(yearly) << " yearly";
+ }
+
+ return true;
+}
+
bool t_rpc_command_executor::print_connections() {
cryptonote::COMMAND_RPC_GET_CONNECTIONS::request req;
cryptonote::COMMAND_RPC_GET_CONNECTIONS::response res;
diff --git a/src/daemon/rpc_command_executor.h b/src/daemon/rpc_command_executor.h
index b1e9828a0..423132b79 100644
--- a/src/daemon/rpc_command_executor.h
+++ b/src/daemon/rpc_command_executor.h
@@ -6,7 +6,7 @@
*/
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -109,6 +109,8 @@ public:
bool stop_mining();
+ bool mining_status();
+
bool stop_daemon();
bool print_status();
diff --git a/src/daemonizer/CMakeLists.txt b/src/daemonizer/CMakeLists.txt
index 2753d0003..d540adc10 100644
--- a/src/daemonizer/CMakeLists.txt
+++ b/src/daemonizer/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/src/daemonizer/daemonizer.h b/src/daemonizer/daemonizer.h
index c5852b59c..a45a2b44f 100644
--- a/src/daemonizer/daemonizer.h
+++ b/src/daemonizer/daemonizer.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/daemonizer/posix_daemonizer.inl b/src/daemonizer/posix_daemonizer.inl
index b3f3f262f..9ec09c678 100644
--- a/src/daemonizer/posix_daemonizer.inl
+++ b/src/daemonizer/posix_daemonizer.inl
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/daemonizer/posix_fork.h b/src/daemonizer/posix_fork.h
index 9294b00e2..27b4ac18d 100644
--- a/src/daemonizer/posix_fork.h
+++ b/src/daemonizer/posix_fork.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/daemonizer/windows_daemonizer.inl b/src/daemonizer/windows_daemonizer.inl
index 7e61e3603..701c098f6 100644
--- a/src/daemonizer/windows_daemonizer.inl
+++ b/src/daemonizer/windows_daemonizer.inl
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/daemonizer/windows_service.cpp b/src/daemonizer/windows_service.cpp
index 1302fa578..7d53b07c7 100644
--- a/src/daemonizer/windows_service.cpp
+++ b/src/daemonizer/windows_service.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/daemonizer/windows_service.h b/src/daemonizer/windows_service.h
index aacf3d039..12429c78a 100644
--- a/src/daemonizer/windows_service.h
+++ b/src/daemonizer/windows_service.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/daemonizer/windows_service_runner.h b/src/daemonizer/windows_service_runner.h
index 06e180823..703795ce9 100644
--- a/src/daemonizer/windows_service_runner.h
+++ b/src/daemonizer/windows_service_runner.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/debug_utilities/CMakeLists.txt b/src/debug_utilities/CMakeLists.txt
index 1bcbfd0cf..7bc2c324f 100644
--- a/src/debug_utilities/CMakeLists.txt
+++ b/src/debug_utilities/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/src/debug_utilities/cn_deserialize.cpp b/src/debug_utilities/cn_deserialize.cpp
index f08f2b928..87ded76bd 100644
--- a/src/debug_utilities/cn_deserialize.cpp
+++ b/src/debug_utilities/cn_deserialize.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/debug_utilities/object_sizes.cpp b/src/debug_utilities/object_sizes.cpp
index 2281d0734..302f0a206 100644
--- a/src/debug_utilities/object_sizes.cpp
+++ b/src/debug_utilities/object_sizes.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/device/CMakeLists.txt b/src/device/CMakeLists.txt
index 91d670b73..ffa1458b0 100644
--- a/src/device/CMakeLists.txt
+++ b/src/device/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2017, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/src/device/device.cpp b/src/device/device.cpp
index d5e3031ff..fbd77dab9 100644
--- a/src/device/device.cpp
+++ b/src/device/device.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/device/device.hpp b/src/device/device.hpp
index 408f64c8b..7f1a60c9f 100644
--- a/src/device/device.hpp
+++ b/src/device/device.hpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/device/device_cold.hpp b/src/device/device_cold.hpp
index 22128cec1..8b8cdf6d2 100644
--- a/src/device/device_cold.hpp
+++ b/src/device/device_cold.hpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/device/device_default.cpp b/src/device/device_default.cpp
index fd15717a7..999fbc22f 100644
--- a/src/device/device_default.cpp
+++ b/src/device/device_default.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/device/device_default.hpp b/src/device/device_default.hpp
index 04b9b4234..90d39495b 100644
--- a/src/device/device_default.hpp
+++ b/src/device/device_default.hpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/device/device_io.hpp b/src/device/device_io.hpp
index 1d5e3564c..fe66736f7 100644
--- a/src/device/device_io.hpp
+++ b/src/device/device_io.hpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/device/device_io_hid.cpp b/src/device/device_io_hid.cpp
index 36c7a241b..f07e0eaae 100644
--- a/src/device/device_io_hid.cpp
+++ b/src/device/device_io_hid.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/device/device_io_hid.hpp b/src/device/device_io_hid.hpp
index c47eefad2..ed22058d6 100644
--- a/src/device/device_io_hid.hpp
+++ b/src/device/device_io_hid.hpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/device/device_ledger.cpp b/src/device/device_ledger.cpp
index 3c7590861..0f197272c 100644
--- a/src/device/device_ledger.cpp
+++ b/src/device/device_ledger.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/device/device_ledger.hpp b/src/device/device_ledger.hpp
index 3f470ee7c..252354e1c 100644
--- a/src/device/device_ledger.hpp
+++ b/src/device/device_ledger.hpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/device/log.cpp b/src/device/log.cpp
index 87505798b..616ad8e90 100644
--- a/src/device/log.cpp
+++ b/src/device/log.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/device/log.hpp b/src/device/log.hpp
index 25a214a6c..fb7ba1fb0 100644
--- a/src/device/log.hpp
+++ b/src/device/log.hpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/device_trezor/CMakeLists.txt b/src/device_trezor/CMakeLists.txt
index 7f979389a..250939da7 100644
--- a/src/device_trezor/CMakeLists.txt
+++ b/src/device_trezor/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2017, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
@@ -67,6 +67,12 @@ set(trezor_private_headers)
if(DEVICE_TREZOR_READY)
message(STATUS "Trezor support enabled")
+ if(USE_DEVICE_TREZOR_DEBUG)
+ list(APPEND trezor_headers trezor/debug_link.hpp trezor/messages/messages-debug.pb.h)
+ list(APPEND trezor_sources trezor/debug_link.cpp trezor/messages/messages-debug.pb.cc)
+ message(STATUS "Trezor debugging enabled")
+ endif()
+
monero_private_headers(device_trezor
${device_private_headers})
diff --git a/src/device_trezor/device_trezor.cpp b/src/device_trezor/device_trezor.cpp
index 8868fb995..ceb6111e0 100644
--- a/src/device_trezor/device_trezor.cpp
+++ b/src/device_trezor/device_trezor.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
@@ -97,7 +97,14 @@ namespace trezor {
auto res = get_view_key();
CHECK_AND_ASSERT_MES(res->watch_key().size() == 32, false, "Trezor returned invalid view key");
+ // Trezor does not make use of spendkey of the device API.
+ // Ledger loads encrypted spendkey, Trezor loads null key (never leaves device).
+ // In the test (debugging mode) we need to leave this field intact as it is already set by
+ // the debugging code and need to remain same for the testing purposes.
+#ifndef WITH_TREZOR_DEBUGGING
spendkey = crypto::null_skey; // not given
+#endif
+
memcpy(viewkey.data, res->watch_key().data(), 32);
return true;
@@ -362,13 +369,9 @@ namespace trezor {
CHECK_AND_ASSERT_THROW_MES(m_features, "Device state not initialized"); // make sure the caller did not reset features
const bool nonce_required = init_msg->tsx_data().has_payment_id() && init_msg->tsx_data().payment_id().size() > 0;
- if (nonce_required){
+ if (nonce_required && init_msg->tsx_data().payment_id().size() == 8){
// Versions 2.0.9 and lower do not support payment ID
- CHECK_AND_ASSERT_THROW_MES(m_features->has_major_version() && m_features->has_minor_version() && m_features->has_patch_version(), "Invalid Trezor firmware version information");
- const uint32_t vma = m_features->major_version();
- const uint32_t vmi = m_features->minor_version();
- const uint32_t vpa = m_features->patch_version();
- if (vma < 2 || (vma == 2 && vmi == 0 && vpa <= 9)) {
+ if (get_version() <= pack_version(2, 0, 9)) {
throw exc::TrezorException("Trezor firmware 2.0.9 and lower does not support transactions with short payment IDs or integrated addresses. Please update.");
}
}
@@ -393,7 +396,7 @@ namespace trezor {
const bool nonce_required = tdata.tsx_data.has_payment_id() && tdata.tsx_data.payment_id().size() > 0;
const bool has_nonce = cryptonote::find_tx_extra_field_by_type(tx_extra_fields, nonce);
- CHECK_AND_ASSERT_THROW_MES(has_nonce == nonce_required, "Transaction nonce presence inconsistent");
+ CHECK_AND_ASSERT_THROW_MES(has_nonce || !nonce_required, "Transaction nonce not present");
if (nonce_required){
const std::string & payment_id = tdata.tsx_data.payment_id();
diff --git a/src/device_trezor/device_trezor.hpp b/src/device_trezor/device_trezor.hpp
index 1f08be887..75f6d5875 100644
--- a/src/device_trezor/device_trezor.hpp
+++ b/src/device_trezor/device_trezor.hpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/device_trezor/device_trezor_base.cpp b/src/device_trezor/device_trezor_base.cpp
index 5071932ee..1892b47d9 100644
--- a/src/device_trezor/device_trezor_base.cpp
+++ b/src/device_trezor/device_trezor_base.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
@@ -44,7 +44,9 @@ namespace trezor {
const uint32_t device_trezor_base::DEFAULT_BIP44_PATH[] = {0x8000002c, 0x80000080};
device_trezor_base::device_trezor_base(): m_callback(nullptr) {
-
+#ifdef WITH_TREZOR_DEBUGGING
+ m_debug = false;
+#endif
}
device_trezor_base::~device_trezor_base() {
@@ -130,6 +132,10 @@ namespace trezor {
}
m_transport->open();
+
+#ifdef WITH_TREZOR_DEBUGGING
+ setup_debug();
+#endif
return true;
} catch(std::exception const& e){
@@ -153,6 +159,13 @@ namespace trezor {
return false;
}
}
+
+#ifdef WITH_TREZOR_DEBUGGING
+ if (m_debug_callback) {
+ m_debug_callback->on_disconnect();
+ m_debug_callback = nullptr;
+ }
+#endif
return true;
}
@@ -355,6 +368,32 @@ namespace trezor {
device_state_reset_unsafe();
}
+#ifdef WITH_TREZOR_DEBUGGING
+#define TREZOR_CALLBACK(method, ...) do { \
+ if (m_debug_callback) m_debug_callback->method(__VA_ARGS__); \
+ if (m_callback) m_callback->method(__VA_ARGS__); \
+}while(0)
+
+ void device_trezor_base::setup_debug(){
+ if (!m_debug){
+ return;
+ }
+
+ if (!m_debug_callback){
+ CHECK_AND_ASSERT_THROW_MES(m_transport, "Transport does not exist");
+ auto debug_transport = m_transport->find_debug();
+ if (debug_transport) {
+ m_debug_callback = std::make_shared<trezor_debug_callback>(debug_transport);
+ } else {
+ MDEBUG("Transport does not have debug link option");
+ }
+ }
+ }
+
+#else
+#define TREZOR_CALLBACK(method, ...) do { if (m_callback) m_callback->method(__VA_ARGS__); } while(0)
+#endif
+
void device_trezor_base::on_button_request(GenericMessage & resp, const messages::common::ButtonRequest * msg)
{
CHECK_AND_ASSERT_THROW_MES(msg, "Empty message");
@@ -363,10 +402,7 @@ namespace trezor {
messages::common::ButtonAck ack;
write_raw(&ack);
- if (m_callback){
- m_callback->on_button_request();
- }
-
+ TREZOR_CALLBACK(on_button_request);
resp = read_raw();
}
@@ -377,9 +413,7 @@ namespace trezor {
epee::wipeable_string pin;
- if (m_callback){
- m_callback->on_pin_request(pin);
- }
+ TREZOR_CALLBACK(on_pin_request, pin);
// TODO: remove PIN from memory
messages::common::PinMatrixAck m;
@@ -393,9 +427,7 @@ namespace trezor {
MDEBUG("on_passhprase_request, on device: " << msg->on_device());
epee::wipeable_string passphrase;
- if (m_callback){
- m_callback->on_passphrase_request(msg->on_device(), passphrase);
- }
+ TREZOR_CALLBACK(on_passphrase_request, msg->on_device(), passphrase);
messages::common::PassphraseAck m;
if (!msg->on_device()){
@@ -421,5 +453,67 @@ namespace trezor {
resp = call_raw(&m);
}
+#ifdef WITH_TREZOR_DEBUGGING
+ void device_trezor_base::wipe_device()
+ {
+ auto msg = std::make_shared<messages::management::WipeDevice>();
+ auto ret = client_exchange<messages::common::Success>(msg);
+ (void)ret;
+ init_device();
+ }
+
+ void device_trezor_base::init_device()
+ {
+ auto msg = std::make_shared<messages::management::Initialize>();
+ m_features = client_exchange<messages::management::Features>(msg);
+ }
+
+ void device_trezor_base::load_device(const std::string & mnemonic, const std::string & pin,
+ bool passphrase_protection, const std::string & label, const std::string & language,
+ bool skip_checksum, bool expand)
+ {
+ if (m_features && m_features->initialized()){
+ throw std::runtime_error("Device is initialized already. Call device.wipe() and try again.");
+ }
+
+ auto msg = std::make_shared<messages::management::LoadDevice>();
+ msg->set_mnemonic(mnemonic);
+ msg->set_pin(pin);
+ msg->set_passphrase_protection(passphrase_protection);
+ msg->set_label(label);
+ msg->set_language(language);
+ msg->set_skip_checksum(skip_checksum);
+ auto ret = client_exchange<messages::common::Success>(msg);
+ (void)ret;
+
+ init_device();
+ }
+
+ trezor_debug_callback::trezor_debug_callback(std::shared_ptr<Transport> & debug_transport){
+ m_debug_link = std::make_shared<DebugLink>();
+ m_debug_link->init(debug_transport);
+ }
+
+ void trezor_debug_callback::on_button_request() {
+ if (m_debug_link) m_debug_link->press_yes();
+ }
+
+ void trezor_debug_callback::on_pin_request(epee::wipeable_string &pin) {
+
+ }
+
+ void trezor_debug_callback::on_passphrase_request(bool on_device, epee::wipeable_string &passphrase) {
+
+ }
+
+ void trezor_debug_callback::on_passphrase_state_request(const std::string &state) {
+
+ }
+
+ void trezor_debug_callback::on_disconnect(){
+ if (m_debug_link) m_debug_link->close();
+ }
+#endif
+
#endif //WITH_DEVICE_TREZOR
}}
diff --git a/src/device_trezor/device_trezor_base.hpp b/src/device_trezor/device_trezor_base.hpp
index 3c35e8aca..8942df797 100644
--- a/src/device_trezor/device_trezor_base.hpp
+++ b/src/device_trezor/device_trezor_base.hpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
@@ -42,6 +42,10 @@
#include "cryptonote_config.h"
#include "trezor.hpp"
+#ifdef WITH_TREZOR_DEBUGGING
+#include "trezor/debug_link.hpp"
+#endif
+
//automatic lock one more level on device ensuring the current thread is allowed to use it
#define AUTO_LOCK_CMD() \
/* lock both mutexes without deadlock*/ \
@@ -57,6 +61,23 @@ namespace trezor {
#ifdef WITH_DEVICE_TREZOR
class device_trezor_base;
+#ifdef WITH_TREZOR_DEBUGGING
+ class trezor_debug_callback {
+ public:
+ trezor_debug_callback()=default;
+ explicit trezor_debug_callback(std::shared_ptr<Transport> & debug_transport);
+
+ void on_button_request();
+ void on_pin_request(epee::wipeable_string &pin);
+ void on_passphrase_request(bool on_device, epee::wipeable_string &passphrase);
+ void on_passphrase_state_request(const std::string &state);
+ void on_disconnect();
+ protected:
+ std::shared_ptr<DebugLink> m_debug_link;
+ };
+
+#endif
+
/**
* TREZOR device template with basic functions
*/
@@ -77,6 +98,13 @@ namespace trezor {
cryptonote::network_type network_type;
+#ifdef WITH_TREZOR_DEBUGGING
+ std::shared_ptr<trezor_debug_callback> m_debug_callback;
+ bool m_debug;
+
+ void setup_debug();
+#endif
+
//
// Internal methods
//
@@ -103,7 +131,7 @@ namespace trezor {
* @throws UnexpectedMessageException if the response message type is different than expected.
* Exception contains message type and the message itself.
*/
- template<class t_message>
+ template<class t_message=google::protobuf::Message>
std::shared_ptr<t_message>
client_exchange(const std::shared_ptr<const google::protobuf::Message> &req,
const boost::optional<messages::MessageType> & resp_type = boost::none,
@@ -229,6 +257,12 @@ namespace trezor {
return m_features;
}
+ uint64_t get_version() const {
+ CHECK_AND_ASSERT_THROW_MES(m_features, "Features not loaded");
+ CHECK_AND_ASSERT_THROW_MES(m_features->has_major_version() && m_features->has_minor_version() && m_features->has_patch_version(), "Invalid Trezor firmware version information");
+ return pack_version(m_features->major_version(), m_features->minor_version(), m_features->patch_version());
+ }
+
void set_derivation_path(const std::string &deriv_path) override;
/* ======================================================================= */
@@ -268,6 +302,23 @@ namespace trezor {
void on_pin_request(GenericMessage & resp, const messages::common::PinMatrixRequest * msg);
void on_passphrase_request(GenericMessage & resp, const messages::common::PassphraseRequest * msg);
void on_passphrase_state_request(GenericMessage & resp, const messages::common::PassphraseStateRequest * msg);
+
+#ifdef WITH_TREZOR_DEBUGGING
+ void set_debug(bool debug){
+ m_debug = debug;
+ }
+
+ void set_debug_callback(std::shared_ptr<trezor_debug_callback> & debug_callback){
+ m_debug_callback = debug_callback;
+ }
+
+ void wipe_device();
+ void init_device();
+ void load_device(const std::string & mnemonic, const std::string & pin="", bool passphrase_protection=false,
+ const std::string & label="test", const std::string & language="english",
+ bool skip_checksum=false, bool expand=false);
+
+#endif
};
#endif
diff --git a/src/device_trezor/trezor.hpp b/src/device_trezor/trezor.hpp
index 97dc0a957..396a27534 100644
--- a/src/device_trezor/trezor.hpp
+++ b/src/device_trezor/trezor.hpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/device_trezor/trezor/debug_link.cpp b/src/device_trezor/trezor/debug_link.cpp
new file mode 100644
index 000000000..c7ee59afe
--- /dev/null
+++ b/src/device_trezor/trezor/debug_link.cpp
@@ -0,0 +1,90 @@
+// 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.
+//
+// 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.
+//
+
+#include "debug_link.hpp"
+
+namespace hw{
+namespace trezor{
+
+ DebugLink::DebugLink(){
+
+ }
+
+ DebugLink::~DebugLink(){
+ if (m_transport){
+ close();
+ }
+ }
+
+ void DebugLink::init(std::shared_ptr<Transport> & transport){
+ CHECK_AND_ASSERT_THROW_MES(!m_transport, "Already initialized");
+ m_transport = transport;
+ m_transport->open();
+ }
+
+ void DebugLink::close(){
+ CHECK_AND_ASSERT_THROW_MES(m_transport, "Not initialized");
+ if (m_transport) m_transport->close();
+ }
+
+ std::shared_ptr<messages::debug::DebugLinkState> DebugLink::state(){
+ return call<messages::debug::DebugLinkState>(
+ messages::debug::DebugLinkGetState(),
+ boost::make_optional(messages::MessageType_DebugLinkGetState));
+ }
+
+ void DebugLink::input_word(const std::string & word){
+ messages::debug::DebugLinkDecision decision;
+ decision.set_input(word);
+ call(decision, boost::none, true);
+ }
+
+ void DebugLink::input_button(bool button){
+ messages::debug::DebugLinkDecision decision;
+ decision.set_yes_no(button);
+ call(decision, boost::none, true);
+ }
+
+ void DebugLink::input_swipe(bool swipe){
+ messages::debug::DebugLinkDecision decision;
+ decision.set_up_down(swipe);
+ call(decision, boost::none, true);
+ }
+
+ void DebugLink::stop(){
+ messages::debug::DebugLinkStop msg;
+ call(msg, boost::none, true);
+ }
+
+
+
+
+
+}
+} \ No newline at end of file
diff --git a/src/device_trezor/trezor/debug_link.hpp b/src/device_trezor/trezor/debug_link.hpp
new file mode 100644
index 000000000..adf5f1d8f
--- /dev/null
+++ b/src/device_trezor/trezor/debug_link.hpp
@@ -0,0 +1,93 @@
+// 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.
+//
+// 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.
+//
+
+#ifndef MONERO_DEBUG_LINK_H
+#define MONERO_DEBUG_LINK_H
+
+#include "transport.hpp"
+#include "messages/messages-debug.pb.h"
+
+
+namespace hw {
+namespace trezor {
+
+ class DebugLink {
+ public:
+
+ DebugLink();
+ virtual ~DebugLink();
+
+ void init(std::shared_ptr<Transport> & transport);
+ void close();
+
+ std::shared_ptr<messages::debug::DebugLinkState> state();
+ void input_word(const std::string & word);
+ void input_button(bool button);
+ void input_swipe(bool swipe);
+ void press_yes() { input_button(true); }
+ void press_no() { input_button(false); }
+ void stop();
+
+ template<class t_message=messages::debug::DebugLinkState>
+ std::shared_ptr<t_message> call(
+ const google::protobuf::Message & req,
+ const boost::optional<messages::MessageType> &resp_type = boost::none,
+ bool no_wait = false)
+ {
+ BOOST_STATIC_ASSERT(boost::is_base_of<google::protobuf::Message, t_message>::value);
+
+ m_transport->write(req);
+ if (no_wait){
+ return nullptr;
+ }
+
+ // Read the response
+ std::shared_ptr<google::protobuf::Message> msg_resp;
+ hw::trezor::messages::MessageType msg_resp_type;
+ m_transport->read(msg_resp, &msg_resp_type);
+
+ messages::MessageType required_type = resp_type ? resp_type.get() : MessageMapper::get_message_wire_number<t_message>();
+ if (msg_resp_type == required_type) {
+ return message_ptr_retype<t_message>(msg_resp);
+ } else if (msg_resp_type == messages::MessageType_Failure){
+ throw_failure_exception(dynamic_cast<messages::common::Failure*>(msg_resp.get()));
+ } else {
+ throw exc::UnexpectedMessageException(msg_resp_type, msg_resp);
+ }
+ };
+
+ private:
+ std::shared_ptr<Transport> m_transport;
+
+ };
+
+}
+}
+
+#endif //MONERO_DEBUG_LINK_H
diff --git a/src/device_trezor/trezor/exceptions.hpp b/src/device_trezor/trezor/exceptions.hpp
index 197dc43a4..41e8c2875 100644
--- a/src/device_trezor/trezor/exceptions.hpp
+++ b/src/device_trezor/trezor/exceptions.hpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/device_trezor/trezor/messages_map.cpp b/src/device_trezor/trezor/messages_map.cpp
index b0d1aa254..6956b369a 100644
--- a/src/device_trezor/trezor/messages_map.cpp
+++ b/src/device_trezor/trezor/messages_map.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
@@ -33,6 +33,10 @@
#include "messages/messages-management.pb.h"
#include "messages/messages-monero.pb.h"
+#ifdef WITH_TREZOR_DEBUGGING
+#include "messages/messages-debug.pb.h"
+#endif
+
using namespace std;
using namespace hw::trezor;
@@ -45,6 +49,9 @@ namespace trezor
"hw.trezor.messages.",
"hw.trezor.messages.common.",
"hw.trezor.messages.management.",
+#ifdef WITH_TREZOR_DEBUGGING
+ "hw.trezor.messages.debug.",
+#endif
"hw.trezor.messages.monero."
};
@@ -68,6 +75,10 @@ namespace trezor
hw::trezor::messages::management::Cancel::default_instance();
hw::trezor::messages::monero::MoneroGetAddress::default_instance();
+#ifdef WITH_TREZOR_DEBUGGING
+ hw::trezor::messages::debug::DebugLinkDecision::default_instance();
+#endif
+
google::protobuf::Descriptor const * desc = nullptr;
for(const string &text : PACKAGES){
desc = google::protobuf::DescriptorPool::generated_pool()
diff --git a/src/device_trezor/trezor/messages_map.hpp b/src/device_trezor/trezor/messages_map.hpp
index f61338f09..28fe9f4c2 100644
--- a/src/device_trezor/trezor/messages_map.hpp
+++ b/src/device_trezor/trezor/messages_map.hpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
@@ -62,14 +62,14 @@ namespace trezor {
static messages::MessageType get_message_wire_number(const google::protobuf::Message & msg);
static messages::MessageType get_message_wire_number(const std::string & msg_name);
- template<class t_message>
+ template<class t_message=google::protobuf::Message>
static messages::MessageType get_message_wire_number() {
BOOST_STATIC_ASSERT(boost::is_base_of<google::protobuf::Message, t_message>::value);
return get_message_wire_number(t_message::default_instance().GetDescriptor()->name());
}
};
- template<class t_message>
+ template<class t_message=google::protobuf::Message>
std::shared_ptr<t_message> message_ptr_retype(std::shared_ptr<google::protobuf::Message> & in){
BOOST_STATIC_ASSERT(boost::is_base_of<google::protobuf::Message, t_message>::value);
if (!in){
@@ -79,7 +79,7 @@ namespace trezor {
return std::dynamic_pointer_cast<t_message>(in);
}
- template<class t_message>
+ template<class t_message=google::protobuf::Message>
std::shared_ptr<t_message> message_ptr_retype_static(std::shared_ptr<google::protobuf::Message> & in){
BOOST_STATIC_ASSERT(boost::is_base_of<google::protobuf::Message, t_message>::value);
if (!in){
diff --git a/src/device_trezor/trezor/protocol.cpp b/src/device_trezor/trezor/protocol.cpp
index 13506a67f..79f6adac9 100644
--- a/src/device_trezor/trezor/protocol.cpp
+++ b/src/device_trezor/trezor/protocol.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/device_trezor/trezor/protocol.hpp b/src/device_trezor/trezor/protocol.hpp
index ce0361640..23f94f948 100644
--- a/src/device_trezor/trezor/protocol.hpp
+++ b/src/device_trezor/trezor/protocol.hpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/device_trezor/trezor/tools/build_protob.py b/src/device_trezor/trezor/tools/build_protob.py
index 2611f3296..eb32f6b4d 100644
--- a/src/device_trezor/trezor/tools/build_protob.py
+++ b/src/device_trezor/trezor/tools/build_protob.py
@@ -2,6 +2,12 @@
import os
import subprocess
import sys
+import argparse
+
+
+parser = argparse.ArgumentParser()
+parser.add_argument("-d", "--debug-msg", default=False, action="store_const", const=True, help="Build debug messages")
+args = parser.parse_args()
CWD = os.path.dirname(os.path.realpath(__file__))
ROOT_DIR = os.path.abspath(os.path.join(CWD, "..", "..", "..", ".."))
@@ -24,6 +30,10 @@ try:
"messages-management.proto",
"messages-monero.proto",
]
+
+ if args.debug_msg:
+ selected += ["messages-debug.proto"]
+
proto_srcs = [os.path.join(TREZOR_COMMON, "protob", x) for x in selected]
exec_args = [
sys.executable,
diff --git a/src/device_trezor/trezor/transport.cpp b/src/device_trezor/trezor/transport.cpp
index cd66e59e8..991ba3395 100644
--- a/src/device_trezor/trezor/transport.cpp
+++ b/src/device_trezor/trezor/transport.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
@@ -84,6 +84,17 @@ namespace trezor{
return std::string(in.GetString());
}
+ uint64_t pack_version(uint32_t major, uint32_t minor, uint32_t patch)
+ {
+ // packing (major, minor, patch) to 64 B: 16 B | 24 B | 24 B
+ const unsigned bits_1 = 16;
+ const unsigned bits_2 = 24;
+ const uint32_t mask_1 = (1 << bits_1) - 1;
+ const uint32_t mask_2 = (1 << bits_2) - 1;
+ CHECK_AND_ASSERT_THROW_MES(major <= mask_1 && minor <= mask_2 && patch <= mask_2, "Version numbers overflow packing scheme");
+ return patch | (((uint64_t)minor) << bits_2) | (((uint64_t)major) << (bits_1 + bits_2));
+ }
+
//
// Helpers
//
@@ -212,6 +223,40 @@ namespace trezor{
msg = msg_wrap;
}
+ Transport::Transport(): m_open_counter(0) {
+
+ }
+
+ bool Transport::pre_open(){
+ if (m_open_counter > 0){
+ MTRACE("Already opened, count: " << m_open_counter);
+ m_open_counter += 1;
+ return false;
+
+ } else if (m_open_counter < 0){
+ MTRACE("Negative open value: " << m_open_counter);
+
+ }
+
+ // Caller should set m_open_counter to 1 after open
+ m_open_counter = 0;
+ return true;
+ }
+
+ bool Transport::pre_close(){
+ m_open_counter -= 1;
+
+ if (m_open_counter < 0){
+ MDEBUG("Already closed. Counter " << m_open_counter);
+
+ } else if (m_open_counter == 0) {
+ return true;
+
+ }
+
+ return false;
+ }
+
//
// Bridge transport
//
@@ -246,6 +291,10 @@ namespace trezor{
}
void BridgeTransport::open() {
+ if (!pre_open()){
+ return;
+ }
+
if (!m_device_path){
throw exc::CommunicationException("Coud not open, empty device path");
}
@@ -259,9 +308,15 @@ namespace trezor{
}
m_session = boost::make_optional(json_get_string(bridge_res["session"]));
+ m_open_counter = 1;
}
void BridgeTransport::close() {
+ if (!pre_close()){
+ return;
+ }
+
+ MTRACE("Closing Trezor:BridgeTransport");
if (!m_device_path || !m_session){
throw exc::CommunicationException("Device not open");
}
@@ -423,6 +478,10 @@ namespace trezor{
}
void UdpTransport::open() {
+ if (!pre_open()){
+ return;
+ }
+
udp::resolver resolver(m_io_service);
udp::resolver::query query(udp::v4(), m_device_host, std::to_string(m_device_port));
m_endpoint = *resolver.resolve(query);
@@ -434,10 +493,16 @@ namespace trezor{
check_deadline();
m_proto->session_begin(*this);
+ m_open_counter = 1;
}
void UdpTransport::close() {
- if (!m_socket){
+ if (!pre_close()){
+ return;
+ }
+
+ MTRACE("Closing Trezor:UdpTransport");
+ if (!m_socket) {
throw exc::CommunicationException("Socket is already closed");
}
@@ -446,6 +511,19 @@ namespace trezor{
m_socket = nullptr;
}
+ std::shared_ptr<Transport> UdpTransport::find_debug() {
+#ifdef WITH_TREZOR_DEBUGGING
+ std::shared_ptr<UdpTransport> t = std::make_shared<UdpTransport>();
+ t->m_proto = std::make_shared<ProtocolV1>();
+ t->m_device_host = m_device_host;
+ t->m_device_port = m_device_port + 1;
+ return t;
+#else
+ MINFO("Debug link is disabled in production");
+ return nullptr;
+#endif
+ }
+
void UdpTransport::write_chunk(const void * buff, size_t size){
require_socket();
@@ -660,8 +738,7 @@ namespace trezor{
WebUsbTransport::WebUsbTransport(
boost::optional<libusb_device_descriptor*> descriptor,
boost::optional<std::shared_ptr<Protocol>> proto
- ): m_conn_count(0),
- m_usb_session(nullptr), m_usb_device(nullptr), m_usb_device_handle(nullptr),
+ ): m_usb_session(nullptr), m_usb_device(nullptr), m_usb_device_handle(nullptr),
m_bus_id(-1), m_device_addr(-1)
{
if (descriptor){
@@ -672,7 +749,7 @@ namespace trezor{
m_proto = proto ? proto.get() : std::make_shared<ProtocolV1>();
-#ifdef WITH_TREZOR_DEBUG
+#ifdef WITH_TREZOR_DEBUGGING
m_debug_mode = false;
#endif
}
@@ -757,12 +834,10 @@ namespace trezor{
};
void WebUsbTransport::open() {
- const int interface = get_interface();
- if (m_conn_count > 0){
- MTRACE("Already opened, count: " << m_conn_count);
- m_conn_count += 1;
+ if (!pre_open()){
return;
}
+ const int interface = get_interface();
#define TREZOR_DESTROY_SESSION() do { libusb_exit(m_usb_session); m_usb_session = nullptr; } while(0)
@@ -840,45 +915,55 @@ namespace trezor{
throw exc::DeviceAcquireException("Unable to claim libusb device");
}
- m_conn_count = 1;
+ m_open_counter = 1;
m_proto->session_begin(*this);
#undef TREZOR_DESTROY_SESSION
};
void WebUsbTransport::close() {
- m_conn_count -= 1;
-
- if (m_conn_count < 0){
- MERROR("Close counter is negative: " << m_conn_count);
-
- } else if (m_conn_count == 0){
- MTRACE("Closing webusb device");
+ if (!pre_close()){
+ return;
+ }
- m_proto->session_end(*this);
+ MTRACE("Closing Trezor:WebUsbTransport");
+ m_proto->session_end(*this);
- int r = libusb_release_interface(m_usb_device_handle, get_interface());
- if (r != 0){
- MERROR("Could not release libusb interface: " << r);
- }
+ int r = libusb_release_interface(m_usb_device_handle, get_interface());
+ if (r != 0){
+ MERROR("Could not release libusb interface: " << r);
+ }
- m_usb_device = nullptr;
- if (m_usb_device_handle) {
- libusb_close(m_usb_device_handle);
- m_usb_device_handle = nullptr;
- }
+ m_usb_device = nullptr;
+ if (m_usb_device_handle) {
+ libusb_close(m_usb_device_handle);
+ m_usb_device_handle = nullptr;
+ }
- if (m_usb_session) {
- libusb_exit(m_usb_session);
- m_usb_session = nullptr;
- }
+ if (m_usb_session) {
+ libusb_exit(m_usb_session);
+ m_usb_session = nullptr;
}
};
+ std::shared_ptr<Transport> WebUsbTransport::find_debug() {
+#ifdef WITH_TREZOR_DEBUGGING
+ require_device();
+ auto t = std::make_shared<WebUsbTransport>(boost::make_optional(m_usb_device_desc.get()));
+ t->m_bus_id = m_bus_id;
+ t->m_device_addr = m_device_addr;
+ t->m_port_numbers = m_port_numbers;
+ t->m_debug_mode = true;
+ return t;
+#else
+ MINFO("Debug link is disabled in production");
+ return nullptr;
+#endif
+ }
int WebUsbTransport::get_interface() const{
const int INTERFACE_NORMAL = 0;
-#ifdef WITH_TREZOR_DEBUG
+#ifdef WITH_TREZOR_DEBUGGING
const int INTERFACE_DEBUG = 1;
return m_debug_mode ? INTERFACE_DEBUG : INTERFACE_NORMAL;
#else
@@ -888,7 +973,7 @@ namespace trezor{
unsigned char WebUsbTransport::get_endpoint() const{
const unsigned char ENDPOINT_NORMAL = 1;
-#ifdef WITH_TREZOR_DEBUG
+#ifdef WITH_TREZOR_DEBUGGING
const unsigned char ENDPOINT_DEBUG = 2;
return m_debug_mode ? ENDPOINT_DEBUG : ENDPOINT_NORMAL;
#else
@@ -1047,4 +1132,3 @@ namespace trezor{
}
}
-
diff --git a/src/device_trezor/trezor/transport.hpp b/src/device_trezor/trezor/transport.hpp
index 1cf0daa85..2945b3184 100644
--- a/src/device_trezor/trezor/transport.hpp
+++ b/src/device_trezor/trezor/transport.hpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
@@ -62,6 +62,8 @@ namespace trezor {
const std::string DEFAULT_BRIDGE = "127.0.0.1:21325";
+ uint64_t pack_version(uint32_t major, uint32_t minor=0, uint32_t patch=0);
+
// Base HTTP comm serialization.
bool t_serialize(const std::string & in, std::string & out);
bool t_serialize(const json_val & in, std::string & out);
@@ -134,7 +136,7 @@ namespace trezor {
class Transport {
public:
- Transport() = default;
+ Transport();
virtual ~Transport() = default;
virtual bool ping() { return false; };
@@ -144,10 +146,16 @@ namespace trezor {
virtual void close(){};
virtual void write(const google::protobuf::Message & req) =0;
virtual void read(std::shared_ptr<google::protobuf::Message> & msg, messages::MessageType * msg_type=nullptr) =0;
+ virtual std::shared_ptr<Transport> find_debug() { return nullptr; };
virtual void write_chunk(const void * buff, size_t size) { };
virtual size_t read_chunk(void * buff, size_t size) { return 0; };
virtual std::ostream& dump(std::ostream& o) const { return o << "Transport<>"; }
+ protected:
+ long m_open_counter;
+
+ virtual bool pre_open();
+ virtual bool pre_close();
};
// Bridge transport
@@ -212,6 +220,7 @@ namespace trezor {
void open() override;
void close() override;
+ std::shared_ptr<Transport> find_debug() override;
void write(const google::protobuf::Message &req) override;
void read(std::shared_ptr<google::protobuf::Message> & msg, messages::MessageType * msg_type=nullptr) override;
@@ -259,6 +268,7 @@ namespace trezor {
void open() override;
void close() override;
+ std::shared_ptr<Transport> find_debug() override;
void write(const google::protobuf::Message &req) override;
void read(std::shared_ptr<google::protobuf::Message> & msg, messages::MessageType * msg_type=nullptr) override;
@@ -274,7 +284,6 @@ namespace trezor {
int get_interface() const;
unsigned char get_endpoint() const;
- int m_conn_count;
std::shared_ptr<Protocol> m_proto;
libusb_context *m_usb_session;
@@ -285,7 +294,7 @@ namespace trezor {
int m_bus_id;
int m_device_addr;
-#ifdef WITH_TREZOR_DEBUG
+#ifdef WITH_TREZOR_DEBUGGING
bool m_debug_mode;
#endif
};
@@ -309,7 +318,7 @@ namespace trezor {
/**
* Transforms path to the particular transport
*/
- template<class t_transport>
+ template<class t_transport=Transport>
std::shared_ptr<t_transport> transport_typed(const std::string & path){
auto t = transport(path);
if (!t){
@@ -362,7 +371,7 @@ namespace trezor {
* @throws UnexpectedMessageException if the response message type is different than expected.
* Exception contains message type and the message itself.
*/
- template<class t_message>
+ template<class t_message=google::protobuf::Message>
std::shared_ptr<t_message>
exchange_message(Transport & transport, const google::protobuf::Message & req,
boost::optional<messages::MessageType> resp_type = boost::none)
diff --git a/src/device_trezor/trezor/trezor_defs.hpp b/src/device_trezor/trezor/trezor_defs.hpp
index 30e76eadc..f0697cdb5 100644
--- a/src/device_trezor/trezor/trezor_defs.hpp
+++ b/src/device_trezor/trezor/trezor_defs.hpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/gen_multisig/CMakeLists.txt b/src/gen_multisig/CMakeLists.txt
index 18a6a9efe..3a5e29273 100644
--- a/src/gen_multisig/CMakeLists.txt
+++ b/src/gen_multisig/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2017-2018, The Monero Project
+# Copyright (c) 2017-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/src/gen_multisig/gen_multisig.cpp b/src/gen_multisig/gen_multisig.cpp
index 8262e86f7..06019c50e 100644
--- a/src/gen_multisig/gen_multisig.cpp
+++ b/src/gen_multisig/gen_multisig.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/CMakeLists.txt b/src/mnemonics/CMakeLists.txt
index e3836bcca..acb9a4338 100644
--- a/src/mnemonics/CMakeLists.txt
+++ b/src/mnemonics/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/src/mnemonics/chinese_simplified.h b/src/mnemonics/chinese_simplified.h
index 0566b1079..ff035dde0 100644
--- a/src/mnemonics/chinese_simplified.h
+++ b/src/mnemonics/chinese_simplified.h
@@ -21,7 +21,7 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-// Code surrounding the word list is Copyright (c) 2014-2018, The Monero Project
+// Code surrounding the word list is Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/dutch.h b/src/mnemonics/dutch.h
index 801caf986..14ba56a7e 100644
--- a/src/mnemonics/dutch.h
+++ b/src/mnemonics/dutch.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/electrum-words.cpp b/src/mnemonics/electrum-words.cpp
index 68d5b84d3..48c9ab1ba 100644
--- a/src/mnemonics/electrum-words.cpp
+++ b/src/mnemonics/electrum-words.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/electrum-words.h b/src/mnemonics/electrum-words.h
index 60d2c5f15..9aa727e45 100644
--- a/src/mnemonics/electrum-words.h
+++ b/src/mnemonics/electrum-words.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/english.h b/src/mnemonics/english.h
index d5c5594ef..677b70052 100644
--- a/src/mnemonics/english.h
+++ b/src/mnemonics/english.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/english_old.h b/src/mnemonics/english_old.h
index e35b907df..179fc45ec 100644
--- a/src/mnemonics/english_old.h
+++ b/src/mnemonics/english_old.h
@@ -1,6 +1,6 @@
// Word list originally created as part of the Electrum project, Copyright (C) 2014 Thomas Voegtlin
//
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/esperanto.h b/src/mnemonics/esperanto.h
index b0be235ed..ef63a2235 100644
--- a/src/mnemonics/esperanto.h
+++ b/src/mnemonics/esperanto.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/french.h b/src/mnemonics/french.h
index 48ec46f78..85925aa53 100644
--- a/src/mnemonics/french.h
+++ b/src/mnemonics/french.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/german.h b/src/mnemonics/german.h
index 883a173a3..40116970c 100644
--- a/src/mnemonics/german.h
+++ b/src/mnemonics/german.h
@@ -1,6 +1,6 @@
// Word list created by Monero contributor Shrikez
//
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/italian.h b/src/mnemonics/italian.h
index 57cdfa25e..204fdcb78 100644
--- a/src/mnemonics/italian.h
+++ b/src/mnemonics/italian.h
@@ -1,6 +1,6 @@
// Word list created by Monero contributor Shrikez
//
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/japanese.h b/src/mnemonics/japanese.h
index 5baabedf2..6213c4976 100644
--- a/src/mnemonics/japanese.h
+++ b/src/mnemonics/japanese.h
@@ -21,7 +21,7 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-// Code surrounding the word list is Copyright (c) 2014-2018, The Monero Project
+// Code surrounding the word list is Copyright (c) 2014-2019, The Monero Project
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
diff --git a/src/mnemonics/language_base.h b/src/mnemonics/language_base.h
index a6f969604..653314b04 100644
--- a/src/mnemonics/language_base.h
+++ b/src/mnemonics/language_base.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/lojban.h b/src/mnemonics/lojban.h
index 5162a8ec9..b6baf46c4 100644
--- a/src/mnemonics/lojban.h
+++ b/src/mnemonics/lojban.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/portuguese.h b/src/mnemonics/portuguese.h
index af04f89c2..dbc51fb2a 100644
--- a/src/mnemonics/portuguese.h
+++ b/src/mnemonics/portuguese.h
@@ -21,7 +21,7 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-// Code surrounding the word list is Copyright (c) 2014-2018, The Monero Project
+// Code surrounding the word list is Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/russian.h b/src/mnemonics/russian.h
index f3e70ede6..d36942a9b 100644
--- a/src/mnemonics/russian.h
+++ b/src/mnemonics/russian.h
@@ -1,6 +1,6 @@
// Word list created by Monero contributor sammy007
//
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/singleton.h b/src/mnemonics/singleton.h
index d317a2d8d..ffe3fe4de 100644
--- a/src/mnemonics/singleton.h
+++ b/src/mnemonics/singleton.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/spanish.h b/src/mnemonics/spanish.h
index 4d7a896a6..a05485775 100644
--- a/src/mnemonics/spanish.h
+++ b/src/mnemonics/spanish.h
@@ -21,7 +21,7 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-// Code surrounding the word list is Copyright (c) 2014-2018, The Monero Project
+// Code surrounding the word list is Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/multisig/CMakeLists.txt b/src/multisig/CMakeLists.txt
index a770c6dc5..4631b75ef 100644
--- a/src/multisig/CMakeLists.txt
+++ b/src/multisig/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2017-2018, The Monero Project
+# Copyright (c) 2017-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/src/multisig/multisig.cpp b/src/multisig/multisig.cpp
index 33d0a312f..14df4d554 100644
--- a/src/multisig/multisig.cpp
+++ b/src/multisig/multisig.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/multisig/multisig.h b/src/multisig/multisig.h
index 93a756812..bc6edbb05 100644
--- a/src/multisig/multisig.h
+++ b/src/multisig/multisig.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/p2p/CMakeLists.txt b/src/p2p/CMakeLists.txt
index 9a1730b8a..3aecc3cf9 100644
--- a/src/p2p/CMakeLists.txt
+++ b/src/p2p/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/src/p2p/net_node.cpp b/src/p2p/net_node.cpp
index 2f0678913..e0f1de14a 100644
--- a/src/p2p/net_node.cpp
+++ b/src/p2p/net_node.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/p2p/net_node.h b/src/p2p/net_node.h
index 4c5f788c3..7840e3832 100644
--- a/src/p2p/net_node.h
+++ b/src/p2p/net_node.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -211,6 +211,7 @@ namespace nodetool
node_server(t_payload_net_handler& payload_handler)
: m_payload_handler(payload_handler),
m_external_port(0),
+ m_rpc_port(0),
m_allow_local_ip(false),
m_hide_my_port(false),
m_no_igd(false),
@@ -400,6 +401,12 @@ namespace nodetool
m_save_graph = save_graph;
epee::net_utils::connection_basic::set_save_graph(save_graph);
}
+
+ void set_rpc_port(uint16_t rpc_port)
+ {
+ m_rpc_port = rpc_port;
+ }
+
private:
std::string m_config_folder;
@@ -407,6 +414,7 @@ namespace nodetool
bool m_first_connection_maker_call;
uint32_t m_listening_port;
uint32_t m_external_port;
+ uint16_t m_rpc_port;
bool m_allow_local_ip;
bool m_hide_my_port;
bool m_no_igd;
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index 341598e80..3542357dc 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -865,7 +865,8 @@ namespace nodetool
}
pi = context.peer_id = rsp.node_data.peer_id;
- m_network_zones.at(context.m_remote_address.get_zone()).m_peerlist.set_peer_just_seen(rsp.node_data.peer_id, context.m_remote_address, context.m_pruning_seed);
+ context.m_rpc_port = rsp.node_data.rpc_port;
+ m_network_zones.at(context.m_remote_address.get_zone()).m_peerlist.set_peer_just_seen(rsp.node_data.peer_id, context.m_remote_address, context.m_pruning_seed, context.m_rpc_port);
// move
for (auto const& zone : m_network_zones)
@@ -931,7 +932,7 @@ namespace nodetool
add_host_fail(context.m_remote_address);
}
if(!context.m_is_income)
- m_network_zones.at(context.m_remote_address.get_zone()).m_peerlist.set_peer_just_seen(context.peer_id, context.m_remote_address, context.m_pruning_seed);
+ m_network_zones.at(context.m_remote_address.get_zone()).m_peerlist.set_peer_just_seen(context.peer_id, context.m_remote_address, context.m_pruning_seed, context.m_rpc_port);
m_payload_handler.process_payload_sync_data(rsp.payload_data, context, false);
});
@@ -1095,6 +1096,7 @@ namespace nodetool
time(&last_seen);
pe_local.last_seen = static_cast<int64_t>(last_seen);
pe_local.pruning_seed = con->m_pruning_seed;
+ pe_local.rpc_port = con->m_rpc_port;
zone.m_peerlist.append_with_peer_white(pe_local);
//update last seen and push it to peerlist manager
@@ -1657,6 +1659,7 @@ namespace nodetool
node_data.my_port = m_external_port ? m_external_port : m_listening_port;
else
node_data.my_port = 0;
+ node_data.rpc_port = zone.m_can_pingback ? m_rpc_port : 0;
node_data.network_id = m_network_id;
return true;
}
@@ -2012,6 +2015,7 @@ namespace nodetool
//associate peer_id with this connection
context.peer_id = arg.node_data.peer_id;
context.m_in_timedsync = false;
+ context.m_rpc_port = arg.node_data.rpc_port;
if(arg.node_data.peer_id != zone.m_config.m_peer_id && arg.node_data.my_port && zone.m_can_pingback)
{
@@ -2031,6 +2035,7 @@ namespace nodetool
pe.last_seen = static_cast<int64_t>(last_seen);
pe.id = peer_id_l;
pe.pruning_seed = context.m_pruning_seed;
+ pe.rpc_port = context.m_rpc_port;
this->m_network_zones.at(context.m_remote_address.get_zone()).m_peerlist.append_with_peer_white(pe);
LOG_DEBUG_CC(context, "PING SUCCESS " << context.m_remote_address.host_str() << ":" << port_l);
});
@@ -2331,7 +2336,7 @@ namespace nodetool
}
else
{
- zone.second.m_peerlist.set_peer_just_seen(pe.id, pe.adr, pe.pruning_seed);
+ zone.second.m_peerlist.set_peer_just_seen(pe.id, pe.adr, pe.pruning_seed, pe.rpc_port);
LOG_PRINT_L2("PEER PROMOTED TO WHITE PEER LIST IP address: " << pe.adr.host_str() << " Peer ID: " << peerid_type(pe.id));
}
}
diff --git a/src/p2p/net_node_common.h b/src/p2p/net_node_common.h
index 944bf48e4..26451b333 100644
--- a/src/p2p/net_node_common.h
+++ b/src/p2p/net_node_common.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/p2p/net_peerlist.h b/src/p2p/net_peerlist.h
index 46726d7d8..ebe0268d8 100644
--- a/src/p2p/net_peerlist.h
+++ b/src/p2p/net_peerlist.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -111,7 +111,7 @@ namespace nodetool
bool append_with_peer_white(const peerlist_entry& pr);
bool append_with_peer_gray(const peerlist_entry& pr);
bool append_with_peer_anchor(const anchor_peerlist_entry& ple);
- bool set_peer_just_seen(peerid_type peer, const epee::net_utils::network_address& addr, uint32_t pruning_seed);
+ bool set_peer_just_seen(peerid_type peer, const epee::net_utils::network_address& addr, uint32_t pruning_seed, uint16_t rpc_port);
bool set_peer_unreachable(const peerlist_entry& pr);
bool is_host_allowed(const epee::net_utils::network_address &address);
bool get_random_gray_peer(peerlist_entry& pe);
@@ -295,7 +295,7 @@ namespace nodetool
}
//--------------------------------------------------------------------------------------------------
inline
- bool peerlist_manager::set_peer_just_seen(peerid_type peer, const epee::net_utils::network_address& addr, uint32_t pruning_seed)
+ bool peerlist_manager::set_peer_just_seen(peerid_type peer, const epee::net_utils::network_address& addr, uint32_t pruning_seed, uint16_t rpc_port)
{
TRY_ENTRY();
CRITICAL_REGION_LOCAL(m_peerlist_lock);
@@ -305,6 +305,7 @@ namespace nodetool
ple.id = peer;
ple.last_seen = time(NULL);
ple.pruning_seed = pruning_seed;
+ ple.rpc_port = rpc_port;
return append_with_peer_white(ple);
CATCH_ENTRY_L0("peerlist_manager::set_peer_just_seen()", false);
}
diff --git a/src/p2p/net_peerlist_boost_serialization.h b/src/p2p/net_peerlist_boost_serialization.h
index 6c891581f..40ef2ebcd 100644
--- a/src/p2p/net_peerlist_boost_serialization.h
+++ b/src/p2p/net_peerlist_boost_serialization.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -42,6 +42,8 @@
#include "common/pruning.h"
#endif
+BOOST_CLASS_VERSION(nodetool::peerlist_entry, 2)
+
namespace boost
{
namespace serialization
@@ -197,6 +199,13 @@ namespace boost
pl.pruning_seed = tools::make_pruning_seed(1+pl.adr.as<epee::net_utils::ipv4_network_address>().ip() % (1<<CRYPTONOTE_PRUNING_LOG_STRIPES), CRYPTONOTE_PRUNING_LOG_STRIPES);
}
#endif
+ if (ver < 2)
+ {
+ if (!typename Archive::is_saving())
+ pl.rpc_port = 0;
+ return;
+ }
+ a & pl.rpc_port;
}
template <class Archive, class ver_type>
diff --git a/src/p2p/p2p_protocol_defs.h b/src/p2p/p2p_protocol_defs.h
index bb4fb9da2..59c6099d5 100644
--- a/src/p2p/p2p_protocol_defs.h
+++ b/src/p2p/p2p_protocol_defs.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -76,12 +76,14 @@ namespace nodetool
peerid_type id;
int64_t last_seen;
uint32_t pruning_seed;
+ uint16_t rpc_port;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(adr)
KV_SERIALIZE(id)
KV_SERIALIZE(last_seen)
KV_SERIALIZE_OPT(pruning_seed, (uint32_t)0)
+ KV_SERIALIZE_OPT(rpc_port, (uint16_t)0)
END_KV_SERIALIZE_MAP()
};
typedef peerlist_entry_base<epee::net_utils::network_address> peerlist_entry;
@@ -127,7 +129,11 @@ namespace nodetool
ss << std::setfill ('0') << std::setw (8) << std::hex << std::noshowbase;
for(const peerlist_entry& pe: pl)
{
- ss << pe.id << "\t" << pe.adr.str() << " \tpruning seed " << pe.pruning_seed << " \tlast_seen: " << epee::misc_utils::get_time_interval_string(now_time - pe.last_seen) << std::endl;
+ ss << pe.id << "\t" << pe.adr.str()
+ << " \trpc port " << (pe.rpc_port > 0 ? std::to_string(pe.rpc_port) : "-")
+ << " \tpruning seed " << pe.pruning_seed
+ << " \tlast_seen: " << epee::misc_utils::get_time_interval_string(now_time - pe.last_seen)
+ << std::endl;
}
return ss.str();
}
@@ -158,6 +164,7 @@ namespace nodetool
uuid network_id;
uint64_t local_time;
uint32_t my_port;
+ uint16_t rpc_port;
peerid_type peer_id;
BEGIN_KV_SERIALIZE_MAP()
@@ -165,6 +172,7 @@ namespace nodetool
KV_SERIALIZE(peer_id)
KV_SERIALIZE(local_time)
KV_SERIALIZE(my_port)
+ KV_SERIALIZE_OPT(rpc_port, (uint16_t)(0))
END_KV_SERIALIZE_MAP()
};
@@ -211,7 +219,7 @@ namespace nodetool
{
const epee::net_utils::network_address &na = p.adr;
const epee::net_utils::ipv4_network_address &ipv4 = na.as<const epee::net_utils::ipv4_network_address>();
- local_peerlist.push_back(peerlist_entry_base<network_address_old>({{ipv4.ip(), ipv4.port()}, p.id, p.last_seen, p.pruning_seed}));
+ local_peerlist.push_back(peerlist_entry_base<network_address_old>({{ipv4.ip(), ipv4.port()}, p.id, p.last_seen, p.pruning_seed, p.rpc_port}));
}
else
MDEBUG("Not including in legacy peer list: " << p.adr.str());
@@ -226,7 +234,7 @@ namespace nodetool
std::vector<peerlist_entry_base<network_address_old>> local_peerlist;
epee::serialization::selector<is_store>::serialize_stl_container_pod_val_as_blob(local_peerlist, stg, hparent_section, "local_peerlist");
for (const auto &p: local_peerlist)
- ((response&)this_ref).local_peerlist_new.push_back(peerlist_entry({epee::net_utils::ipv4_network_address(p.adr.ip, p.adr.port), p.id, p.last_seen, p.pruning_seed}));
+ ((response&)this_ref).local_peerlist_new.push_back(peerlist_entry({epee::net_utils::ipv4_network_address(p.adr.ip, p.adr.port), p.id, p.last_seen, p.pruning_seed, p.rpc_port}));
}
}
END_KV_SERIALIZE_MAP()
@@ -481,7 +489,3 @@ namespace nodetool
}
}
-
-BOOST_CLASS_VERSION(nodetool::peerlist_entry, 1)
-
-
diff --git a/src/p2p/stdafx.h b/src/p2p/stdafx.h
index b6ff37811..12a371702 100644
--- a/src/p2p/stdafx.h
+++ b/src/p2p/stdafx.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/platform/mingw/alloca.h b/src/platform/mingw/alloca.h
index 71934b19a..e4722af2a 100644
--- a/src/platform/mingw/alloca.h
+++ b/src/platform/mingw/alloca.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/platform/msc/alloca.h b/src/platform/msc/alloca.h
index 89743e12b..fcf1731b0 100644
--- a/src/platform/msc/alloca.h
+++ b/src/platform/msc/alloca.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/platform/msc/inline_c.h b/src/platform/msc/inline_c.h
index b274f3ec2..23c11bd06 100644
--- a/src/platform/msc/inline_c.h
+++ b/src/platform/msc/inline_c.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/platform/msc/stdbool.h b/src/platform/msc/stdbool.h
index 63e4200b2..4d24995bd 100644
--- a/src/platform/msc/stdbool.h
+++ b/src/platform/msc/stdbool.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/platform/msc/sys/param.h b/src/platform/msc/sys/param.h
index ca9c9282d..e3cfb7e86 100644
--- a/src/platform/msc/sys/param.h
+++ b/src/platform/msc/sys/param.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/ringct/CMakeLists.txt b/src/ringct/CMakeLists.txt
index 29f166a3b..0192aa931 100644
--- a/src/ringct/CMakeLists.txt
+++ b/src/ringct/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2016-2018, The Monero Project
+# Copyright (c) 2016-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/src/ringct/bulletproofs.cc b/src/ringct/bulletproofs.cc
index b5fd626dc..e394ef088 100644
--- a/src/ringct/bulletproofs.cc
+++ b/src/ringct/bulletproofs.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/ringct/bulletproofs.h b/src/ringct/bulletproofs.h
index b86202ccc..21d494834 100644
--- a/src/ringct/bulletproofs.h
+++ b/src/ringct/bulletproofs.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/ringct/rctCryptoOps.c b/src/ringct/rctCryptoOps.c
index 6fdd17f6b..fbbf6f9bd 100644
--- a/src/ringct/rctCryptoOps.c
+++ b/src/ringct/rctCryptoOps.c
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/ringct/rctCryptoOps.h b/src/ringct/rctCryptoOps.h
index e5c1c987a..2a25d13a7 100644
--- a/src/ringct/rctCryptoOps.h
+++ b/src/ringct/rctCryptoOps.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/rpc/CMakeLists.txt b/src/rpc/CMakeLists.txt
index 60cae036c..cffe8e1eb 100644
--- a/src/rpc/CMakeLists.txt
+++ b/src/rpc/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index fa27c259d..ff55167fe 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -65,6 +65,11 @@ namespace
reasons += ", ";
reasons += reason;
}
+
+ uint64_t round_up(uint64_t value, uint64_t quantum)
+ {
+ return (value + quantum - 1) / quantum * quantum;
+ }
}
namespace cryptonote
@@ -247,7 +252,9 @@ namespace cryptonote
boost::shared_lock<boost::shared_mutex> lock(m_bootstrap_daemon_mutex);
res.was_bootstrap_ever_used = m_was_bootstrap_ever_used;
}
- res.database_size = restricted ? 0 : m_core.get_blockchain_storage().get_db().get_database_size();
+ res.database_size = m_core.get_blockchain_storage().get_db().get_database_size();
+ if (restricted)
+ res.database_size = round_up(res.database_size, 5ull* 1024 * 1024 * 1024);
res.update_available = restricted ? false : m_core.is_update_available();
res.version = restricted ? "" : MONERO_VERSION;
return true;
@@ -908,11 +915,30 @@ namespace cryptonote
res.active = lMiner.is_mining();
res.is_background_mining_enabled = lMiner.get_is_background_mining_enabled();
+ res.block_target = m_core.get_blockchain_storage().get_current_hard_fork_version() < 2 ? DIFFICULTY_TARGET_V1 : DIFFICULTY_TARGET_V2;
if ( lMiner.is_mining() ) {
res.speed = lMiner.get_speed();
res.threads_count = lMiner.get_threads_count();
- const account_public_address& lMiningAdr = lMiner.get_mining_address();
- res.address = get_account_address_as_str(nettype(), false, lMiningAdr);
+ res.block_reward = lMiner.get_block_reward();
+ }
+ const account_public_address& lMiningAdr = lMiner.get_mining_address();
+ res.address = get_account_address_as_str(nettype(), false, lMiningAdr);
+ const uint8_t major_version = m_core.get_blockchain_storage().get_current_hard_fork_version();
+ const unsigned variant = major_version >= 7 ? major_version - 6 : 0;
+ switch (variant)
+ {
+ case 0: res.pow_algorithm = "Cryptonight"; break;
+ case 1: res.pow_algorithm = "CNv1 (Cryptonight variant 1)"; break;
+ case 2: case 3: res.pow_algorithm = "CNv2 (Cryptonight variant 2)"; break;
+ case 4: case 5: res.pow_algorithm = "CNv4 (Cryptonight variant 4)"; break;
+ default: res.pow_algorithm = "I'm not sure actually"; break;
+ }
+ if (res.is_background_mining_enabled)
+ {
+ res.bg_idle_threshold = lMiner.get_idle_threshold();
+ res.bg_min_idle_seconds = lMiner.get_min_idle_seconds();
+ res.bg_ignore_battery = lMiner.get_ignore_battery();
+ res.bg_target = lMiner.get_mining_target();
}
res.status = CORE_RPC_STATUS_OK;
@@ -943,9 +969,9 @@ namespace cryptonote
{
if (entry.adr.get_type_id() == epee::net_utils::ipv4_network_address::get_type_id())
res.white_list.emplace_back(entry.id, entry.adr.as<epee::net_utils::ipv4_network_address>().ip(),
- entry.adr.as<epee::net_utils::ipv4_network_address>().port(), entry.last_seen, entry.pruning_seed);
+ entry.adr.as<epee::net_utils::ipv4_network_address>().port(), entry.last_seen, entry.pruning_seed, entry.rpc_port);
else
- res.white_list.emplace_back(entry.id, entry.adr.str(), entry.last_seen, entry.pruning_seed);
+ res.white_list.emplace_back(entry.id, entry.adr.str(), entry.last_seen, entry.pruning_seed, entry.rpc_port);
}
res.gray_list.reserve(gray_list.size());
@@ -953,9 +979,9 @@ namespace cryptonote
{
if (entry.adr.get_type_id() == epee::net_utils::ipv4_network_address::get_type_id())
res.gray_list.emplace_back(entry.id, entry.adr.as<epee::net_utils::ipv4_network_address>().ip(),
- entry.adr.as<epee::net_utils::ipv4_network_address>().port(), entry.last_seen, entry.pruning_seed);
+ entry.adr.as<epee::net_utils::ipv4_network_address>().port(), entry.last_seen, entry.pruning_seed, entry.rpc_port);
else
- res.gray_list.emplace_back(entry.id, entry.adr.str(), entry.last_seen, entry.pruning_seed);
+ res.gray_list.emplace_back(entry.id, entry.adr.str(), entry.last_seen, entry.pruning_seed, entry.rpc_port);
}
res.status = CORE_RPC_STATUS_OK;
diff --git a/src/rpc/core_rpc_server.h b/src/rpc/core_rpc_server.h
index 54fce3cd9..fe066b31b 100644
--- a/src/rpc/core_rpc_server.h
+++ b/src/rpc/core_rpc_server.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -53,6 +53,7 @@ namespace cryptonote
{
public:
+ static const command_line::arg_descriptor<bool> arg_public_node;
static const command_line::arg_descriptor<std::string, false, true, 2> arg_rpc_bind_port;
static const command_line::arg_descriptor<std::string> arg_rpc_restricted_bind_port;
static const command_line::arg_descriptor<bool> arg_restricted_rpc;
diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h
index 88fa9b4e7..f65c7c8dd 100644
--- a/src/rpc/core_rpc_server_commands_defs.h
+++ b/src/rpc/core_rpc_server_commands_defs.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -84,7 +84,7 @@ namespace cryptonote
// advance which version they will stop working with
// Don't go over 32767 for any of these
#define CORE_RPC_VERSION_MAJOR 2
-#define CORE_RPC_VERSION_MINOR 3
+#define CORE_RPC_VERSION_MINOR 4
#define MAKE_CORE_RPC_VERSION(major,minor) (((major)<<16)|(minor))
#define CORE_RPC_VERSION MAKE_CORE_RPC_VERSION(CORE_RPC_VERSION_MAJOR, CORE_RPC_VERSION_MINOR)
@@ -1055,7 +1055,14 @@ namespace cryptonote
uint64_t speed;
uint32_t threads_count;
std::string address;
+ std::string pow_algorithm;
bool is_background_mining_enabled;
+ uint8_t bg_idle_threshold;
+ uint8_t bg_min_idle_seconds;
+ bool bg_ignore_battery;
+ uint8_t bg_target;
+ uint32_t block_target;
+ uint64_t block_reward;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(status)
@@ -1063,7 +1070,14 @@ namespace cryptonote
KV_SERIALIZE(speed)
KV_SERIALIZE(threads_count)
KV_SERIALIZE(address)
+ KV_SERIALIZE(pow_algorithm)
KV_SERIALIZE(is_background_mining_enabled)
+ KV_SERIALIZE(bg_idle_threshold)
+ KV_SERIALIZE(bg_min_idle_seconds)
+ KV_SERIALIZE(bg_ignore_battery)
+ KV_SERIALIZE(bg_target)
+ KV_SERIALIZE(block_target)
+ KV_SERIALIZE(block_reward)
END_KV_SERIALIZE_MAP()
};
typedef epee::misc_utils::struct_init<response_t> response;
@@ -1372,16 +1386,17 @@ namespace cryptonote
std::string host;
uint32_t ip;
uint16_t port;
+ uint16_t rpc_port;
uint64_t last_seen;
uint32_t pruning_seed;
peer() = default;
- peer(uint64_t id, const std::string &host, uint64_t last_seen, uint32_t pruning_seed)
- : id(id), host(host), ip(0), port(0), last_seen(last_seen), pruning_seed(pruning_seed)
+ peer(uint64_t id, const std::string &host, uint64_t last_seen, uint32_t pruning_seed, uint16_t rpc_port)
+ : id(id), host(host), ip(0), port(0), rpc_port(rpc_port), last_seen(last_seen), pruning_seed(pruning_seed)
{}
- peer(uint64_t id, uint32_t ip, uint16_t port, uint64_t last_seen, uint32_t pruning_seed)
- : id(id), host(std::to_string(ip)), ip(ip), port(port), last_seen(last_seen), pruning_seed(pruning_seed)
+ peer(uint64_t id, uint32_t ip, uint16_t port, uint64_t last_seen, uint32_t pruning_seed, uint16_t rpc_port)
+ : id(id), host(std::to_string(ip)), ip(ip), port(port), rpc_port(rpc_port), last_seen(last_seen), pruning_seed(pruning_seed)
{}
BEGIN_KV_SERIALIZE_MAP()
@@ -1389,6 +1404,7 @@ namespace cryptonote
KV_SERIALIZE(host)
KV_SERIALIZE(ip)
KV_SERIALIZE(port)
+ KV_SERIALIZE_OPT(rpc_port, (uint16_t)0)
KV_SERIALIZE(last_seen)
KV_SERIALIZE_OPT(pruning_seed, (uint32_t)0)
END_KV_SERIALIZE_MAP()
diff --git a/src/rpc/core_rpc_server_error_codes.h b/src/rpc/core_rpc_server_error_codes.h
index 5a754749f..b13049e61 100644
--- a/src/rpc/core_rpc_server_error_codes.h
+++ b/src/rpc/core_rpc_server_error_codes.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/rpc/daemon_handler.cpp b/src/rpc/daemon_handler.cpp
index 871f7d368..14b492786 100644
--- a/src/rpc/daemon_handler.cpp
+++ b/src/rpc/daemon_handler.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/rpc/daemon_handler.h b/src/rpc/daemon_handler.h
index 2c8ac3867..87161784e 100644
--- a/src/rpc/daemon_handler.h
+++ b/src/rpc/daemon_handler.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/rpc/daemon_messages.cpp b/src/rpc/daemon_messages.cpp
index 7c7442014..ecd3683e5 100644
--- a/src/rpc/daemon_messages.cpp
+++ b/src/rpc/daemon_messages.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2016-2018, The Monero Project
+// Copyright (c) 2016-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/rpc/daemon_messages.h b/src/rpc/daemon_messages.h
index d2014247c..8ce56b6af 100644
--- a/src/rpc/daemon_messages.h
+++ b/src/rpc/daemon_messages.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2016-2018, The Monero Project
+// Copyright (c) 2016-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/rpc/daemon_rpc_version.h b/src/rpc/daemon_rpc_version.h
index e20af5b21..b3eb9699b 100644
--- a/src/rpc/daemon_rpc_version.h
+++ b/src/rpc/daemon_rpc_version.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2016-2018, The Monero Project
+// Copyright (c) 2016-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/rpc/instanciations.cpp b/src/rpc/instanciations.cpp
index ec8882982..94fdb5f18 100644
--- a/src/rpc/instanciations.cpp
+++ b/src/rpc/instanciations.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/rpc/message.cpp b/src/rpc/message.cpp
index 0ebe34efe..158b58005 100644
--- a/src/rpc/message.cpp
+++ b/src/rpc/message.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2016-2018, The Monero Project
+// Copyright (c) 2016-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/rpc/message.h b/src/rpc/message.h
index 56087b998..2b7b61ab3 100644
--- a/src/rpc/message.h
+++ b/src/rpc/message.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2016-2018, The Monero Project
+// Copyright (c) 2016-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/rpc/message_data_structs.h b/src/rpc/message_data_structs.h
index 73cf28cec..26c5038f6 100644
--- a/src/rpc/message_data_structs.h
+++ b/src/rpc/message_data_structs.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2016-2018, The Monero Project
+// Copyright (c) 2016-2019, The Monero Project
//
// All rights reserved.
//
@@ -78,6 +78,7 @@ namespace rpc
uint64_t id;
uint32_t ip;
uint16_t port;
+ uint16_t rpc_port;
uint64_t last_seen;
uint32_t pruning_seed;
};
diff --git a/src/rpc/rpc_args.cpp b/src/rpc/rpc_args.cpp
index 60c78480a..f2be94f51 100644
--- a/src/rpc/rpc_args.cpp
+++ b/src/rpc/rpc_args.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/rpc/rpc_args.h b/src/rpc/rpc_args.h
index 8e375385b..216ba3712 100644
--- a/src/rpc/rpc_args.h
+++ b/src/rpc/rpc_args.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/rpc/rpc_handler.h b/src/rpc/rpc_handler.h
index e0d520408..2439eaa58 100644
--- a/src/rpc/rpc_handler.h
+++ b/src/rpc/rpc_handler.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2016-2018, The Monero Project
+// Copyright (c) 2016-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/rpc/zmq_server.cpp b/src/rpc/zmq_server.cpp
index a2ff76668..ae748e052 100644
--- a/src/rpc/zmq_server.cpp
+++ b/src/rpc/zmq_server.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2016-2018, The Monero Project
+// Copyright (c) 2016-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/rpc/zmq_server.h b/src/rpc/zmq_server.h
index 0cd906a3f..1b1e4c7cf 100644
--- a/src/rpc/zmq_server.h
+++ b/src/rpc/zmq_server.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2016-2018, The Monero Project
+// Copyright (c) 2016-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/serialization/CMakeLists.txt b/src/serialization/CMakeLists.txt
index 5a6bebf09..28b775a37 100644
--- a/src/serialization/CMakeLists.txt
+++ b/src/serialization/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2016-2018, The Monero Project
+# Copyright (c) 2016-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/src/serialization/binary_archive.h b/src/serialization/binary_archive.h
index 242b8fd68..a0e4eff9d 100644
--- a/src/serialization/binary_archive.h
+++ b/src/serialization/binary_archive.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/serialization/binary_utils.h b/src/serialization/binary_utils.h
index 79b30b337..790661e49 100644
--- a/src/serialization/binary_utils.h
+++ b/src/serialization/binary_utils.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/serialization/container.h b/src/serialization/container.h
index 978a59d2a..dfe0f9691 100644
--- a/src/serialization/container.h
+++ b/src/serialization/container.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/serialization/crypto.h b/src/serialization/crypto.h
index 87172834f..d2537146e 100644
--- a/src/serialization/crypto.h
+++ b/src/serialization/crypto.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/serialization/debug_archive.h b/src/serialization/debug_archive.h
index c6033a399..093ca41eb 100644
--- a/src/serialization/debug_archive.h
+++ b/src/serialization/debug_archive.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/serialization/deque.h b/src/serialization/deque.h
index 994d3f195..97f16d0a5 100644
--- a/src/serialization/deque.h
+++ b/src/serialization/deque.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/serialization/json_archive.h b/src/serialization/json_archive.h
index 04436c21c..c9f4e175e 100644
--- a/src/serialization/json_archive.h
+++ b/src/serialization/json_archive.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/serialization/json_object.cpp b/src/serialization/json_object.cpp
index f0fc35855..73e17a775 100644
--- a/src/serialization/json_object.cpp
+++ b/src/serialization/json_object.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2016-2018, The Monero Project
+// Copyright (c) 2016-2019, The Monero Project
//
// All rights reserved.
//
@@ -569,6 +569,7 @@ void toJsonValue(rapidjson::Document& doc, const cryptonote::connection_info& in
INSERT_INTO_JSON_OBJECT(val, doc, ip, info.ip);
INSERT_INTO_JSON_OBJECT(val, doc, port, info.port);
+ INSERT_INTO_JSON_OBJECT(val, doc, rpc_port, info.rpc_port);
INSERT_INTO_JSON_OBJECT(val, doc, peer_id, info.peer_id);
@@ -603,6 +604,7 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::connection_info& inf
GET_FROM_JSON_OBJECT(val, info.ip, ip);
GET_FROM_JSON_OBJECT(val, info.port, port);
+ GET_FROM_JSON_OBJECT(val, info.rpc_port, rpc_port);
GET_FROM_JSON_OBJECT(val, info.peer_id, peer_id);
@@ -732,6 +734,7 @@ void toJsonValue(rapidjson::Document& doc, const cryptonote::rpc::peer& peer, ra
INSERT_INTO_JSON_OBJECT(val, doc, id, peer.id);
INSERT_INTO_JSON_OBJECT(val, doc, ip, peer.ip);
INSERT_INTO_JSON_OBJECT(val, doc, port, peer.port);
+ INSERT_INTO_JSON_OBJECT(val, doc, rpc_port, peer.rpc_port);
INSERT_INTO_JSON_OBJECT(val, doc, last_seen, peer.last_seen);
INSERT_INTO_JSON_OBJECT(val, doc, pruning_seed, peer.pruning_seed);
}
@@ -747,6 +750,7 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::rpc::peer& peer)
GET_FROM_JSON_OBJECT(val, peer.id, id);
GET_FROM_JSON_OBJECT(val, peer.ip, ip);
GET_FROM_JSON_OBJECT(val, peer.port, port);
+ GET_FROM_JSON_OBJECT(val, peer.rpc_port, rpc_port);
GET_FROM_JSON_OBJECT(val, peer.last_seen, last_seen);
GET_FROM_JSON_OBJECT(val, peer.pruning_seed, pruning_seed);
}
diff --git a/src/serialization/json_object.h b/src/serialization/json_object.h
index b6384ca0d..c804d148b 100644
--- a/src/serialization/json_object.h
+++ b/src/serialization/json_object.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2016-2018, The Monero Project
+// Copyright (c) 2016-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/serialization/json_utils.h b/src/serialization/json_utils.h
index 16f32cf66..05122f3bd 100644
--- a/src/serialization/json_utils.h
+++ b/src/serialization/json_utils.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/serialization/list.h b/src/serialization/list.h
index ef0063a98..b7b65e184 100644
--- a/src/serialization/list.h
+++ b/src/serialization/list.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/serialization/pair.h b/src/serialization/pair.h
index 67105d530..aed0c4699 100644
--- a/src/serialization/pair.h
+++ b/src/serialization/pair.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/serialization/serialization.h b/src/serialization/serialization.h
index 2050e88e2..007bf265f 100644
--- a/src/serialization/serialization.h
+++ b/src/serialization/serialization.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/serialization/set.h b/src/serialization/set.h
index edf170852..ae602a2f1 100644
--- a/src/serialization/set.h
+++ b/src/serialization/set.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/serialization/string.h b/src/serialization/string.h
index 97268d454..fd8450f7b 100644
--- a/src/serialization/string.h
+++ b/src/serialization/string.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/serialization/unordered_set.h b/src/serialization/unordered_set.h
index b277f0c4a..6dd01fd93 100644
--- a/src/serialization/unordered_set.h
+++ b/src/serialization/unordered_set.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/serialization/variant.h b/src/serialization/variant.h
index 1d00ab461..5a179ca87 100644
--- a/src/serialization/variant.h
+++ b/src/serialization/variant.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/serialization/vector.h b/src/serialization/vector.h
index f180b5353..ad96582a5 100644
--- a/src/serialization/vector.h
+++ b/src/serialization/vector.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/simplewallet/CMakeLists.txt b/src/simplewallet/CMakeLists.txt
index e292f85dd..030867dc0 100644
--- a/src/simplewallet/CMakeLists.txt
+++ b/src/simplewallet/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 8c0b300ad..8952a43dd 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h
index c3dc16d96..6655fda27 100644
--- a/src/simplewallet/simplewallet.h
+++ b/src/simplewallet/simplewallet.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/version.cpp.in b/src/version.cpp.in
index ff2405811..8aaa41b19 100644
--- a/src/version.cpp.in
+++ b/src/version.cpp.in
@@ -1,6 +1,6 @@
#define DEF_MONERO_VERSION_TAG "@VERSIONTAG@"
-#define DEF_MONERO_VERSION "0.13.0.0-master"
-#define DEF_MONERO_RELEASE_NAME "Beryllium Bullet"
+#define DEF_MONERO_VERSION "0.14.1.0"
+#define DEF_MONERO_RELEASE_NAME "Boron Butterfly"
#define DEF_MONERO_VERSION_FULL DEF_MONERO_VERSION "-" DEF_MONERO_VERSION_TAG
#include "version.h"
diff --git a/src/wallet/CMakeLists.txt b/src/wallet/CMakeLists.txt
index 2991f75c5..efd61cb5a 100644
--- a/src/wallet/CMakeLists.txt
+++ b/src/wallet/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/src/wallet/api/CMakeLists.txt b/src/wallet/api/CMakeLists.txt
index d6f2bf6b7..3376ec70e 100644
--- a/src/wallet/api/CMakeLists.txt
+++ b/src/wallet/api/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/src/wallet/api/address_book.cpp b/src/wallet/api/address_book.cpp
index 7ef011e06..7be78bba7 100644
--- a/src/wallet/api/address_book.cpp
+++ b/src/wallet/api/address_book.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/wallet/api/address_book.h b/src/wallet/api/address_book.h
index f4ca68efd..92e6eaa17 100644
--- a/src/wallet/api/address_book.h
+++ b/src/wallet/api/address_book.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/wallet/api/pending_transaction.cpp b/src/wallet/api/pending_transaction.cpp
index 913e3156f..e649f1f3a 100644
--- a/src/wallet/api/pending_transaction.cpp
+++ b/src/wallet/api/pending_transaction.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/wallet/api/pending_transaction.h b/src/wallet/api/pending_transaction.h
index 50b9f07ef..4ec7c656a 100644
--- a/src/wallet/api/pending_transaction.h
+++ b/src/wallet/api/pending_transaction.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/wallet/api/subaddress.cpp b/src/wallet/api/subaddress.cpp
index 61dbbf4b0..8a1d34864 100644
--- a/src/wallet/api/subaddress.cpp
+++ b/src/wallet/api/subaddress.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/wallet/api/subaddress.h b/src/wallet/api/subaddress.h
index f3db7d97b..87585ec16 100644
--- a/src/wallet/api/subaddress.h
+++ b/src/wallet/api/subaddress.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/wallet/api/subaddress_account.cpp b/src/wallet/api/subaddress_account.cpp
index 4765465c3..9bc9d1d91 100644
--- a/src/wallet/api/subaddress_account.cpp
+++ b/src/wallet/api/subaddress_account.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/wallet/api/subaddress_account.h b/src/wallet/api/subaddress_account.h
index b052182f8..358e446d4 100644
--- a/src/wallet/api/subaddress_account.h
+++ b/src/wallet/api/subaddress_account.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/wallet/api/transaction_history.cpp b/src/wallet/api/transaction_history.cpp
index ba46a6904..f4ad8b1f6 100644
--- a/src/wallet/api/transaction_history.cpp
+++ b/src/wallet/api/transaction_history.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/wallet/api/transaction_history.h b/src/wallet/api/transaction_history.h
index 7bdce97e2..67fe1989d 100644
--- a/src/wallet/api/transaction_history.h
+++ b/src/wallet/api/transaction_history.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/wallet/api/transaction_info.cpp b/src/wallet/api/transaction_info.cpp
index cc3209609..21573c6f6 100644
--- a/src/wallet/api/transaction_info.cpp
+++ b/src/wallet/api/transaction_info.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/wallet/api/transaction_info.h b/src/wallet/api/transaction_info.h
index 37e0445d9..d5c8f31cf 100644
--- a/src/wallet/api/transaction_info.h
+++ b/src/wallet/api/transaction_info.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/wallet/api/unsigned_transaction.cpp b/src/wallet/api/unsigned_transaction.cpp
index 29910a3b6..c2c04cbc3 100644
--- a/src/wallet/api/unsigned_transaction.cpp
+++ b/src/wallet/api/unsigned_transaction.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/wallet/api/unsigned_transaction.h b/src/wallet/api/unsigned_transaction.h
index 8a3330014..f1af80fa1 100644
--- a/src/wallet/api/unsigned_transaction.h
+++ b/src/wallet/api/unsigned_transaction.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/wallet/api/utils.cpp b/src/wallet/api/utils.cpp
index 86fe56564..24252868a 100644
--- a/src/wallet/api/utils.cpp
+++ b/src/wallet/api/utils.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp
index 44cd67657..da6ddc8a3 100644
--- a/src/wallet/api/wallet.cpp
+++ b/src/wallet/api/wallet.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/wallet/api/wallet.h b/src/wallet/api/wallet.h
index 55240d64f..bd33b773c 100644
--- a/src/wallet/api/wallet.h
+++ b/src/wallet/api/wallet.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/wallet/api/wallet2_api.h b/src/wallet/api/wallet2_api.h
index 5c301974f..c549c260b 100644
--- a/src/wallet/api/wallet2_api.h
+++ b/src/wallet/api/wallet2_api.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/wallet/api/wallet_manager.cpp b/src/wallet/api/wallet_manager.cpp
index 89fe01c0d..f584e88ac 100644
--- a/src/wallet/api/wallet_manager.cpp
+++ b/src/wallet/api/wallet_manager.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/wallet/api/wallet_manager.h b/src/wallet/api/wallet_manager.h
index b3c0d6c00..0c83d794f 100644
--- a/src/wallet/api/wallet_manager.h
+++ b/src/wallet/api/wallet_manager.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/wallet/node_rpc_proxy.cpp b/src/wallet/node_rpc_proxy.cpp
index 605531e59..f5f3c0e1b 100644
--- a/src/wallet/node_rpc_proxy.cpp
+++ b/src/wallet/node_rpc_proxy.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/wallet/node_rpc_proxy.h b/src/wallet/node_rpc_proxy.h
index 65f13eaaa..3630aec08 100644
--- a/src/wallet/node_rpc_proxy.h
+++ b/src/wallet/node_rpc_proxy.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 085e6075f..8bb886c6d 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -793,9 +793,8 @@ uint64_t calculate_fee(bool use_per_byte_fee, const cryptonote::transaction &tx,
return calculate_fee(base_fee, blob_size, fee_multiplier);
}
-crypto::hash8 get_short_payment_id(const tools::wallet2::pending_tx &ptx, hw::device &hwdev)
+bool get_short_payment_id(crypto::hash8 &payment_id8, const tools::wallet2::pending_tx &ptx, hw::device &hwdev)
{
- crypto::hash8 payment_id8 = null_hash8;
std::vector<tx_extra_field> tx_extra_fields;
parse_tx_extra(ptx.tx.extra, tx_extra_fields); // ok if partially parsed
cryptonote::tx_extra_nonce extra_nonce;
@@ -806,19 +805,19 @@ crypto::hash8 get_short_payment_id(const tools::wallet2::pending_tx &ptx, hw::de
if (ptx.dests.empty())
{
MWARNING("Encrypted payment id found, but no destinations public key, cannot decrypt");
- return crypto::null_hash8;
+ return false;
}
- hwdev.decrypt_payment_id(payment_id8, ptx.dests[0].addr.m_view_public_key, ptx.tx_key);
+ return hwdev.decrypt_payment_id(payment_id8, ptx.dests[0].addr.m_view_public_key, ptx.tx_key);
}
}
- return payment_id8;
+ return false;
}
tools::wallet2::tx_construction_data get_construction_data_with_decrypted_short_payment_id(const tools::wallet2::pending_tx &ptx, hw::device &hwdev)
{
tools::wallet2::tx_construction_data construction_data = ptx.construction_data;
- crypto::hash8 payment_id = get_short_payment_id(ptx,hwdev);
- if (payment_id != null_hash8)
+ crypto::hash8 payment_id = null_hash8;
+ if (get_short_payment_id(payment_id, ptx, hwdev))
{
// Remove encrypted
remove_field_from_tx_extra(construction_data.extra, typeid(cryptonote::tx_extra_nonce));
@@ -1495,11 +1494,17 @@ void wallet2::scan_output(const cryptonote::transaction &tx, bool miner_tx, cons
}
THROW_WALLET_EXCEPTION_IF(std::find(outs.begin(), outs.end(), i) != outs.end(), error::wallet_internal_error, "Same output cannot be added twice");
- outs.push_back(i);
if (tx_scan_info.money_transfered == 0 && !miner_tx)
{
tx_scan_info.money_transfered = tools::decodeRct(tx.rct_signatures, tx_scan_info.received->derivation, i, tx_scan_info.mask, m_account.get_device());
}
+ if (tx_scan_info.money_transfered == 0)
+ {
+ MERROR("Invalid output amount, skipping");
+ tx_scan_info.error = true;
+ return;
+ }
+ outs.push_back(i);
THROW_WALLET_EXCEPTION_IF(tx_money_got_in_outs[tx_scan_info.received->index] >= std::numeric_limits<uint64_t>::max() - tx_scan_info.money_transfered,
error::wallet_internal_error, "Overflow in received amounts");
tx_money_got_in_outs[tx_scan_info.received->index] += tx_scan_info.money_transfered;
@@ -9143,6 +9148,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
{
const size_t estimated_rct_tx_weight = estimate_tx_weight(use_rct, tx.selected_transfers.size(), fake_outs_count, tx.dsts.size()+1, extra.size(), bulletproof);
try_tx = dsts.empty() || (estimated_rct_tx_weight >= TX_WEIGHT_TARGET(upper_transaction_weight_limit));
+ THROW_WALLET_EXCEPTION_IF(try_tx && tx.dsts.empty(), error::tx_too_big, estimated_rct_tx_weight, upper_transaction_weight_limit);
}
}
diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h
index b7ebe03d9..36271c82a 100644
--- a/src/wallet/wallet2.h
+++ b/src/wallet/wallet2.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -67,6 +67,7 @@
#define MONERO_DEFAULT_LOG_CATEGORY "wallet.wallet2"
class Serialization_portability_wallet_Test;
+class wallet_accessor_test;
namespace tools
{
@@ -171,6 +172,7 @@ namespace tools
class wallet2
{
friend class ::Serialization_portability_wallet_Test;
+ friend class ::wallet_accessor_test;
friend class wallet_keys_unlocker;
friend class wallet_device_callback;
public:
diff --git a/src/wallet/wallet_args.cpp b/src/wallet/wallet_args.cpp
index b9d0a6a75..a4bb342ca 100644
--- a/src/wallet/wallet_args.cpp
+++ b/src/wallet/wallet_args.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/wallet/wallet_args.h b/src/wallet/wallet_args.h
index a1f251144..c861dca11 100644
--- a/src/wallet/wallet_args.h
+++ b/src/wallet/wallet_args.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/src/wallet/wallet_errors.h b/src/wallet/wallet_errors.h
index 35862bda1..6ebaaa395 100644
--- a/src/wallet/wallet_errors.h
+++ b/src/wallet/wallet_errors.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -699,26 +699,43 @@ namespace tools
explicit tx_too_big(std::string&& loc, const cryptonote::transaction& tx, uint64_t tx_weight_limit)
: transfer_error(std::move(loc), "transaction is too big")
, m_tx(tx)
+ , m_tx_valid(true)
+ , m_tx_weight(cryptonote::get_transaction_weight(tx))
, m_tx_weight_limit(tx_weight_limit)
{
}
+ explicit tx_too_big(std::string&& loc, uint64_t tx_weight, uint64_t tx_weight_limit)
+ : transfer_error(std::move(loc), "transaction would be too big")
+ , m_tx_valid(false)
+ , m_tx_weight(tx_weight)
+ , m_tx_weight_limit(tx_weight_limit)
+ {
+ }
+
+ bool tx_valid() const { return m_tx_valid; }
const cryptonote::transaction& tx() const { return m_tx; }
+ uint64_t tx_weight() const { return m_tx_weight; }
uint64_t tx_weight_limit() const { return m_tx_weight_limit; }
std::string to_string() const
{
std::ostringstream ss;
- cryptonote::transaction tx = m_tx;
ss << transfer_error::to_string() <<
", tx_weight_limit = " << m_tx_weight_limit <<
- ", tx weight = " << get_transaction_weight(m_tx) <<
- ", tx:\n" << cryptonote::obj_to_json_str(tx);
+ ", tx weight = " << m_tx_weight;
+ if (m_tx_valid)
+ {
+ cryptonote::transaction tx = m_tx;
+ ss << ", tx:\n" << cryptonote::obj_to_json_str(tx);
+ }
return ss.str();
}
private:
cryptonote::transaction m_tx;
+ bool m_tx_valid;
+ uint64_t m_tx_weight;
uint64_t m_tx_weight_limit;
};
//----------------------------------------------------------------------------------------------------
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index 90afa91fd..5b7cf90d0 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -3177,6 +3177,174 @@ namespace tools
}
}
//------------------------------------------------------------------------------------------------------------------------------
+ bool wallet_rpc_server::on_generate_from_keys(const wallet_rpc::COMMAND_RPC_GENERATE_FROM_KEYS::request &req, wallet_rpc::COMMAND_RPC_GENERATE_FROM_KEYS::response &res, epee::json_rpc::error &er, const connection_context *ctx)
+ {
+ if (m_wallet_dir.empty())
+ {
+ er.code = WALLET_RPC_ERROR_CODE_NO_WALLET_DIR;
+ er.message = "No wallet dir configured";
+ return false;
+ }
+
+ // early check for mandatory fields
+ if (req.filename.empty())
+ {
+ er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
+ er.message = "field 'filename' is mandatory. Please provide a filename to save the restored wallet to.";
+ return false;
+ }
+ if (req.viewkey.empty())
+ {
+ er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
+ er.message = "field 'viewkey' is mandatory. Please provide a view key you want to restore from.";
+ return false;
+ }
+ if (req.address.empty())
+ {
+ er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
+ er.message = "field 'address' is mandatory. Please provide a public address.";
+ return false;
+ }
+
+ namespace po = boost::program_options;
+ po::variables_map vm2;
+ const char *ptr = strchr(req.filename.c_str(), '/');
+ #ifdef _WIN32
+ if (!ptr)
+ ptr = strchr(req.filename.c_str(), '\\');
+ if (!ptr)
+ ptr = strchr(req.filename.c_str(), ':');
+ #endif
+ if (ptr)
+ {
+ er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
+ er.message = "Invalid filename";
+ return false;
+ }
+ std::string wallet_file = m_wallet_dir + "/" + req.filename;
+ // check if wallet file already exists
+ if (!wallet_file.empty())
+ {
+ try
+ {
+ boost::system::error_code ignored_ec;
+ THROW_WALLET_EXCEPTION_IF(boost::filesystem::exists(wallet_file, ignored_ec), error::file_exists, wallet_file);
+ }
+ catch (const std::exception &e)
+ {
+ er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
+ er.message = "Wallet already exists.";
+ return false;
+ }
+ }
+
+ {
+ po::options_description desc("dummy");
+ const command_line::arg_descriptor<std::string, true> arg_password = {"password", "password"};
+ const char *argv[4];
+ int argc = 3;
+ argv[0] = "wallet-rpc";
+ argv[1] = "--password";
+ argv[2] = req.password.c_str();
+ argv[3] = NULL;
+ vm2 = *m_vm;
+ command_line::add_arg(desc, arg_password);
+ po::store(po::parse_command_line(argc, argv, desc), vm2);
+ }
+
+ auto rc = tools::wallet2::make_new(vm2, true, nullptr);
+ std::unique_ptr<wallet2> wal;
+ wal = std::move(rc.first);
+ if (!wal)
+ {
+ er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
+ er.message = "Failed to create wallet";
+ return false;
+ }
+
+ cryptonote::address_parse_info info;
+ if(!get_account_address_from_str(info, wal->nettype(), req.address))
+ {
+ er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
+ er.message = "Failed to parse public address";
+ return false;
+ }
+
+ epee::wipeable_string password = rc.second.password();
+ epee::wipeable_string viewkey_string = req.viewkey;
+ crypto::secret_key viewkey;
+ if (!viewkey_string.hex_to_pod(unwrap(unwrap(viewkey))))
+ {
+ er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
+ er.message = "Failed to parse view key secret key";
+ return false;
+ }
+
+ try
+ {
+ if (!req.spendkey.empty())
+ {
+ epee::wipeable_string spendkey_string = req.spendkey;
+ crypto::secret_key spendkey;
+ if (!spendkey_string.hex_to_pod(unwrap(unwrap(spendkey))))
+ {
+ er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
+ er.message = "Failed to parse spend key secret key";
+ return false;
+ }
+ wal->generate(wallet_file, std::move(rc.second).password(), info.address, spendkey, viewkey, false);
+ res.info = "Wallet has been generated successfully.";
+ }
+ else
+ {
+ wal->generate(wallet_file, std::move(rc.second).password(), info.address, viewkey, false);
+ res.info = "Watch-only wallet has been generated successfully.";
+ }
+ MINFO("Wallet has been generated.\n");
+ }
+ catch (const std::exception &e)
+ {
+ handle_rpc_exception(std::current_exception(), er, WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR);
+ return false;
+ }
+
+ if (!wal)
+ {
+ er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
+ er.message = "Failed to generate wallet";
+ return false;
+ }
+
+ // set blockheight if given
+ try
+ {
+ wal->set_refresh_from_block_height(req.restore_height);
+ wal->rewrite(wallet_file, password);
+ }
+ catch (const std::exception &e)
+ {
+ handle_rpc_exception(std::current_exception(), er, WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR);
+ return false;
+ }
+
+ if (m_wallet)
+ {
+ try
+ {
+ m_wallet->store();
+ }
+ catch (const std::exception &e)
+ {
+ handle_rpc_exception(std::current_exception(), er, WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR);
+ return false;
+ }
+ delete m_wallet;
+ }
+ m_wallet = wal.release();
+ res.address = m_wallet->get_account().get_public_address_str(m_wallet->nettype());
+ return true;
+ }
+ //------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server::on_restore_deterministic_wallet(const wallet_rpc::COMMAND_RPC_RESTORE_DETERMINISTIC_WALLET::request &req, wallet_rpc::COMMAND_RPC_RESTORE_DETERMINISTIC_WALLET::response &res, epee::json_rpc::error &er, const connection_context *ctx)
{
if (m_wallet_dir.empty())
@@ -4040,6 +4208,7 @@ int main(int argc, char** argv) {
command_line::add_arg(desc_params, arg_rpc_ssl_private_key);
command_line::add_arg(desc_params, arg_rpc_ssl_certificate);
command_line::add_arg(desc_params, arg_rpc_ssl_allowed_certificates);
+ command_line::add_arg(desc_params, arg_rpc_ssl_allowed_fingerprints);
daemonizer::init_options(hidden_options, desc_params);
desc_params.add(hidden_options);
diff --git a/src/wallet/wallet_rpc_server.h b/src/wallet/wallet_rpc_server.h
index 8157344c2..affaf10f7 100644
--- a/src/wallet/wallet_rpc_server.h
+++ b/src/wallet/wallet_rpc_server.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -137,6 +137,7 @@ namespace tools
MAP_JON_RPC_WE("open_wallet", on_open_wallet, wallet_rpc::COMMAND_RPC_OPEN_WALLET)
MAP_JON_RPC_WE("close_wallet", on_close_wallet, wallet_rpc::COMMAND_RPC_CLOSE_WALLET)
MAP_JON_RPC_WE("change_wallet_password", on_change_wallet_password, wallet_rpc::COMMAND_RPC_CHANGE_WALLET_PASSWORD)
+ MAP_JON_RPC_WE("generate_from_keys", on_generate_from_keys, wallet_rpc::COMMAND_RPC_GENERATE_FROM_KEYS)
MAP_JON_RPC_WE("restore_deterministic_wallet", on_restore_deterministic_wallet, wallet_rpc::COMMAND_RPC_RESTORE_DETERMINISTIC_WALLET)
MAP_JON_RPC_WE("is_multisig", on_is_multisig, wallet_rpc::COMMAND_RPC_IS_MULTISIG)
MAP_JON_RPC_WE("prepare_multisig", on_prepare_multisig, wallet_rpc::COMMAND_RPC_PREPARE_MULTISIG)
@@ -217,6 +218,7 @@ namespace tools
bool on_open_wallet(const wallet_rpc::COMMAND_RPC_OPEN_WALLET::request& req, wallet_rpc::COMMAND_RPC_OPEN_WALLET::response& res, epee::json_rpc::error& er, const connection_context *ctx = NULL);
bool on_close_wallet(const wallet_rpc::COMMAND_RPC_CLOSE_WALLET::request& req, wallet_rpc::COMMAND_RPC_CLOSE_WALLET::response& res, epee::json_rpc::error& er, const connection_context *ctx = NULL);
bool on_change_wallet_password(const wallet_rpc::COMMAND_RPC_CHANGE_WALLET_PASSWORD::request& req, wallet_rpc::COMMAND_RPC_CHANGE_WALLET_PASSWORD::response& res, epee::json_rpc::error& er, const connection_context *ctx = NULL);
+ bool on_generate_from_keys(const wallet_rpc::COMMAND_RPC_GENERATE_FROM_KEYS::request& req, wallet_rpc::COMMAND_RPC_GENERATE_FROM_KEYS::response& res, epee::json_rpc::error& er, const connection_context *ctx = NULL);
bool on_restore_deterministic_wallet(const wallet_rpc::COMMAND_RPC_RESTORE_DETERMINISTIC_WALLET::request& req, wallet_rpc::COMMAND_RPC_RESTORE_DETERMINISTIC_WALLET::response& res, epee::json_rpc::error& er, const connection_context *ctx = NULL);
bool on_is_multisig(const wallet_rpc::COMMAND_RPC_IS_MULTISIG::request& req, wallet_rpc::COMMAND_RPC_IS_MULTISIG::response& res, epee::json_rpc::error& er, const connection_context *ctx = NULL);
bool on_prepare_multisig(const wallet_rpc::COMMAND_RPC_PREPARE_MULTISIG::request& req, wallet_rpc::COMMAND_RPC_PREPARE_MULTISIG::response& res, epee::json_rpc::error& er, const connection_context *ctx = NULL);
diff --git a/src/wallet/wallet_rpc_server_commands_defs.h b/src/wallet/wallet_rpc_server_commands_defs.h
index 546e572bc..0879502b9 100644
--- a/src/wallet/wallet_rpc_server_commands_defs.h
+++ b/src/wallet/wallet_rpc_server_commands_defs.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -2074,6 +2074,39 @@ namespace wallet_rpc
typedef epee::misc_utils::struct_init<response_t> response;
};
+ struct COMMAND_RPC_GENERATE_FROM_KEYS
+ {
+ struct request
+ {
+ uint64_t restore_height;
+ std::string filename;
+ std::string address;
+ std::string spendkey;
+ std::string viewkey;
+ std::string password;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE_OPT(restore_height, (uint64_t)0)
+ KV_SERIALIZE(filename)
+ KV_SERIALIZE(address)
+ KV_SERIALIZE(spendkey)
+ KV_SERIALIZE(viewkey)
+ KV_SERIALIZE(password)
+ END_KV_SERIALIZE_MAP()
+ };
+
+ struct response
+ {
+ std::string address;
+ std::string info;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(address)
+ KV_SERIALIZE(info)
+ END_KV_SERIALIZE_MAP()
+ };
+ };
+
struct COMMAND_RPC_RESTORE_DETERMINISTIC_WALLET
{
struct request_t
diff --git a/src/wallet/wallet_rpc_server_error_codes.h b/src/wallet/wallet_rpc_server_error_codes.h
index 9b3a2847d..440a58a47 100644
--- a/src/wallet/wallet_rpc_server_error_codes.h
+++ b/src/wallet/wallet_rpc_server_error_codes.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 89d77cf32..bbb0bc051 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
@@ -92,6 +92,10 @@ if (BUILD_GUI_DEPS)
add_subdirectory(libwallet_api_tests)
endif()
+if (TREZOR_DEBUG)
+ add_subdirectory(trezor)
+endif()
+
# add_subdirectory(daemon_tests)
set(hash_targets_sources
diff --git a/tests/core_proxy/CMakeLists.txt b/tests/core_proxy/CMakeLists.txt
index 105c20d22..9818d35d7 100644
--- a/tests/core_proxy/CMakeLists.txt
+++ b/tests/core_proxy/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/tests/core_proxy/core_proxy.cpp b/tests/core_proxy/core_proxy.cpp
index 583111517..388808269 100644
--- a/tests/core_proxy/core_proxy.cpp
+++ b/tests/core_proxy/core_proxy.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_proxy/core_proxy.h b/tests/core_proxy/core_proxy.h
index 33a5b4d13..6c8b3ccb6 100644
--- a/tests/core_proxy/core_proxy.h
+++ b/tests/core_proxy/core_proxy.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/CMakeLists.txt b/tests/core_tests/CMakeLists.txt
index 1ac0e7864..f93cbf3ad 100644
--- a/tests/core_tests/CMakeLists.txt
+++ b/tests/core_tests/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
@@ -42,7 +42,8 @@ set(core_tests_sources
tx_validation.cpp
v2_tests.cpp
rct.cpp
- bulletproofs.cpp)
+ bulletproofs.cpp
+ wallet_tools.cpp)
set(core_tests_headers
block_reward.h
@@ -60,7 +61,8 @@ set(core_tests_headers
tx_validation.h
v2_tests.h
rct.h
- bulletproofs.h)
+ bulletproofs.h
+ wallet_tools.h)
add_executable(core_tests
${core_tests_sources}
@@ -73,6 +75,7 @@ target_link_libraries(core_tests
version
epee
device
+ wallet
${CMAKE_THREAD_LIBS_INIT}
${EXTRA_LIBRARIES})
enable_stack_trace(core_tests)
diff --git a/tests/core_tests/block_reward.cpp b/tests/core_tests/block_reward.cpp
index e55378439..17fc762ec 100644
--- a/tests/core_tests/block_reward.cpp
+++ b/tests/core_tests/block_reward.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/block_reward.h b/tests/core_tests/block_reward.h
index b7eb7c98e..6234bb9c5 100644
--- a/tests/core_tests/block_reward.h
+++ b/tests/core_tests/block_reward.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/block_validation.cpp b/tests/core_tests/block_validation.cpp
index 760cc4328..566ec1440 100644
--- a/tests/core_tests/block_validation.cpp
+++ b/tests/core_tests/block_validation.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/block_validation.h b/tests/core_tests/block_validation.h
index d229e4530..4a65b029e 100644
--- a/tests/core_tests/block_validation.h
+++ b/tests/core_tests/block_validation.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/bulletproofs.cpp b/tests/core_tests/bulletproofs.cpp
index 3e2db2e29..fd3f5114b 100644
--- a/tests/core_tests/bulletproofs.cpp
+++ b/tests/core_tests/bulletproofs.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/bulletproofs.h b/tests/core_tests/bulletproofs.h
index b0289f355..efc751df7 100644
--- a/tests/core_tests/bulletproofs.h
+++ b/tests/core_tests/bulletproofs.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/chain_split_1.cpp b/tests/core_tests/chain_split_1.cpp
index d78e793bb..c51accb67 100644
--- a/tests/core_tests/chain_split_1.cpp
+++ b/tests/core_tests/chain_split_1.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/chain_split_1.h b/tests/core_tests/chain_split_1.h
index 75602d1b0..503c3da19 100644
--- a/tests/core_tests/chain_split_1.h
+++ b/tests/core_tests/chain_split_1.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/chain_switch_1.cpp b/tests/core_tests/chain_switch_1.cpp
index 18a813b19..0554fd676 100644
--- a/tests/core_tests/chain_switch_1.cpp
+++ b/tests/core_tests/chain_switch_1.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/chain_switch_1.h b/tests/core_tests/chain_switch_1.h
index 989b6df11..c084de262 100644
--- a/tests/core_tests/chain_switch_1.h
+++ b/tests/core_tests/chain_switch_1.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/chaingen.cpp b/tests/core_tests/chaingen.cpp
index d3cb52246..09bc10ea8 100644
--- a/tests/core_tests/chaingen.cpp
+++ b/tests/core_tests/chaingen.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -31,6 +31,11 @@
#include <vector>
#include <iostream>
#include <sstream>
+#include <algorithm>
+#include <array>
+#include <random>
+#include <sstream>
+#include <fstream>
#include "include_base_utils.h"
@@ -105,10 +110,11 @@ void test_generator::add_block(const cryptonote::block& blk, size_t txs_weight,
bool test_generator::construct_block(cryptonote::block& blk, uint64_t height, const crypto::hash& prev_id,
const cryptonote::account_base& miner_acc, uint64_t timestamp, uint64_t already_generated_coins,
- std::vector<size_t>& block_weights, const std::list<cryptonote::transaction>& tx_list)
+ std::vector<size_t>& block_weights, const std::list<cryptonote::transaction>& tx_list,
+ const boost::optional<uint8_t>& hf_ver)
{
- blk.major_version = CURRENT_BLOCK_MAJOR_VERSION;
- blk.minor_version = CURRENT_BLOCK_MINOR_VERSION;
+ blk.major_version = hf_ver ? hf_ver.get() : CURRENT_BLOCK_MAJOR_VERSION;
+ blk.minor_version = hf_ver ? hf_ver.get() : CURRENT_BLOCK_MINOR_VERSION;
blk.timestamp = timestamp;
blk.prev_id = prev_id;
@@ -135,7 +141,7 @@ bool test_generator::construct_block(cryptonote::block& blk, uint64_t height, co
size_t target_block_weight = txs_weight + get_transaction_weight(blk.miner_tx);
while (true)
{
- if (!construct_miner_tx(height, misc_utils::median(block_weights), already_generated_coins, target_block_weight, total_fee, miner_acc.get_keys().m_account_address, blk.miner_tx, blobdata(), 10))
+ if (!construct_miner_tx(height, misc_utils::median(block_weights), already_generated_coins, target_block_weight, total_fee, miner_acc.get_keys().m_account_address, blk.miner_tx, blobdata(), 10, hf_ver ? hf_ver.get() : 1))
return false;
size_t actual_block_weight = txs_weight + get_transaction_weight(blk.miner_tx);
@@ -180,10 +186,10 @@ bool test_generator::construct_block(cryptonote::block& blk, uint64_t height, co
// Nonce search...
blk.nonce = 0;
- while (!miner::find_nonce_for_given_block(blk, get_test_difficulty(), height))
+ while (!miner::find_nonce_for_given_block(blk, get_test_difficulty(hf_ver), height))
blk.timestamp++;
- add_block(blk, txs_weight, block_weights, already_generated_coins);
+ add_block(blk, txs_weight, block_weights, already_generated_coins, hf_ver ? hf_ver.get() : 1);
return true;
}
@@ -197,17 +203,18 @@ bool test_generator::construct_block(cryptonote::block& blk, const cryptonote::a
bool test_generator::construct_block(cryptonote::block& blk, const cryptonote::block& blk_prev,
const cryptonote::account_base& miner_acc,
- const std::list<cryptonote::transaction>& tx_list/* = std::list<cryptonote::transaction>()*/)
+ const std::list<cryptonote::transaction>& tx_list/* = std::list<cryptonote::transaction>()*/,
+ const boost::optional<uint8_t>& hf_ver)
{
uint64_t height = boost::get<txin_gen>(blk_prev.miner_tx.vin.front()).height + 1;
crypto::hash prev_id = get_block_hash(blk_prev);
// Keep difficulty unchanged
- uint64_t timestamp = blk_prev.timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN;
+ uint64_t timestamp = blk_prev.timestamp + current_difficulty_window(hf_ver); // DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN;
uint64_t already_generated_coins = get_already_generated_coins(prev_id);
std::vector<size_t> block_weights;
get_last_n_block_weights(block_weights, prev_id, CRYPTONOTE_REWARD_BLOCKS_WINDOW);
- return construct_block(blk, height, prev_id, miner_acc, timestamp, already_generated_coins, block_weights, tx_list);
+ return construct_block(blk, height, prev_id, miner_acc, timestamp, already_generated_coins, block_weights, tx_list, hf_ver);
}
bool test_generator::construct_block_manually(block& blk, const block& prev_block, const account_base& miner_acc,
@@ -244,7 +251,7 @@ bool test_generator::construct_block_manually(block& blk, const block& prev_bloc
//blk.tree_root_hash = get_tx_tree_hash(blk);
- difficulty_type a_diffic = actual_params & bf_diffic ? diffic : get_test_difficulty();
+ difficulty_type a_diffic = actual_params & bf_diffic ? diffic : get_test_difficulty(hf_version);
fill_nonce(blk, a_diffic, height);
add_block(blk, txs_weight, block_weights, already_generated_coins, hf_version);
@@ -259,49 +266,6 @@ bool test_generator::construct_block_manually_tx(cryptonote::block& blk, const c
return construct_block_manually(blk, prev_block, miner_acc, bf_tx_hashes, 0, 0, 0, crypto::hash(), 0, transaction(), tx_hashes, txs_weight);
}
-
-struct output_index {
- const cryptonote::txout_target_v out;
- uint64_t amount;
- size_t blk_height; // block height
- size_t tx_no; // index of transaction in block
- size_t out_no; // index of out in transaction
- size_t idx;
- bool spent;
- const cryptonote::block *p_blk;
- const cryptonote::transaction *p_tx;
-
- output_index(const cryptonote::txout_target_v &_out, uint64_t _a, size_t _h, size_t tno, size_t ono, const cryptonote::block *_pb, const cryptonote::transaction *_pt)
- : out(_out), amount(_a), blk_height(_h), tx_no(tno), out_no(ono), idx(0), spent(false), p_blk(_pb), p_tx(_pt) { }
-
- output_index(const output_index &other)
- : out(other.out), amount(other.amount), blk_height(other.blk_height), tx_no(other.tx_no), out_no(other.out_no), idx(other.idx), spent(other.spent), p_blk(other.p_blk), p_tx(other.p_tx) { }
-
- const std::string toString() const {
- std::stringstream ss;
-
- ss << "output_index{blk_height=" << blk_height
- << " tx_no=" << tx_no
- << " out_no=" << out_no
- << " amount=" << amount
- << " idx=" << idx
- << " spent=" << spent
- << "}";
-
- return ss.str();
- }
-
- output_index& operator=(const output_index& other)
- {
- new(this) output_index(other);
- return *this;
- }
-};
-
-typedef std::map<uint64_t, std::vector<size_t> > map_output_t;
-typedef std::map<uint64_t, std::vector<output_index> > map_output_idx_t;
-typedef pair<uint64_t, size_t> outloc_t;
-
namespace
{
uint64_t get_inputs_amount(const vector<tx_source_entry> &s)
@@ -339,6 +303,9 @@ bool init_output_indices(map_output_idx_t& outs, std::map<uint64_t, std::vector<
const tx_out &out = tx.vout[j];
output_index oi(out.target, out.amount, boost::get<txin_gen>(*blk.miner_tx.vin.begin()).height, i, j, &blk, vtx[i]);
+ oi.set_rct(tx.version == 2);
+ oi.unlock_time = tx.unlock_time;
+ oi.is_coin_base = i == 0;
if (2 == out.target.which()) { // out_to_key
outs[out.amount].push_back(oi);
@@ -416,8 +383,9 @@ bool fill_output_entries(std::vector<output_index>& out_indices, size_t sender_o
if (append)
{
+ rct::key comm = oi.commitment();
const txout_to_key& otk = boost::get<txout_to_key>(oi.out);
- output_entries.push_back(tx_source_entry::output_entry(oi.idx, rct::ctkey({rct::pk2rct(otk.key), rct::identity()})));
+ output_entries.push_back(tx_source_entry::output_entry(oi.idx, rct::ctkey({rct::pk2rct(otk.key), comm})));
}
}
@@ -452,6 +420,8 @@ bool fill_tx_sources(std::vector<tx_source_entry>& sources, const std::vector<te
const output_index& oi = outs[o.first][sender_out];
if (oi.spent)
continue;
+ if (oi.rct)
+ continue;
cryptonote::tx_source_entry ts;
ts.amount = oi.amount;
@@ -463,6 +433,11 @@ bool fill_tx_sources(std::vector<tx_source_entry>& sources, const std::vector<te
ts.real_output = realOutput;
ts.rct = false;
+ ts.mask = rct::identity(); // non-rct has identity mask by definition
+
+ rct::key comm = rct::zeroCommit(ts.amount);
+ for(auto & ot : ts.outputs)
+ ot.second.mask = comm;
sources.push_back(ts);
@@ -477,38 +452,347 @@ bool fill_tx_sources(std::vector<tx_source_entry>& sources, const std::vector<te
return sources_found;
}
-bool fill_tx_destination(tx_destination_entry &de, const cryptonote::account_base &to, uint64_t amount) {
- de.addr = to.get_keys().m_account_address;
+bool fill_tx_destination(tx_destination_entry &de, const cryptonote::account_public_address &to, uint64_t amount) {
+ de.addr = to;
de.amount = amount;
return true;
}
-void fill_tx_sources_and_destinations(const std::vector<test_event_entry>& events, const block& blk_head,
- const cryptonote::account_base& from, const cryptonote::account_base& to,
- uint64_t amount, uint64_t fee, size_t nmix, std::vector<tx_source_entry>& sources,
- std::vector<tx_destination_entry>& destinations)
+map_txid_output_t::iterator block_tracker::find_out(const crypto::hash &txid, size_t out)
+{
+ return find_out(std::make_pair(txid, out));
+}
+
+map_txid_output_t::iterator block_tracker::find_out(const output_hasher &id)
+{
+ return m_map_outs.find(id);
+}
+
+void block_tracker::process(const std::vector<cryptonote::block>& blockchain, const map_hash2tx_t& mtx)
+{
+ std::vector<const cryptonote::block*> blks;
+ blks.reserve(blockchain.size());
+
+ BOOST_FOREACH (const block& blk, blockchain) {
+ auto hsh = get_block_hash(blk);
+ auto it = m_blocks.find(hsh);
+ if (it == m_blocks.end()){
+ m_blocks[hsh] = blk;
+ }
+
+ blks.push_back(&m_blocks[hsh]);
+ }
+
+ process(blks, mtx);
+}
+
+void block_tracker::process(const std::vector<const cryptonote::block*>& blockchain, const map_hash2tx_t& mtx)
+{
+ BOOST_FOREACH (const block* blk, blockchain) {
+ vector<const transaction*> vtx;
+ vtx.push_back(&(blk->miner_tx));
+
+ BOOST_FOREACH(const crypto::hash &h, blk->tx_hashes) {
+ const map_hash2tx_t::const_iterator cit = mtx.find(h);
+ CHECK_AND_ASSERT_THROW_MES(mtx.end() != cit, "block contains an unknown tx hash");
+ vtx.push_back(cit->second);
+ }
+
+ for (size_t i = 0; i < vtx.size(); i++) {
+ process(blk, vtx[i], i);
+ }
+ }
+}
+
+void block_tracker::process(const block* blk, const transaction * tx, size_t i)
+{
+ for (size_t j = 0; j < tx->vout.size(); ++j) {
+ const tx_out &out = tx->vout[j];
+
+ if (typeid(cryptonote::txout_to_key) != out.target.type()) { // out_to_key
+ continue;
+ }
+
+ const uint64_t rct_amount = tx->version == 2 ? 0 : out.amount;
+ const output_hasher hid = std::make_pair(tx->hash, j);
+ auto it = find_out(hid);
+ if (it != m_map_outs.end()){
+ continue;
+ }
+
+ output_index oi(out.target, out.amount, boost::get<txin_gen>(blk->miner_tx.vin.front()).height, i, j, blk, tx);
+ oi.set_rct(tx->version == 2);
+ oi.idx = m_outs[rct_amount].size();
+ oi.unlock_time = tx->unlock_time;
+ oi.is_coin_base = tx->vin.size() == 1 && tx->vin.back().type() == typeid(cryptonote::txin_gen);
+
+ m_outs[rct_amount].push_back(oi);
+ m_map_outs.insert({hid, oi});
+ }
+}
+
+void block_tracker::global_indices(const cryptonote::transaction *tx, std::vector<uint64_t> &indices)
+{
+ indices.clear();
+
+ for(size_t j=0; j < tx->vout.size(); ++j){
+ auto it = find_out(tx->hash, j);
+ if (it != m_map_outs.end()){
+ indices.push_back(it->second.idx);
+ }
+ }
+}
+
+void block_tracker::get_fake_outs(size_t num_outs, uint64_t amount, uint64_t global_index, uint64_t cur_height, std::vector<get_outs_entry> &outs){
+ auto & vct = m_outs[amount];
+ const size_t n_outs = vct.size();
+
+ std::set<size_t> used;
+ std::vector<size_t> choices;
+ choices.resize(n_outs);
+ for(size_t i=0; i < n_outs; ++i) choices[i] = i;
+ shuffle(choices.begin(), choices.end(), std::default_random_engine(crypto::rand<unsigned>()));
+
+ size_t n_iters = 0;
+ ssize_t idx = -1;
+ outs.reserve(num_outs);
+ while(outs.size() < num_outs){
+ n_iters += 1;
+ idx = (idx + 1) % n_outs;
+ size_t oi_idx = choices[(size_t)idx];
+ CHECK_AND_ASSERT_THROW_MES((n_iters / n_outs) <= outs.size(), "Fake out pick selection problem");
+
+ auto & oi = vct[oi_idx];
+ if (oi.idx == global_index)
+ continue;
+ if (oi.out.type() != typeid(cryptonote::txout_to_key))
+ continue;
+ if (oi.unlock_time > cur_height)
+ continue;
+ if (used.find(oi_idx) != used.end())
+ continue;
+
+ rct::key comm = oi.commitment();
+ auto out = boost::get<txout_to_key>(oi.out);
+ auto item = std::make_tuple(oi.idx, out.key, comm);
+ outs.push_back(item);
+ used.insert(oi_idx);
+ }
+}
+
+std::string block_tracker::dump_data()
+{
+ ostringstream ss;
+ for (auto &m_out : m_outs)
+ {
+ auto & vct = m_out.second;
+ ss << m_out.first << " => |vector| = " << vct.size() << '\n';
+
+ for (const auto & oi : vct)
+ {
+ auto out = boost::get<txout_to_key>(oi.out);
+
+ ss << " idx: " << oi.idx
+ << ", rct: " << oi.rct
+ << ", xmr: " << oi.amount
+ << ", key: " << dump_keys(out.key.data)
+ << ", msk: " << dump_keys(oi.comm.bytes)
+ << ", txid: " << dump_keys(oi.p_tx->hash.data)
+ << '\n';
+ }
+ }
+
+ return ss.str();
+}
+
+void block_tracker::dump_data(const std::string & fname)
+{
+ ofstream myfile;
+ myfile.open (fname);
+ myfile << dump_data();
+ myfile.close();
+}
+
+std::string dump_data(const cryptonote::transaction &tx)
+{
+ ostringstream ss;
+ ss << "msg: " << dump_keys(tx.rct_signatures.message.bytes)
+ << ", vin: ";
+
+ for(auto & in : tx.vin){
+ if (typeid(txin_to_key) == in.type()){
+ auto tk = boost::get<txin_to_key>(in);
+ std::vector<uint64_t> full_off;
+ int64_t last = -1;
+
+ ss << " i: " << tk.amount << " [";
+ for(auto ix : tk.key_offsets){
+ ss << ix << ", ";
+ if (last == -1){
+ last = ix;
+ full_off.push_back(ix);
+ } else {
+ last += ix;
+ full_off.push_back((uint64_t)last);
+ }
+ }
+
+ ss << "], full: [";
+ for(auto ix : full_off){
+ ss << ix << ", ";
+ }
+ ss << "]; ";
+
+ } else if (typeid(txin_gen) == in.type()){
+ ss << " h: " << boost::get<txin_gen>(in).height << ", ";
+ } else {
+ ss << " ?, ";
+ }
+ }
+
+ ss << ", mixring: \n";
+ for (const auto & row : tx.rct_signatures.mixRing){
+ for(auto cur : row){
+ ss << " (" << dump_keys(cur.dest.bytes) << ", " << dump_keys(cur.mask.bytes) << ")\n ";
+ }
+ ss << "; ";
+ }
+
+ return ss.str();
+}
+
+cryptonote::account_public_address get_address(const var_addr_t& inp)
+{
+ if (typeid(cryptonote::account_public_address) == inp.type()){
+ return boost::get<cryptonote::account_public_address>(inp);
+ } else if(typeid(cryptonote::account_keys) == inp.type()){
+ return boost::get<cryptonote::account_keys>(inp).m_account_address;
+ } else if (typeid(cryptonote::account_base) == inp.type()){
+ return boost::get<cryptonote::account_base>(inp).get_keys().m_account_address;
+ } else if (typeid(cryptonote::tx_destination_entry) == inp.type()){
+ return boost::get<cryptonote::tx_destination_entry>(inp).addr;
+ } else {
+ throw std::runtime_error("Unexpected type");
+ }
+}
+
+cryptonote::account_public_address get_address(const cryptonote::account_public_address& inp)
+{
+ return inp;
+}
+
+cryptonote::account_public_address get_address(const cryptonote::account_keys& inp)
+{
+ return inp.m_account_address;
+}
+
+cryptonote::account_public_address get_address(const cryptonote::account_base& inp)
+{
+ return inp.get_keys().m_account_address;
+}
+
+cryptonote::account_public_address get_address(const cryptonote::tx_destination_entry& inp)
+{
+ return inp.addr;
+}
+
+uint64_t sum_amount(const std::vector<tx_destination_entry>& destinations)
+{
+ uint64_t amount = 0;
+ for(auto & cur : destinations){
+ amount += cur.amount;
+ }
+
+ return amount;
+}
+
+uint64_t sum_amount(const std::vector<cryptonote::tx_source_entry>& sources)
+{
+ uint64_t amount = 0;
+ for(auto & cur : sources){
+ amount += cur.amount;
+ }
+
+ return amount;
+}
+
+void fill_tx_destinations(const var_addr_t& from, const std::vector<tx_destination_entry>& dests,
+ uint64_t fee,
+ const std::vector<tx_source_entry> &sources,
+ std::vector<tx_destination_entry>& destinations,
+ bool always_change)
+
{
- sources.clear();
destinations.clear();
+ uint64_t amount = sum_amount(dests);
+ std::copy(dests.begin(), dests.end(), std::back_inserter(destinations));
- if (!fill_tx_sources(sources, events, blk_head, from, amount + fee, nmix))
- throw std::runtime_error("couldn't fill transaction sources");
+ tx_destination_entry de_change;
+ uint64_t cache_back = get_inputs_amount(sources) - (amount + fee);
+
+ if (cache_back > 0 || always_change) {
+ if (!fill_tx_destination(de_change, get_address(from), cache_back <= 0 ? 0 : cache_back))
+ throw std::runtime_error("couldn't fill transaction cache back destination");
+ destinations.push_back(de_change);
+ }
+}
+
+void fill_tx_destinations(const var_addr_t& from, const cryptonote::account_public_address& to,
+ uint64_t amount, uint64_t fee,
+ const std::vector<tx_source_entry> &sources,
+ std::vector<tx_destination_entry>& destinations,
+ std::vector<tx_destination_entry>& destinations_pure,
+ bool always_change)
+{
+ destinations.clear();
tx_destination_entry de;
if (!fill_tx_destination(de, to, amount))
throw std::runtime_error("couldn't fill transaction destination");
destinations.push_back(de);
+ destinations_pure.push_back(de);
tx_destination_entry de_change;
uint64_t cache_back = get_inputs_amount(sources) - (amount + fee);
- if (0 < cache_back)
- {
- if (!fill_tx_destination(de_change, from, cache_back))
+
+ if (cache_back > 0 || always_change) {
+ if (!fill_tx_destination(de_change, get_address(from), cache_back <= 0 ? 0 : cache_back))
throw std::runtime_error("couldn't fill transaction cache back destination");
destinations.push_back(de_change);
}
}
+void fill_tx_destinations(const var_addr_t& from, const cryptonote::account_public_address& to,
+ uint64_t amount, uint64_t fee,
+ const std::vector<tx_source_entry> &sources,
+ std::vector<tx_destination_entry>& destinations, bool always_change)
+{
+ std::vector<tx_destination_entry> destinations_pure;
+ fill_tx_destinations(from, to, amount, fee, sources, destinations, destinations_pure, always_change);
+}
+
+void fill_tx_sources_and_destinations(const std::vector<test_event_entry>& events, const block& blk_head,
+ const cryptonote::account_base& from, const cryptonote::account_public_address& to,
+ uint64_t amount, uint64_t fee, size_t nmix, std::vector<tx_source_entry>& sources,
+ std::vector<tx_destination_entry>& destinations)
+{
+ sources.clear();
+ destinations.clear();
+
+ if (!fill_tx_sources(sources, events, blk_head, from, amount + fee, nmix))
+ throw std::runtime_error("couldn't fill transaction sources");
+
+ fill_tx_destinations(from, to, amount, fee, sources, destinations, false);
+}
+
+void fill_tx_sources_and_destinations(const std::vector<test_event_entry>& events, const block& blk_head,
+ const cryptonote::account_base& from, const cryptonote::account_base& to,
+ uint64_t amount, uint64_t fee, size_t nmix, std::vector<tx_source_entry>& sources,
+ std::vector<tx_destination_entry>& destinations)
+{
+ fill_tx_sources_and_destinations(events, blk_head, from, to.get_keys().m_account_address, amount, fee, nmix, sources, destinations);
+}
+
void fill_nonce(cryptonote::block& blk, const difficulty_type& diffic, uint64_t height)
{
blk.nonce = 0;
@@ -516,6 +800,32 @@ void fill_nonce(cryptonote::block& blk, const difficulty_type& diffic, uint64_t
blk.timestamp++;
}
+cryptonote::tx_destination_entry build_dst(const var_addr_t& to, bool is_subaddr, uint64_t amount)
+{
+ tx_destination_entry de;
+ de.amount = amount;
+ de.addr = get_address(to);
+ de.is_subaddress = is_subaddr;
+ return de;
+}
+
+std::vector<cryptonote::tx_destination_entry> build_dsts(const var_addr_t& to1, bool sub1, uint64_t am1)
+{
+ std::vector<cryptonote::tx_destination_entry> res;
+ res.push_back(build_dst(to1, sub1, am1));
+ return res;
+}
+
+std::vector<cryptonote::tx_destination_entry> build_dsts(std::initializer_list<dest_wrapper_t> inps)
+{
+ std::vector<cryptonote::tx_destination_entry> res;
+ res.reserve(inps.size());
+ for(auto & c : inps){
+ res.push_back(build_dst(c.addr, c.is_subaddr, c.amount));
+ }
+ return res;
+}
+
bool construct_miner_tx_manually(size_t height, uint64_t already_generated_coins,
const account_public_address& miner_address, transaction& tx, uint64_t fee,
keypair* p_txkey/* = 0*/)
@@ -556,22 +866,70 @@ bool construct_miner_tx_manually(size_t height, uint64_t already_generated_coins
return true;
}
-bool construct_tx_to_key(const std::vector<test_event_entry>& events, cryptonote::transaction& tx, const block& blk_head,
- const cryptonote::account_base& from, const cryptonote::account_base& to, uint64_t amount,
- uint64_t fee, size_t nmix)
+bool construct_tx_to_key(const std::vector<test_event_entry>& events, cryptonote::transaction& tx, const cryptonote::block& blk_head,
+ const cryptonote::account_base& from, const var_addr_t& to, uint64_t amount,
+ uint64_t fee, size_t nmix, bool rct, rct::RangeProofType range_proof_type, int bp_version)
+{
+ vector<tx_source_entry> sources;
+ vector<tx_destination_entry> destinations;
+ fill_tx_sources_and_destinations(events, blk_head, from, get_address(to), amount, fee, nmix, sources, destinations);
+
+ return construct_tx_rct(from.get_keys(), sources, destinations, from.get_keys().m_account_address, std::vector<uint8_t>(), tx, 0, rct, range_proof_type, bp_version);
+}
+
+bool construct_tx_to_key(const std::vector<test_event_entry>& events, cryptonote::transaction& tx, const cryptonote::block& blk_head,
+ const cryptonote::account_base& from, std::vector<cryptonote::tx_destination_entry> destinations,
+ uint64_t fee, size_t nmix, bool rct, rct::RangeProofType range_proof_type, int bp_version)
{
vector<tx_source_entry> sources;
+ vector<tx_destination_entry> destinations_all;
+ uint64_t amount = sum_amount(destinations);
+
+ if (!fill_tx_sources(sources, events, blk_head, from, amount + fee, nmix))
+ throw std::runtime_error("couldn't fill transaction sources");
+
+ fill_tx_destinations(from, destinations, fee, sources, destinations_all, false);
+
+ return construct_tx_rct(from.get_keys(), sources, destinations_all, get_address(from), std::vector<uint8_t>(), tx, 0, rct, range_proof_type, bp_version);
+}
+
+bool construct_tx_to_key(cryptonote::transaction& tx,
+ const cryptonote::account_base& from, const var_addr_t& to, uint64_t amount,
+ std::vector<cryptonote::tx_source_entry> &sources,
+ uint64_t fee, bool rct, rct::RangeProofType range_proof_type, int bp_version)
+{
vector<tx_destination_entry> destinations;
- fill_tx_sources_and_destinations(events, blk_head, from, to, amount, fee, nmix, sources, destinations);
+ fill_tx_destinations(from, get_address(to), amount, fee, sources, destinations, rct);
+ return construct_tx_rct(from.get_keys(), sources, destinations, get_address(from), std::vector<uint8_t>(), tx, 0, rct, range_proof_type, bp_version);
+}
+
+bool construct_tx_to_key(cryptonote::transaction& tx,
+ const cryptonote::account_base& from,
+ const std::vector<cryptonote::tx_destination_entry>& destinations,
+ std::vector<cryptonote::tx_source_entry> &sources,
+ uint64_t fee, bool rct, rct::RangeProofType range_proof_type, int bp_version)
+{
+ vector<tx_destination_entry> all_destinations;
+ fill_tx_destinations(from, destinations, fee, sources, all_destinations, rct);
+ return construct_tx_rct(from.get_keys(), sources, all_destinations, get_address(from), std::vector<uint8_t>(), tx, 0, rct, range_proof_type, bp_version);
+}
- return construct_tx(from.get_keys(), sources, destinations, from.get_keys().m_account_address, std::vector<uint8_t>(), tx, 0);
+bool construct_tx_rct(const cryptonote::account_keys& sender_account_keys, std::vector<cryptonote::tx_source_entry>& sources, const std::vector<cryptonote::tx_destination_entry>& destinations, const boost::optional<cryptonote::account_public_address>& change_addr, std::vector<uint8_t> extra, cryptonote::transaction& tx, uint64_t unlock_time, bool rct, rct::RangeProofType range_proof_type, int bp_version)
+{
+ std::unordered_map<crypto::public_key, cryptonote::subaddress_index> subaddresses;
+ subaddresses[sender_account_keys.m_account_address.m_spend_public_key] = {0, 0};
+ crypto::secret_key tx_key;
+ std::vector<crypto::secret_key> additional_tx_keys;
+ std::vector<tx_destination_entry> destinations_copy = destinations;
+ rct::RCTConfig rct_config = {range_proof_type, bp_version};
+ return construct_tx_and_get_tx_key(sender_account_keys, subaddresses, sources, destinations_copy, change_addr, extra, tx, unlock_time, tx_key, additional_tx_keys, rct, rct_config, nullptr);
}
transaction construct_tx_with_fee(std::vector<test_event_entry>& events, const block& blk_head,
- const account_base& acc_from, const account_base& acc_to, uint64_t amount, uint64_t fee)
+ const account_base& acc_from, const var_addr_t& to, uint64_t amount, uint64_t fee)
{
transaction tx;
- construct_tx_to_key(events, tx, blk_head, acc_from, acc_to, amount, fee, 0);
+ construct_tx_to_key(events, tx, blk_head, acc_from, to, amount, fee, 0);
events.push_back(tx);
return tx;
}
@@ -602,6 +960,24 @@ uint64_t get_balance(const cryptonote::account_base& addr, const std::vector<cry
return res;
}
+bool extract_hard_forks(const std::vector<test_event_entry>& events, v_hardforks_t& hard_forks)
+{
+ for(auto & ev : events)
+ {
+ if (typeid(event_replay_settings) == ev.type())
+ {
+ const auto & rep_settings = boost::get<event_replay_settings>(ev);
+ if (rep_settings.hard_forks)
+ {
+ const auto & hf = rep_settings.hard_forks.get();
+ std::copy(hf.begin(), hf.end(), std::back_inserter(hard_forks));
+ }
+ }
+ }
+
+ return !hard_forks.empty();
+}
+
void get_confirmed_txs(const std::vector<cryptonote::block>& blockchain, const map_hash2tx_t& mtx, map_hash2tx_t& confirmed_txs)
{
std::unordered_set<crypto::hash> confirmed_hashes;
@@ -622,6 +998,74 @@ void get_confirmed_txs(const std::vector<cryptonote::block>& blockchain, const m
}
}
+bool trim_block_chain(std::vector<cryptonote::block>& blockchain, const crypto::hash& tail){
+ size_t cut = 0;
+ bool found = true;
+
+ for(size_t i = 0; i < blockchain.size(); ++i){
+ crypto::hash chash = get_block_hash(blockchain[i]);
+ if (chash == tail){
+ cut = i;
+ found = true;
+ break;
+ }
+ }
+
+ if (found && cut > 0){
+ blockchain.erase(blockchain.begin(), blockchain.begin() + cut);
+ }
+
+ return found;
+}
+
+bool trim_block_chain(std::vector<const cryptonote::block*>& blockchain, const crypto::hash& tail){
+ size_t cut = 0;
+ bool found = true;
+
+ for(size_t i = 0; i < blockchain.size(); ++i){
+ crypto::hash chash = get_block_hash(*blockchain[i]);
+ if (chash == tail){
+ cut = i;
+ found = true;
+ break;
+ }
+ }
+
+ if (found && cut > 0){
+ blockchain.erase(blockchain.begin(), blockchain.begin() + cut);
+ }
+
+ return found;
+}
+
+uint64_t num_blocks(const std::vector<test_event_entry>& events)
+{
+ uint64_t res = 0;
+ BOOST_FOREACH(const test_event_entry& ev, events)
+ {
+ if (typeid(block) == ev.type())
+ {
+ res += 1;
+ }
+ }
+
+ return res;
+}
+
+cryptonote::block get_head_block(const std::vector<test_event_entry>& events)
+{
+ for(auto it = events.rbegin(); it != events.rend(); ++it)
+ {
+ auto &ev = *it;
+ if (typeid(block) == ev.type())
+ {
+ return boost::get<block>(ev);
+ }
+ }
+
+ throw std::runtime_error("No block event");
+}
+
bool find_block_chain(const std::vector<test_event_entry>& events, std::vector<cryptonote::block>& blockchain, map_hash2tx_t& mtx, const crypto::hash& head) {
std::unordered_map<crypto::hash, const block*> block_index;
BOOST_FOREACH(const test_event_entry& ev, events)
@@ -655,6 +1099,38 @@ bool find_block_chain(const std::vector<test_event_entry>& events, std::vector<c
return b_success;
}
+bool find_block_chain(const std::vector<test_event_entry>& events, std::vector<const cryptonote::block*>& blockchain, map_hash2tx_t& mtx, const crypto::hash& head) {
+ std::unordered_map<crypto::hash, const block*> block_index;
+ BOOST_FOREACH(const test_event_entry& ev, events)
+ {
+ if (typeid(block) == ev.type())
+ {
+ const block* blk = &boost::get<block>(ev);
+ block_index[get_block_hash(*blk)] = blk;
+ }
+ else if (typeid(transaction) == ev.type())
+ {
+ const transaction& tx = boost::get<transaction>(ev);
+ mtx[get_transaction_hash(tx)] = &tx;
+ }
+ }
+
+ bool b_success = false;
+ crypto::hash id = head;
+ for (auto it = block_index.find(id); block_index.end() != it; it = block_index.find(id))
+ {
+ blockchain.push_back(it->second);
+ id = it->second->prev_id;
+ if (null_hash == id)
+ {
+ b_success = true;
+ break;
+ }
+ }
+ reverse(blockchain.begin(), blockchain.end());
+ return b_success;
+}
+
void test_chain_unit_base::register_callback(const std::string& cb_name, verify_callback cb)
{
diff --git a/tests/core_tests/chaingen.h b/tests/core_tests/chaingen.h
index 82c480163..8bf5a9b08 100644
--- a/tests/core_tests/chaingen.h
+++ b/tests/core_tests/chaingen.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -37,8 +37,12 @@
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/program_options.hpp>
+#include <boost/optional.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/serialization/variant.hpp>
+#include <boost/serialization/optional.hpp>
+#include <boost/serialization/unordered_map.hpp>
+#include <boost/functional/hash.hpp>
#include "include_base_utils.h"
#include "common/boost_serialization_helper.h"
@@ -129,13 +133,32 @@ private:
}
};
+typedef std::vector<std::pair<uint8_t, uint64_t>> v_hardforks_t;
+struct event_replay_settings
+{
+ boost::optional<v_hardforks_t> hard_forks;
+
+ event_replay_settings() = default;
+
+private:
+ friend class boost::serialization::access;
+
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int /*version*/)
+ {
+ ar & hard_forks;
+ }
+};
+
+
VARIANT_TAG(binary_archive, callback_entry, 0xcb);
VARIANT_TAG(binary_archive, cryptonote::account_base, 0xcc);
VARIANT_TAG(binary_archive, serialized_block, 0xcd);
VARIANT_TAG(binary_archive, serialized_transaction, 0xce);
VARIANT_TAG(binary_archive, event_visitor_settings, 0xcf);
+VARIANT_TAG(binary_archive, event_replay_settings, 0xda);
-typedef boost::variant<cryptonote::block, cryptonote::transaction, std::vector<cryptonote::transaction>, cryptonote::account_base, callback_entry, serialized_block, serialized_transaction, event_visitor_settings> test_event_entry;
+typedef boost::variant<cryptonote::block, cryptonote::transaction, std::vector<cryptonote::transaction>, cryptonote::account_base, callback_entry, serialized_block, serialized_transaction, event_visitor_settings, event_replay_settings> test_event_entry;
typedef std::unordered_map<crypto::hash, const cryptonote::transaction*> map_hash2tx_t;
class test_chain_unit_base
@@ -173,6 +196,17 @@ public:
crypto::hash prev_id;
uint64_t already_generated_coins;
size_t block_weight;
+
+ private:
+ friend class boost::serialization::access;
+
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int /*version*/)
+ {
+ ar & prev_id;
+ ar & already_generated_coins;
+ ar & block_weight;
+ }
};
enum block_fields
@@ -189,6 +223,8 @@ public:
bf_hf_version= 1 << 8
};
+ test_generator() {}
+ test_generator(const test_generator &other): m_blocks_info(other.m_blocks_info) {}
void get_block_chain(std::vector<block_info>& blockchain, const crypto::hash& head, size_t n) const;
void get_last_n_block_weights(std::vector<size_t>& block_weights, const crypto::hash& head, size_t n) const;
uint64_t get_already_generated_coins(const crypto::hash& blk_id) const;
@@ -198,10 +234,12 @@ public:
uint8_t hf_version = 1);
bool construct_block(cryptonote::block& blk, uint64_t height, const crypto::hash& prev_id,
const cryptonote::account_base& miner_acc, uint64_t timestamp, uint64_t already_generated_coins,
- std::vector<size_t>& block_weights, const std::list<cryptonote::transaction>& tx_list);
+ std::vector<size_t>& block_weights, const std::list<cryptonote::transaction>& tx_list,
+ const boost::optional<uint8_t>& hf_ver = boost::none);
bool construct_block(cryptonote::block& blk, const cryptonote::account_base& miner_acc, uint64_t timestamp);
bool construct_block(cryptonote::block& blk, const cryptonote::block& blk_prev, const cryptonote::account_base& miner_acc,
- const std::list<cryptonote::transaction>& tx_list = std::list<cryptonote::transaction>());
+ const std::list<cryptonote::transaction>& tx_list = std::list<cryptonote::transaction>(),
+ const boost::optional<uint8_t>& hf_ver = boost::none);
bool construct_block_manually(cryptonote::block& blk, const cryptonote::block& prev_block,
const cryptonote::account_base& miner_acc, int actual_params = bf_none, uint8_t major_ver = 0,
@@ -214,30 +252,241 @@ public:
private:
std::unordered_map<crypto::hash, block_info> m_blocks_info;
+
+ friend class boost::serialization::access;
+
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int /*version*/)
+ {
+ ar & m_blocks_info;
+ }
};
-inline cryptonote::difficulty_type get_test_difficulty() {return 1;}
+template<typename T>
+std::string dump_keys(T * buff32)
+{
+ std::ostringstream ss;
+ char buff[10];
+
+ ss << "[";
+ for(int i = 0; i < 32; i++)
+ {
+ snprintf(buff, 10, "0x%02x", ((uint8_t)buff32[i] & 0xff));
+ ss << buff;
+ if (i < 31)
+ ss << ",";
+ }
+ ss << "]";
+ return ss.str();
+}
+
+struct output_index {
+ const cryptonote::txout_target_v out;
+ uint64_t amount;
+ size_t blk_height; // block height
+ size_t tx_no; // index of transaction in block
+ size_t out_no; // index of out in transaction
+ size_t idx;
+ uint64_t unlock_time;
+ bool is_coin_base;
+ bool spent;
+ bool rct;
+ rct::key comm;
+ const cryptonote::block *p_blk;
+ const cryptonote::transaction *p_tx;
+
+ output_index(const cryptonote::txout_target_v &_out, uint64_t _a, size_t _h, size_t tno, size_t ono, const cryptonote::block *_pb, const cryptonote::transaction *_pt)
+ : out(_out), amount(_a), blk_height(_h), tx_no(tno), out_no(ono), idx(0), unlock_time(0),
+ is_coin_base(false), spent(false), rct(false), p_blk(_pb), p_tx(_pt)
+ {
+
+ }
+
+ output_index(const output_index &other)
+ : out(other.out), amount(other.amount), blk_height(other.blk_height), tx_no(other.tx_no), rct(other.rct),
+ out_no(other.out_no), idx(other.idx), unlock_time(other.unlock_time), is_coin_base(other.is_coin_base),
+ spent(other.spent), comm(other.comm), p_blk(other.p_blk), p_tx(other.p_tx) { }
+
+ void set_rct(bool arct) {
+ rct = arct;
+ if (rct && p_tx->rct_signatures.outPk.size() > out_no)
+ comm = p_tx->rct_signatures.outPk[out_no].mask;
+ else
+ comm = rct::commit(amount, rct::identity());
+ }
+
+ rct::key commitment() const {
+ return comm;
+ }
+
+ const std::string toString() const {
+ std::stringstream ss;
+
+ ss << "output_index{blk_height=" << blk_height
+ << " tx_no=" << tx_no
+ << " out_no=" << out_no
+ << " amount=" << amount
+ << " idx=" << idx
+ << " unlock_time=" << unlock_time
+ << " spent=" << spent
+ << " is_coin_base=" << is_coin_base
+ << " rct=" << rct
+ << " comm=" << dump_keys(comm.bytes)
+ << "}";
+
+ return ss.str();
+ }
+
+ output_index& operator=(const output_index& other)
+ {
+ new(this) output_index(other);
+ return *this;
+ }
+};
+
+typedef std::tuple<uint64_t, crypto::public_key, rct::key> get_outs_entry;
+typedef std::pair<crypto::hash, size_t> output_hasher;
+typedef boost::hash<output_hasher> output_hasher_hasher;
+typedef std::map<uint64_t, std::vector<size_t> > map_output_t;
+typedef std::map<uint64_t, std::vector<output_index> > map_output_idx_t;
+typedef std::unordered_map<crypto::hash, cryptonote::block> map_block_t;
+typedef std::unordered_map<output_hasher, output_index, output_hasher_hasher> map_txid_output_t;
+typedef std::unordered_map<crypto::public_key, cryptonote::subaddress_index> subaddresses_t;
+typedef std::pair<uint64_t, size_t> outloc_t;
+
+typedef boost::variant<cryptonote::account_public_address, cryptonote::account_keys, cryptonote::account_base, cryptonote::tx_destination_entry> var_addr_t;
+typedef struct {
+ const var_addr_t addr;
+ bool is_subaddr;
+ uint64_t amount;
+} dest_wrapper_t;
+
+// Daemon functionality
+class block_tracker
+{
+public:
+ map_output_idx_t m_outs;
+ map_txid_output_t m_map_outs; // mapping (txid, out) -> output_index
+ map_block_t m_blocks;
+
+ block_tracker() = default;
+ block_tracker(const block_tracker &bt): m_outs(bt.m_outs), m_map_outs(bt.m_map_outs), m_blocks(bt.m_blocks) {};
+ map_txid_output_t::iterator find_out(const crypto::hash &txid, size_t out);
+ map_txid_output_t::iterator find_out(const output_hasher &id);
+ void process(const std::vector<cryptonote::block>& blockchain, const map_hash2tx_t& mtx);
+ void process(const std::vector<const cryptonote::block*>& blockchain, const map_hash2tx_t& mtx);
+ void process(const cryptonote::block* blk, const cryptonote::transaction * tx, size_t i);
+ void global_indices(const cryptonote::transaction *tx, std::vector<uint64_t> &indices);
+ void get_fake_outs(size_t num_outs, uint64_t amount, uint64_t global_index, uint64_t cur_height, std::vector<get_outs_entry> &outs);
+
+ std::string dump_data();
+ void dump_data(const std::string & fname);
+
+private:
+ friend class boost::serialization::access;
+
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int /*version*/)
+ {
+ ar & m_outs;
+ ar & m_map_outs;
+ ar & m_blocks;
+ }
+};
+
+std::string dump_data(const cryptonote::transaction &tx);
+cryptonote::account_public_address get_address(const var_addr_t& inp);
+cryptonote::account_public_address get_address(const cryptonote::account_public_address& inp);
+cryptonote::account_public_address get_address(const cryptonote::account_keys& inp);
+cryptonote::account_public_address get_address(const cryptonote::account_base& inp);
+cryptonote::account_public_address get_address(const cryptonote::tx_destination_entry& inp);
+
+inline cryptonote::difficulty_type get_test_difficulty(const boost::optional<uint8_t>& hf_ver=boost::none) {return !hf_ver || hf_ver.get() <= 1 ? 1 : 2;}
+inline uint64_t current_difficulty_window(const boost::optional<uint8_t>& hf_ver=boost::none){ return !hf_ver || hf_ver.get() <= 1 ? DIFFICULTY_TARGET_V1 : DIFFICULTY_TARGET_V2; }
void fill_nonce(cryptonote::block& blk, const cryptonote::difficulty_type& diffic, uint64_t height);
+cryptonote::tx_destination_entry build_dst(const var_addr_t& to, bool is_subaddr=false, uint64_t amount=0);
+std::vector<cryptonote::tx_destination_entry> build_dsts(const var_addr_t& to1, bool sub1=false, uint64_t am1=0);
+std::vector<cryptonote::tx_destination_entry> build_dsts(std::initializer_list<dest_wrapper_t> inps);
+uint64_t sum_amount(const std::vector<cryptonote::tx_destination_entry>& destinations);
+uint64_t sum_amount(const std::vector<cryptonote::tx_source_entry>& sources);
+
bool construct_miner_tx_manually(size_t height, uint64_t already_generated_coins,
const cryptonote::account_public_address& miner_address, cryptonote::transaction& tx,
- uint64_t fee, cryptonote::keypair* p_txkey = 0);
+ uint64_t fee, cryptonote::keypair* p_txkey = nullptr);
+
bool construct_tx_to_key(const std::vector<test_event_entry>& events, cryptonote::transaction& tx,
- const cryptonote::block& blk_head, const cryptonote::account_base& from, const cryptonote::account_base& to,
- uint64_t amount, uint64_t fee, size_t nmix);
+ const cryptonote::block& blk_head, const cryptonote::account_base& from, const var_addr_t& to, uint64_t amount,
+ uint64_t fee, size_t nmix, bool rct=false, rct::RangeProofType range_proof_type=rct::RangeProofBorromean, int bp_version = 0);
+
+bool construct_tx_to_key(const std::vector<test_event_entry>& events, cryptonote::transaction& tx, const cryptonote::block& blk_head,
+ const cryptonote::account_base& from, std::vector<cryptonote::tx_destination_entry> destinations,
+ uint64_t fee, size_t nmix, bool rct=false, rct::RangeProofType range_proof_type=rct::RangeProofBorromean, int bp_version = 0);
+
+bool construct_tx_to_key(cryptonote::transaction& tx, const cryptonote::account_base& from, const var_addr_t& to, uint64_t amount,
+ std::vector<cryptonote::tx_source_entry> &sources,
+ uint64_t fee, bool rct=false, rct::RangeProofType range_proof_type=rct::RangeProofBorromean, int bp_version = 0);
+
+bool construct_tx_to_key(cryptonote::transaction& tx, const cryptonote::account_base& from, const std::vector<cryptonote::tx_destination_entry>& destinations,
+ std::vector<cryptonote::tx_source_entry> &sources,
+ uint64_t fee, bool rct, rct::RangeProofType range_proof_type, int bp_version = 0);
+
cryptonote::transaction construct_tx_with_fee(std::vector<test_event_entry>& events, const cryptonote::block& blk_head,
- const cryptonote::account_base& acc_from, const cryptonote::account_base& acc_to,
+ const cryptonote::account_base& acc_from, const var_addr_t& to,
uint64_t amount, uint64_t fee);
+bool construct_tx_rct(const cryptonote::account_keys& sender_account_keys,
+ std::vector<cryptonote::tx_source_entry>& sources,
+ const std::vector<cryptonote::tx_destination_entry>& destinations,
+ const boost::optional<cryptonote::account_public_address>& change_addr,
+ std::vector<uint8_t> extra, cryptonote::transaction& tx, uint64_t unlock_time,
+ bool rct=false, rct::RangeProofType range_proof_type=rct::RangeProofBorromean, int bp_version = 0);
+
+
+uint64_t num_blocks(const std::vector<test_event_entry>& events);
+cryptonote::block get_head_block(const std::vector<test_event_entry>& events);
+
void get_confirmed_txs(const std::vector<cryptonote::block>& blockchain, const map_hash2tx_t& mtx, map_hash2tx_t& confirmed_txs);
+bool trim_block_chain(std::vector<cryptonote::block>& blockchain, const crypto::hash& tail);
+bool trim_block_chain(std::vector<const cryptonote::block*>& blockchain, const crypto::hash& tail);
bool find_block_chain(const std::vector<test_event_entry>& events, std::vector<cryptonote::block>& blockchain, map_hash2tx_t& mtx, const crypto::hash& head);
+bool find_block_chain(const std::vector<test_event_entry>& events, std::vector<const cryptonote::block*>& blockchain, map_hash2tx_t& mtx, const crypto::hash& head);
+
+void fill_tx_destinations(const var_addr_t& from, const cryptonote::account_public_address& to,
+ uint64_t amount, uint64_t fee,
+ const std::vector<cryptonote::tx_source_entry> &sources,
+ std::vector<cryptonote::tx_destination_entry>& destinations, bool always_change=false);
+
+void fill_tx_destinations(const var_addr_t& from, const std::vector<cryptonote::tx_destination_entry>& dests,
+ uint64_t fee,
+ const std::vector<cryptonote::tx_source_entry> &sources,
+ std::vector<cryptonote::tx_destination_entry>& destinations,
+ bool always_change);
+
+void fill_tx_destinations(const var_addr_t& from, const cryptonote::account_public_address& to,
+ uint64_t amount, uint64_t fee,
+ const std::vector<cryptonote::tx_source_entry> &sources,
+ std::vector<cryptonote::tx_destination_entry>& destinations,
+ std::vector<cryptonote::tx_destination_entry>& destinations_pure,
+ bool always_change=false);
+
+
+void fill_tx_sources_and_destinations(const std::vector<test_event_entry>& events, const cryptonote::block& blk_head,
+ const cryptonote::account_base& from, const cryptonote::account_public_address& to,
+ uint64_t amount, uint64_t fee, size_t nmix,
+ std::vector<cryptonote::tx_source_entry>& sources,
+ std::vector<cryptonote::tx_destination_entry>& destinations);
+
void fill_tx_sources_and_destinations(const std::vector<test_event_entry>& events, const cryptonote::block& blk_head,
const cryptonote::account_base& from, const cryptonote::account_base& to,
uint64_t amount, uint64_t fee, size_t nmix,
std::vector<cryptonote::tx_source_entry>& sources,
std::vector<cryptonote::tx_destination_entry>& destinations);
+
uint64_t get_balance(const cryptonote::account_base& addr, const std::vector<cryptonote::block>& blockchain, const map_hash2tx_t& mtx);
+bool extract_hard_forks(const std::vector<test_event_entry>& events, v_hardforks_t& hard_forks);
+
//--------------------------------------------------------------------------
template<class t_test_class>
auto do_check_tx_verification_context(const cryptonote::tx_verification_context& tvc, bool tx_added, size_t event_index, const cryptonote::transaction& tx, t_test_class& validator, int)
@@ -338,6 +587,12 @@ public:
m_ev_index = ev_index;
}
+ bool operator()(const event_replay_settings& settings)
+ {
+ log_event("event_replay_settings");
+ return true;
+ }
+
bool operator()(const event_visitor_settings& settings)
{
log_event("event_visitor_settings");
@@ -461,12 +716,20 @@ private:
template<class t_test_class>
inline bool replay_events_through_core(cryptonote::core& cr, const std::vector<test_event_entry>& events, t_test_class& validator)
{
+ return replay_events_through_core_plain(cr, events, validator, true);
+}
+//--------------------------------------------------------------------------
+template<class t_test_class>
+inline bool replay_events_through_core_plain(cryptonote::core& cr, const std::vector<test_event_entry>& events, t_test_class& validator, bool reinit=true)
+{
TRY_ENTRY();
//init core here
-
- CHECK_AND_ASSERT_MES(typeid(cryptonote::block) == events[0].type(), false, "First event must be genesis block creation");
- cr.set_genesis_block(boost::get<cryptonote::block>(events[0]));
+ if (reinit) {
+ CHECK_AND_ASSERT_MES(typeid(cryptonote::block) == events[0].type(), false,
+ "First event must be genesis block creation");
+ cr.set_genesis_block(boost::get<cryptonote::block>(events[0]));
+ }
bool r = true;
push_core_event_visitor<t_test_class> visitor(cr, events, validator);
@@ -489,10 +752,9 @@ struct get_test_options {
};
get_test_options():hard_forks{std::make_pair((uint8_t)1, (uint64_t)0), std::make_pair((uint8_t)0, (uint64_t)0)}{}
};
-
//--------------------------------------------------------------------------
template<class t_test_class>
-inline bool do_replay_events(std::vector<test_event_entry>& events)
+inline bool do_replay_events_get_core(std::vector<test_event_entry>& events, cryptonote::core **core)
{
boost::program_options::options_description desc("Allowed options");
cryptonote::core::init_options(desc);
@@ -506,12 +768,24 @@ inline bool do_replay_events(std::vector<test_event_entry>& events)
if (!r)
return false;
- cryptonote::cryptonote_protocol_stub pr; //TODO: stub only for this kind of test, make real validation of relayed objects
- cryptonote::core c(&pr);
+ *core = new cryptonote::core(nullptr);
+ auto & c = **core;
+
// FIXME: make sure that vm has arg_testnet_on set to true or false if
// this test needs for it to be so.
get_test_options<t_test_class> gto;
- if (!c.init(vm, &gto.test_options))
+
+ // Hardforks can be specified in events.
+ v_hardforks_t hardforks;
+ cryptonote::test_options test_options_tmp{};
+ const cryptonote::test_options * test_options_ = &gto.test_options;
+ if (extract_hard_forks(events, hardforks)){
+ hardforks.push_back(std::make_pair((uint8_t)0, (uint64_t)0)); // terminator
+ test_options_tmp.hard_forks = hardforks.data();
+ test_options_ = &test_options_tmp;
+ }
+
+ if (!c.init(vm, test_options_))
{
MERROR("Failed to init core");
return false;
@@ -529,7 +803,31 @@ inline bool do_replay_events(std::vector<test_event_entry>& events)
t_test_class validator;
bool ret = replay_events_through_core<t_test_class>(c, events, validator);
- c.deinit();
+// c.deinit();
+ return ret;
+}
+//--------------------------------------------------------------------------
+template<class t_test_class>
+inline bool replay_events_through_core_validate(std::vector<test_event_entry>& events, cryptonote::core & c)
+{
+ std::vector<crypto::hash> pool_txs;
+ if (!c.get_pool_transaction_hashes(pool_txs))
+ {
+ MERROR("Failed to flush txpool");
+ return false;
+ }
+ c.get_blockchain_storage().flush_txes_from_pool(pool_txs);
+
+ t_test_class validator;
+ return replay_events_through_core_plain<t_test_class>(c, events, validator, false);
+}
+//--------------------------------------------------------------------------
+template<class t_test_class>
+inline bool do_replay_events(std::vector<test_event_entry>& events)
+{
+ cryptonote::core * core;
+ bool ret = do_replay_events_get_core<t_test_class>(events, &core);
+ core->deinit();
return ret;
}
//--------------------------------------------------------------------------
@@ -546,6 +844,12 @@ inline bool do_replay_file(const std::string& filename)
}
//--------------------------------------------------------------------------
+#define DEFAULT_HARDFORKS(HARDFORKS) do { \
+ HARDFORKS.push_back(std::make_pair((uint8_t)1, (uint64_t)0)); \
+} while(0)
+
+#define ADD_HARDFORK(HARDFORKS, FORK, HEIGHT) HARDFORKS.push_back(std::make_pair((uint8_t)FORK, (uint64_t)HEIGHT))
+
#define GENERATE_ACCOUNT(account) \
cryptonote::account_base account; \
account.generate();
@@ -589,6 +893,11 @@ inline bool do_replay_file(const std::string& filename)
generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC); \
VEC_EVENTS.push_back(BLK_NAME);
+#define MAKE_NEXT_BLOCK_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, HF) \
+ cryptonote::block BLK_NAME; \
+ generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, std::list<cryptonote::transaction>(), HF); \
+ VEC_EVENTS.push_back(BLK_NAME);
+
#define MAKE_NEXT_BLOCK_TX1(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TX1) \
cryptonote::block BLK_NAME; \
{ \
@@ -598,46 +907,91 @@ inline bool do_replay_file(const std::string& filename)
} \
VEC_EVENTS.push_back(BLK_NAME);
+#define MAKE_NEXT_BLOCK_TX1_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TX1, HF) \
+ cryptonote::block BLK_NAME; \
+ { \
+ std::list<cryptonote::transaction> tx_list; \
+ tx_list.push_back(TX1); \
+ generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, tx_list, HF); \
+ } \
+ VEC_EVENTS.push_back(BLK_NAME);
+
#define MAKE_NEXT_BLOCK_TX_LIST(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST) \
cryptonote::block BLK_NAME; \
generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST); \
VEC_EVENTS.push_back(BLK_NAME);
-#define REWIND_BLOCKS_N(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, COUNT) \
+#define MAKE_NEXT_BLOCK_TX_LIST_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST, HF) \
cryptonote::block BLK_NAME; \
+ generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST, HF); \
+ VEC_EVENTS.push_back(BLK_NAME);
+
+#define REWIND_BLOCKS_N_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, COUNT, HF) \
+ cryptonote::block BLK_NAME; \
{ \
- cryptonote::block blk_last = PREV_BLOCK; \
+ cryptonote::block blk_last = PREV_BLOCK; \
for (size_t i = 0; i < COUNT; ++i) \
{ \
- MAKE_NEXT_BLOCK(VEC_EVENTS, blk, blk_last, MINER_ACC); \
+ MAKE_NEXT_BLOCK_HF(VEC_EVENTS, blk, blk_last, MINER_ACC, HF); \
blk_last = blk; \
} \
BLK_NAME = blk_last; \
}
+#define REWIND_BLOCKS_N(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, COUNT) REWIND_BLOCKS_N_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, COUNT, boost::none)
#define REWIND_BLOCKS(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC) REWIND_BLOCKS_N(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW)
+#define REWIND_BLOCKS_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, HF) REWIND_BLOCKS_N_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW, HF)
#define MAKE_TX_MIX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, NMIX, HEAD) \
cryptonote::transaction TX_NAME; \
construct_tx_to_key(VEC_EVENTS, TX_NAME, HEAD, FROM, TO, AMOUNT, TESTS_DEFAULT_FEE, NMIX); \
VEC_EVENTS.push_back(TX_NAME);
+#define MAKE_TX_MIX_RCT(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, NMIX, HEAD) \
+ cryptonote::transaction TX_NAME; \
+ construct_tx_to_key(VEC_EVENTS, TX_NAME, HEAD, FROM, TO, AMOUNT, TESTS_DEFAULT_FEE, NMIX, true, rct::RangeProofPaddedBulletproof); \
+ VEC_EVENTS.push_back(TX_NAME);
+
#define MAKE_TX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, HEAD) MAKE_TX_MIX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, 0, HEAD)
#define MAKE_TX_MIX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD) \
{ \
- cryptonote::transaction t; \
+ cryptonote::transaction t; \
construct_tx_to_key(VEC_EVENTS, t, HEAD, FROM, TO, AMOUNT, TESTS_DEFAULT_FEE, NMIX); \
SET_NAME.push_back(t); \
VEC_EVENTS.push_back(t); \
}
+#define MAKE_TX_MIX_LIST_RCT(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD) \
+ MAKE_TX_MIX_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD, rct::RangeProofPaddedBulletproof, 1)
+#define MAKE_TX_MIX_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD, RCT_TYPE, BP_VER) \
+ { \
+ cryptonote::transaction t; \
+ construct_tx_to_key(VEC_EVENTS, t, HEAD, FROM, TO, AMOUNT, TESTS_DEFAULT_FEE, NMIX, true, RCT_TYPE, BP_VER); \
+ SET_NAME.push_back(t); \
+ VEC_EVENTS.push_back(t); \
+ }
+
+#define MAKE_TX_MIX_DEST_LIST_RCT(VEC_EVENTS, SET_NAME, FROM, TO, NMIX, HEAD) \
+ MAKE_TX_MIX_DEST_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, NMIX, HEAD, rct::RangeProofPaddedBulletproof, 1)
+#define MAKE_TX_MIX_DEST_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, NMIX, HEAD, RCT_TYPE, BP_VER) \
+ { \
+ cryptonote::transaction t; \
+ construct_tx_to_key(VEC_EVENTS, t, HEAD, FROM, TO, TESTS_DEFAULT_FEE, NMIX, true, RCT_TYPE, BP_VER); \
+ SET_NAME.push_back(t); \
+ VEC_EVENTS.push_back(t); \
+ }
+
#define MAKE_TX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD) MAKE_TX_MIX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, 0, HEAD)
#define MAKE_TX_LIST_START(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD) \
std::list<cryptonote::transaction> SET_NAME; \
MAKE_TX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD);
+#define MAKE_TX_LIST_START_RCT(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD) \
+ std::list<cryptonote::transaction> SET_NAME; \
+ MAKE_TX_MIX_LIST_RCT(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD);
+
#define MAKE_MINER_TX_AND_KEY_MANUALLY(TX, BLK, KEY) \
transaction TX; \
if (!construct_miner_tx_manually(get_block_height(BLK) + 1, generator.get_already_generated_coins(BLK), \
@@ -668,19 +1022,7 @@ inline bool do_replay_file(const std::string& filename)
return 1; \
}
-#define GENERATE_AND_PLAY(genclass) \
- if (list_tests) \
- std::cout << #genclass << std::endl; \
- else if (filter.empty() || boost::regex_match(std::string(#genclass), match, boost::regex(filter))) \
- { \
- std::vector<test_event_entry> events; \
- ++tests_count; \
- bool generated = false; \
- try \
- { \
- genclass g; \
- generated = g.generate(events);; \
- } \
+#define CATCH_REPLAY(genclass) \
catch (const std::exception& ex) \
{ \
MERROR(#genclass << " generation failed: what=" << ex.what()); \
@@ -688,7 +1030,9 @@ inline bool do_replay_file(const std::string& filename)
catch (...) \
{ \
MERROR(#genclass << " generation failed: generic exception"); \
- } \
+ }
+
+#define REPLAY_CORE(genclass) \
if (generated && do_replay_events< genclass >(events)) \
{ \
MGINFO_GREEN("#TEST# Succeeded " << #genclass); \
@@ -697,7 +1041,54 @@ inline bool do_replay_file(const std::string& filename)
{ \
MERROR("#TEST# Failed " << #genclass); \
failed_tests.push_back(#genclass); \
+ }
+
+#define REPLAY_WITH_CORE(genclass, CORE) \
+ if (generated && replay_events_through_core_validate< genclass >(events, CORE)) \
+ { \
+ MGINFO_GREEN("#TEST# Succeeded " << #genclass); \
+ } \
+ else \
+ { \
+ MERROR("#TEST# Failed " << #genclass); \
+ failed_tests.push_back(#genclass); \
+ }
+
+#define CATCH_GENERATE_REPLAY(genclass) \
+ CATCH_REPLAY(genclass); \
+ REPLAY_CORE(genclass);
+
+#define CATCH_GENERATE_REPLAY_CORE(genclass, CORE) \
+ CATCH_REPLAY(genclass); \
+ REPLAY_WITH_CORE(genclass, CORE);
+
+#define GENERATE_AND_PLAY(genclass) \
+ if (list_tests) \
+ std::cout << #genclass << std::endl; \
+ else if (filter.empty() || boost::regex_match(std::string(#genclass), match, boost::regex(filter))) \
+ { \
+ std::vector<test_event_entry> events; \
+ ++tests_count; \
+ bool generated = false; \
+ try \
+ { \
+ genclass g; \
+ generated = g.generate(events); \
+ } \
+ CATCH_GENERATE_REPLAY(genclass); \
+ }
+
+#define GENERATE_AND_PLAY_INSTANCE(genclass, ins, CORE) \
+ if (filter.empty() || boost::regex_match(std::string(#genclass), match, boost::regex(filter))) \
+ { \
+ std::vector<test_event_entry> events; \
+ ++tests_count; \
+ bool generated = false; \
+ try \
+ { \
+ generated = ins.generate(events); \
} \
+ CATCH_GENERATE_REPLAY_CORE(genclass, CORE); \
}
#define CALL_TEST(test_name, function) \
diff --git a/tests/core_tests/chaingen001.cpp b/tests/core_tests/chaingen001.cpp
index a76cf1592..b313f4821 100644
--- a/tests/core_tests/chaingen001.cpp
+++ b/tests/core_tests/chaingen001.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/chaingen_main.cpp b/tests/core_tests/chaingen_main.cpp
index 71b8c4463..cb35cfde2 100644
--- a/tests/core_tests/chaingen_main.cpp
+++ b/tests/core_tests/chaingen_main.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/chaingen_tests_list.h b/tests/core_tests/chaingen_tests_list.h
index c12e97f95..cf20c725c 100644
--- a/tests/core_tests/chaingen_tests_list.h
+++ b/tests/core_tests/chaingen_tests_list.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/double_spend.cpp b/tests/core_tests/double_spend.cpp
index c60ea885e..afd212b27 100644
--- a/tests/core_tests/double_spend.cpp
+++ b/tests/core_tests/double_spend.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/double_spend.h b/tests/core_tests/double_spend.h
index 276e74853..70d9f84b9 100644
--- a/tests/core_tests/double_spend.h
+++ b/tests/core_tests/double_spend.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/double_spend.inl b/tests/core_tests/double_spend.inl
index d02147065..600899b6f 100644
--- a/tests/core_tests/double_spend.inl
+++ b/tests/core_tests/double_spend.inl
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/integer_overflow.cpp b/tests/core_tests/integer_overflow.cpp
index e7e1ac9ca..42df4aa3b 100644
--- a/tests/core_tests/integer_overflow.cpp
+++ b/tests/core_tests/integer_overflow.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/integer_overflow.h b/tests/core_tests/integer_overflow.h
index eaca268e4..75a60eb15 100644
--- a/tests/core_tests/integer_overflow.h
+++ b/tests/core_tests/integer_overflow.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/multisig.cpp b/tests/core_tests/multisig.cpp
index 37fda6643..e0c90423d 100644
--- a/tests/core_tests/multisig.cpp
+++ b/tests/core_tests/multisig.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/multisig.h b/tests/core_tests/multisig.h
index e0d227840..1e8226d26 100644
--- a/tests/core_tests/multisig.h
+++ b/tests/core_tests/multisig.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/rct.cpp b/tests/core_tests/rct.cpp
index bb7dd013b..248354177 100644
--- a/tests/core_tests/rct.cpp
+++ b/tests/core_tests/rct.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/rct.h b/tests/core_tests/rct.h
index 641f3dd5e..72460d98e 100644
--- a/tests/core_tests/rct.h
+++ b/tests/core_tests/rct.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/ring_signature_1.cpp b/tests/core_tests/ring_signature_1.cpp
index 8b2b943cc..eb5ee48ec 100644
--- a/tests/core_tests/ring_signature_1.cpp
+++ b/tests/core_tests/ring_signature_1.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/ring_signature_1.h b/tests/core_tests/ring_signature_1.h
index 7ff6cfd96..256f5732b 100644
--- a/tests/core_tests/ring_signature_1.h
+++ b/tests/core_tests/ring_signature_1.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/transaction_tests.cpp b/tests/core_tests/transaction_tests.cpp
index 810dec6fc..14028b5be 100644
--- a/tests/core_tests/transaction_tests.cpp
+++ b/tests/core_tests/transaction_tests.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/transaction_tests.h b/tests/core_tests/transaction_tests.h
index 9500c66f6..eac2c3479 100644
--- a/tests/core_tests/transaction_tests.h
+++ b/tests/core_tests/transaction_tests.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/tx_validation.cpp b/tests/core_tests/tx_validation.cpp
index f0a385ee5..232c86482 100644
--- a/tests/core_tests/tx_validation.cpp
+++ b/tests/core_tests/tx_validation.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/tx_validation.h b/tests/core_tests/tx_validation.h
index 01a258a20..8d457cdb5 100644
--- a/tests/core_tests/tx_validation.h
+++ b/tests/core_tests/tx_validation.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/v2_tests.cpp b/tests/core_tests/v2_tests.cpp
index b96c744b3..8c2b51acf 100644
--- a/tests/core_tests/v2_tests.cpp
+++ b/tests/core_tests/v2_tests.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/v2_tests.h b/tests/core_tests/v2_tests.h
index cd2bcb839..71b0f0e83 100644
--- a/tests/core_tests/v2_tests.h
+++ b/tests/core_tests/v2_tests.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/core_tests/wallet_tools.cpp b/tests/core_tests/wallet_tools.cpp
new file mode 100644
index 000000000..ff7ce3a34
--- /dev/null
+++ b/tests/core_tests/wallet_tools.cpp
@@ -0,0 +1,287 @@
+//
+// Created by Dusan Klinec on 2019-02-28.
+//
+
+#include "wallet_tools.h"
+#include <random>
+
+using namespace std;
+using namespace epee;
+using namespace crypto;
+using namespace cryptonote;
+
+// Shared random generator
+static std::default_random_engine RND(crypto::rand<unsigned>());
+
+void wallet_accessor_test::set_account(tools::wallet2 * wallet, cryptonote::account_base& account)
+{
+ wallet->clear();
+ wallet->m_account = account;
+ wallet->m_nettype = MAINNET;
+
+ wallet->m_key_device_type = account.get_device().get_type();
+ wallet->m_account_public_address = account.get_keys().m_account_address;
+ wallet->m_watch_only = false;
+ wallet->m_multisig = false;
+ wallet->m_multisig_threshold = 0;
+ wallet->m_multisig_signers.clear();
+ wallet->m_device_name = account.get_device().get_name();
+
+ wallet->m_subaddress_lookahead_major = 5;
+ wallet->m_subaddress_lookahead_minor = 20;
+
+ wallet->setup_new_blockchain(); // generates also subadress register
+}
+
+void wallet_accessor_test::process_parsed_blocks(tools::wallet2 * wallet, uint64_t start_height, const std::vector<cryptonote::block_complete_entry> &blocks, const std::vector<tools::wallet2::parsed_block> &parsed_blocks, uint64_t& blocks_added)
+{
+ wallet->process_parsed_blocks(start_height, blocks, parsed_blocks, blocks_added);
+}
+
+void wallet_tools::process_transactions(tools::wallet2 * wallet, const std::vector<test_event_entry>& events, const cryptonote::block& blk_head, block_tracker &bt, const boost::optional<crypto::hash>& blk_tail)
+{
+ map_hash2tx_t mtx;
+ std::vector<const cryptonote::block*> blockchain;
+ find_block_chain(events, blockchain, mtx, get_block_hash(blk_head));
+
+ if (blk_tail){
+ trim_block_chain(blockchain, blk_tail.get());
+ }
+
+ process_transactions(wallet, blockchain, mtx, bt);
+}
+
+void wallet_tools::process_transactions(tools::wallet2 * wallet, const std::vector<const cryptonote::block*>& blockchain, const map_hash2tx_t & mtx, block_tracker &bt)
+{
+ uint64_t start_height=0, blocks_added=0;
+ std::vector<cryptonote::block_complete_entry> v_bche;
+ std::vector<tools::wallet2::parsed_block> v_parsed_block;
+
+ v_bche.reserve(blockchain.size());
+ v_parsed_block.reserve(blockchain.size());
+
+ size_t idx = 0;
+ for(auto bl : blockchain)
+ {
+ idx += 1;
+ uint64_t height;
+ v_bche.emplace_back();
+ v_parsed_block.emplace_back();
+
+ wallet_tools::gen_block_data(bt, bl, mtx, v_bche.back(), v_parsed_block.back(), idx == 1 ? start_height : height);
+ }
+
+ if (wallet)
+ wallet_accessor_test::process_parsed_blocks(wallet, start_height, v_bche, v_parsed_block, blocks_added);
+}
+
+bool wallet_tools::fill_tx_sources(tools::wallet2 * wallet, std::vector<cryptonote::tx_source_entry>& sources, size_t mixin, const boost::optional<size_t>& num_utxo, const boost::optional<uint64_t>& min_amount, block_tracker &bt, std::vector<size_t> &selected, uint64_t cur_height, ssize_t offset, int step, const boost::optional<fnc_accept_tx_source_t>& fnc_accept)
+{
+ CHECK_AND_ASSERT_THROW_MES(step != 0, "Step is zero");
+ sources.clear();
+
+ auto & transfers = wallet_accessor_test::get_transfers(wallet);
+ std::unordered_set<size_t> selected_idx;
+ std::unordered_set<crypto::key_image> selected_kis;
+ const size_t ntrans = wallet->get_num_transfer_details();
+ size_t roffset = offset >= 0 ? offset : ntrans - offset - 1;
+ size_t iters = 0;
+ uint64_t sum = 0;
+ size_t cur_utxo = 0;
+ bool abort = false;
+ unsigned brk_cond = 0;
+ unsigned brk_thresh = num_utxo && min_amount ? 2 : (num_utxo || min_amount ? 1 : 0);
+
+#define EVAL_BRK_COND() do { \
+ brk_cond = 0; \
+ if (num_utxo && num_utxo.get() <= cur_utxo) \
+ brk_cond += 1; \
+ if (min_amount && min_amount.get() <= sum) \
+ brk_cond += 1; \
+ } while(0)
+
+ for(ssize_t i = roffset; iters < ntrans && !abort; i += step, ++iters)
+ {
+ EVAL_BRK_COND();
+ if (brk_cond >= brk_thresh)
+ break;
+
+ i = i < 0 ? (i + ntrans) : i % ntrans;
+ auto & td = transfers[i];
+ if (td.m_spent)
+ continue;
+ if (td.m_block_height + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW > cur_height)
+ continue;
+ if (selected_idx.find((size_t)i) != selected_idx.end()){
+ MERROR("Should not happen (selected_idx not found): " << i);
+ continue;
+ }
+ if (selected_kis.find(td.m_key_image) != selected_kis.end()){
+ MERROR("Should not happen (selected KI): " << i << "ki: " << dump_keys(td.m_key_image.data));
+ continue;
+ }
+
+ try {
+ cryptonote::tx_source_entry src;
+ wallet_tools::gen_tx_src(mixin, cur_height, td, src, bt);
+
+ // Acceptor function
+ if (fnc_accept){
+ tx_source_info_crate_t c_info{.td=&td, .src=&src, .selected_idx=&selected_idx, .selected_kis=&selected_kis,
+ .ntrans=ntrans, .iters=iters, .sum=sum, .cur_utxo=cur_utxo};
+
+ bool take_it = (fnc_accept.get())(c_info, abort);
+ if (!take_it){
+ continue;
+ }
+ }
+
+ MINFO("Selected " << i << " from tx: " << dump_keys(td.m_txid.data)
+ << " ki: " << dump_keys(td.m_key_image.data)
+ << " amnt: " << td.amount()
+ << " rct: " << td.is_rct()
+ << " glob: " << td.m_global_output_index);
+
+ sum += td.amount();
+ cur_utxo += 1;
+
+ sources.emplace_back(src);
+ selected.push_back((size_t)i);
+ selected_idx.insert((size_t)i);
+ selected_kis.insert(td.m_key_image);
+
+ } catch(const std::exception &e){
+ MTRACE("Output " << i << ", from: " << dump_keys(td.m_txid.data)
+ << ", amnt: " << td.amount() << ", rct: " << td.is_rct()
+ << ", glob: " << td.m_global_output_index << " is not applicable: " << e.what());
+ }
+ }
+
+ EVAL_BRK_COND();
+ return brk_cond >= brk_thresh;
+#undef EVAL_BRK_COND
+}
+
+void wallet_tools::gen_tx_src(size_t mixin, uint64_t cur_height, const tools::wallet2::transfer_details & td, cryptonote::tx_source_entry & src, block_tracker &bt)
+{
+ src.amount = td.amount();
+ src.rct = td.is_rct();
+
+ std::vector<tools::wallet2::get_outs_entry> outs;
+ bt.get_fake_outs(mixin, td.is_rct() ? 0 : td.amount(), td.m_global_output_index, cur_height, outs);
+
+ for (size_t n = 0; n < mixin; ++n)
+ {
+ cryptonote::tx_source_entry::output_entry oe;
+ oe.first = std::get<0>(outs[n]);
+ oe.second.dest = rct::pk2rct(std::get<1>(outs[n]));
+ oe.second.mask = std::get<2>(outs[n]);
+ src.outputs.push_back(oe);
+ }
+
+ size_t real_idx = crypto::rand<size_t>() % mixin;
+
+ cryptonote::tx_source_entry::output_entry &real_oe = src.outputs[real_idx];
+ real_oe.first = td.m_global_output_index;
+ real_oe.second.dest = rct::pk2rct(boost::get<txout_to_key>(td.m_tx.vout[td.m_internal_output_index].target).key);
+ real_oe.second.mask = rct::commit(td.amount(), td.m_mask);
+
+ std::sort(src.outputs.begin(), src.outputs.end(), [&](const cryptonote::tx_source_entry::output_entry i0, const cryptonote::tx_source_entry::output_entry i1) {
+ return i0.first < i1.first;
+ });
+
+ for (size_t i = 0; i < src.outputs.size(); ++i){
+ if (src.outputs[i].first == td.m_global_output_index){
+ src.real_output = i;
+ break;
+ }
+ }
+
+ src.mask = td.m_mask;
+ src.real_out_tx_key = get_tx_pub_key_from_extra(td.m_tx, td.m_pk_index);
+ src.real_out_additional_tx_keys = get_additional_tx_pub_keys_from_extra(td.m_tx);
+ src.real_output_in_tx_index = td.m_internal_output_index;
+ src.multisig_kLRki = rct::multisig_kLRki({rct::zero(), rct::zero(), rct::zero(), rct::zero()});
+}
+
+void wallet_tools::gen_block_data(block_tracker &bt, const cryptonote::block *bl, const map_hash2tx_t &mtx, cryptonote::block_complete_entry &bche, tools::wallet2::parsed_block &parsed_block, uint64_t &height)
+{
+ vector<const transaction*> vtx;
+ vtx.push_back(&(bl->miner_tx));
+ height = boost::get<txin_gen>(*bl->miner_tx.vin.begin()).height;
+
+ BOOST_FOREACH(const crypto::hash &h, bl->tx_hashes) {
+ const map_hash2tx_t::const_iterator cit = mtx.find(h);
+ CHECK_AND_ASSERT_THROW_MES(mtx.end() != cit, "block contains an unknown tx hash @ " << height << ", " << h);
+ vtx.push_back(cit->second);
+ }
+
+ bche.block = "NA";
+ bche.txs.resize(bl->tx_hashes.size());
+
+ parsed_block.error = false;
+ parsed_block.hash = get_block_hash(*bl);
+ parsed_block.block = *bl;
+ parsed_block.txes.reserve(bl->tx_hashes.size());
+
+ auto & o_indices = parsed_block.o_indices.indices;
+ o_indices.reserve(bl->tx_hashes.size() + 1);
+
+ size_t cur = 0;
+ BOOST_FOREACH(const transaction *tx, vtx){
+ cur += 1;
+ o_indices.emplace_back();
+ bt.process(bl, tx, cur - 1);
+ bt.global_indices(tx, o_indices.back().indices);
+
+ if (cur > 1) // miner not included
+ parsed_block.txes.push_back(*tx);
+ }
+}
+
+void wallet_tools::compute_subaddresses(std::unordered_map<crypto::public_key, cryptonote::subaddress_index> &subaddresses, cryptonote::account_base & creds, size_t account, size_t minors)
+{
+ auto &hwdev = hw::get_device("default");
+ const std::vector<crypto::public_key> pkeys = hwdev.get_subaddress_spend_public_keys(creds.get_keys(), account, 0, minors);
+
+ for(uint32_t c = 0; c < pkeys.size(); ++c){
+ cryptonote::subaddress_index sidx{(uint32_t)account, c};
+ subaddresses[pkeys[c]] = sidx;
+ }
+}
+
+cryptonote::account_public_address get_address(const tools::wallet2* inp)
+{
+ return (inp)->get_account().get_keys().m_account_address;
+}
+
+bool construct_tx_to_key(cryptonote::transaction& tx,
+ tools::wallet2 * sender_wallet, const var_addr_t& to, uint64_t amount,
+ std::vector<cryptonote::tx_source_entry> &sources,
+ uint64_t fee, bool rct, rct::RangeProofType range_proof_type, int bp_version)
+{
+ vector<tx_destination_entry> destinations;
+ fill_tx_destinations(sender_wallet->get_account(), get_address(to), amount, fee, sources, destinations, rct);
+ return construct_tx_rct(sender_wallet, sources, destinations, get_address(sender_wallet), std::vector<uint8_t>(), tx, 0, rct, range_proof_type, bp_version);
+}
+
+bool construct_tx_to_key(cryptonote::transaction& tx,
+ tools::wallet2 * sender_wallet,
+ const std::vector<cryptonote::tx_destination_entry>& destinations,
+ std::vector<cryptonote::tx_source_entry> &sources,
+ uint64_t fee, bool rct, rct::RangeProofType range_proof_type, int bp_version)
+{
+ vector<tx_destination_entry> all_destinations;
+ fill_tx_destinations(sender_wallet->get_account(), destinations, fee, sources, all_destinations, rct);
+ return construct_tx_rct(sender_wallet, sources, all_destinations, get_address(sender_wallet), std::vector<uint8_t>(), tx, 0, rct, range_proof_type, bp_version);
+}
+
+bool construct_tx_rct(tools::wallet2 * sender_wallet, std::vector<cryptonote::tx_source_entry>& sources, const std::vector<cryptonote::tx_destination_entry>& destinations, const boost::optional<cryptonote::account_public_address>& change_addr, std::vector<uint8_t> extra, cryptonote::transaction& tx, uint64_t unlock_time, bool rct, rct::RangeProofType range_proof_type, int bp_version)
+{
+ subaddresses_t & subaddresses = wallet_accessor_test::get_subaddresses(sender_wallet);
+ crypto::secret_key tx_key;
+ std::vector<crypto::secret_key> additional_tx_keys;
+ std::vector<tx_destination_entry> destinations_copy = destinations;
+ rct::RCTConfig rct_config = {range_proof_type, bp_version};
+ return construct_tx_and_get_tx_key(sender_wallet->get_account().get_keys(), subaddresses, sources, destinations_copy, change_addr, extra, tx, unlock_time, tx_key, additional_tx_keys, rct, rct_config, nullptr);
+}
diff --git a/tests/core_tests/wallet_tools.h b/tests/core_tests/wallet_tools.h
new file mode 100644
index 000000000..03db04c99
--- /dev/null
+++ b/tests/core_tests/wallet_tools.h
@@ -0,0 +1,86 @@
+// Copyright (c) 2014-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.
+//
+// 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.
+//
+// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
+
+#pragma once
+
+#include "chaingen.h"
+#include "wallet/wallet2.h"
+
+typedef struct {
+ tools::wallet2::transfer_details * td;
+ cryptonote::tx_source_entry * src;
+
+ std::unordered_set<size_t> * selected_idx;
+ std::unordered_set<crypto::key_image> * selected_kis;
+ size_t ntrans;
+ size_t iters;
+ uint64_t sum;
+ size_t cur_utxo;
+} tx_source_info_crate_t;
+
+typedef std::function<bool(const tx_source_info_crate_t &info, bool &abort)> fnc_accept_tx_source_t;
+
+// Wallet friend, direct access to required fields and private methods
+class wallet_accessor_test
+{
+public:
+ static void set_account(tools::wallet2 * wallet, cryptonote::account_base& account);
+ static tools::wallet2::transfer_container & get_transfers(tools::wallet2 * wallet) { return wallet->m_transfers; }
+ static subaddresses_t & get_subaddresses(tools::wallet2 * wallet) { return wallet->m_subaddresses; }
+ static void process_parsed_blocks(tools::wallet2 * wallet, uint64_t start_height, const std::vector<cryptonote::block_complete_entry> &blocks, const std::vector<tools::wallet2::parsed_block> &parsed_blocks, uint64_t& blocks_added);
+};
+
+class wallet_tools
+{
+public:
+ static void gen_tx_src(size_t mixin, uint64_t cur_height, const tools::wallet2::transfer_details & td, cryptonote::tx_source_entry & src, block_tracker &bt);
+ static void gen_block_data(block_tracker &bt, const cryptonote::block *bl, const map_hash2tx_t & mtx, cryptonote::block_complete_entry &bche, tools::wallet2::parsed_block &parsed_block, uint64_t &height);
+ static void compute_subaddresses(std::unordered_map<crypto::public_key, cryptonote::subaddress_index> &subaddresses, cryptonote::account_base & creds, size_t account, size_t minors);
+ static void process_transactions(tools::wallet2 * wallet, const std::vector<test_event_entry>& events, const cryptonote::block& blk_head, block_tracker &bt, const boost::optional<crypto::hash>& blk_tail=boost::none);
+ static void process_transactions(tools::wallet2 * wallet, const std::vector<const cryptonote::block*>& blockchain, const map_hash2tx_t & mtx, block_tracker &bt);
+ static bool fill_tx_sources(tools::wallet2 * wallet, std::vector<cryptonote::tx_source_entry>& sources, size_t mixin, const boost::optional<size_t>& num_utxo, const boost::optional<uint64_t>& min_amount, block_tracker &bt, std::vector<size_t> &selected, uint64_t cur_height, ssize_t offset=0, int step=1, const boost::optional<fnc_accept_tx_source_t>& fnc_accept=boost::none);
+};
+
+cryptonote::account_public_address get_address(const tools::wallet2*);
+
+bool construct_tx_to_key(cryptonote::transaction& tx, tools::wallet2 * from_wallet, const var_addr_t& to, uint64_t amount,
+ std::vector<cryptonote::tx_source_entry> &sources,
+ uint64_t fee, bool rct=false, rct::RangeProofType range_proof_type=rct::RangeProofBorromean, int bp_version = 0);
+
+bool construct_tx_to_key(cryptonote::transaction& tx, tools::wallet2 * sender_wallet, const std::vector<cryptonote::tx_destination_entry>& destinations,
+ std::vector<cryptonote::tx_source_entry> &sources,
+ uint64_t fee, bool rct, rct::RangeProofType range_proof_type, int bp_version = 0);
+
+bool construct_tx_rct(tools::wallet2 * sender_wallet,
+ std::vector<cryptonote::tx_source_entry>& sources,
+ const std::vector<cryptonote::tx_destination_entry>& destinations,
+ const boost::optional<cryptonote::account_public_address>& change_addr,
+ std::vector<uint8_t> extra, cryptonote::transaction& tx, uint64_t unlock_time,
+ bool rct=false, rct::RangeProofType range_proof_type=rct::RangeProofBorromean, int bp_version = 0);
diff --git a/tests/crypto/CMakeLists.txt b/tests/crypto/CMakeLists.txt
index f4612ab4c..883efb3b0 100644
--- a/tests/crypto/CMakeLists.txt
+++ b/tests/crypto/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/tests/crypto/crypto-ops-data.c b/tests/crypto/crypto-ops-data.c
index 9bdd6b88f..63fedff07 100644
--- a/tests/crypto/crypto-ops-data.c
+++ b/tests/crypto/crypto-ops-data.c
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/crypto/crypto-ops.c b/tests/crypto/crypto-ops.c
index 476de786a..9b1ccfcee 100644
--- a/tests/crypto/crypto-ops.c
+++ b/tests/crypto/crypto-ops.c
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/crypto/crypto-tests.h b/tests/crypto/crypto-tests.h
index d910a845c..be8d5a2e1 100644
--- a/tests/crypto/crypto-tests.h
+++ b/tests/crypto/crypto-tests.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/crypto/crypto.cpp b/tests/crypto/crypto.cpp
index 6a1dd1b29..160e0a23f 100644
--- a/tests/crypto/crypto.cpp
+++ b/tests/crypto/crypto.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/crypto/hash.c b/tests/crypto/hash.c
index 6b865abd9..d65f13f11 100644
--- a/tests/crypto/hash.c
+++ b/tests/crypto/hash.c
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/crypto/main.cpp b/tests/crypto/main.cpp
index cc3b53b83..3cdef4ce7 100644
--- a/tests/crypto/main.cpp
+++ b/tests/crypto/main.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/crypto/random.c b/tests/crypto/random.c
index e9464d457..7a17cbccc 100644
--- a/tests/crypto/random.c
+++ b/tests/crypto/random.c
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/cryptolib.pl b/tests/cryptolib.pl
index 3d4cb638b..d26ce601c 100644
--- a/tests/cryptolib.pl
+++ b/tests/cryptolib.pl
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/tests/cryptotest.pl b/tests/cryptotest.pl
index 13f8db09e..57f6e2c5a 100644
--- a/tests/cryptotest.pl
+++ b/tests/cryptotest.pl
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/tests/daemon_tests/CMakeLists.txt b/tests/daemon_tests/CMakeLists.txt
index bc1dce2cc..a32f26584 100644
--- a/tests/daemon_tests/CMakeLists.txt
+++ b/tests/daemon_tests/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/tests/daemon_tests/transfers.cpp b/tests/daemon_tests/transfers.cpp
index 726f11dfb..e20e6b280 100644
--- a/tests/daemon_tests/transfers.cpp
+++ b/tests/daemon_tests/transfers.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/difficulty/CMakeLists.txt b/tests/difficulty/CMakeLists.txt
index 3cb8af8d5..2ed495806 100644
--- a/tests/difficulty/CMakeLists.txt
+++ b/tests/difficulty/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/tests/difficulty/difficulty.cpp b/tests/difficulty/difficulty.cpp
index 996913a19..ee20e27e4 100644
--- a/tests/difficulty/difficulty.cpp
+++ b/tests/difficulty/difficulty.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/difficulty/generate-data b/tests/difficulty/generate-data
index c41ce025d..3a9976e05 100755
--- a/tests/difficulty/generate-data
+++ b/tests/difficulty/generate-data
@@ -1,6 +1,6 @@
#!/usr/bin/python3
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/tests/functional_tests/CMakeLists.txt b/tests/functional_tests/CMakeLists.txt
index 7a2a7fbd1..2e3519994 100644
--- a/tests/functional_tests/CMakeLists.txt
+++ b/tests/functional_tests/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/tests/functional_tests/main.cpp b/tests/functional_tests/main.cpp
index b9a686dbc..c6869f755 100644
--- a/tests/functional_tests/main.cpp
+++ b/tests/functional_tests/main.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/functional_tests/transactions_flow_test.cpp b/tests/functional_tests/transactions_flow_test.cpp
index 7e5b73415..32b601d7a 100644
--- a/tests/functional_tests/transactions_flow_test.cpp
+++ b/tests/functional_tests/transactions_flow_test.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/functional_tests/transactions_flow_test.h b/tests/functional_tests/transactions_flow_test.h
index 78135b9c0..530400df8 100644
--- a/tests/functional_tests/transactions_flow_test.h
+++ b/tests/functional_tests/transactions_flow_test.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/functional_tests/transactions_generation_from_blockchain.cpp b/tests/functional_tests/transactions_generation_from_blockchain.cpp
index 92dc00f2d..b9c43e0e9 100644
--- a/tests/functional_tests/transactions_generation_from_blockchain.cpp
+++ b/tests/functional_tests/transactions_generation_from_blockchain.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/functional_tests/transactions_generation_from_blockchain.h b/tests/functional_tests/transactions_generation_from_blockchain.h
index b684f7c7a..cb5f94f80 100644
--- a/tests/functional_tests/transactions_generation_from_blockchain.h
+++ b/tests/functional_tests/transactions_generation_from_blockchain.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/fuzz/CMakeLists.txt b/tests/fuzz/CMakeLists.txt
index fdb745699..a6ef139f5 100644
--- a/tests/fuzz/CMakeLists.txt
+++ b/tests/fuzz/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/tests/fuzz/base58.cpp b/tests/fuzz/base58.cpp
index a4857bdd1..5f909a5d9 100644
--- a/tests/fuzz/base58.cpp
+++ b/tests/fuzz/base58.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/fuzz/block.cpp b/tests/fuzz/block.cpp
index eed3b94b2..850c58890 100644
--- a/tests/fuzz/block.cpp
+++ b/tests/fuzz/block.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/fuzz/bulletproof.cpp b/tests/fuzz/bulletproof.cpp
index 2f3a2f8d1..e9a6ded7d 100644
--- a/tests/fuzz/bulletproof.cpp
+++ b/tests/fuzz/bulletproof.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/fuzz/cold-outputs.cpp b/tests/fuzz/cold-outputs.cpp
index 29b3ed267..f3f35e140 100644
--- a/tests/fuzz/cold-outputs.cpp
+++ b/tests/fuzz/cold-outputs.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/fuzz/cold-transaction.cpp b/tests/fuzz/cold-transaction.cpp
index fa3041ba3..83493f8a0 100644
--- a/tests/fuzz/cold-transaction.cpp
+++ b/tests/fuzz/cold-transaction.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/fuzz/fuzzer.cpp b/tests/fuzz/fuzzer.cpp
index ab14e2b79..24db5ee05 100644
--- a/tests/fuzz/fuzzer.cpp
+++ b/tests/fuzz/fuzzer.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/fuzz/fuzzer.h b/tests/fuzz/fuzzer.h
index 2bf01914a..5cbd1abc2 100644
--- a/tests/fuzz/fuzzer.h
+++ b/tests/fuzz/fuzzer.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/fuzz/http-client.cpp b/tests/fuzz/http-client.cpp
index 909325832..1750838ae 100644
--- a/tests/fuzz/http-client.cpp
+++ b/tests/fuzz/http-client.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/fuzz/levin.cpp b/tests/fuzz/levin.cpp
index 573abd1d3..fe9ef418e 100644
--- a/tests/fuzz/levin.cpp
+++ b/tests/fuzz/levin.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/fuzz/load_from_binary.cpp b/tests/fuzz/load_from_binary.cpp
index 89f122902..85b7361e5 100644
--- a/tests/fuzz/load_from_binary.cpp
+++ b/tests/fuzz/load_from_binary.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/fuzz/load_from_json.cpp b/tests/fuzz/load_from_json.cpp
index 083555f7e..3ba98050b 100644
--- a/tests/fuzz/load_from_json.cpp
+++ b/tests/fuzz/load_from_json.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/fuzz/parse_url.cpp b/tests/fuzz/parse_url.cpp
index fb5754a70..3db78f9d9 100644
--- a/tests/fuzz/parse_url.cpp
+++ b/tests/fuzz/parse_url.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/fuzz/signature.cpp b/tests/fuzz/signature.cpp
index f82ada8b4..ab8faa29f 100644
--- a/tests/fuzz/signature.cpp
+++ b/tests/fuzz/signature.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/fuzz/transaction.cpp b/tests/fuzz/transaction.cpp
index 934bd4685..0f62888a1 100644
--- a/tests/fuzz/transaction.cpp
+++ b/tests/fuzz/transaction.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/hash-target.cpp b/tests/hash-target.cpp
index 2737ae30e..70368ce24 100644
--- a/tests/hash-target.cpp
+++ b/tests/hash-target.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/hash/CMakeLists.txt b/tests/hash/CMakeLists.txt
index 105cf2c13..a0c78bfdc 100644
--- a/tests/hash/CMakeLists.txt
+++ b/tests/hash/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/tests/hash/main.cpp b/tests/hash/main.cpp
index acfd99e96..adf1bd9c4 100644
--- a/tests/hash/main.cpp
+++ b/tests/hash/main.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/io.h b/tests/io.h
index ec5a9ee60..0f65ed297 100644
--- a/tests/io.h
+++ b/tests/io.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/libwallet_api_tests/CMakeLists.txt b/tests/libwallet_api_tests/CMakeLists.txt
index 1a9cbc5a6..cb1d563b0 100644
--- a/tests/libwallet_api_tests/CMakeLists.txt
+++ b/tests/libwallet_api_tests/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp
index fe31541df..02faae50d 100644
--- a/tests/libwallet_api_tests/main.cpp
+++ b/tests/libwallet_api_tests/main.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/net_load_tests/CMakeLists.txt b/tests/net_load_tests/CMakeLists.txt
index 1407bbf70..40b5561a7 100644
--- a/tests/net_load_tests/CMakeLists.txt
+++ b/tests/net_load_tests/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/tests/net_load_tests/clt.cpp b/tests/net_load_tests/clt.cpp
index 77cce2be7..fc2280f23 100644
--- a/tests/net_load_tests/clt.cpp
+++ b/tests/net_load_tests/clt.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/net_load_tests/net_load_tests.h b/tests/net_load_tests/net_load_tests.h
index 6c4f7cb76..cdc2d267a 100644
--- a/tests/net_load_tests/net_load_tests.h
+++ b/tests/net_load_tests/net_load_tests.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/net_load_tests/srv.cpp b/tests/net_load_tests/srv.cpp
index 092c6955c..fe32ec5cb 100644
--- a/tests/net_load_tests/srv.cpp
+++ b/tests/net_load_tests/srv.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/performance_tests/CMakeLists.txt b/tests/performance_tests/CMakeLists.txt
index 5cd054d86..aa424da80 100644
--- a/tests/performance_tests/CMakeLists.txt
+++ b/tests/performance_tests/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/tests/performance_tests/bulletproof.h b/tests/performance_tests/bulletproof.h
index 7bb702c3d..7136fbbfe 100644
--- a/tests/performance_tests/bulletproof.h
+++ b/tests/performance_tests/bulletproof.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/performance_tests/check_tx_signature.h b/tests/performance_tests/check_tx_signature.h
index 755d8f941..329714c56 100644
--- a/tests/performance_tests/check_tx_signature.h
+++ b/tests/performance_tests/check_tx_signature.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/performance_tests/cn_fast_hash.h b/tests/performance_tests/cn_fast_hash.h
index 2ddaef269..63b2c5bee 100644
--- a/tests/performance_tests/cn_fast_hash.h
+++ b/tests/performance_tests/cn_fast_hash.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/performance_tests/cn_slow_hash.h b/tests/performance_tests/cn_slow_hash.h
index 79ebb8778..4f410d62d 100644
--- a/tests/performance_tests/cn_slow_hash.h
+++ b/tests/performance_tests/cn_slow_hash.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/performance_tests/construct_tx.h b/tests/performance_tests/construct_tx.h
index 71d42073d..ebfe46edf 100644
--- a/tests/performance_tests/construct_tx.h
+++ b/tests/performance_tests/construct_tx.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/performance_tests/crypto_ops.h b/tests/performance_tests/crypto_ops.h
index 3ebb6f470..5b215cef4 100644
--- a/tests/performance_tests/crypto_ops.h
+++ b/tests/performance_tests/crypto_ops.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/performance_tests/derive_public_key.h b/tests/performance_tests/derive_public_key.h
index 35c4ff062..ad0b3b55f 100644
--- a/tests/performance_tests/derive_public_key.h
+++ b/tests/performance_tests/derive_public_key.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/performance_tests/derive_secret_key.h b/tests/performance_tests/derive_secret_key.h
index c478a2a99..ba01b57c0 100644
--- a/tests/performance_tests/derive_secret_key.h
+++ b/tests/performance_tests/derive_secret_key.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/performance_tests/equality.h b/tests/performance_tests/equality.h
index 8d24d7da7..5788ebec8 100644
--- a/tests/performance_tests/equality.h
+++ b/tests/performance_tests/equality.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/performance_tests/ge_frombytes_vartime.h b/tests/performance_tests/ge_frombytes_vartime.h
index 3f7d55182..1a0601c74 100644
--- a/tests/performance_tests/ge_frombytes_vartime.h
+++ b/tests/performance_tests/ge_frombytes_vartime.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/performance_tests/ge_tobytes.h b/tests/performance_tests/ge_tobytes.h
index 3d46f4838..66e6fce38 100644
--- a/tests/performance_tests/ge_tobytes.h
+++ b/tests/performance_tests/ge_tobytes.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/performance_tests/generate_key_derivation.h b/tests/performance_tests/generate_key_derivation.h
index 3f6238265..1f0066589 100644
--- a/tests/performance_tests/generate_key_derivation.h
+++ b/tests/performance_tests/generate_key_derivation.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/performance_tests/generate_key_image.h b/tests/performance_tests/generate_key_image.h
index 5155e64a5..df39d7088 100644
--- a/tests/performance_tests/generate_key_image.h
+++ b/tests/performance_tests/generate_key_image.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/performance_tests/generate_key_image_helper.h b/tests/performance_tests/generate_key_image_helper.h
index ede48b6ca..d4d83c07d 100644
--- a/tests/performance_tests/generate_key_image_helper.h
+++ b/tests/performance_tests/generate_key_image_helper.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/performance_tests/generate_keypair.h b/tests/performance_tests/generate_keypair.h
index 91c830166..cf28f7f58 100644
--- a/tests/performance_tests/generate_keypair.h
+++ b/tests/performance_tests/generate_keypair.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/performance_tests/is_out_to_acc.h b/tests/performance_tests/is_out_to_acc.h
index 9f81995ac..8b4516843 100644
--- a/tests/performance_tests/is_out_to_acc.h
+++ b/tests/performance_tests/is_out_to_acc.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/performance_tests/main.cpp b/tests/performance_tests/main.cpp
index 22a86cb59..e6558a364 100644
--- a/tests/performance_tests/main.cpp
+++ b/tests/performance_tests/main.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/performance_tests/multi_tx_test_base.h b/tests/performance_tests/multi_tx_test_base.h
index ae9d6ea7a..bdbbee37d 100644
--- a/tests/performance_tests/multi_tx_test_base.h
+++ b/tests/performance_tests/multi_tx_test_base.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/performance_tests/performance_tests.h b/tests/performance_tests/performance_tests.h
index 17d16b0f6..606c5980f 100644
--- a/tests/performance_tests/performance_tests.h
+++ b/tests/performance_tests/performance_tests.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/performance_tests/performance_utils.h b/tests/performance_tests/performance_utils.h
index e46a7bce4..8a45bea90 100644
--- a/tests/performance_tests/performance_utils.h
+++ b/tests/performance_tests/performance_utils.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -40,7 +40,7 @@
void set_process_affinity(int core)
{
-#if defined (__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__sun)
+#if defined (__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__sun)
return;
#elif defined(BOOST_WINDOWS)
DWORD_PTR mask = 1;
@@ -62,7 +62,7 @@ void set_process_affinity(int core)
void set_thread_high_priority()
{
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__sun)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(_NetBSD_) || defined(__sun)
return;
#elif defined(BOOST_WINDOWS)
::SetPriorityClass(::GetCurrentProcess(), HIGH_PRIORITY_CLASS);
diff --git a/tests/performance_tests/range_proof.h b/tests/performance_tests/range_proof.h
index 0ce962cd9..548237814 100644
--- a/tests/performance_tests/range_proof.h
+++ b/tests/performance_tests/range_proof.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/performance_tests/rct_mlsag.h b/tests/performance_tests/rct_mlsag.h
index 888f4b260..0141710f7 100644
--- a/tests/performance_tests/rct_mlsag.h
+++ b/tests/performance_tests/rct_mlsag.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/performance_tests/sc_reduce32.h b/tests/performance_tests/sc_reduce32.h
index fc5606414..8db1ca70a 100644
--- a/tests/performance_tests/sc_reduce32.h
+++ b/tests/performance_tests/sc_reduce32.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/performance_tests/signature.h b/tests/performance_tests/signature.h
index 21110b525..63c63ea46 100644
--- a/tests/performance_tests/signature.h
+++ b/tests/performance_tests/signature.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/performance_tests/single_tx_test_base.h b/tests/performance_tests/single_tx_test_base.h
index 365d25444..52fbf5f80 100644
--- a/tests/performance_tests/single_tx_test_base.h
+++ b/tests/performance_tests/single_tx_test_base.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/performance_tests/subaddress_expand.h b/tests/performance_tests/subaddress_expand.h
index 2a13ff5c2..61fcb41f3 100644
--- a/tests/performance_tests/subaddress_expand.h
+++ b/tests/performance_tests/subaddress_expand.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/trezor/CMakeLists.txt b/tests/trezor/CMakeLists.txt
new file mode 100644
index 000000000..67c2f8438
--- /dev/null
+++ b/tests/trezor/CMakeLists.txt
@@ -0,0 +1,63 @@
+# Copyright (c) 2014-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.
+#
+# 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(trezor_tests_sources
+ trezor_tests.cpp
+ ../core_tests/chaingen.cpp
+ ../core_tests/wallet_tools.cpp)
+
+set(trezor_tests_headers
+ trezor_tests.h
+ ../core_tests/chaingen.h
+ ../core_tests/wallet_tools.h)
+
+add_executable(trezor_tests
+ ${trezor_tests_sources}
+ ${trezor_tests_headers})
+
+target_link_libraries(trezor_tests
+ PRIVATE
+ multisig
+ cryptonote_core
+ p2p
+ version
+ epee
+ device
+ device_trezor
+ wallet
+ ${CMAKE_THREAD_LIBS_INIT}
+ ${EXTRA_LIBRARIES})
+
+enable_stack_trace(trezor_tests)
+set_property(TARGET trezor_tests
+ PROPERTY
+ FOLDER "tests")
+
+add_test(
+ NAME trezor_tests
+ COMMAND trezor_tests)
diff --git a/tests/trezor/trezor_tests.cpp b/tests/trezor/trezor_tests.cpp
new file mode 100644
index 000000000..c2b46f698
--- /dev/null
+++ b/tests/trezor/trezor_tests.cpp
@@ -0,0 +1,1409 @@
+// Copyright (c) 2014-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.
+//
+// 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.
+//
+// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
+
+#include "include_base_utils.h"
+#include "cryptonote_basic/cryptonote_basic_impl.h"
+#include "cryptonote_basic/account.h"
+#include "cryptonote_core/cryptonote_tx_utils.h"
+#include "misc_language.h"
+#include "string_tools.h"
+
+using namespace cryptonote;
+
+#include <boost/regex.hpp>
+#include "common/util.h"
+#include "common/command_line.h"
+#include "trezor_tests.h"
+#include "device/device_cold.hpp"
+#include "device_trezor/device_trezor.hpp"
+
+
+namespace po = boost::program_options;
+
+namespace
+{
+ const command_line::arg_descriptor<std::string> arg_filter = { "filter", "Regular expression filter for which tests to run" };
+ const command_line::arg_descriptor<bool> arg_generate_and_play_test_data = {"generate_and_play_test_data", ""};
+ const command_line::arg_descriptor<std::string> arg_trezor_path = {"trezor_path", "Path to the trezor device to use, has to support debug link", ""};
+ const command_line::arg_descriptor<bool> arg_heavy_tests = {"heavy_tests", "Runs expensive tests (volume tests with real device)", false};
+ const command_line::arg_descriptor<std::string> arg_chain_path = {"chain_path", "Path to the serialized blockchain, speeds up testing", ""};
+ const command_line::arg_descriptor<bool> arg_fix_chain = {"fix_chain", "If chain_patch is given and file cannot be used, it is ignored and overwriten", false};
+}
+
+
+#define TREZOR_ACCOUNT_ORDERING &m_miner_account, &m_alice_account, &m_bob_account, &m_eve_account
+#define TREZOR_COMMON_TEST_CASE(genclass, CORE, BASE) \
+ rollback_chain(CORE, BASE.head_block()); \
+ { \
+ genclass ctest; \
+ BASE.fork(ctest); \
+ GENERATE_AND_PLAY_INSTANCE(genclass, ctest, *(CORE)); \
+ }
+
+#define TREZOR_SETUP_CHAIN(NAME) do { \
+ ++tests_count; \
+ try { \
+ setup_chain(&core, trezor_base, chain_path, fix_chain); \
+ } catch (const std::exception& ex) { \
+ failed_tests.emplace_back("gen_trezor_base " #NAME); \
+ } \
+} while(0)
+
+static void rollback_chain(cryptonote::core * core, const cryptonote::block & head);
+static void setup_chain(cryptonote::core ** core, gen_trezor_base & trezor_base, std::string chain_path, bool fix_chain);
+
+int main(int argc, char* argv[])
+{
+ TRY_ENTRY();
+ tools::on_startup();
+ epee::string_tools::set_module_name_and_folder(argv[0]);
+
+ //set up logging options
+ mlog_configure(mlog_get_default_log_path("trezor_tests.log"), true);
+ mlog_set_log_level(2);
+
+ po::options_description desc_options("Allowed options");
+ command_line::add_arg(desc_options, command_line::arg_help);
+ command_line::add_arg(desc_options, arg_filter);
+ command_line::add_arg(desc_options, arg_trezor_path);
+ command_line::add_arg(desc_options, arg_heavy_tests);
+ command_line::add_arg(desc_options, arg_chain_path);
+ command_line::add_arg(desc_options, arg_fix_chain);
+
+ po::variables_map vm;
+ bool r = command_line::handle_error_helper(desc_options, [&]()
+ {
+ po::store(po::parse_command_line(argc, argv, desc_options), vm);
+ po::notify(vm);
+ return true;
+ });
+ if (!r)
+ return 1;
+
+ if (command_line::get_arg(vm, command_line::arg_help))
+ {
+ std::cout << desc_options << std::endl;
+ return 0;
+ }
+
+ const std::string filter = tools::glob_to_regex(command_line::get_arg(vm, arg_filter));
+ boost::smatch match;
+
+ size_t tests_count = 0;
+ std::vector<std::string> failed_tests;
+ std::string trezor_path = command_line::get_arg(vm, arg_trezor_path);
+ std::string chain_path = command_line::get_arg(vm, arg_chain_path);
+ const bool heavy_tests = command_line::get_arg(vm, arg_heavy_tests);
+ const bool fix_chain = command_line::get_arg(vm, arg_fix_chain);
+
+ hw::trezor::register_all();
+
+ // Bootstrapping common chain & accounts
+ cryptonote::core * core = nullptr;
+
+ gen_trezor_base trezor_base;
+ trezor_base.setup_args(trezor_path, heavy_tests);
+ trezor_base.rct_config({rct::RangeProofPaddedBulletproof, 1}); // HF9 tests
+
+ TREZOR_SETUP_CHAIN("HF9");
+
+ // Individual test cases using shared pre-generated blockchain.
+ TREZOR_COMMON_TEST_CASE(gen_trezor_ki_sync, core, trezor_base);
+
+ // Transaction tests
+ TREZOR_COMMON_TEST_CASE(gen_trezor_1utxo, core, trezor_base);
+ TREZOR_COMMON_TEST_CASE(gen_trezor_1utxo_paymentid_short, core, trezor_base);
+ TREZOR_COMMON_TEST_CASE(gen_trezor_1utxo_paymentid_short_integrated, core, trezor_base);
+ TREZOR_COMMON_TEST_CASE(gen_trezor_1utxo_paymentid_long, core, trezor_base);
+ TREZOR_COMMON_TEST_CASE(gen_trezor_4utxo, core, trezor_base);
+ TREZOR_COMMON_TEST_CASE(gen_trezor_4utxo_acc1, core, trezor_base);
+ TREZOR_COMMON_TEST_CASE(gen_trezor_4utxo_to_sub, core, trezor_base);
+ TREZOR_COMMON_TEST_CASE(gen_trezor_4utxo_to_2sub, core, trezor_base);
+ TREZOR_COMMON_TEST_CASE(gen_trezor_4utxo_to_1norm_2sub, core, trezor_base);
+ TREZOR_COMMON_TEST_CASE(gen_trezor_2utxo_sub_acc_to_1norm_2sub, core, trezor_base);
+ TREZOR_COMMON_TEST_CASE(gen_trezor_4utxo_to_7outs, core, trezor_base);
+
+ if (trezor_base.heavy_tests())
+ {
+ TREZOR_COMMON_TEST_CASE(gen_trezor_many_utxo, core, trezor_base);
+ }
+
+ core->deinit();
+ el::Level level = (failed_tests.empty() ? el::Level::Info : el::Level::Error);
+ MLOG(level, "\nREPORT:");
+ MLOG(level, " Test run: " << tests_count);
+ MLOG(level, " Failures: " << failed_tests.size());
+ if (!failed_tests.empty())
+ {
+ MLOG(level, "FAILED TESTS:");
+ BOOST_FOREACH(auto test_name, failed_tests)
+ {
+ MLOG(level, " " << test_name);
+ }
+ }
+
+ return failed_tests.empty() ? 0 : 1;
+
+ CATCH_ENTRY_L0("main", 1);
+}
+
+static void rollback_chain(cryptonote::core * core, const cryptonote::block & head)
+{
+ CHECK_AND_ASSERT_THROW_MES(core, "Core is null");
+
+ block popped_block;
+ std::vector<transaction> popped_txs;
+
+ crypto::hash head_hash = get_block_hash(head), cur_hash{};
+ uint64_t height = get_block_height(head), cur_height=0;
+
+ do {
+ core->get_blockchain_top(cur_height, cur_hash);
+
+ if (cur_height <= height && head_hash == cur_hash)
+ return;
+
+ CHECK_AND_ASSERT_THROW_MES(cur_height > height, "Height differs");
+ core->get_blockchain_storage().get_db().pop_block(popped_block, popped_txs);
+ } while(true);
+}
+
+static bool unserialize_chain_from_file(std::vector<test_event_entry>& events, gen_trezor_base &test_base, const std::string& file_path)
+{
+ TRY_ENTRY();
+ std::ifstream data_file;
+ data_file.open( file_path, std::ios_base::binary | std::ios_base::in);
+ if(data_file.fail())
+ return false;
+ try
+ {
+ boost::archive::portable_binary_iarchive a(data_file);
+ test_base.clear();
+
+ a >> events;
+ a >> test_base;
+ return true;
+ }
+ catch(...)
+ {
+ MWARNING("Chain deserialization failed");
+ return false;
+ }
+ CATCH_ENTRY_L0("unserialize_chain_from_file", false);
+}
+
+static bool serialize_chain_to_file(std::vector<test_event_entry>& events, gen_trezor_base &test_base, const std::string& file_path)
+{
+ TRY_ENTRY();
+ std::ofstream data_file;
+ data_file.open( file_path, std::ios_base::binary | std::ios_base::out | std::ios::trunc);
+ if(data_file.fail())
+ return false;
+ try
+ {
+
+ boost::archive::portable_binary_oarchive a(data_file);
+ a << events;
+ a << test_base;
+ return !data_file.fail();
+ }
+ catch(...)
+ {
+ MWARNING("Chain deserialization failed");
+ return false;
+ }
+ return false;
+ CATCH_ENTRY_L0("serialize_chain_to_file", false);
+}
+
+static void setup_chain(cryptonote::core ** core, gen_trezor_base & trezor_base, std::string chain_path, bool fix_chain)
+{
+ std::vector<test_event_entry> events;
+ const bool do_serialize = !chain_path.empty();
+ const bool chain_file_exists = do_serialize && boost::filesystem::exists(chain_path);
+ bool loaded = false;
+ bool generated = false;
+
+ if (chain_file_exists)
+ {
+ if (!unserialize_chain_from_file(events, trezor_base, chain_path))
+ {
+ MERROR("Failed to deserialize data from file: " << chain_path);
+ if (!fix_chain)
+ {
+ throw std::runtime_error("Chain load error");
+ }
+ } else
+ {
+ trezor_base.load(events);
+ generated = true;
+ loaded = true;
+ }
+ }
+
+ if (!generated)
+ {
+ try
+ {
+ generated = trezor_base.generate(events);
+
+ if (generated && !loaded && do_serialize)
+ {
+ trezor_base.update_trackers(events);
+ if (!serialize_chain_to_file(events, trezor_base, chain_path))
+ {
+ MERROR("Failed to serialize data to file: " << chain_path);
+ }
+ }
+ }
+ CATCH_REPLAY(gen_trezor_base);
+ }
+
+ trezor_base.fix_hf(events);
+ if (generated && do_replay_events_get_core<gen_trezor_base>(events, core))
+ {
+ MGINFO_GREEN("#TEST-chain-init# Succeeded ");
+ }
+ else
+ {
+ MERROR("#TEST-chain-init# Failed ");
+ throw std::runtime_error("Chain init error");
+ }
+}
+
+static void add_hforks(std::vector<test_event_entry>& events, const v_hardforks_t& hard_forks)
+{
+ event_replay_settings repl_set;
+ repl_set.hard_forks = boost::make_optional(hard_forks);
+ events.push_back(repl_set);
+}
+
+static void add_top_hfork(std::vector<test_event_entry>& events, const v_hardforks_t& hard_forks)
+{
+ event_replay_settings repl_set;
+ v_hardforks_t top_fork;
+ top_fork.push_back(hard_forks.back());
+ repl_set.hard_forks = boost::make_optional(top_fork);
+ events.push_back(repl_set);
+}
+
+static crypto::public_key get_tx_pub_key_from_received_outs(const tools::wallet2::transfer_details &td)
+{
+ std::vector<tx_extra_field> tx_extra_fields;
+ parse_tx_extra(td.m_tx.extra, tx_extra_fields);
+
+ tx_extra_pub_key pub_key_field;
+ THROW_WALLET_EXCEPTION_IF(!find_tx_extra_field_by_type(tx_extra_fields, pub_key_field, 0), tools::error::wallet_internal_error,
+ "Public key wasn't found in the transaction extra");
+ const crypto::public_key tx_pub_key = pub_key_field.pub_key;
+ bool two_found = find_tx_extra_field_by_type(tx_extra_fields, pub_key_field, 1);
+ if (!two_found) {
+ return tx_pub_key;
+ } else {
+ throw std::runtime_error("Unsupported tx pub resolution");
+ }
+}
+
+static void setup_shim(hw::wallet_shim * shim)
+{
+ shim->get_tx_pub_key_from_received_outs = &get_tx_pub_key_from_received_outs;
+}
+
+bool get_short_payment_id(crypto::hash8 &payment_id8, const tools::wallet2::pending_tx &ptx, hw::device &hwdev)
+{
+ std::vector<tx_extra_field> tx_extra_fields;
+ parse_tx_extra(ptx.tx.extra, tx_extra_fields); // ok if partially parsed
+ cryptonote::tx_extra_nonce extra_nonce;
+ if (find_tx_extra_field_by_type(tx_extra_fields, extra_nonce))
+ {
+ if(get_encrypted_payment_id_from_tx_extra_nonce(extra_nonce.nonce, payment_id8))
+ {
+ if (ptx.dests.empty())
+ {
+ MWARNING("Encrypted payment id found, but no destinations public key, cannot decrypt");
+ return false;
+ }
+ return hwdev.decrypt_payment_id(payment_id8, ptx.dests[0].addr.m_view_public_key, ptx.tx_key);
+ }
+ }
+ return false;
+}
+
+static tools::wallet2::tx_construction_data get_construction_data_with_decrypted_short_payment_id(const tools::wallet2::pending_tx &ptx, hw::device &hwdev)
+{
+ tools::wallet2::tx_construction_data construction_data = ptx.construction_data;
+ crypto::hash8 payment_id = crypto::null_hash8;
+ if (get_short_payment_id(payment_id, ptx, hwdev))
+ {
+ // Remove encrypted
+ remove_field_from_tx_extra(construction_data.extra, typeid(cryptonote::tx_extra_nonce));
+ // Add decrypted
+ std::string extra_nonce;
+ set_encrypted_payment_id_to_tx_extra_nonce(extra_nonce, payment_id);
+ THROW_WALLET_EXCEPTION_IF(!add_extra_nonce_to_tx_extra(construction_data.extra, extra_nonce),
+ tools::error::wallet_internal_error, "Failed to add decrypted payment id to tx extra");
+ MDEBUG("Decrypted payment ID: " << payment_id);
+ }
+ return construction_data;
+}
+
+static std::string get_payment_id(const std::vector<uint8_t> &tx_extra)
+{
+ std::vector<cryptonote::tx_extra_field> tx_extra_fields;
+ cryptonote::parse_tx_extra(tx_extra, tx_extra_fields); // ok if partially parsed
+ cryptonote::tx_extra_nonce extra_nonce;
+
+ ::crypto::hash payment_id{};
+ if (find_tx_extra_field_by_type(tx_extra_fields, extra_nonce))
+ {
+ ::crypto::hash8 payment_id8{};
+ if(cryptonote::get_encrypted_payment_id_from_tx_extra_nonce(extra_nonce.nonce, payment_id8))
+ {
+ return std::string(payment_id8.data, 8);
+ }
+ else if (cryptonote::get_payment_id_from_tx_extra_nonce(extra_nonce.nonce, payment_id))
+ {
+ return std::string(payment_id.data, 32);
+ }
+ }
+ return std::string();
+}
+
+static crypto::hash8 to_short_payment_id(const std::string & payment_id)
+{
+ crypto::hash8 payment_id_short;
+ CHECK_AND_ASSERT_THROW_MES(payment_id.size() == 8, "Invalid argument");
+ memcpy(payment_id_short.data, payment_id.data(), 8);
+ return payment_id_short;
+}
+
+static crypto::hash to_long_payment_id(const std::string & payment_id)
+{
+ crypto::hash payment_id_long;
+ CHECK_AND_ASSERT_THROW_MES(payment_id.size() == 32, "Invalid argument");
+ memcpy(payment_id_long.data, payment_id.data(), 32);
+ return payment_id_long;
+}
+
+static std::vector<uint8_t> build_payment_id_extra(const std::string & payment_id)
+{
+ std::vector<uint8_t> res;
+
+ if (payment_id.size() == 8) {
+ std::string extra_nonce;
+ set_encrypted_payment_id_to_tx_extra_nonce(extra_nonce, to_short_payment_id(payment_id));
+ THROW_WALLET_EXCEPTION_IF(!add_extra_nonce_to_tx_extra(res, extra_nonce),
+ tools::error::wallet_internal_error, "Failed to add decrypted payment id to tx extra");
+
+ } else if (payment_id.size() == 32){
+ std::string extra_nonce;
+ set_payment_id_to_tx_extra_nonce(extra_nonce, to_long_payment_id(payment_id));
+ THROW_WALLET_EXCEPTION_IF(!add_extra_nonce_to_tx_extra(res, extra_nonce),
+ tools::error::wallet_internal_error, "Failed to add decrypted payment id to tx extra");
+ }
+
+ return res;
+}
+
+static cryptonote::address_parse_info init_addr_parse_info(cryptonote::account_public_address &addr, bool is_sub=false, boost::optional<crypto::hash8> payment_id = boost::none)
+{
+ cryptonote::address_parse_info res;
+ res.address = addr;
+ res.is_subaddress = is_sub;
+ if (payment_id){
+ res.has_payment_id = true;
+ res.payment_id = payment_id.get();
+ } else {
+ res.has_payment_id = false;
+ }
+ return res;
+}
+
+static void expand_tsx(cryptonote::transaction &tx)
+{
+ auto & rv = tx.rct_signatures;
+ if (rv.type == rct::RCTTypeFull)
+ {
+ rv.p.MGs.resize(1);
+ rv.p.MGs[0].II.resize(tx.vin.size());
+ for (size_t n = 0; n < tx.vin.size(); ++n)
+ rv.p.MGs[0].II[n] = rct::ki2rct(boost::get<txin_to_key>(tx.vin[n]).k_image);
+ }
+ else if (rv.type == rct::RCTTypeSimple || rv.type == rct::RCTTypeBulletproof || rv.type == rct::RCTTypeBulletproof2)
+ {
+ CHECK_AND_ASSERT_THROW_MES(rv.p.MGs.size() == tx.vin.size(), "Bad MGs size");
+ for (size_t n = 0; n < tx.vin.size(); ++n)
+ {
+ rv.p.MGs[n].II.resize(1);
+ rv.p.MGs[n].II[0] = rct::ki2rct(boost::get<txin_to_key>(tx.vin[n]).k_image);
+ }
+ }
+}
+
+static std::vector<tools::wallet2*> vct_wallets(tools::wallet2* w1=nullptr, tools::wallet2* w2=nullptr, tools::wallet2* w3=nullptr, tools::wallet2* w4=nullptr, tools::wallet2* w5=nullptr)
+{
+ std::vector<tools::wallet2*> res;
+ if (w1)
+ res.push_back(w1);
+ if (w2)
+ res.push_back(w2);
+ if (w3)
+ res.push_back(w3);
+ if (w4)
+ res.push_back(w4);
+ if (w5)
+ res.push_back(w5);
+ return res;
+}
+
+// gen_trezor_base
+const uint64_t gen_trezor_base::m_ts_start = 1338224400;
+const uint64_t gen_trezor_base::m_wallet_ts = m_ts_start - 60*60*24*4;
+const std::string gen_trezor_base::m_device_name = "Trezor:udp";
+const std::string gen_trezor_base::m_master_seed_str = "14821d0bc5659b24cafbc889dc4fc60785ee08b65d71c525f81eeaba4f3a570f";
+const std::string gen_trezor_base::m_device_seed = "permit universe parent weapon amused modify essay borrow tobacco budget walnut lunch consider gallery ride amazing frog forget treat market chapter velvet useless topple";
+const std::string gen_trezor_base::m_alice_spend_private = m_master_seed_str;
+const std::string gen_trezor_base::m_alice_view_private = "a6ccd4ac344a295d1387f8d18c81bdd394f1845de84188e204514ef9370fd403";
+
+gen_trezor_base::gen_trezor_base(){
+ m_rct_config = {rct::RangeProofPaddedBulletproof, 1};
+}
+
+gen_trezor_base::gen_trezor_base(const gen_trezor_base &other):
+ m_generator(other.m_generator), m_bt(other.m_bt), m_miner_account(other.m_miner_account),
+ m_bob_account(other.m_bob_account), m_alice_account(other.m_alice_account), m_eve_account(other.m_eve_account),
+ m_hard_forks(other.m_hard_forks), m_trezor(other.m_trezor), m_rct_config(other.m_rct_config)
+{
+
+}
+
+void gen_trezor_base::setup_args(const std::string & trezor_path, bool heavy_tests)
+{
+ m_trezor_path = trezor_path.empty() ? m_device_name : std::string("Trezor:") + trezor_path;
+ m_heavy_tests = heavy_tests;
+}
+
+void gen_trezor_base::setup_trezor()
+{
+ hw::device &hwdev = hw::get_device(m_trezor_path);
+ m_trezor = dynamic_cast<hw::trezor::device_trezor *>(&hwdev);
+ CHECK_AND_ASSERT_THROW_MES(m_trezor, "Dynamic cast failed");
+
+ m_trezor->set_debug(true); // debugging commands on Trezor (auto-confirm transactions)
+
+ CHECK_AND_ASSERT_THROW_MES(m_trezor->set_name(m_trezor_path), "Could not set device name " << m_trezor_path);
+ m_trezor->set_network_type(MAINNET);
+ m_trezor->set_derivation_path(""); // empty derivation path
+
+ CHECK_AND_ASSERT_THROW_MES(m_trezor->init(), "Could not initialize the device " << m_trezor_path);
+ CHECK_AND_ASSERT_THROW_MES(m_trezor->connect(), "Could not connect to the device " << m_trezor_path);
+ m_trezor->wipe_device();
+ m_trezor->load_device(m_device_seed);
+ m_trezor->release();
+ m_trezor->disconnect();
+}
+
+void gen_trezor_base::fork(gen_trezor_base & other)
+{
+ other.m_generator = m_generator;
+ other.m_bt = m_bt;
+ other.m_events = m_events;
+ other.m_head = m_head;
+ other.m_hard_forks = m_hard_forks;
+ other.m_trezor_path = m_trezor_path;
+ other.m_heavy_tests = m_heavy_tests;
+ other.m_rct_config = m_rct_config;
+
+ other.m_miner_account = m_miner_account;
+ other.m_bob_account = m_bob_account;
+ other.m_alice_account = m_alice_account;
+ other.m_eve_account = m_eve_account;
+ other.m_trezor = m_trezor;
+}
+
+void gen_trezor_base::clear()
+{
+ m_generator = test_generator();
+ m_bt = block_tracker();
+ m_events.clear();
+ m_hard_forks.clear();
+ m_trezor = nullptr;
+}
+
+void gen_trezor_base::add_shared_events(std::vector<test_event_entry>& events)
+{
+ events.reserve(m_events.size());
+ for(const test_event_entry & c : m_events){
+ events.push_back(c);
+ }
+}
+
+void gen_trezor_base::init_fields()
+{
+ m_miner_account.generate();
+ DEFAULT_HARDFORKS(m_hard_forks);
+
+ crypto::secret_key master_seed{};
+ CHECK_AND_ASSERT_THROW_MES(epee::string_tools::hex_to_pod(m_master_seed_str, master_seed), "Hexdecode fails");
+
+ m_alice_account.generate(master_seed, true);
+ m_alice_account.set_createtime(m_wallet_ts);
+}
+
+bool gen_trezor_base::generate(std::vector<test_event_entry>& events)
+{
+ init_fields();
+ setup_trezor();
+ m_alice_account.create_from_device(*m_trezor);
+ m_alice_account.set_createtime(m_wallet_ts);
+
+ // Events, custom genesis so it matches wallet genesis
+ auto & generator = m_generator; // macro shortcut
+
+ cryptonote::block blk_gen;
+ std::vector<size_t> block_weights;
+ generate_genesis_block(blk_gen, get_config(MAINNET).GENESIS_TX, get_config(MAINNET).GENESIS_NONCE);
+ events.push_back(blk_gen);
+ generator.add_block(blk_gen, 0, block_weights, 0);
+
+ // First event has to be the genesis block
+ m_bob_account.generate();
+ m_eve_account.generate();
+ m_bob_account.set_createtime(m_wallet_ts);
+ m_eve_account.set_createtime(m_wallet_ts);
+ cryptonote::account_base * accounts[] = {TREZOR_ACCOUNT_ORDERING};
+ for(cryptonote::account_base * ac : accounts){
+ events.push_back(*ac);
+ }
+
+ // Another block with predefined timestamp.
+ // Carefully set reward and already generated coins so it passes miner_tx check.
+ cryptonote::block blk_0;
+ {
+ std::list<cryptonote::transaction> tx_list;
+ const crypto::hash prev_id = get_block_hash(blk_gen);
+ const uint64_t already_generated_coins = generator.get_already_generated_coins(prev_id);
+ block_weights.clear();
+ generator.get_last_n_block_weights(block_weights, prev_id, CRYPTONOTE_REWARD_BLOCKS_WINDOW);
+ generator.construct_block(blk_0, 1, prev_id, m_miner_account, m_ts_start, already_generated_coins, block_weights, tx_list);
+ }
+
+ events.push_back(blk_0);
+ MDEBUG("Gen+1 block has time: " << blk_0.timestamp << " blid: " << get_block_hash(blk_0));
+
+ // Generate some spendable funds on the Miner account
+ REWIND_BLOCKS_N(events, blk_3, blk_0, m_miner_account, 40);
+
+ // Rewind so the miners funds are unlocked for initial transactions.
+ REWIND_BLOCKS(events, blk_3r, blk_3, m_miner_account);
+
+ // Non-rct transactions Miner -> Bob
+ MAKE_TX_LIST_START(events, txs_blk_4, m_miner_account, m_alice_account, MK_COINS(10), blk_3);
+ MAKE_TX_LIST(events, txs_blk_4, m_miner_account, m_alice_account, MK_COINS(7), blk_3);
+ MAKE_TX_LIST(events, txs_blk_4, m_miner_account, m_alice_account, MK_COINS(7), blk_3);
+ MAKE_TX_LIST(events, txs_blk_4, m_miner_account, m_alice_account, MK_COINS(14), blk_3);
+ MAKE_TX_LIST(events, txs_blk_4, m_miner_account, m_alice_account, MK_COINS(20), blk_3);
+ MAKE_TX_LIST(events, txs_blk_4, m_miner_account, m_alice_account, MK_COINS(2), blk_3);
+ MAKE_TX_LIST(events, txs_blk_4, m_miner_account, m_alice_account, MK_COINS(2), blk_3);
+ MAKE_TX_LIST(events, txs_blk_4, m_miner_account, m_alice_account, MK_COINS(5), blk_3);
+ MAKE_NEXT_BLOCK_TX_LIST(events, blk_4, blk_3r, m_miner_account, txs_blk_4);
+ REWIND_BLOCKS(events, blk_4r, blk_4, m_miner_account); // rewind to unlock
+
+ // Hard fork to bulletproofs version, v9.
+ const uint8_t CUR_HF = 9;
+ auto hardfork_height = num_blocks(events); // next block is v9
+ ADD_HARDFORK(m_hard_forks, CUR_HF, hardfork_height);
+ add_hforks(events, m_hard_forks);
+ MDEBUG("Hardfork height: " << hardfork_height << " at block: " << get_block_hash(blk_4r));
+
+ // RCT transactions, wallets have to be used, wallet init
+ m_wl_alice.reset(new tools::wallet2(MAINNET, 1, true));
+ m_wl_bob.reset(new tools::wallet2(MAINNET, 1, true));
+ wallet_accessor_test::set_account(m_wl_alice.get(), m_alice_account);
+ wallet_accessor_test::set_account(m_wl_bob.get(), m_bob_account);
+
+ auto addr_alice_sub_0_1 = m_wl_alice->get_subaddress({0, 1});
+ auto addr_alice_sub_0_2 = m_wl_alice->get_subaddress({0, 2});
+ auto addr_alice_sub_0_3 = m_wl_alice->get_subaddress({0, 3});
+ auto addr_alice_sub_0_4 = m_wl_alice->get_subaddress({0, 4});
+ auto addr_alice_sub_0_5 = m_wl_alice->get_subaddress({0, 5});
+ auto addr_alice_sub_1_0 = m_wl_alice->get_subaddress({1, 0});
+ auto addr_alice_sub_1_1 = m_wl_alice->get_subaddress({1, 1});
+ auto addr_alice_sub_1_2 = m_wl_alice->get_subaddress({1, 2});
+
+ // Miner -> Bob, RCT funds
+ MAKE_TX_LIST_START_RCT(events, txs_blk_5, m_miner_account, m_alice_account, MK_COINS(5), 10, blk_4);
+
+ const size_t target_rct = m_heavy_tests ? 105 : 15;
+ for(size_t i = 0; i < target_rct; ++i)
+ {
+ MAKE_TX_MIX_LIST_RCT(events, txs_blk_5, m_miner_account, m_alice_account, MK_COINS(1) >> 2, 10, blk_4);
+ }
+
+ // Sub-address destinations
+ MAKE_TX_MIX_DEST_LIST_RCT(events, txs_blk_5, m_miner_account, build_dsts(addr_alice_sub_0_1, true, MK_COINS(1) >> 1), 10, blk_4);
+ MAKE_TX_MIX_DEST_LIST_RCT(events, txs_blk_5, m_miner_account, build_dsts(addr_alice_sub_0_2, true, MK_COINS(1) >> 1), 10, blk_4);
+ MAKE_TX_MIX_DEST_LIST_RCT(events, txs_blk_5, m_miner_account, build_dsts(addr_alice_sub_0_3, true, MK_COINS(1) >> 1), 10, blk_4);
+ MAKE_TX_MIX_DEST_LIST_RCT(events, txs_blk_5, m_miner_account, build_dsts(addr_alice_sub_0_4, true, MK_COINS(1) >> 1), 10, blk_4);
+
+ // Sub-address destinations + multi out to force use of additional keys
+ MAKE_TX_MIX_DEST_LIST_RCT(events, txs_blk_5, m_miner_account, build_dsts({{addr_alice_sub_0_1, true, MK_COINS(1) >> 1}, {addr_alice_sub_0_2, true, MK_COINS(1) >> 1}}), 10, blk_4);
+ MAKE_TX_MIX_DEST_LIST_RCT(events, txs_blk_5, m_miner_account, build_dsts({{addr_alice_sub_0_1, true, MK_COINS(1) >> 1}, {addr_alice_sub_0_2, true, MK_COINS(1) >> 1}, {addr_alice_sub_0_3, true, MK_COINS(1) >> 1}}), 10, blk_4);
+ MAKE_TX_MIX_DEST_LIST_RCT(events, txs_blk_5, m_miner_account, build_dsts({{m_miner_account, false, MK_COINS(1) >> 1}, {addr_alice_sub_0_2, true, MK_COINS(1) >> 1}, {addr_alice_sub_0_3, true, MK_COINS(1) >> 1}}), 10, blk_4);
+ MAKE_TX_MIX_DEST_LIST_RCT(events, txs_blk_5, m_miner_account, build_dsts({{m_miner_account, false, MK_COINS(1) >> 1}, {addr_alice_sub_0_2, true, MK_COINS(1) >> 1}, {addr_alice_sub_0_3, true, MK_COINS(1) >> 1}}), 10, blk_4);
+
+ // Transfer to other accounts
+ MAKE_TX_MIX_DEST_LIST_RCT(events, txs_blk_5, m_miner_account, build_dsts(addr_alice_sub_1_0, true, MK_COINS(1) >> 1), 10, blk_4);
+ MAKE_TX_MIX_DEST_LIST_RCT(events, txs_blk_5, m_miner_account, build_dsts(addr_alice_sub_1_1, true, MK_COINS(1) >> 1), 10, blk_4);
+ MAKE_TX_MIX_DEST_LIST_RCT(events, txs_blk_5, m_miner_account, build_dsts({{addr_alice_sub_1_0, true, MK_COINS(1) >> 1}, {addr_alice_sub_1_1, true, MK_COINS(1) >> 1}, {addr_alice_sub_0_3, true, MK_COINS(1) >> 1}}), 10, blk_4);
+ MAKE_TX_MIX_DEST_LIST_RCT(events, txs_blk_5, m_miner_account, build_dsts({{addr_alice_sub_1_1, true, MK_COINS(1) >> 1}, {addr_alice_sub_1_1, true, MK_COINS(1) >> 1}, {addr_alice_sub_0_2, true, MK_COINS(1) >> 1}}), 10, blk_4);
+ MAKE_TX_MIX_DEST_LIST_RCT(events, txs_blk_5, m_miner_account, build_dsts({{addr_alice_sub_1_2, true, MK_COINS(1) >> 1}, {addr_alice_sub_1_1, true, MK_COINS(1) >> 1}, {addr_alice_sub_0_5, true, MK_COINS(1) >> 1}}), 10, blk_4);
+
+ // Simple RCT transactions
+ MAKE_TX_MIX_LIST_RCT(events, txs_blk_5, m_miner_account, m_alice_account, MK_COINS(7), 10, blk_4);
+ MAKE_TX_MIX_LIST_RCT(events, txs_blk_5, m_miner_account, m_alice_account, MK_COINS(1), 10, blk_4);
+ MAKE_TX_MIX_LIST_RCT(events, txs_blk_5, m_miner_account, m_alice_account, MK_COINS(3), 10, blk_4);
+ MAKE_TX_MIX_LIST_RCT(events, txs_blk_5, m_miner_account, m_alice_account, MK_COINS(4), 10, blk_4);
+ MAKE_NEXT_BLOCK_TX_LIST_HF(events, blk_5, blk_4r, m_miner_account, txs_blk_5, CUR_HF);
+
+ // Simple transaction check
+ bool resx = rct::verRctSemanticsSimple(txs_blk_5.begin()->rct_signatures);
+ bool resy = rct::verRctNonSemanticsSimple(txs_blk_5.begin()->rct_signatures);
+ CHECK_AND_ASSERT_THROW_MES(resx, "Tsx5[0] semantics failed");
+ CHECK_AND_ASSERT_THROW_MES(resy, "Tsx5[0] non-semantics failed");
+
+ REWIND_BLOCKS_HF(events, blk_5r, blk_5, m_miner_account, CUR_HF); // rewind to unlock
+
+ // RCT transactions, wallets have to be used
+ wallet_tools::process_transactions(m_wl_alice.get(), events, blk_5r, m_bt);
+ wallet_tools::process_transactions(m_wl_bob.get(), events, blk_5r, m_bt);
+
+ // Send Alice -> Bob, manually constructed. Simple TX test, precondition.
+ cryptonote::transaction tx_1;
+ std::vector<size_t> selected_transfers;
+ std::vector<tx_source_entry> sources;
+ bool res = wallet_tools::fill_tx_sources(m_wl_alice.get(), sources, TREZOR_TEST_MIXIN, boost::none, MK_COINS(2), m_bt, selected_transfers, num_blocks(events) - 1, 0, 1);
+ CHECK_AND_ASSERT_THROW_MES(res, "TX Fill sources failed");
+
+ construct_tx_to_key(tx_1, m_wl_alice.get(), m_bob_account, MK_COINS(1), sources, TREZOR_TEST_FEE, true, rct::RangeProofPaddedBulletproof, 1);
+ events.push_back(tx_1);
+ MAKE_NEXT_BLOCK_TX1_HF(events, blk_6, blk_5r, m_miner_account, tx_1, CUR_HF);
+ MDEBUG("Post 1st tsx: " << (num_blocks(events) - 1) << " at block: " << get_block_hash(blk_6));
+
+ // Simple transaction check
+ resx = rct::verRctSemanticsSimple(tx_1.rct_signatures);
+ resy = rct::verRctNonSemanticsSimple(tx_1.rct_signatures);
+ CHECK_AND_ASSERT_THROW_MES(resx, "tx_1 semantics failed");
+ CHECK_AND_ASSERT_THROW_MES(resy, "tx_1 non-semantics failed");
+
+ REWIND_BLOCKS_HF(events, blk_6r, blk_6, m_miner_account, CUR_HF);
+ m_head = blk_6r;
+ m_events = events;
+ return true;
+}
+
+void gen_trezor_base::load(std::vector<test_event_entry>& events)
+{
+ init_fields();
+ m_events = events;
+
+ unsigned acc_idx = 0;
+ cryptonote::account_base * accounts[] = {TREZOR_ACCOUNT_ORDERING};
+ unsigned accounts_num = (sizeof(accounts) / sizeof(accounts[0]));
+
+ for(auto & ev : events)
+ {
+ if (typeid(cryptonote::block) == ev.type())
+ {
+ m_head = boost::get<cryptonote::block>(ev);
+ }
+ else if (typeid(cryptonote::account_base) == ev.type()) // accounts
+ {
+ const auto & acc = boost::get<cryptonote::account_base>(ev);
+ if (acc_idx < accounts_num)
+ {
+ *accounts[acc_idx++] = acc;
+ }
+ }
+ else if (typeid(event_replay_settings) == ev.type()) // hard forks
+ {
+ const auto & rep_settings = boost::get<event_replay_settings>(ev);
+ if (rep_settings.hard_forks)
+ {
+ const auto & hf = rep_settings.hard_forks.get();
+ std::copy(hf.begin(), hf.end(), std::back_inserter(m_hard_forks));
+ }
+ }
+ }
+
+ // Setup wallets, synchronize blocks
+ m_bob_account.set_createtime(m_wallet_ts);
+ m_eve_account.set_createtime(m_wallet_ts);
+
+ setup_trezor();
+ m_alice_account.create_from_device(*m_trezor);
+ m_alice_account.set_createtime(m_wallet_ts);
+
+ m_wl_alice.reset(new tools::wallet2(MAINNET, 1, true));
+ m_wl_bob.reset(new tools::wallet2(MAINNET, 1, true));
+ m_wl_eve.reset(new tools::wallet2(MAINNET, 1, true));
+ wallet_accessor_test::set_account(m_wl_alice.get(), m_alice_account);
+ wallet_accessor_test::set_account(m_wl_bob.get(), m_bob_account);
+ wallet_accessor_test::set_account(m_wl_eve.get(), m_eve_account);
+
+ wallet_tools::process_transactions(m_wl_alice.get(), events, m_head, m_bt);
+ wallet_tools::process_transactions(m_wl_bob.get(), events, m_head, m_bt);
+}
+
+void gen_trezor_base::fix_hf(std::vector<test_event_entry>& events)
+{
+ // If current test requires higher hard-fork, move it up
+ const auto current_hf = m_hard_forks.back().first;
+ if (m_rct_config.bp_version == 2 && current_hf < 10){
+ auto hardfork_height = num_blocks(events);
+ ADD_HARDFORK(m_hard_forks, 10, hardfork_height);
+ add_top_hfork(events, m_hard_forks);
+ MDEBUG("Hardfork height: " << hardfork_height);
+ }
+}
+
+void gen_trezor_base::update_trackers(std::vector<test_event_entry>& events)
+{
+ wallet_tools::process_transactions(nullptr, events, m_head, m_bt);
+}
+
+void gen_trezor_base::test_setup(std::vector<test_event_entry>& events)
+{
+ add_shared_events(events);
+
+ setup_trezor();
+ m_alice_account.create_from_device(*m_trezor);
+ m_alice_account.set_createtime(m_wallet_ts);
+
+ m_wl_alice.reset(new tools::wallet2(MAINNET, 1, true));
+ m_wl_bob.reset(new tools::wallet2(MAINNET, 1, true));
+ m_wl_eve.reset(new tools::wallet2(MAINNET, 1, true));
+ wallet_accessor_test::set_account(m_wl_alice.get(), m_alice_account);
+ wallet_accessor_test::set_account(m_wl_bob.get(), m_bob_account);
+ wallet_accessor_test::set_account(m_wl_eve.get(), m_eve_account);
+ wallet_tools::process_transactions(m_wl_alice.get(), events, m_head, m_bt);
+ wallet_tools::process_transactions(m_wl_bob.get(), events, m_head, m_bt);
+ wallet_tools::process_transactions(m_wl_eve.get(), events, m_head, m_bt);
+}
+
+void gen_trezor_base::test_trezor_tx(std::vector<test_event_entry>& events, std::vector<tools::wallet2::pending_tx>& ptxs, std::vector<cryptonote::address_parse_info>& dsts_info, test_generator &generator, std::vector<tools::wallet2*> wallets, bool is_sweep)
+{
+ // Construct pending transaction for signature in the Trezor.
+ const uint64_t height_pre = num_blocks(events) - 1;
+ cryptonote::block head_block = get_head_block(events);
+ const crypto::hash head_hash = get_block_hash(head_block);
+
+ // If current test requires higher hard-fork, move it up
+ const auto current_hf = m_hard_forks.back().first;
+ const uint8_t tx_hf = m_rct_config.bp_version == 2 ? 10 : 9;
+ if (tx_hf > current_hf){
+ throw std::runtime_error("Too late for HF change");
+ }
+
+ tools::wallet2::unsigned_tx_set txs;
+ std::list<cryptonote::transaction> tx_list;
+
+ for(auto &ptx : ptxs) {
+ txs.txes.push_back(get_construction_data_with_decrypted_short_payment_id(ptx, *m_trezor));
+ }
+ txs.transfers = std::make_pair(0, wallet_accessor_test::get_transfers(m_wl_alice.get()));
+
+ auto dev_cold = dynamic_cast<::hw::device_cold*>(m_trezor);
+ CHECK_AND_ASSERT_THROW_MES(dev_cold, "Device does not implement cold signing interface");
+
+ tools::wallet2::signed_tx_set exported_txs;
+ hw::tx_aux_data aux_data;
+ hw::wallet_shim wallet_shim;
+ setup_shim(&wallet_shim);
+ aux_data.tx_recipients = dsts_info;
+ dev_cold->tx_sign(&wallet_shim, txs, exported_txs, aux_data);
+
+ MDEBUG("Signed tx data from hw: " << exported_txs.ptx.size() << " transactions");
+ CHECK_AND_ASSERT_THROW_MES(exported_txs.ptx.size() == ptxs.size(), "Invalid transaction sizes");
+
+ for (size_t i = 0; i < exported_txs.ptx.size(); ++i){
+ auto &c_ptx = exported_txs.ptx[i];
+ c_ptx.tx.rct_signatures.mixRing = ptxs[i].tx.rct_signatures.mixRing;
+ expand_tsx(c_ptx.tx);
+
+ // Simple TX tests, more complex are performed in the core.
+ MTRACE(cryptonote::obj_to_json_str(c_ptx.tx));
+ bool resx = rct::verRctSemanticsSimple(c_ptx.tx.rct_signatures);
+ bool resy = rct::verRctNonSemanticsSimple(c_ptx.tx.rct_signatures);
+ CHECK_AND_ASSERT_THROW_MES(resx, "Trezor tx_1 semantics failed");
+ CHECK_AND_ASSERT_THROW_MES(resy, "Trezor tx_1 Nonsemantics failed");
+
+ events.push_back(c_ptx.tx);
+ tx_list.push_back(c_ptx.tx);
+ MDEBUG("Transaction: " << dump_data(c_ptx.tx));
+ }
+
+ MAKE_NEXT_BLOCK_TX_LIST_HF(events, blk_7, m_head, m_miner_account, tx_list, tx_hf);
+ MDEBUG("Trezor tsx: " << (num_blocks(events) - 1) << " at block: " << get_block_hash(blk_7));
+
+ // TX receive test
+ uint64_t sum_in = 0;
+ uint64_t sum_out = 0;
+
+ for(size_t txid = 0; txid < exported_txs.ptx.size(); ++txid) {
+ auto &c_ptx = exported_txs.ptx[txid];
+ auto &c_tx = c_ptx.tx;
+ const crypto::hash txhash = cryptonote::get_transaction_hash(c_tx);
+ const size_t num_outs = c_tx.vout.size();
+ size_t num_received = 0;
+ uint64_t cur_sum_in = 0;
+ uint64_t cur_sum_out = 0;
+ uint64_t cur_sum_out_recv = 0;
+ std::unordered_set<size_t> recv_out_idx;
+ std::string exp_payment_id = get_payment_id(c_ptx.construction_data.extra);
+ std::string enc_payment_id = get_payment_id(c_tx.extra);
+ size_t num_payment_id_checks_done = 0;
+
+ CHECK_AND_ASSERT_THROW_MES(exp_payment_id.empty() || exp_payment_id.size() == 8 || exp_payment_id.size() == 32, "Required payment ID invalid");
+ CHECK_AND_ASSERT_THROW_MES((exp_payment_id.size() == 32) == (enc_payment_id.size() == 32), "Required and built payment ID size mismatch");
+ CHECK_AND_ASSERT_THROW_MES(exp_payment_id.size() <= enc_payment_id.size(), "Required and built payment ID size mismatch");
+
+ for(auto &src : c_ptx.construction_data.sources){
+ cur_sum_in += src.amount;
+ }
+
+ for(auto &dst : c_ptx.construction_data.splitted_dsts){
+ cur_sum_out += dst.amount;
+ }
+
+ CHECK_AND_ASSERT_THROW_MES(c_tx.rct_signatures.txnFee + cur_sum_out == cur_sum_in, "Tx Input Output amount mismatch");
+
+ for (size_t widx = 0; widx < wallets.size(); ++widx) {
+ const bool sender = widx == 0;
+ tools::wallet2 *wl = wallets[widx];
+
+ wallet_tools::process_transactions(wl, events, blk_7, m_bt, boost::make_optional(head_hash));
+
+ tools::wallet2::transfer_container m_trans;
+ tools::wallet2::transfer_container m_trans_txid;
+ wl->get_transfers(m_trans);
+
+ std::copy_if(m_trans.begin(), m_trans.end(), std::back_inserter(m_trans_txid), [&txhash](const tools::wallet2::transfer_details& item) {
+ return item.m_txid == txhash;
+ });
+
+ // Testing if the transaction output has been received
+ num_received += m_trans_txid.size();
+ for (auto & ctran : m_trans_txid){
+ cur_sum_out_recv += ctran.amount();
+ recv_out_idx.insert(ctran.m_internal_output_index);
+ CHECK_AND_ASSERT_THROW_MES(!ctran.m_spent, "Txout is spent");
+ CHECK_AND_ASSERT_THROW_MES(!sender || ctran.m_key_image_known, "Key Image unknown for recipient"); // sender is Trezor, does not need to have KI
+ }
+
+ // Sender output payment (contains change and stuff)
+ if (sender) {
+ std::list<std::pair<crypto::hash, tools::wallet2::confirmed_transfer_details>> confirmed_transfers; // txid -> tdetail
+ std::list<std::pair<crypto::hash, tools::wallet2::confirmed_transfer_details>> confirmed_transfers_txid; // txid -> tdetail
+ wl->get_payments_out(confirmed_transfers, height_pre);
+
+ std::copy_if(confirmed_transfers.begin(), confirmed_transfers.end(), std::back_inserter(confirmed_transfers_txid), [&txhash](const std::pair<crypto::hash, tools::wallet2::confirmed_transfer_details>& item) {
+ return item.first == txhash;
+ });
+
+ CHECK_AND_ASSERT_THROW_MES(confirmed_transfers_txid.size() == 1, "Sender does not have outgoing transfer for the transaction");
+ }
+
+ // Received payment from the block
+ std::list<std::pair<crypto::hash, tools::wallet2::payment_details>> payments; // payment id -> [payment details] multimap
+ std::list<std::pair<crypto::hash, tools::wallet2::payment_details>> payments_txid; // payment id -> [payment details] multimap
+ wl->get_payments(payments, height_pre);
+
+ std::copy_if(payments.begin(), payments.end(), std::back_inserter(payments_txid), [&txhash](const std::pair<crypto::hash, tools::wallet2::payment_details>& item) {
+ return item.second.m_tx_hash == txhash;
+ });
+
+ for(auto &paydet : payments_txid){
+ CHECK_AND_ASSERT_THROW_MES(exp_payment_id.empty() || (memcmp(exp_payment_id.data(), paydet.first.data, exp_payment_id.size()) == 0), "Payment ID mismatch");
+ num_payment_id_checks_done += 1;
+ }
+ }
+
+ CHECK_AND_ASSERT_THROW_MES(c_tx.rct_signatures.txnFee + cur_sum_out_recv == cur_sum_in, "Tx Input Output amount mismatch");
+ CHECK_AND_ASSERT_THROW_MES(exp_payment_id.empty() || num_payment_id_checks_done > 0, "No Payment ID checks");
+
+ if(!is_sweep){
+ CHECK_AND_ASSERT_THROW_MES(num_received == num_outs, "Number of received outputs do not match number of outgoing");
+ CHECK_AND_ASSERT_THROW_MES(recv_out_idx.size() == num_outs, "Num of outs received do not match");
+ } else {
+ CHECK_AND_ASSERT_THROW_MES(num_received + 1 >= num_outs, "Number of received outputs do not match number of outgoing");
+ CHECK_AND_ASSERT_THROW_MES(recv_out_idx.size() + 1 >= num_outs, "Num of outs received do not match"); // can have dummy out
+ }
+
+ sum_in += cur_sum_in;
+ sum_out += cur_sum_out + c_tx.rct_signatures.txnFee;
+ }
+
+ CHECK_AND_ASSERT_THROW_MES(sum_in == sum_out, "Tx amount mismatch");
+}
+
+#define TREZOR_TEST_PREFIX() \
+ test_generator generator(m_generator); \
+ test_setup(events); \
+ tsx_builder t_builder_o(this); \
+ tsx_builder * t_builder = &t_builder_o
+
+#define TREZOR_TEST_SUFFIX() \
+ auto _dsts = t_builder->build(); \
+ auto _dsts_info = t_builder->dest_info(); \
+ test_trezor_tx(events, _dsts, _dsts_info, generator, vct_wallets(m_wl_alice.get(), m_wl_bob.get(), m_wl_eve.get())); \
+ return true
+
+#define TREZOR_SKIP_IF_VERSION_LEQ(x) if (m_trezor->get_version() <= x) { MDEBUG("Test skipped"); return true; }
+#define TREZOR_TEST_PAYMENT_ID "\xde\xad\xc0\xde\xde\xad\xc0\xde"
+#define TREZOR_TEST_PAYMENT_ID_LONG "\xde\xad\xc0\xde\xde\xad\xc0\xde\xde\xad\xc0\xde\xde\xad\xc0\xde\xde\xad\xc0\xde\xde\xad\xc0\xde\xde\xad\xc0\xde\xde\xad\xc0\xde"
+
+tsx_builder * tsx_builder::sources(std::vector<cryptonote::tx_source_entry> & sources, std::vector<size_t> & selected_transfers)
+{
+ m_sources = sources;
+ m_selected_transfers = selected_transfers;
+ return this;
+}
+
+tsx_builder * tsx_builder::compute_sources(boost::optional<size_t> num_utxo, boost::optional<uint64_t> min_amount, ssize_t offset, int step, boost::optional<fnc_accept_tx_source_t> fnc_accept)
+{
+ CHECK_AND_ASSERT_THROW_MES(m_tester, "m_tester wallet empty");
+ CHECK_AND_ASSERT_THROW_MES(m_from, "m_from wallet empty");
+
+ // typedef std::function<bool(const tx_source_info_crate_t &info, bool &abort)> fnc_accept_tx_source_t;
+ boost::optional<fnc_accept_tx_source_t> fnc_accept_to_use = boost::none;
+
+ auto c_account = m_account;
+ fnc_accept_tx_source_t fnc_acc = [c_account, &fnc_accept] (const tx_source_info_crate_t &info, bool &abort) -> bool {
+ if (info.td->m_subaddr_index.major != c_account){
+ return false;
+ }
+ if (fnc_accept){
+ return (fnc_accept.get())(info, abort);
+ }
+ return true;
+ };
+
+ fnc_accept_to_use = fnc_acc;
+ bool res = wallet_tools::fill_tx_sources(m_from, m_sources, m_mixin, num_utxo, min_amount, m_tester->m_bt, m_selected_transfers, m_cur_height, offset, step, fnc_accept_to_use);
+ CHECK_AND_ASSERT_THROW_MES(res, "Tx source fill error");
+ return this;
+}
+
+tsx_builder * tsx_builder::compute_sources_to_sub(boost::optional<size_t> num_utxo, boost::optional<uint64_t> min_amount, ssize_t offset, int step, boost::optional<fnc_accept_tx_source_t> fnc_accept)
+{
+ fnc_accept_tx_source_t fnc = [&fnc_accept] (const tx_source_info_crate_t &info, bool &abort) -> bool {
+ if (info.td->m_subaddr_index.minor == 0){
+ return false;
+ }
+ if (fnc_accept){
+ return (fnc_accept.get())(info, abort);
+ }
+ return true;
+ };
+
+ return compute_sources(num_utxo, min_amount, offset, step, fnc);
+}
+
+tsx_builder * tsx_builder::compute_sources_to_sub_acc(boost::optional<size_t> num_utxo, boost::optional<uint64_t> min_amount, ssize_t offset, int step, boost::optional<fnc_accept_tx_source_t> fnc_accept)
+{
+ fnc_accept_tx_source_t fnc = [&fnc_accept] (const tx_source_info_crate_t &info, bool &abort) -> bool {
+ if (info.td->m_subaddr_index.minor == 0 || info.src->real_out_additional_tx_keys.size() == 0){
+ return false;
+ }
+ if (fnc_accept){
+ return (fnc_accept.get())(info, abort);
+ }
+ return true;
+ };
+
+ return compute_sources(num_utxo, min_amount, offset, step, fnc);
+}
+
+tsx_builder * tsx_builder::destinations(std::vector<cryptonote::tx_destination_entry> &dsts)
+{
+ m_destinations_orig = dsts;
+ return this;
+}
+
+tsx_builder * tsx_builder::add_destination(const cryptonote::tx_destination_entry &dst)
+{
+ m_destinations_orig.push_back(dst);
+ return this;
+}
+
+tsx_builder * tsx_builder::add_destination(const var_addr_t addr, bool is_subaddr, uint64_t amount)
+{
+ m_destinations_orig.push_back(build_dst(addr, is_subaddr, amount));
+ return this;
+}
+
+tsx_builder * tsx_builder::add_destination(const tools::wallet2 * wallet, bool is_subaddr, uint64_t amount)
+{
+ m_destinations_orig.push_back(build_dst(get_address(wallet), is_subaddr, amount));
+ return this;
+}
+
+tsx_builder * tsx_builder::set_integrated(size_t idx)
+{
+ m_integrated.insert(idx);
+ return this;
+}
+
+tsx_builder * tsx_builder::clear_current()
+{
+ m_account = 0;
+ m_selected_transfers.clear();
+ m_sources.clear();
+ m_destinations.clear();
+ m_destinations_orig.clear();
+ m_dsts_info.clear();
+ m_integrated.clear();
+ m_payment_id.clear();
+ return this;
+}
+
+tsx_builder * tsx_builder::build_tx()
+{
+ CHECK_AND_ASSERT_THROW_MES(m_tester, "m_tester wallet empty");
+ CHECK_AND_ASSERT_THROW_MES(m_from, "m_from wallet empty");
+
+ // Amount sanity check input >= fee + outputs
+ const uint64_t out_amount = sum_amount(m_destinations_orig);
+ const uint64_t in_amount = sum_amount(m_sources);
+ CHECK_AND_ASSERT_THROW_MES(in_amount >= out_amount + m_fee, "Not enough input credits for outputs and fees");
+
+ // Create new pending transaction, init with sources and destinations
+ m_ptxs.emplace_back();
+ auto & ptx = m_ptxs.back();
+
+ std::vector<uint8_t> extra = build_payment_id_extra(m_payment_id);
+ fill_tx_destinations(m_from->get_subaddress({m_account, 0}), m_destinations_orig, m_fee, m_sources, m_destinations, true);
+ construct_pending_tx(ptx, extra);
+
+ ptx.construction_data.subaddr_account = m_account;
+
+ // Build destinations parse info
+ for(size_t i = 0; i < m_destinations_orig.size(); ++i){
+ auto & cdest = m_destinations_orig[i];
+ cryptonote::address_parse_info info = init_addr_parse_info(cdest.addr, cdest.is_subaddress);
+ if (m_integrated.find(i) != m_integrated.end()){
+ CHECK_AND_ASSERT_THROW_MES(m_payment_id.size() == 8, "Integrated set but payment_id.size() != 8");
+ info.has_payment_id = true;
+ info.payment_id = to_short_payment_id(m_payment_id);
+ }
+
+ m_dsts_info.push_back(info);
+ }
+
+ return this;
+}
+
+tsx_builder * tsx_builder::construct_pending_tx(tools::wallet2::pending_tx &ptx, boost::optional<std::vector<uint8_t>> extra)
+{
+ CHECK_AND_ASSERT_THROW_MES(m_from, "Wallet not provided");
+
+ cryptonote::transaction tx;
+ subaddresses_t & subaddresses = wallet_accessor_test::get_subaddresses(m_from);
+ crypto::secret_key tx_key;
+ std::vector<crypto::secret_key> additional_tx_keys;
+ std::vector<tx_destination_entry> destinations_copy = m_destinations;
+
+ auto change_addr = m_from->get_account().get_keys().m_account_address;
+ bool r = construct_tx_and_get_tx_key(m_from->get_account().get_keys(), subaddresses, m_sources, destinations_copy,
+ change_addr, extra ? extra.get() : std::vector<uint8_t>(), tx, 0, tx_key,
+ additional_tx_keys, true, m_rct_config, nullptr);
+
+ CHECK_AND_ASSERT_THROW_MES(r, "Transaction construction failed");
+
+ ptx.key_images = "";
+ ptx.fee = TESTS_DEFAULT_FEE;
+ ptx.dust = 0;
+ ptx.dust_added_to_fee = false;
+ ptx.tx = tx;
+ ptx.change_dts = m_destinations.back();
+ ptx.selected_transfers = m_selected_transfers;
+ ptx.tx_key = tx_key;
+ ptx.additional_tx_keys = additional_tx_keys;
+ ptx.dests = m_destinations;
+ ptx.multisig_sigs.clear();
+ ptx.construction_data.sources = m_sources;
+ ptx.construction_data.change_dts = m_destinations.back();
+ ptx.construction_data.splitted_dsts = m_destinations;
+ ptx.construction_data.selected_transfers = ptx.selected_transfers;
+ ptx.construction_data.extra = tx.extra;
+ ptx.construction_data.unlock_time = 0;
+ ptx.construction_data.use_rct = true;
+ ptx.construction_data.use_bulletproofs = true;
+ ptx.construction_data.dests = m_destinations_orig;
+
+ ptx.construction_data.subaddr_account = 0;
+ ptx.construction_data.subaddr_indices.clear();
+ for(uint32_t i = 0; i < 20; ++i)
+ ptx.construction_data.subaddr_indices.insert(i);
+
+ return this;
+}
+
+std::vector<tools::wallet2::pending_tx> tsx_builder::build()
+{
+ return m_ptxs;
+}
+
+bool gen_trezor_ki_sync::generate(std::vector<test_event_entry>& events)
+{
+ test_generator generator(m_generator);
+ test_setup(events);
+
+ auto dev_cold = dynamic_cast<::hw::device_cold*>(m_trezor);
+ CHECK_AND_ASSERT_THROW_MES(dev_cold, "Device does not implement cold signing interface");
+
+ std::vector<std::pair<crypto::key_image, crypto::signature>> ski;
+ tools::wallet2::transfer_container transfers;
+ hw::wallet_shim wallet_shim;
+ setup_shim(&wallet_shim);
+ m_wl_alice->get_transfers(transfers);
+
+ dev_cold->ki_sync(&wallet_shim, transfers, ski);
+ CHECK_AND_ASSERT_THROW_MES(ski.size() == transfers.size(), "Size mismatch");
+ for(size_t i = 0; i < transfers.size(); ++i)
+ {
+ auto & td = transfers[i];
+ auto & kip = ski[i];
+ CHECK_AND_ASSERT_THROW_MES(!td.m_key_image_known || td.m_key_image == kip.first, "Key Image invalid: " << i);
+ }
+
+ uint64_t spent = 0, unspent = 0;
+ m_wl_alice->import_key_images(ski, 0, spent, unspent, false);
+ return true;
+}
+
+bool gen_trezor_1utxo::generate(std::vector<test_event_entry>& events)
+{
+ TREZOR_TEST_PREFIX();
+ t_builder->cur_height(num_blocks(events) - 1)
+ ->mixin(TREZOR_TEST_MIXIN)
+ ->fee(TREZOR_TEST_FEE)
+ ->from(m_wl_alice.get(), 0)
+ ->compute_sources(boost::none, MK_COINS(1), -1, -1)
+ ->add_destination(m_eve_account, false, 1000)
+ ->rct_config(m_rct_config)
+ ->build_tx();
+
+ TREZOR_TEST_SUFFIX();
+}
+
+bool gen_trezor_1utxo_paymentid_short::generate(std::vector<test_event_entry>& events)
+{
+ TREZOR_TEST_PREFIX();
+ TREZOR_SKIP_IF_VERSION_LEQ(hw::trezor::pack_version(2, 0, 9));
+ t_builder->cur_height(num_blocks(events) - 1)
+ ->mixin(TREZOR_TEST_MIXIN)
+ ->fee(TREZOR_TEST_FEE)
+ ->from(m_wl_alice.get(), 0)
+ ->compute_sources(boost::none, MK_COINS(1), -1, -1)
+ ->add_destination(m_eve_account, false, 1000)
+ ->payment_id(TREZOR_TEST_PAYMENT_ID)
+ ->rct_config(m_rct_config)
+ ->build_tx();
+
+ TREZOR_TEST_SUFFIX();
+}
+
+bool gen_trezor_1utxo_paymentid_short_integrated::generate(std::vector<test_event_entry>& events)
+{
+ TREZOR_TEST_PREFIX();
+ TREZOR_SKIP_IF_VERSION_LEQ(hw::trezor::pack_version(2, 0, 9));
+ t_builder->cur_height(num_blocks(events) - 1)
+ ->mixin(TREZOR_TEST_MIXIN)
+ ->fee(TREZOR_TEST_FEE)
+ ->from(m_wl_alice.get(), 0)
+ ->compute_sources(boost::none, MK_COINS(1), -1, -1)
+ ->add_destination(m_eve_account, false, 1000)
+ ->payment_id(TREZOR_TEST_PAYMENT_ID)
+ ->set_integrated(0)
+ ->rct_config(m_rct_config)
+ ->build_tx();
+
+ TREZOR_TEST_SUFFIX();
+}
+
+bool gen_trezor_1utxo_paymentid_long::generate(std::vector<test_event_entry>& events)
+{
+ TREZOR_TEST_PREFIX();
+ t_builder->cur_height(num_blocks(events) - 1)
+ ->mixin(TREZOR_TEST_MIXIN)
+ ->fee(TREZOR_TEST_FEE)
+ ->from(m_wl_alice.get(), 0)
+ ->compute_sources(boost::none, MK_COINS(1), -1, -1)
+ ->add_destination(m_eve_account, false, 1000)
+ ->payment_id(TREZOR_TEST_PAYMENT_ID_LONG)
+ ->rct_config(m_rct_config)
+ ->build_tx();
+
+ TREZOR_TEST_SUFFIX();
+}
+
+bool gen_trezor_4utxo::generate(std::vector<test_event_entry>& events)
+{
+ TREZOR_TEST_PREFIX();
+ t_builder->cur_height(num_blocks(events) - 1)
+ ->mixin(TREZOR_TEST_MIXIN)
+ ->fee(TREZOR_TEST_FEE)
+ ->from(m_wl_alice.get(), 0)
+ ->compute_sources(4, MK_COINS(1), -1, -1)
+ ->add_destination(m_eve_account, false, 1000)
+ ->rct_config(m_rct_config)
+ ->build_tx();
+
+ TREZOR_TEST_SUFFIX();
+}
+
+bool gen_trezor_4utxo_acc1::generate(std::vector<test_event_entry>& events)
+{
+ TREZOR_TEST_PREFIX();
+ t_builder->cur_height(num_blocks(events) - 1)
+ ->mixin(TREZOR_TEST_MIXIN)
+ ->fee(TREZOR_TEST_FEE)
+ ->from(m_wl_alice.get(), 1)
+ ->compute_sources(4, MK_COINS(1), -1, -1)
+ ->add_destination(m_wl_eve->get_subaddress({0, 1}), true, 1000)
+ ->rct_config(m_rct_config)
+ ->build_tx();
+
+ TREZOR_TEST_SUFFIX();
+}
+
+bool gen_trezor_4utxo_to_sub::generate(std::vector<test_event_entry>& events)
+{
+ TREZOR_TEST_PREFIX();
+ t_builder->cur_height(num_blocks(events) - 1)
+ ->mixin(TREZOR_TEST_MIXIN)
+ ->fee(TREZOR_TEST_FEE)
+ ->from(m_wl_alice.get(), 0)
+ ->compute_sources(4, MK_COINS(1), -1, -1)
+ ->add_destination(m_wl_eve->get_subaddress({0, 1}), true, 1000)
+ ->rct_config(m_rct_config)
+ ->build_tx();
+
+ TREZOR_TEST_SUFFIX();
+}
+
+bool gen_trezor_4utxo_to_2sub::generate(std::vector<test_event_entry>& events)
+{
+ TREZOR_TEST_PREFIX();
+ t_builder->cur_height(num_blocks(events) - 1)
+ ->mixin(TREZOR_TEST_MIXIN)
+ ->fee(TREZOR_TEST_FEE)
+ ->from(m_wl_alice.get(), 0)
+ ->compute_sources(4, MK_COINS(1), -1, -1)
+ ->add_destination(m_wl_eve->get_subaddress({0, 1}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({1, 3}), true, 1000)
+ ->rct_config(m_rct_config)
+ ->build_tx();
+
+ TREZOR_TEST_SUFFIX();
+}
+
+bool gen_trezor_4utxo_to_1norm_2sub::generate(std::vector<test_event_entry>& events)
+{
+ TREZOR_TEST_PREFIX();
+ t_builder->cur_height(num_blocks(events) - 1)
+ ->mixin(TREZOR_TEST_MIXIN)
+ ->fee(TREZOR_TEST_FEE)
+ ->from(m_wl_alice.get(), 0)
+ ->compute_sources(4, MK_COINS(1), -1, -1)
+ ->add_destination(m_wl_eve->get_subaddress({1, 1}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({2, 1}), true, 1000)
+ ->add_destination(m_wl_eve.get(), false, 1000)
+ ->rct_config(m_rct_config)
+ ->build_tx();
+
+ TREZOR_TEST_SUFFIX();
+}
+
+bool gen_trezor_2utxo_sub_acc_to_1norm_2sub::generate(std::vector<test_event_entry>& events)
+{
+ TREZOR_TEST_PREFIX();
+ t_builder->cur_height(num_blocks(events) - 1)
+ ->mixin(TREZOR_TEST_MIXIN)
+ ->fee(TREZOR_TEST_FEE)
+ ->from(m_wl_alice.get(), 0)
+ ->compute_sources_to_sub_acc(2, MK_COINS(1) >> 2, -1, -1)
+ ->add_destination(m_wl_eve->get_subaddress({1, 1}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({2, 1}), true, 1000)
+ ->add_destination(m_wl_eve.get(), false, 1000)
+ ->rct_config(m_rct_config)
+ ->build_tx();
+
+ TREZOR_TEST_SUFFIX();
+}
+
+bool gen_trezor_4utxo_to_7outs::generate(std::vector<test_event_entry>& events)
+{
+ TREZOR_TEST_PREFIX();
+ t_builder->cur_height(num_blocks(events) - 1)
+ ->mixin(TREZOR_TEST_MIXIN)
+ ->fee(TREZOR_TEST_FEE)
+ ->from(m_wl_alice.get(), 0)
+ ->compute_sources(4, MK_COINS(1), -1, -1)
+ ->add_destination(m_wl_eve->get_subaddress({1, 1}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({2, 1}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({0, 1}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({0, 2}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({0, 3}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({0, 4}), true, 1000)
+ ->add_destination(m_wl_eve.get(), false, 1000)
+ ->rct_config(m_rct_config)
+ ->build_tx();
+
+ TREZOR_TEST_SUFFIX();
+}
+
+bool gen_trezor_many_utxo::generate(std::vector<test_event_entry>& events)
+{
+ TREZOR_TEST_PREFIX();
+ t_builder->cur_height(num_blocks(events) - 1)
+ ->mixin(TREZOR_TEST_MIXIN)
+ ->fee(TREZOR_TEST_FEE)
+ ->from(m_wl_alice.get(), 0)
+ ->compute_sources(110, MK_COINS(1), -1, -1)
+ ->add_destination(m_eve_account, false, 1000)
+ ->rct_config(m_rct_config)
+ ->build_tx();
+
+ TREZOR_TEST_SUFFIX();
+}
+
diff --git a/tests/trezor/trezor_tests.h b/tests/trezor/trezor_tests.h
new file mode 100644
index 000000000..41db1cce5
--- /dev/null
+++ b/tests/trezor/trezor_tests.h
@@ -0,0 +1,248 @@
+// Copyright (c) 2014-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.
+//
+// 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.
+//
+// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
+
+#pragma once
+
+#include <device_trezor/device_trezor.hpp>
+#include "../core_tests/chaingen.h"
+#include "../core_tests/wallet_tools.h"
+
+#define TREZOR_TEST_FEE 90000000000
+#define TREZOR_TEST_MIXIN 11
+
+/************************************************************************/
+/* */
+/************************************************************************/
+class tsx_builder;
+class gen_trezor_base : public test_chain_unit_base
+{
+public:
+ friend class tsx_builder;
+
+ gen_trezor_base();
+ gen_trezor_base(const gen_trezor_base &other);
+ virtual ~gen_trezor_base() {};
+
+ void setup_args(const std::string & trezor_path, bool heavy_tests=false);
+ virtual bool generate(std::vector<test_event_entry>& events);
+ virtual void load(std::vector<test_event_entry>& events); // load events, init test obj
+ void fix_hf(std::vector<test_event_entry>& events);
+ void update_trackers(std::vector<test_event_entry>& events);
+
+ void fork(gen_trezor_base & other); // fork generated chain to another test
+ void clear(); // clears m_events, bt, generator, hforks
+ void add_shared_events(std::vector<test_event_entry>& events); // m_events -> events
+ void test_setup(std::vector<test_event_entry>& events); // init setup env, wallets
+
+ void test_trezor_tx(std::vector<test_event_entry>& events,
+ std::vector<tools::wallet2::pending_tx>& ptxs,
+ std::vector<cryptonote::address_parse_info>& dsts_info,
+ test_generator &generator,
+ std::vector<tools::wallet2*> wallets,
+ bool is_sweep=false);
+
+ crypto::hash head_hash() { return get_block_hash(m_head); }
+ cryptonote::block head_block() { return m_head; }
+ bool heavy_tests() { return m_heavy_tests; }
+ void rct_config(rct::RCTConfig rct_config) { m_rct_config = rct_config; }
+ uint8_t cur_hf(){ return m_hard_forks.size() > 0 ? m_hard_forks.back().first : 0; }
+
+ // Static configuration
+ static const uint64_t m_ts_start;
+ static const uint64_t m_wallet_ts;
+ static const std::string m_device_name;
+ static const std::string m_master_seed_str;
+ static const std::string m_device_seed;
+ static const std::string m_alice_spend_private;
+ static const std::string m_alice_view_private;
+
+protected:
+ void setup_trezor();
+ void init_fields();
+
+ test_generator m_generator;
+ block_tracker m_bt;
+
+ v_hardforks_t m_hard_forks;
+ cryptonote::block m_head;
+ std::vector<test_event_entry> m_events;
+
+ std::string m_trezor_path;
+ bool m_heavy_tests;
+ rct::RCTConfig m_rct_config;
+
+ cryptonote::account_base m_miner_account;
+ cryptonote::account_base m_bob_account;
+ cryptonote::account_base m_alice_account;
+ cryptonote::account_base m_eve_account;
+ hw::trezor::device_trezor * m_trezor;
+ std::unique_ptr<tools::wallet2> m_wl_alice;
+ std::unique_ptr<tools::wallet2> m_wl_bob;
+ std::unique_ptr<tools::wallet2> m_wl_eve;
+
+ friend class boost::serialization::access;
+
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int /*version*/)
+ {
+ ar & m_generator;
+ }
+};
+
+class tsx_builder {
+public:
+ tsx_builder(): m_tester(nullptr), m_from(nullptr), m_account(0), m_mixin(TREZOR_TEST_MIXIN), m_fee(TREZOR_TEST_FEE),
+ m_rct_config({rct::RangeProofPaddedBulletproof, 1 }){}
+
+ tsx_builder(gen_trezor_base * tester): m_tester(tester), m_from(nullptr), m_account(0),
+ m_mixin(TREZOR_TEST_MIXIN), m_fee(TREZOR_TEST_FEE),
+ m_rct_config({rct::RangeProofPaddedBulletproof, 1 }){}
+
+ tsx_builder * cur_height(uint64_t cur_height) { m_cur_height = cur_height; return this; }
+ tsx_builder * mixin(size_t mixin=TREZOR_TEST_MIXIN) { m_mixin = mixin; return this; }
+ tsx_builder * fee(uint64_t fee=TREZOR_TEST_FEE) { m_fee = fee; return this; }
+ tsx_builder * payment_id(const std::string & payment_id) { m_payment_id = payment_id; return this; }
+ tsx_builder * from(tools::wallet2 *from, uint32_t account=0) { m_from = from; m_account=account; return this; }
+ tsx_builder * sources(std::vector<cryptonote::tx_source_entry> & sources, std::vector<size_t> & selected_transfers);
+ tsx_builder * compute_sources(boost::optional<size_t> num_utxo=boost::none, boost::optional<uint64_t> min_amount=boost::none, ssize_t offset=-1, int step=1, boost::optional<fnc_accept_tx_source_t> fnc_accept=boost::none);
+ tsx_builder * compute_sources_to_sub(boost::optional<size_t> num_utxo=boost::none, boost::optional<uint64_t> min_amount=boost::none, ssize_t offset=-1, int step=1, boost::optional<fnc_accept_tx_source_t> fnc_accept=boost::none);
+ tsx_builder * compute_sources_to_sub_acc(boost::optional<size_t> num_utxo=boost::none, boost::optional<uint64_t> min_amount=boost::none, ssize_t offset=-1, int step=1, boost::optional<fnc_accept_tx_source_t> fnc_accept=boost::none);
+
+ tsx_builder * destinations(std::vector<cryptonote::tx_destination_entry> &dsts);
+ tsx_builder * add_destination(const cryptonote::tx_destination_entry &dst);
+ tsx_builder * add_destination(const tools::wallet2 * wallet, bool is_subaddr=false, uint64_t amount=1000);
+ tsx_builder * add_destination(const var_addr_t addr, bool is_subaddr=false, uint64_t amount=1000);
+ tsx_builder * set_integrated(size_t idx);
+ tsx_builder * rct_config(const rct::RCTConfig & rct_config) {m_rct_config = rct_config; return this; };
+
+ tsx_builder * build_tx();
+ tsx_builder * construct_pending_tx(tools::wallet2::pending_tx &ptx, boost::optional<std::vector<uint8_t>> extra = boost::none);
+ tsx_builder * clear_current();
+ std::vector<tools::wallet2::pending_tx> build();
+ std::vector<cryptonote::address_parse_info> dest_info(){ return m_dsts_info; }
+
+protected:
+ gen_trezor_base * m_tester;
+ uint64_t m_cur_height;
+ std::vector<tools::wallet2::pending_tx> m_ptxs; // all transactions
+
+ // current transaction
+ size_t m_mixin;
+ uint64_t m_fee;
+ tools::wallet2 * m_from;
+ uint32_t m_account;
+ cryptonote::transaction m_tx;
+ std::vector<size_t> m_selected_transfers;
+ std::vector<cryptonote::tx_source_entry> m_sources;
+ std::vector<cryptonote::tx_destination_entry> m_destinations;
+ std::vector<cryptonote::tx_destination_entry> m_destinations_orig;
+ std::vector<cryptonote::address_parse_info> m_dsts_info;
+ std::unordered_set<size_t> m_integrated;
+ std::string m_payment_id;
+ rct::RCTConfig m_rct_config;
+};
+
+class gen_trezor_ki_sync : public gen_trezor_base
+{
+public:
+ bool generate(std::vector<test_event_entry>& events) override;
+};
+
+class gen_trezor_1utxo : public gen_trezor_base
+{
+public:
+ bool generate(std::vector<test_event_entry>& events) override;
+};
+
+class gen_trezor_1utxo_paymentid_short : public gen_trezor_base
+{
+public:
+ bool generate(std::vector<test_event_entry>& events) override;
+};
+
+class gen_trezor_1utxo_paymentid_short_integrated : public gen_trezor_base
+{
+public:
+ bool generate(std::vector<test_event_entry>& events) override;
+};
+
+class gen_trezor_1utxo_paymentid_long : public gen_trezor_base
+{
+public:
+ bool generate(std::vector<test_event_entry>& events) override;
+};
+
+class gen_trezor_4utxo : public gen_trezor_base
+{
+public:
+ bool generate(std::vector<test_event_entry>& events) override;
+};
+
+class gen_trezor_4utxo_acc1 : public gen_trezor_base
+{
+public:
+ bool generate(std::vector<test_event_entry>& events) override;
+};
+
+class gen_trezor_4utxo_to_sub : public gen_trezor_base
+{
+public:
+ bool generate(std::vector<test_event_entry>& events) override;
+};
+
+class gen_trezor_4utxo_to_2sub : public gen_trezor_base
+{
+public:
+ bool generate(std::vector<test_event_entry>& events) override;
+};
+
+class gen_trezor_4utxo_to_1norm_2sub : public gen_trezor_base
+{
+public:
+ bool generate(std::vector<test_event_entry>& events) override;
+};
+
+class gen_trezor_2utxo_sub_acc_to_1norm_2sub : public gen_trezor_base
+{
+public:
+ bool generate(std::vector<test_event_entry>& events) override;
+};
+
+class gen_trezor_4utxo_to_7outs : public gen_trezor_base
+{
+public:
+ bool generate(std::vector<test_event_entry>& events) override;
+};
+
+class gen_trezor_many_utxo : public gen_trezor_base
+{
+public:
+ bool generate(std::vector<test_event_entry>& events) override;
+};
diff --git a/tests/unit_tests/CMakeLists.txt b/tests/unit_tests/CMakeLists.txt
index aea82ede2..b355d566d 100644
--- a/tests/unit_tests/CMakeLists.txt
+++ b/tests/unit_tests/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/tests/unit_tests/account.cpp b/tests/unit_tests/account.cpp
index 113622b5e..7073ab3e8 100644
--- a/tests/unit_tests/account.cpp
+++ b/tests/unit_tests/account.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/address_from_url.cpp b/tests/unit_tests/address_from_url.cpp
index f6c0ad105..4b06c6487 100644
--- a/tests/unit_tests/address_from_url.cpp
+++ b/tests/unit_tests/address_from_url.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/apply_permutation.cpp b/tests/unit_tests/apply_permutation.cpp
index e2420eb45..76d10c8ff 100644
--- a/tests/unit_tests/apply_permutation.cpp
+++ b/tests/unit_tests/apply_permutation.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/ban.cpp b/tests/unit_tests/ban.cpp
index ccfcfc15a..eb1ee8932 100644
--- a/tests/unit_tests/ban.cpp
+++ b/tests/unit_tests/ban.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/base58.cpp b/tests/unit_tests/base58.cpp
index 7edb28e62..1996afd04 100644
--- a/tests/unit_tests/base58.cpp
+++ b/tests/unit_tests/base58.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/block_queue.cpp b/tests/unit_tests/block_queue.cpp
index f7b7c63fd..0cba7c443 100644
--- a/tests/unit_tests/block_queue.cpp
+++ b/tests/unit_tests/block_queue.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/block_reward.cpp b/tests/unit_tests/block_reward.cpp
index a897e4140..1dd9072b9 100644
--- a/tests/unit_tests/block_reward.cpp
+++ b/tests/unit_tests/block_reward.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/blockchain_db.cpp b/tests/unit_tests/blockchain_db.cpp
index f9a6adf03..4fbc21ddc 100644
--- a/tests/unit_tests/blockchain_db.cpp
+++ b/tests/unit_tests/blockchain_db.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/bulletproofs.cpp b/tests/unit_tests/bulletproofs.cpp
index 4f07415b0..9ac0df45b 100644
--- a/tests/unit_tests/bulletproofs.cpp
+++ b/tests/unit_tests/bulletproofs.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/canonical_amounts.cpp b/tests/unit_tests/canonical_amounts.cpp
index 227a64a7f..74fcc9548 100644
--- a/tests/unit_tests/canonical_amounts.cpp
+++ b/tests/unit_tests/canonical_amounts.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/chacha.cpp b/tests/unit_tests/chacha.cpp
index 699890522..e06081f8f 100644
--- a/tests/unit_tests/chacha.cpp
+++ b/tests/unit_tests/chacha.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/checkpoints.cpp b/tests/unit_tests/checkpoints.cpp
index ec09c596b..90229a0b8 100644
--- a/tests/unit_tests/checkpoints.cpp
+++ b/tests/unit_tests/checkpoints.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/command_line.cpp b/tests/unit_tests/command_line.cpp
index 327fceefe..6d5afb708 100644
--- a/tests/unit_tests/command_line.cpp
+++ b/tests/unit_tests/command_line.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/crypto.cpp b/tests/unit_tests/crypto.cpp
index e09ec7f7a..7100c8013 100644
--- a/tests/unit_tests/crypto.cpp
+++ b/tests/unit_tests/crypto.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/decompose_amount_into_digits.cpp b/tests/unit_tests/decompose_amount_into_digits.cpp
index 11c6189e5..5049dd83d 100644
--- a/tests/unit_tests/decompose_amount_into_digits.cpp
+++ b/tests/unit_tests/decompose_amount_into_digits.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/dns_resolver.cpp b/tests/unit_tests/dns_resolver.cpp
index 2b3627f02..6bffc01d8 100644
--- a/tests/unit_tests/dns_resolver.cpp
+++ b/tests/unit_tests/dns_resolver.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/epee_boosted_tcp_server.cpp b/tests/unit_tests/epee_boosted_tcp_server.cpp
index 41554f948..32989f545 100644
--- a/tests/unit_tests/epee_boosted_tcp_server.cpp
+++ b/tests/unit_tests/epee_boosted_tcp_server.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/epee_levin_protocol_handler_async.cpp b/tests/unit_tests/epee_levin_protocol_handler_async.cpp
index 9ea71875b..697845f60 100644
--- a/tests/unit_tests/epee_levin_protocol_handler_async.cpp
+++ b/tests/unit_tests/epee_levin_protocol_handler_async.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/epee_utils.cpp b/tests/unit_tests/epee_utils.cpp
index 9a32d149a..946731826 100644
--- a/tests/unit_tests/epee_utils.cpp
+++ b/tests/unit_tests/epee_utils.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/fee.cpp b/tests/unit_tests/fee.cpp
index 8ccb38fc9..3b0bc1f09 100644
--- a/tests/unit_tests/fee.cpp
+++ b/tests/unit_tests/fee.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/get_xtype_from_string.cpp b/tests/unit_tests/get_xtype_from_string.cpp
index 54ba473a6..75452894a 100644
--- a/tests/unit_tests/get_xtype_from_string.cpp
+++ b/tests/unit_tests/get_xtype_from_string.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/hardfork.cpp b/tests/unit_tests/hardfork.cpp
index 12dfde1bc..bb26b5533 100644
--- a/tests/unit_tests/hardfork.cpp
+++ b/tests/unit_tests/hardfork.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/hashchain.cpp b/tests/unit_tests/hashchain.cpp
index df87f5df2..d07dfdb7a 100644
--- a/tests/unit_tests/hashchain.cpp
+++ b/tests/unit_tests/hashchain.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/http.cpp b/tests/unit_tests/http.cpp
index 372448764..938f444d7 100644
--- a/tests/unit_tests/http.cpp
+++ b/tests/unit_tests/http.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/logging.cpp b/tests/unit_tests/logging.cpp
index 476e92bef..12d49e2fb 100644
--- a/tests/unit_tests/logging.cpp
+++ b/tests/unit_tests/logging.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2016-2018, The Monero Project
+// Copyright (c) 2016-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/main.cpp b/tests/unit_tests/main.cpp
index f7251a09e..76d17f2ad 100644
--- a/tests/unit_tests/main.cpp
+++ b/tests/unit_tests/main.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/memwipe.cpp b/tests/unit_tests/memwipe.cpp
index dd98b8142..e0f5ada20 100644
--- a/tests/unit_tests/memwipe.cpp
+++ b/tests/unit_tests/memwipe.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/mnemonics.cpp b/tests/unit_tests/mnemonics.cpp
index 59642828d..16634e7a1 100644
--- a/tests/unit_tests/mnemonics.cpp
+++ b/tests/unit_tests/mnemonics.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/mul_div.cpp b/tests/unit_tests/mul_div.cpp
index 768b95d4b..b11f715cd 100644
--- a/tests/unit_tests/mul_div.cpp
+++ b/tests/unit_tests/mul_div.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/multisig.cpp b/tests/unit_tests/multisig.cpp
index eb3196863..9a74b3dce 100644
--- a/tests/unit_tests/multisig.cpp
+++ b/tests/unit_tests/multisig.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/output_selection.cpp b/tests/unit_tests/output_selection.cpp
index fecd547f7..a528679e4 100644
--- a/tests/unit_tests/output_selection.cpp
+++ b/tests/unit_tests/output_selection.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/parse_amount.cpp b/tests/unit_tests/parse_amount.cpp
index eb8c925b1..f4f57f90f 100644
--- a/tests/unit_tests/parse_amount.cpp
+++ b/tests/unit_tests/parse_amount.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/ringct.cpp b/tests/unit_tests/ringct.cpp
index 3f302cb83..e239154cf 100644
--- a/tests/unit_tests/ringct.cpp
+++ b/tests/unit_tests/ringct.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/serialization.cpp b/tests/unit_tests/serialization.cpp
index 343a11c37..eb70caefc 100644
--- a/tests/unit_tests/serialization.cpp
+++ b/tests/unit_tests/serialization.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/sha256.cpp b/tests/unit_tests/sha256.cpp
index 0d1788f3e..898c9e4b3 100644
--- a/tests/unit_tests/sha256.cpp
+++ b/tests/unit_tests/sha256.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/slow_memmem.cpp b/tests/unit_tests/slow_memmem.cpp
index 436259bee..4f13e00e6 100644
--- a/tests/unit_tests/slow_memmem.cpp
+++ b/tests/unit_tests/slow_memmem.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/subaddress.cpp b/tests/unit_tests/subaddress.cpp
index 67802d736..385a2a8ab 100644
--- a/tests/unit_tests/subaddress.cpp
+++ b/tests/unit_tests/subaddress.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/test_peerlist.cpp b/tests/unit_tests/test_peerlist.cpp
index 03aa48ea0..dbb3aaf96 100644
--- a/tests/unit_tests/test_peerlist.cpp
+++ b/tests/unit_tests/test_peerlist.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/test_protocol_pack.cpp b/tests/unit_tests/test_protocol_pack.cpp
index d385bbc42..7329c0d23 100644
--- a/tests/unit_tests/test_protocol_pack.cpp
+++ b/tests/unit_tests/test_protocol_pack.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/test_tx_utils.cpp b/tests/unit_tests/test_tx_utils.cpp
index 55c76c3b6..d8d760b07 100644
--- a/tests/unit_tests/test_tx_utils.cpp
+++ b/tests/unit_tests/test_tx_utils.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/unbound.cpp b/tests/unit_tests/unbound.cpp
index 3676e88f0..d122b2ad2 100644
--- a/tests/unit_tests/unbound.cpp
+++ b/tests/unit_tests/unbound.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2016-2018, The Monero Project
+// Copyright (c) 2016-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/unit_tests_utils.h b/tests/unit_tests/unit_tests_utils.h
index ecd97e3d5..5944bd55a 100644
--- a/tests/unit_tests/unit_tests_utils.h
+++ b/tests/unit_tests/unit_tests_utils.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/uri.cpp b/tests/unit_tests/uri.cpp
index 999c117c2..df1dbc130 100644
--- a/tests/unit_tests/uri.cpp
+++ b/tests/unit_tests/uri.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2016-2018, The Monero Project
+// Copyright (c) 2016-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/varint.cpp b/tests/unit_tests/varint.cpp
index db675c888..ca0900682 100644
--- a/tests/unit_tests/varint.cpp
+++ b/tests/unit_tests/varint.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/tests/unit_tests/vercmp.cpp b/tests/unit_tests/vercmp.cpp
index 43045979e..77399fa89 100644
--- a/tests/unit_tests/vercmp.cpp
+++ b/tests/unit_tests/vercmp.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
diff --git a/translations/CMakeLists.txt b/translations/CMakeLists.txt
index dc7772c1d..589005a42 100644
--- a/translations/CMakeLists.txt
+++ b/translations/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2017-2018, The Monero Project
+# Copyright (c) 2017-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/translations/generate_translations_header.c b/translations/generate_translations_header.c
index 008a1b75e..4c80eec31 100644
--- a/translations/generate_translations_header.c
+++ b/translations/generate_translations_header.c
@@ -1,5 +1,5 @@
// Copyright (c) 2013, Sergey Lyubka
-// Copyright (c) 2017-2018, The Monero Project
+// Copyright (c) 2017-2019, The Monero Project
// All rights reserved.
// Released under the MIT license.
diff --git a/utils/build_scripts/windows.bat b/utils/build_scripts/windows.bat
index 717324fab..76d4f86bb 100644
--- a/utils/build_scripts/windows.bat
+++ b/utils/build_scripts/windows.bat
@@ -1,4 +1,4 @@
-:: Copyright (c) 2014-2018, The Monero Project
+:: Copyright (c) 2014-2019, The Monero Project
::
:: All rights reserved.
::
diff --git a/utils/munin_plugins/alt_blocks_count b/utils/munin_plugins/alt_blocks_count
index 5f9e43671..2510b7bc3 100644
--- a/utils/munin_plugins/alt_blocks_count
+++ b/utils/munin_plugins/alt_blocks_count
@@ -1,6 +1,6 @@
#!/bin/bash
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/utils/munin_plugins/difficulty b/utils/munin_plugins/difficulty
index f9a72b0ca..a7d90c15f 100644
--- a/utils/munin_plugins/difficulty
+++ b/utils/munin_plugins/difficulty
@@ -1,6 +1,6 @@
#!/bin/bash
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/utils/munin_plugins/grey_peerlist_size b/utils/munin_plugins/grey_peerlist_size
index 52f5b99cb..b1cf66f14 100644
--- a/utils/munin_plugins/grey_peerlist_size
+++ b/utils/munin_plugins/grey_peerlist_size
@@ -1,6 +1,6 @@
#!/bin/bash
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/utils/munin_plugins/height b/utils/munin_plugins/height
index 470798b8f..20b3e65ef 100644
--- a/utils/munin_plugins/height
+++ b/utils/munin_plugins/height
@@ -1,6 +1,6 @@
#!/bin/bash
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/utils/munin_plugins/incoming_connections_count b/utils/munin_plugins/incoming_connections_count
index 3fea27fa2..1dcc1f4d0 100644
--- a/utils/munin_plugins/incoming_connections_count
+++ b/utils/munin_plugins/incoming_connections_count
@@ -1,6 +1,6 @@
#!/bin/bash
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/utils/munin_plugins/outgoing_connections_count b/utils/munin_plugins/outgoing_connections_count
index 49d8f4fc4..45a0500dd 100644
--- a/utils/munin_plugins/outgoing_connections_count
+++ b/utils/munin_plugins/outgoing_connections_count
@@ -1,6 +1,6 @@
#!/bin/bash
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/utils/munin_plugins/tx_count b/utils/munin_plugins/tx_count
index d63c8a9d1..e81e5f321 100644
--- a/utils/munin_plugins/tx_count
+++ b/utils/munin_plugins/tx_count
@@ -1,6 +1,6 @@
#!/bin/bash
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/utils/munin_plugins/tx_pool_size b/utils/munin_plugins/tx_pool_size
index f01685a41..245733578 100644
--- a/utils/munin_plugins/tx_pool_size
+++ b/utils/munin_plugins/tx_pool_size
@@ -1,6 +1,6 @@
#!/bin/bash
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
diff --git a/utils/munin_plugins/white_peerlist_size b/utils/munin_plugins/white_peerlist_size
index bd7d7a3c5..8d87a9f0a 100644
--- a/utils/munin_plugins/white_peerlist_size
+++ b/utils/munin_plugins/white_peerlist_size
@@ -1,6 +1,6 @@
#!/bin/bash
-# Copyright (c) 2014-2018, The Monero Project
+# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#