Commit 2ac125f2 authored by cryptonotefoundation's avatar cryptonotefoundation

CryptoNoteWallet update

parent 5a886fd7
......@@ -14,8 +14,7 @@ include_directories(${CMAKE_BINARY_DIR}
src
cryptonote/external
cryptonote/include
cryptonote/src
cryptonote/contrib/epee/include)
cryptonote/src)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Widgets REQUIRED)
......@@ -44,79 +43,130 @@ add_definitions(-DGIT_REVISION=\"${GIT_REVISION}\")
set(CMAKE_AUTOMOC ON)
set(CRYPTONOTE_SOURCES
cryptonote/contrib/epee/include/misc_log_ex.cpp
cryptonote/contrib/epee/include/misc_os_dependent.cpp
cryptonote/contrib/epee/include/string_tools.cpp
cryptonote/external/miniupnpc/connecthostport.c
cryptonote/external/miniupnpc/igd_desc_parse.c
cryptonote/external/miniupnpc/minisoap.c
cryptonote/external/miniupnpc/miniupnpc.c
cryptonote/external/miniupnpc/miniwget.c
cryptonote/external/miniupnpc/minixml.c
cryptonote/external/miniupnpc/portlistingparse.c
cryptonote/external/miniupnpc/receivedata.c
cryptonote/external/miniupnpc/upnpcommands.c
cryptonote/external/miniupnpc/upnpreplyparse.c
cryptonote/src/common/base58.cpp
cryptonote/src/common/command_line.cpp
cryptonote/src/common/util.cpp
cryptonote/src/crypto/blake256.c
cryptonote/src/crypto/chacha8.c
cryptonote/src/crypto/crypto-ops-data.c
cryptonote/src/crypto/crypto-ops.c
cryptonote/src/crypto/crypto.cpp
cryptonote/src/crypto/groestl.c
cryptonote/src/crypto/hash-extra-blake.c
cryptonote/src/crypto/hash-extra-groestl.c
cryptonote/src/crypto/hash-extra-jh.c
cryptonote/src/crypto/hash-extra-skein.c
cryptonote/src/crypto/hash.c
cryptonote/src/crypto/jh.c
cryptonote/src/crypto/keccak.c
cryptonote/src/crypto/oaes_lib.c
cryptonote/src/crypto/random.c
cryptonote/src/crypto/skein.c
cryptonote/src/crypto/slow-hash.c
cryptonote/src/crypto/slow-hash.cpp
cryptonote/src/crypto/tree-hash.c
cryptonote/src/cryptonote_core/BlockIndex.cpp
cryptonote/src/cryptonote_core/CoreConfig.cpp
cryptonote/src/cryptonote_core/Currency.cpp
cryptonote/src/cryptonote_core/MinerConfig.cpp
cryptonote/src/cryptonote_core/Transaction.cpp
cryptonote/src/cryptonote_core/account.cpp
cryptonote/src/cryptonote_core/blockchain_storage.cpp
cryptonote/src/cryptonote_core/checkpoints.cpp
cryptonote/src/cryptonote_core/cryptonote_basic_impl.cpp
cryptonote/src/cryptonote_core/cryptonote_core.cpp
cryptonote/src/cryptonote_core/cryptonote_format_utils.cpp
cryptonote/src/cryptonote_core/cryptonote_serialization.cpp
cryptonote/src/cryptonote_core/difficulty.cpp
cryptonote/src/cryptonote_core/miner.cpp
cryptonote/src/cryptonote_core/tx_pool.cpp
cryptonote/src/inprocess_node/InProcessNode.cpp
cryptonote/src/inprocess_node/InProcessNodeErrors.cpp
cryptonote/src/node_rpc_proxy/NodeErrors.cpp
cryptonote/src/node_rpc_proxy/NodeRpcProxy.cpp
cryptonote/src/p2p/NetNodeConfig.cpp
cryptonote/src/serialization/BinaryInputStreamSerializer.cpp
cryptonote/src/serialization/BinaryOutputStreamSerializer.cpp
cryptonote/src/transfers/BlockchainSynchronizer.cpp
cryptonote/src/transfers/SynchronizationState.cpp
cryptonote/src/transfers/TransfersConsumer.cpp
cryptonote/src/transfers/TransfersContainer.cpp
cryptonote/src/transfers/TransfersSubscription.cpp
cryptonote/src/transfers/TransfersSynchronizer.cpp
cryptonote/src/wallet/KeysStorage.cpp
cryptonote/src/wallet/Wallet.cpp
cryptonote/src/wallet/WalletAsyncContextCounter.cpp
cryptonote/src/wallet/WalletErrors.cpp
cryptonote/src/wallet/WalletSerializer.cpp
cryptonote/src/wallet/WalletSerialization.cpp
cryptonote/src/wallet/WalletTransactionSender.cpp
cryptonote/src/wallet/WalletUnconfirmedTransactions.cpp
cryptonote/src/wallet/WalletUserTransactionsCache.cpp
cryptonote/src/wallet/LegacyKeysImporter.cpp
cryptonote/external/miniupnpc/connecthostport.c
cryptonote/external/miniupnpc/igd_desc_parse.c
cryptonote/external/miniupnpc/minisoap.c
cryptonote/external/miniupnpc/miniupnpc.c
cryptonote/external/miniupnpc/miniwget.c
cryptonote/external/miniupnpc/minixml.c
cryptonote/external/miniupnpc/portlistingparse.c
cryptonote/external/miniupnpc/receivedata.c
cryptonote/external/miniupnpc/upnpcommands.c
cryptonote/external/miniupnpc/upnpreplyparse.c
cryptonote/src/Common/Base58.cpp
cryptonote/src/Common/CommandLine.cpp
cryptonote/src/Common/Util.cpp
cryptonote/src/Common/StringTools.cpp
cryptonote/src/Common/JsonValue.cpp
cryptonote/src/Common/ConsoleTools.cpp
cryptonote/src/Common/MemoryInputStream.cpp
cryptonote/src/Common/PathTools.cpp
cryptonote/src/Common/StdInputStream.cpp
cryptonote/src/Common/StdOutputStream.cpp
cryptonote/src/Common/StreamTools.cpp
cryptonote/src/Common/StringOutputStream.cpp
cryptonote/src/Common/StringView.cpp
cryptonote/src/Common/VectorOutputStream.cpp
cryptonote/src/crypto/blake256.c
cryptonote/src/crypto/chacha8.c
cryptonote/src/crypto/crypto-ops-data.c
cryptonote/src/crypto/crypto-ops.c
cryptonote/src/crypto/crypto.cpp
cryptonote/src/crypto/groestl.c
cryptonote/src/crypto/hash-extra-blake.c
cryptonote/src/crypto/hash-extra-groestl.c
cryptonote/src/crypto/hash-extra-jh.c
cryptonote/src/crypto/hash-extra-skein.c
cryptonote/src/crypto/hash.c
cryptonote/src/crypto/jh.c
cryptonote/src/crypto/keccak.c
cryptonote/src/crypto/oaes_lib.c
cryptonote/src/crypto/random.c
cryptonote/src/crypto/skein.c
cryptonote/src/crypto/slow-hash.c
cryptonote/src/crypto/slow-hash.cpp
cryptonote/src/crypto/tree-hash.c
cryptonote/src/CryptoNoteCore/BlockchainIndices.cpp
cryptonote/src/CryptoNoteCore/BlockchainMessages.cpp
cryptonote/src/CryptoNoteCore/BlockIndex.cpp
cryptonote/src/CryptoNoteCore/CoreConfig.cpp
cryptonote/src/CryptoNoteCore/CryptoNoteBasic.cpp
cryptonote/src/CryptoNoteCore/CryptoNoteTools.cpp
cryptonote/src/CryptoNoteCore/Currency.cpp
cryptonote/src/CryptoNoteCore/MinerConfig.cpp
cryptonote/src/CryptoNoteCore/Transaction.cpp
cryptonote/src/CryptoNoteCore/Account.cpp
cryptonote/src/CryptoNoteCore/Blockchain.cpp
cryptonote/src/CryptoNoteCore/Checkpoints.cpp
cryptonote/src/CryptoNoteCore/CryptoNoteBasicImpl.cpp
cryptonote/src/CryptoNoteCore/Core.cpp
cryptonote/src/CryptoNoteCore/CryptoNoteFormatUtils.cpp
cryptonote/src/CryptoNoteCore/CryptoNoteSerialization.cpp
cryptonote/src/CryptoNoteCore/Difficulty.cpp
cryptonote/src/CryptoNoteCore/IBlock.cpp
cryptonote/src/CryptoNoteCore/Miner.cpp
cryptonote/src/CryptoNoteCore/TransactionExtra.cpp
cryptonote/src/CryptoNoteCore/TransactionPool.cpp
cryptonote/src/CryptoNoteCore/TransactionPrefixImpl.cpp
cryptonote/src/CryptoNoteCore/TransactionUtils.cpp
cryptonote/src/InProcessNode/InProcessNode.cpp
cryptonote/src/InProcessNode/InProcessNodeErrors.cpp
cryptonote/src/NodeRpcProxy/NodeErrors.cpp
cryptonote/src/NodeRpcProxy/NodeRpcProxy.cpp
cryptonote/src/P2p/NetNodeConfig.cpp
cryptonote/src/Serialization/BinaryInputStreamSerializer.cpp
cryptonote/src/Serialization/BinaryOutputStreamSerializer.cpp
cryptonote/src/Serialization/JsonInputValueSerializer.cpp
cryptonote/src/Serialization/JsonOutputStreamSerializer.cpp
cryptonote/src/Serialization/KVBinaryInputStreamSerializer.cpp
cryptonote/src/Serialization/KVBinaryOutputStreamSerializer.cpp
cryptonote/src/Serialization/SerializationOverloads.cpp
cryptonote/src/Transfers/BlockchainSynchronizer.cpp
cryptonote/src/Transfers/SynchronizationState.cpp
cryptonote/src/Transfers/TransfersConsumer.cpp
cryptonote/src/Transfers/TransfersContainer.cpp
cryptonote/src/Transfers/TransfersSubscription.cpp
cryptonote/src/Transfers/TransfersSynchronizer.cpp
cryptonote/src/Wallet/LegacyKeysImporter.cpp
cryptonote/src/Wallet/WalletAsyncContextCounter.cpp
cryptonote/src/Wallet/WalletErrors.cpp
cryptonote/src/WalletLegacy/KeysStorage.cpp
cryptonote/src/WalletLegacy/WalletLegacy.cpp
cryptonote/src/WalletLegacy/WalletHelper.cpp
cryptonote/src/WalletLegacy/WalletLegacySerializer.cpp
cryptonote/src/WalletLegacy/WalletLegacySerialization.cpp
cryptonote/src/WalletLegacy/WalletTransactionSender.cpp
cryptonote/src/WalletLegacy/WalletUnconfirmedTransactions.cpp
cryptonote/src/WalletLegacy/WalletUserTransactionsCache.cpp
cryptonote/src/System/ContextGroup.cpp
cryptonote/src/System/Event.cpp
cryptonote/src/System/EventLock.cpp
cryptonote/src/System/InterruptedException.cpp
cryptonote/src/System/Ipv4Address.cpp
cryptonote/src/System/TcpStream.cpp
cryptonote/src/HTTP/HttpRequest.cpp
cryptonote/src/HTTP/HttpParser.cpp
cryptonote/src/HTTP/HttpParserErrorCodes.cpp
cryptonote/src/HTTP/HttpResponse.cpp
cryptonote/src/Rpc/HttpClient.cpp
cryptonote/src/Rpc/JsonRpc.cpp
cryptonote/src/P2p/NetNode.cpp
cryptonote/src/P2p/LevinProtocol.cpp
cryptonote/src/P2p/NetNodeConfig.cpp
cryptonote/src/P2p/PeerListManager.cpp
cryptonote/src/CryptoNoteProtocol/CryptoNoteProtocolHandler.cpp
cryptonote/src/Logging/ILogger.cpp
cryptonote/src/Logging/LoggerGroup.cpp
cryptonote/src/Logging/CommonLogger.cpp
cryptonote/src/Logging/LoggerManager.cpp
cryptonote/src/Logging/FileLogger.cpp
cryptonote/src/Logging/StreamLogger.cpp
cryptonote/src/Logging/ConsoleLogger.cpp
cryptonote/src/Logging/LoggerMessage.cpp
cryptonote/src/Logging/LoggerRef.cpp
cryptonote/src/BlockchainExplorer/BlockchainExplorer.cpp
cryptonote/src/BlockchainExplorer/BlockchainExplorerDataBuilder.cpp
cryptonote/src/BlockchainExplorer/BlockchainExplorerErrors.cpp
)
file(GLOB_RECURSE SOURCES src/*.cpp)
......
......@@ -2,54 +2,122 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <QCoreApplication>
#include <common/util.h>
#include <Common/Util.h>
#include <CryptoNoteConfig.h>
#include "CommandLineParser.h"
#include "CurrencyAdapter.h"
namespace WalletGui {
CommandLineParser::CommandLineParser() : QObject(), m_parser(), m_help_option(m_parser.addHelpOption()),
m_version_option(m_parser.addVersionOption()),
m_data_dir_option("data-dir", tr("Specify data directory"), tr("directory"), QString::fromStdString(tools::get_default_data_dir())) {
m_parser.setApplicationDescription(QString(tr("%1 wallet")).arg(CurrencyAdapter::instance().getCurrencyDisplayName()));
CommandLineParser::CommandLineParser(QObject* _parent) : QObject(_parent), m_parser(), m_helpOption(m_parser.addHelpOption()),
m_versionOption(m_parser.addVersionOption()),
m_testnetOption("testnet", tr("Used to deploy test nets. Checkpoints and hardcoded seeds are ignored, network id is changed. "
"Use it with –data-dir flag. The wallet must be launched with –testnet flag")),
m_p2pBindIpOption("p2p-bind-ip", tr("Interface for p2p network protocol"), tr("ip"), "0.0.0.0"),
m_p2pBindPortOption("p2p-bind-port", tr("Port for p2p network protocol"), tr("port"), QString::number(CryptoNote::P2P_DEFAULT_PORT)),
m_p2pExternalOption("p2p-external-port", tr("xternal port for p2p network protocol (if port forwarding used with NAT)"),
tr("port"), 0),
m_allowLocalIpOption("allow-local-ip", tr("Allow local ip add to peer list, mostly in debug purposes")),
m_addPeerOption("add-peer", tr("Manually add peer to local peerlist"), tr("peer")),
m_addPriorityNodeOption("add-priority-node", tr("Specify list of peers to connect to and attempt to keep the connection open"),
tr("node")),
m_addExclusiveNodeOption("add-exclusive-node", tr("Specify list of peers to connect to only. If this option is given the options "
"add-priority-node and seed-node are ignored"), tr("node")),
m_seedNodeOption("seed-node", tr("Connect to a node to retrieve peer addresses, and disconnect"), tr("node")),
m_hideMyPortOption("hide-my-port", tr("Do not announce yourself as peerlist candidate")),
m_dataDirOption("data-dir", tr("Specify data directory"), tr("directory"), QString::fromStdString(Tools::getDefaultDataDirectory())),
m_minimized("minimized", tr("Run application in minimized mode")) {
m_parser.setApplicationDescription(tr("Bytecoin wallet"));
m_parser.addHelpOption();
m_parser.addVersionOption();
m_parser.addOption(m_data_dir_option);
m_parser.addOption(m_testnetOption);
m_parser.addOption(m_p2pBindIpOption);
m_parser.addOption(m_p2pBindPortOption);
m_parser.addOption(m_p2pExternalOption);
m_parser.addOption(m_allowLocalIpOption);
m_parser.addOption(m_addPeerOption);
m_parser.addOption(m_addPriorityNodeOption);
m_parser.addOption(m_addExclusiveNodeOption);
m_parser.addOption(m_seedNodeOption);
m_parser.addOption(m_hideMyPortOption);
m_parser.addOption(m_dataDirOption);
m_parser.addOption(m_minimized);
}
CommandLineParser::~CommandLineParser() {
}
bool CommandLineParser::process() {
bool CommandLineParser::process(const QStringList& _argv) {
#ifdef Q_OS_WIN
return m_parser.parse(QCoreApplication::arguments());
return m_parser.parse(_argv);
#else
m_parser.process(*QCoreApplication::instance());
m_parser.process(_argv);
return true;
#endif
}
bool CommandLineParser::hasHelpOption() const {
return m_parser.isSet(m_help_option);
return m_parser.isSet(m_helpOption);
}
bool CommandLineParser::hasMinimizedOption() const {
return m_parser.isSet(m_minimized);
}
bool CommandLineParser::hasVersionOption() const {
return m_parser.isSet(m_version_option);
return m_parser.isSet(m_versionOption);
}
bool CommandLineParser::hasTestnetOption() const {
return m_parser.isSet(m_testnetOption);
}
bool CommandLineParser::hasAllowLocalIpOption() const {
return m_parser.isSet(m_allowLocalIpOption);
}
bool CommandLineParser::hasHideMyPortOption() const {
return m_parser.isSet(m_hideMyPortOption);
}
QString CommandLineParser::errorText() const {
QString CommandLineParser::getErrorText() const {
return m_parser.errorText();
}
QString CommandLineParser::helpText() const {
QString CommandLineParser::getHelpText() const {
return m_parser.helpText();
}
QString CommandLineParser::getP2pBindIp() const {
return m_parser.value(m_p2pBindIpOption);
}
quint16 CommandLineParser::getP2pBindPort() const {
return m_parser.value(m_p2pBindPortOption).toUShort();
}
quint16 CommandLineParser::getP2pExternalPort() const {
return m_parser.value(m_p2pExternalOption).toUShort();
}
QStringList CommandLineParser::getPeers() const {
return m_parser.values(m_addPeerOption);
}
QStringList CommandLineParser::getPiorityNodes() const {
return m_parser.values(m_addPriorityNodeOption);
}
QStringList CommandLineParser::getExclusiveNodes() const {
return m_parser.values(m_addExclusiveNodeOption);
}
QStringList CommandLineParser::getSeedNodes() const {
return m_parser.values(m_seedNodeOption);
}
QString CommandLineParser::getDataDir() const {
return m_parser.value(m_data_dir_option);
return m_parser.value(m_dataDirOption);
}
}
......@@ -11,24 +11,46 @@ namespace WalletGui {
class CommandLineParser : public QObject {
Q_OBJECT
Q_DISABLE_COPY(CommandLineParser)
public:
CommandLineParser();
CommandLineParser(QObject* _parent);
~CommandLineParser();
bool process();
bool process(const QStringList& _argv);
bool hasHelpOption() const;
bool hasVersionOption() const;
QString errorText() const;
QString helpText() const;
bool hasTestnetOption() const;
bool hasMinimizedOption() const;
bool hasAllowLocalIpOption() const;
bool hasHideMyPortOption() const;
QString getErrorText() const;
QString getHelpText() const;
QString getP2pBindIp() const;
quint16 getP2pBindPort() const;
quint16 getP2pExternalPort() const;
QStringList getPeers() const;
QStringList getPiorityNodes() const;
QStringList getExclusiveNodes() const;
QStringList getSeedNodes() const;
QString getDataDir() const;
private:
QCommandLineParser m_parser;
QCommandLineOption m_help_option;
QCommandLineOption m_version_option;
QCommandLineOption m_data_dir_option;
QCommandLineOption m_helpOption;
QCommandLineOption m_versionOption;
QCommandLineOption m_testnetOption;
QCommandLineOption m_p2pBindIpOption;
QCommandLineOption m_p2pBindPortOption;
QCommandLineOption m_p2pExternalOption;
QCommandLineOption m_allowLocalIpOption;
QCommandLineOption m_addPeerOption;
QCommandLineOption m_addPriorityNodeOption;
QCommandLineOption m_addExclusiveNodeOption;
QCommandLineOption m_seedNodeOption;
QCommandLineOption m_hideMyPortOption;
QCommandLineOption m_dataDirOption;
QCommandLineOption m_minimized;
};
}
......@@ -2,34 +2,27 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "CryptoNote.h"
#include "cryptonote_core/cryptonote_basic_impl.h"
#include "cryptonote_core/cryptonote_format_utils.h"
#include "cryptonote_core/Currency.h"
#include "node_rpc_proxy/NodeRpcProxy.h"
#include "cryptonote_core/CoreConfig.h"
#include "cryptonote_core/cryptonote_core.h"
#include "cryptonote_protocol/cryptonote_protocol_handler.h"
#include "inprocess_node/InProcessNode.h"
#include "p2p/net_node.h"
#include "wallet/Wallet.h"
#include "CryptoNoteWrapper.h"
#include "CryptoNoteCore/CryptoNoteBasicImpl.h"
#include "CryptoNoteCore/CryptoNoteFormatUtils.h"
#include "CryptoNoteCore/Currency.h"
#include "NodeRpcProxy/NodeRpcProxy.h"
#include "CryptoNoteCore/CoreConfig.h"
#include "P2p/NetNodeConfig.h"
#include "CryptoNoteCore/Core.h"
#include "CryptoNoteProtocol/CryptoNoteProtocolHandler.h"
#include "InProcessNode/InProcessNode.h"
#include "P2p/NetNode.h"
#include "WalletLegacy/WalletLegacy.h"
#include "Logging/LoggerManager.h"
#include "System/Dispatcher.h"
namespace WalletGui {
namespace {
bool parsePaymentId(const std::string& payment_id_str, crypto::hash& payment_id) {
cryptonote::blobdata payment_id_data;
if (!epee::string_tools::parse_hexstr_to_binbuff(payment_id_str, payment_id_data)) {
return false;
}
if (sizeof(crypto::hash) != payment_id_data.size()) {
return false;
}
payment_id = *reinterpret_cast<const crypto::hash*>(payment_id_data.data());
return true;
bool parsePaymentId(const std::string& payment_id_str, Crypto::Hash& payment_id) {
return CryptoNote::parsePaymentId(payment_id_str, payment_id);
}
std::string convertPaymentId(const std::string& paymentIdString) {
......@@ -37,7 +30,7 @@ std::string convertPaymentId(const std::string& paymentIdString) {
return "";
}
crypto::hash paymentId;
Crypto::Hash paymentId;
if (!parsePaymentId(paymentIdString, paymentId)) {
std::stringstream errorStr;
errorStr << "Payment id has invalid format: \"" + paymentIdString + "\", expected 64-character string";
......@@ -45,9 +38,9 @@ std::string convertPaymentId(const std::string& paymentIdString) {
}
std::vector<uint8_t> extra;
std::string extra_nonce;
cryptonote::set_payment_id_to_tx_extra_nonce(extra_nonce, paymentId);
if (!cryptonote::add_extra_nonce_to_tx_extra(extra, extra_nonce)) {
CryptoNote::BinaryArray extraNonce;
CryptoNote::setPaymentIdToTransactionExtraNonce(extraNonce, paymentId);
if (!CryptoNote::addExtraNonceToTransactionExtra(extra, extraNonce)) {
std::stringstream errorStr;
errorStr << "Something went wrong with payment_id. Please check its format: \"" + paymentIdString + "\", expected 64-character string";
throw std::runtime_error(errorStr.str());
......@@ -57,19 +50,19 @@ std::string convertPaymentId(const std::string& paymentIdString) {
}
std::string extractPaymentId(const std::string& extra) {
std::vector<cryptonote::tx_extra_field> extraFields;
std::vector<CryptoNote::TransactionExtraField> extraFields;
std::vector<uint8_t> extraVector;
std::copy(extra.begin(), extra.end(), std::back_inserter(extraVector));
if (!cryptonote::parse_tx_extra(extraVector, extraFields)) {
if (!CryptoNote::parseTransactionExtra(extraVector, extraFields)) {
throw std::runtime_error("Can't parse extra");
}
std::string result;
cryptonote::tx_extra_nonce extra_nonce;
if (cryptonote::find_tx_extra_field_by_type(extraFields, extra_nonce)) {
crypto::hash paymentIdHash;
if (cryptonote::get_payment_id_from_tx_extra_nonce(extra_nonce.nonce, paymentIdHash)) {
CryptoNote::TransactionExtraNonce extraNonce;
if (CryptoNote::findTransactionExtraFieldByType(extraFields, extraNonce)) {
Crypto::Hash paymentIdHash;
if (CryptoNote::getPaymentIdFromTransactionExtraNonce(extraNonce.nonce, paymentIdHash)) {
unsigned char* buff = reinterpret_cast<unsigned char *>(&paymentIdHash);
for (size_t i = 0; i < sizeof(paymentIdHash); ++i) {
result.push_back("0123456789ABCDEF"[buff[i] >> 4]);
......@@ -80,7 +73,7 @@ std::string extractPaymentId(const std::string& extra) {
return result;
}
}
......@@ -89,7 +82,7 @@ Node::~Node() {
class RpcNode : CryptoNote::INodeObserver, public Node {
public:
RpcNode(const cryptonote::Currency& currency, INodeCallback& callback, const std::string& nodeHost, unsigned short nodePort) :
RpcNode(const CryptoNote::Currency& currency, INodeCallback& callback, const std::string& nodeHost, unsigned short nodePort) :
m_callback(callback),
m_currency(currency),
m_node(nodeHost, nodePort) {
......@@ -130,14 +123,14 @@ public:
return m_node.getPeerCount();
}
CryptoNote::IWallet* createWallet() override {
return new CryptoNote::Wallet(m_currency, m_node);
CryptoNote::IWalletLegacy* createWallet() override {
return new CryptoNote::WalletLegacy(m_currency, m_node);
}
private:
INodeCallback& m_callback;
const cryptonote::Currency& m_currency;
cryptonote::NodeRpcProxy m_node;
const CryptoNote::Currency& m_currency;
CryptoNote::NodeRpcProxy m_node;
void peerCountUpdated(size_t count) {
m_callback.peerCountUpdated(*this, count);
......@@ -154,52 +147,57 @@ private:
class InprocessNode : CryptoNote::INodeObserver, public Node {
public:
InprocessNode(const cryptonote::Currency& currency, INodeCallback& callback, const cryptonote::CoreConfig& coreConfig) :
InprocessNode(const CryptoNote::Currency& currency, Logging::LoggerManager& logManager, const CryptoNote::CoreConfig& coreConfig,
const CryptoNote::NetNodeConfig& netNodeConfig, INodeCallback& callback) :
m_currency(currency), m_dispatcher(),
m_callback(callback),
m_currency(currency),
m_coreConfig(coreConfig),
m_core(m_currency, nullptr),
m_protocolHandler(m_core, nullptr),
m_nodeServer(m_protocolHandler),
m_netNodeConfig(netNodeConfig),
m_protocolHandler(currency, m_dispatcher, m_core, nullptr, logManager),
m_core(currency, &m_protocolHandler, logManager),
m_nodeServer(m_dispatcher, m_protocolHandler, logManager),
m_node(m_core, m_protocolHandler) {
m_core.set_cryptonote_protocol(&m_protocolHandler);
m_protocolHandler.set_p2p_endpoint(&m_nodeServer);
cryptonote::checkpoints checkpoints;
for (const cryptonote::CheckpointData& checkpoint : cryptonote::CHECKPOINTS) {
CryptoNote::Checkpoints checkpoints(logManager);
for (const CryptoNote::CheckpointData& checkpoint : CryptoNote::CHECKPOINTS) {
checkpoints.add_checkpoint(checkpoint.height, checkpoint.blockId);
}
m_core.set_checkpoints(std::move(checkpoints));
}
~InprocessNode() override {
}
void init(const std::function<void(std::error_code)>& callback) override {
if (!m_core.init(m_coreConfig, cryptonote::MinerConfig(), true)) {
callback(make_error_code(cryptonote::error::NOT_INITIALIZED));
try {
if (!m_core.init(m_coreConfig, CryptoNote::MinerConfig(), true)) {
callback(make_error_code(CryptoNote::error::NOT_INITIALIZED));
return;
}
if (!m_nodeServer.init(nodetool::NetNodeConfig(), false)) {
m_core.deinit();
callback(make_error_code(cryptonote::error::NOT_INITIALIZED));
}
if (!m_nodeServer.init(m_netNodeConfig)) {
callback(make_error_code(CryptoNote::error::NOT_INITIALIZED));
return;
}
} catch (std::runtime_error& _err) {
callback(make_error_code(CryptoNote::error::NOT_INITIALIZED));
return;
}
m_node.init([this, callback](std::error_code ec) {
m_node.addObserver(this);
callback(ec);
m_node.addObserver(this);
callback(ec);
});
m_nodeServer.run();
m_nodeServer.deinit();
m_core.deinit();
m_node.shutdown();
}
void deinit() override {
m_nodeServer.send_stop_signal();
m_nodeServer.sendStopSignal();
}
std::string convertPaymentId(const std::string& paymentIdString) override {
......@@ -226,17 +224,19 @@ public:
return m_node.getPeerCount();
}
CryptoNote::IWallet* createWallet() override {
return new CryptoNote::Wallet(m_currency, m_node);
CryptoNote::IWalletLegacy* createWallet() override {
return new CryptoNote::WalletLegacy(m_currency, m_node);
}
private:
INodeCallback& m_callback;
const cryptonote::Currency& m_currency;
cryptonote::CoreConfig m_coreConfig;
cryptonote::core m_core;
cryptonote::t_cryptonote_protocol_handler<cryptonote::core> m_protocolHandler;
nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<cryptonote::core>> m_nodeServer;
const CryptoNote::Currency& m_currency;
System::Dispatcher m_dispatcher;
CryptoNote::CoreConfig m_coreConfig;
CryptoNote::NetNodeConfig m_netNodeConfig;
CryptoNote::core m_core;
CryptoNote::CryptoNoteProtocolHandler m_protocolHandler;
CryptoNote::NodeServer m_nodeServer;
CryptoNote::InProcessNode m_node;
std::future<bool> m_nodeServerFuture;
......@@ -253,12 +253,13 @@ private:
}
};
Node* createRpcNode(const cryptonote::Currency& currency, INodeCallback& callback, const std::string& nodeHost, unsigned short nodePort) {
Node* createRpcNode(const CryptoNote::Currency& currency, INodeCallback& callback, const std::string& nodeHost, unsigned short nodePort) {
return new RpcNode(currency, callback, nodeHost, nodePort);
}
Node* createInprocessNode(const cryptonote::Currency& currency, INodeCallback& callback, const cryptonote::CoreConfig& coreConfig) {
return new InprocessNode(currency, callback, coreConfig);
Node* createInprocessNode(const CryptoNote::Currency& currency, Logging::LoggerManager& logManager,
const CryptoNote::CoreConfig& coreConfig, const CryptoNote::NetNodeConfig& netNodeConfig, INodeCallback& callback) {
return new InprocessNode(currency, logManager, coreConfig, netNodeConfig, callback);
}
}
......@@ -9,19 +9,18 @@
#include <string>
#include <system_error>
#include <cryptonote_core/CoreConfig.h>
namespace cryptonote {
namespace CryptoNote {
class INode;
class IWalletLegacy;
class Currency;
class CoreConfig;
class NetNodeConfig;
}
namespace CryptoNote {
class INode;
class IWallet;
namespace Logging {
class LoggerManager;
}
namespace WalletGui {
......@@ -39,7 +38,7 @@ public:
virtual uint64_t getLastLocalBlockTimestamp() const = 0;
virtual uint64_t getPeerCount() const = 0;
virtual CryptoNote::IWallet* createWallet() = 0;
virtual CryptoNote::IWalletLegacy* createWallet() = 0;
};
class INodeCallback {
......@@ -49,7 +48,8 @@ public:
virtual void lastKnownBlockHeightUpdated(Node& node, uint64_t height) = 0;
};
Node* createRpcNode(const cryptonote::Currency& currency, INodeCallback& callback, const std::string& nodeHost, unsigned short nodePort);
Node* createInprocessNode(const cryptonote::Currency& currency, INodeCallback& callback, const cryptonote::CoreConfig& coreConfig);
Node* createRpcNode(const CryptoNote::Currency& currency, INodeCallback& callback, const std::string& nodeHost, unsigned short nodePort);
Node* createInprocessNode(const CryptoNote::Currency& currency, Logging::LoggerManager& logManager,
const CryptoNote::CoreConfig& coreConfig, const CryptoNote::NetNodeConfig& netNodeConfig, INodeCallback& callback);
}
......@@ -4,6 +4,7 @@
#include "CurrencyAdapter.h"
#include "CryptoNoteWalletConfig.h"
#include "LoggerAdapter.h"
namespace WalletGui {
......@@ -12,13 +13,13 @@ CurrencyAdapter& CurrencyAdapter::instance() {
return inst;
}
CurrencyAdapter::CurrencyAdapter() : m_currency(cryptonote::CurrencyBuilder().currency()) {
CurrencyAdapter::CurrencyAdapter() : m_currency(CryptoNote::CurrencyBuilder(LoggerAdapter::instance().getLoggerManager()).currency()) {
}
CurrencyAdapter::~CurrencyAdapter() {
}
const cryptonote::Currency& CurrencyAdapter::getCurrency() {
const CryptoNote::Currency& CurrencyAdapter::getCurrency() {
return m_currency;
}
......@@ -31,7 +32,7 @@ QString CurrencyAdapter::getCurrencyDisplayName() const {
}