Skip to content

Commit 12bfe41

Browse files
authored
Merge pull request #196 from ConcealNetwork/legacy-green
Replace WalletLegacy with WalletGreen
2 parents 60243cb + 36d1441 commit 12bfe41

33 files changed

+519
-934
lines changed

.github/workflows/check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ jobs:
256256

257257
build-macos:
258258
name: macOS
259-
runs-on: macos-11
259+
runs-on: macos-12
260260
steps:
261261
- uses: actions/checkout@master
262262

.github/workflows/macOS.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
jobs:
99
build-macos:
1010
name: macOS
11-
runs-on: macos-11
11+
runs-on: macos-12
1212
steps:
1313
- uses: actions/checkout@master
1414

CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ set(CRYPTONOTE_SOURCES
7878
cryptonote/src/Common/MemoryInputStream.cpp
7979
cryptonote/src/Common/PathTools.cpp
8080
cryptonote/src/Common/DnsTools.cpp
81+
cryptonote/src/Common/ScopeExit.cpp
8182
cryptonote/src/Common/StdInputStream.cpp
8283
cryptonote/src/Common/StdOutputStream.cpp
8384
cryptonote/src/Common/StreamTools.cpp
@@ -150,12 +151,13 @@ set(CRYPTONOTE_SOURCES
150151
cryptonote/src/Wallet/LegacyKeysImporter.cpp
151152
cryptonote/src/Wallet/WalletAsyncContextCounter.cpp
152153
cryptonote/src/Wallet/WalletErrors.cpp
154+
cryptonote/src/Wallet/WalletGreen.cpp
155+
cryptonote/src/Wallet/WalletSerializationV1.cpp
156+
cryptonote/src/Wallet/WalletSerializationV2.cpp
157+
cryptonote/src/Wallet/WalletUtils.cpp
153158
cryptonote/src/WalletLegacy/KeysStorage.cpp
154-
cryptonote/src/WalletLegacy/WalletLegacy.cpp
155-
cryptonote/src/WalletLegacy/WalletHelper.cpp
156159
cryptonote/src/WalletLegacy/WalletLegacySerializer.cpp
157160
cryptonote/src/WalletLegacy/WalletLegacySerialization.cpp
158-
cryptonote/src/WalletLegacy/WalletTransactionSender.cpp
159161
cryptonote/src/WalletLegacy/WalletUnconfirmedTransactions.cpp
160162
cryptonote/src/WalletLegacy/WalletUserTransactionsCache.cpp
161163
cryptonote/src/System/ContextGroup.cpp

appimage/create-appimage.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ if ! test -f "linuxdeploy-plugin-qt-x86_64.AppImage"; then
88
fi
99
chmod u+x ./*.AppImage
1010
cp ../build/release/conceal-desktop .
11-
mkdir -p usr/share/icons
1211
mkdir -p usr/lib
13-
cp ../src/images/conceal.png usr/share/icons
1412
cp /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 usr/lib
1513
cp /usr/lib/x86_64-linux-gnu/libssl.so.1.1 usr/lib
16-
./linuxdeploy-x86_64.AppImage --executable ./conceal-desktop --desktop-file conceal-desktop.desktop --appdir . --output appimage --plugin qt
14+
./linuxdeploy-x86_64.AppImage --executable ./conceal-desktop --desktop-file conceal-desktop.desktop --appdir . --output appimage --plugin qt --icon-file ../src/images/conceal.png

conceal-desktop.pro

Lines changed: 2 additions & 298 deletions
Large diffs are not rendered by default.

src/CryptoNoteWrapper.cpp

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,23 @@
1111
#include "CryptoNoteCore/CryptoNoteBasicImpl.h"
1212
#include "CryptoNoteCore/CryptoNoteFormatUtils.h"
1313
#include "CryptoNoteCore/Currency.h"
14+
#include "CryptoNoteCore/TransactionExtra.h"
1415
#include "NodeRpcProxy/NodeRpcProxy.h"
1516
#include "CryptoNoteCore/CoreConfig.h"
1617
#include "P2p/NetNodeConfig.h"
1718
#include "CryptoNoteCore/Core.h"
1819
#include "CryptoNoteProtocol/CryptoNoteProtocolHandler.h"
1920
#include "InProcessNode/InProcessNode.h"
21+
#include "InProcessNode/InProcessNodeErrors.h"
2022
#include "P2p/NetNode.h"
21-
#include "WalletLegacy/WalletLegacy.h"
23+
#include "Wallet/WalletGreen.h"
2224
#include "Logging/LoggerManager.h"
2325
#include "System/Dispatcher.h"
2426
#include "Settings.h"
2527

28+
#include <QTimer>
29+
#include <QThread>
30+
2631
namespace WalletGui {
2732

2833
namespace {
@@ -88,28 +93,30 @@ std::string extractPaymentId(const std::string& extra) {
8893

8994
}
9095

91-
Node::~Node() {
92-
}
9396

94-
class RpcNode : cn::INodeObserver, public Node {
97+
class RpcNode : public cn::INodeObserver, public Node {
9598
public:
96-
RpcNode(const cn::Currency& currency, logging::LoggerManager& logManager, INodeCallback& callback, const std::string& nodeHost, unsigned short nodePort) :
97-
m_callback(callback),
98-
m_currency(currency),
99-
m_logger(logManager),
100-
m_node(nodeHost, nodePort) {
99+
RpcNode(const cn::Currency& currency, logging::LoggerManager& logManager, INodeCallback& callback,
100+
const std::string& nodeHost, unsigned short nodePort)
101+
: m_callback(callback),
102+
m_currency(currency),
103+
m_stopEvent(m_dispatcher),
104+
m_node(nodeHost, nodePort),
105+
m_logger(logManager) {
101106
m_node.addObserver(this);
102107
}
103108

104-
~RpcNode() override {
105-
}
109+
~RpcNode() override = default;
106110

107111
void init(const std::function<void(std::error_code)>& callback) override {
108112
m_node.init(callback);
113+
m_stopEvent.wait();
109114
}
110115

111116
void deinit() override {
112-
/* nothing to be done here */
117+
m_dispatcher.remoteSpawn([this] {
118+
m_stopEvent.set();
119+
});
113120
}
114121

115122
std::string convertPaymentId(const std::string& paymentIdString) override {
@@ -136,37 +143,40 @@ class RpcNode : cn::INodeObserver, public Node {
136143
return m_node.getPeerCount();
137144
}
138145

139-
cn::IWalletLegacy* createWallet() override {
140-
return new cn::WalletLegacy(m_currency, m_node, m_logger, Settings::instance().isTestnet());
146+
std::unique_ptr<cn::IWallet> createWallet() override {
147+
return std::unique_ptr<cn::IWallet>(
148+
new cn::WalletGreen(m_dispatcher, m_currency, m_node, m_logger));
141149
}
142150

143151
private:
144152
INodeCallback& m_callback;
145153
const cn::Currency& m_currency;
154+
platform_system::Dispatcher m_dispatcher;
155+
platform_system::Event m_stopEvent;
146156
cn::NodeRpcProxy m_node;
147157
logging::LoggerManager& m_logger;
148158

149-
void peerCountUpdated(size_t count) {
159+
void peerCountUpdated(size_t count) override {
150160
m_callback.peerCountUpdated(*this, count);
151161
}
152162

153-
void localBlockchainUpdated(uint64_t height) {
163+
void localBlockchainUpdated(uint32_t height) override {
154164
m_callback.localBlockchainUpdated(*this, height);
155165
}
156166

157-
void lastKnownBlockHeightUpdated(uint64_t height) {
167+
void lastKnownBlockHeightUpdated(uint32_t height) override {
158168
m_callback.lastKnownBlockHeightUpdated(*this, height);
159169
}
160170
};
161171

162-
class InprocessNode : cn::INodeObserver, public Node {
172+
class InprocessNode : public cn::INodeObserver, public Node {
163173
public:
164174
InprocessNode(const cn::Currency& currency, logging::LoggerManager& logManager, const cn::CoreConfig& coreConfig,
165175
const cn::NetNodeConfig& netNodeConfig, INodeCallback& callback) :
166-
m_currency(currency),
167-
m_dispatcher(),
168-
m_loggerManager(logManager),
169176
m_callback(callback),
177+
m_currency(currency),
178+
m_stopEvent(m_dispatcher),
179+
m_loggerManager(logManager),
170180
m_coreConfig(coreConfig),
171181
m_netNodeConfig(netNodeConfig),
172182
m_protocolHandler(currency, m_dispatcher, m_core, nullptr, logManager),
@@ -183,9 +193,7 @@ class InprocessNode : cn::INodeObserver, public Node {
183193
m_protocolHandler.set_p2p_endpoint(&m_nodeServer);
184194
}
185195

186-
~InprocessNode() override {
187-
188-
}
196+
~InprocessNode() override = default;
189197

190198
void init(const std::function<void(std::error_code)>& callback) override {
191199
try {
@@ -242,33 +250,34 @@ class InprocessNode : cn::INodeObserver, public Node {
242250
return m_node.getPeerCount();
243251
}
244252

245-
cn::IWalletLegacy* createWallet() override {
246-
return new cn::WalletLegacy(m_currency, m_node, m_loggerManager, Settings::instance().isTestnet());
253+
std::unique_ptr<cn::IWallet> createWallet() override {
254+
return std::unique_ptr<cn::IWallet>(
255+
new cn::WalletGreen(m_dispatcher, m_currency, m_node, m_loggerManager));
247256
}
248257

249258
private:
250259
INodeCallback& m_callback;
251260
const cn::Currency& m_currency;
252261
platform_system::Dispatcher m_dispatcher;
262+
platform_system::Event m_stopEvent;
253263
logging::LoggerManager& m_loggerManager;
254264
cn::CoreConfig m_coreConfig;
255265
cn::NetNodeConfig m_netNodeConfig;
256-
cn::core m_core;
257266
cn::CryptoNoteProtocolHandler m_protocolHandler;
267+
cn::core m_core;
258268
cn::NodeServer m_nodeServer;
259269
cn::InProcessNode m_node;
260270
std::future<bool> m_nodeServerFuture;
261271

262-
263-
void peerCountUpdated(size_t count) {
272+
void peerCountUpdated(size_t count) override {
264273
m_callback.peerCountUpdated(*this, count);
265274
}
266275

267-
void localBlockchainUpdated(uint64_t height) {
276+
void localBlockchainUpdated(uint32_t height) override {
268277
m_callback.localBlockchainUpdated(*this, height);
269278
}
270279

271-
void lastKnownBlockHeightUpdated(uint64_t height) {
280+
void lastKnownBlockHeightUpdated(uint32_t height) override {
272281
m_callback.lastKnownBlockHeightUpdated(*this, height);
273282
}
274283
};

src/CryptoNoteWrapper.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
namespace cn {
1818

1919
class INode;
20-
class IWalletLegacy;
20+
class IWallet;
2121
class Currency;
2222
class CoreConfig;
2323
class NetNodeConfig;
@@ -32,7 +32,7 @@ namespace WalletGui {
3232

3333
class Node {
3434
public:
35-
virtual ~Node() = 0;
35+
virtual ~Node() = default;
3636
virtual void init(const std::function<void(std::error_code)>& callback) = 0;
3737
virtual void deinit() = 0;
3838

@@ -43,11 +43,12 @@ class Node {
4343
virtual uint64_t getLastLocalBlockTimestamp() const = 0;
4444
virtual uint64_t getPeerCount() const = 0;
4545

46-
virtual cn::IWalletLegacy* createWallet() = 0;
46+
virtual std::unique_ptr<cn::IWallet> createWallet() = 0;
4747
};
4848

4949
class INodeCallback {
5050
public:
51+
virtual ~INodeCallback() = default;
5152
virtual void peerCountUpdated(Node& node, size_t count) = 0;
5253
virtual void localBlockchainUpdated(Node& node, uint64_t height) = 0;
5354
virtual void lastKnownBlockHeightUpdated(Node& node, uint64_t height) = 0;

0 commit comments

Comments
 (0)