Electroneum
Loading...
Searching...
No Matches
wallet_manager.h
Go to the documentation of this file.
1// Copyrights(c) 2017-2021, The Electroneum Project
2// Copyrights(c) 2014-2019, The Monero Project
3//
4// All rights reserved.
5//
6// Redistribution and use in source and binary forms, with or without modification, are
7// permitted provided that the following conditions are met:
8//
9// 1. Redistributions of source code must retain the above copyright notice, this list of
10// conditions and the following disclaimer.
11//
12// 2. Redistributions in binary form must reproduce the above copyright notice, this list
13// of conditions and the following disclaimer in the documentation and/or other
14// materials provided with the distribution.
15//
16// 3. Neither the name of the copyright holder nor the names of its contributors may be
17// used to endorse or promote products derived from this software without specific
18// prior written permission.
19//
20// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
21// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
28// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29//
30// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
31
32
34#include "net/http_client.h"
35#include <string>
36
37namespace Electroneum {
38
39class WalletManagerImpl : public WalletManager
40{
41public:
42 Wallet * createWallet(const std::string &path, const std::string &password,
43 const std::string &language, NetworkType nettype, uint64_t kdf_rounds = 1) override;
44 Wallet * openWallet(const std::string &path, const std::string &password, NetworkType nettype, uint64_t kdf_rounds = 1, WalletListener * listener = nullptr) override;
45 virtual Wallet * recoveryWallet(const std::string &path,
46 const std::string &password,
47 const std::string &mnemonic,
48 NetworkType nettype,
49 uint64_t restoreHeight,
50 uint64_t kdf_rounds = 1) override;
51 virtual Wallet * createWalletFromKeys(const std::string &path,
52 const std::string &password,
53 const std::string &language,
54 NetworkType nettype,
55 uint64_t restoreHeight,
56 const std::string &addressString,
57 const std::string &viewKeyString,
58 const std::string &spendKeyString = "",
59 uint64_t kdf_rounds = 1) override;
60 // next two methods are deprecated - use the above version which allow setting of a password
61 virtual Wallet * recoveryWallet(const std::string &path, const std::string &mnemonic, NetworkType nettype, uint64_t restoreHeight) override;
62 // deprecated: use createWalletFromKeys(..., password, ...) instead
63 virtual Wallet * createWalletFromKeys(const std::string &path,
64 const std::string &language,
65 NetworkType nettype,
66 uint64_t restoreHeight,
67 const std::string &addressString,
68 const std::string &viewKeyString,
69 const std::string &spendKeyString = "") override;
70 virtual Wallet * createWalletFromDevice(const std::string &path,
71 const std::string &password,
72 NetworkType nettype,
73 const std::string &deviceName,
74 uint64_t restoreHeight = 0,
75 const std::string &subaddressLookahead = "",
76 uint64_t kdf_rounds = 1,
77 WalletListener * listener = nullptr) override;
78 virtual bool closeWallet(Wallet *wallet, bool store = true) override;
79 bool walletExists(const std::string &path) override;
80 bool verifyWalletPassword(const std::string &keys_file_name, const std::string &password, bool no_spend_key, uint64_t kdf_rounds = 1) const override;
81 bool queryWalletDevice(Wallet::Device& device_type, const std::string &keys_file_name, const std::string &password, uint64_t kdf_rounds = 1) const override;
82 std::vector<std::string> findWallets(const std::string &path) override;
83 std::string errorString() const override;
84 void setDaemonAddress(const std::string &address) override;
85 bool connected(uint32_t *version = NULL) override;
86 uint64_t blockchainHeight() override;
88 uint64_t networkDifficulty() override;
89 double miningHashRate() override;
90 uint64_t blockTarget() override;
91 bool isMining() override;
92 bool startMining(const std::string &address, uint32_t threads = 1, bool background_mining = false, bool ignore_battery = true) override;
93 bool stopMining() override;
94 std::string resolveOpenAlias(const std::string &address, bool &dnssec_valid) const override;
95
96private:
97 WalletManagerImpl() {}
98 friend struct WalletManagerFactory;
99 std::string m_daemonAddress;
101 std::string m_errorString;
102};
103
104} // namespace
105
106namespace Bitelectroneum = Electroneum;
uint8_t version
Wallet * openWallet(const std::string &path, const std::string &password, NetworkType nettype, uint64_t kdf_rounds=1, WalletListener *listener=nullptr) override
Opens existing wallet.
double miningHashRate() override
returns current mining hash rate (0 if not mining)
void setDaemonAddress(const std::string &address) override
set the daemon address (hostname and port)
virtual bool closeWallet(Wallet *wallet, bool store=true) override
Closes wallet. In case operation succeeded, wallet object deleted. in case operation failed,...
std::string errorString() const override
returns verbose error string regarding last error;
bool connected(uint32_t *version=NULL) override
returns whether the daemon can be reached, and its version number
uint64_t blockchainTargetHeight() override
returns current blockchain target height
std::vector< std::string > findWallets(const std::string &path) override
findWallets - searches for the wallet files by given path name recursively
bool isMining() override
returns true iff mining
uint64_t blockTarget() override
returns current block target
std::string resolveOpenAlias(const std::string &address, bool &dnssec_valid) const override
resolves an OpenAlias address to a electroneum address
bool walletExists(const std::string &path) override
TODO: delme walletExists - check if the given filename is the wallet.
bool verifyWalletPassword(const std::string &keys_file_name, const std::string &password, bool no_spend_key, uint64_t kdf_rounds=1) const override
verifyWalletPassword - check if the given filename is the wallet
bool startMining(const std::string &address, uint32_t threads=1, bool background_mining=false, bool ignore_battery=true) override
starts mining with the set number of threads
bool queryWalletDevice(Wallet::Device &device_type, const std::string &keys_file_name, const std::string &password, uint64_t kdf_rounds=1) const override
determine the key storage for the specified wallet file
virtual Wallet * createWalletFromDevice(const std::string &path, const std::string &password, NetworkType nettype, const std::string &deviceName, uint64_t restoreHeight=0, const std::string &subaddressLookahead="", uint64_t kdf_rounds=1, WalletListener *listener=nullptr) override
creates wallet using hardware device.
virtual Wallet * createWalletFromKeys(const std::string &path, const std::string &password, const std::string &language, NetworkType nettype, uint64_t restoreHeight, const std::string &addressString, const std::string &viewKeyString, const std::string &spendKeyString="", uint64_t kdf_rounds=1) override
recovers existing wallet using keys. Creates a view only wallet if spend key is omitted
Wallet * createWallet(const std::string &path, const std::string &password, const std::string &language, NetworkType nettype, uint64_t kdf_rounds=1) override
Creates new wallet.
uint64_t blockchainHeight() override
returns current blockchain height
uint64_t networkDifficulty() override
returns current network difficulty
bool stopMining() override
stops mining
virtual Wallet * recoveryWallet(const std::string &path, const std::string &password, const std::string &mnemonic, NetworkType nettype, uint64_t restoreHeight, uint64_t kdf_rounds=1) override
recovers existing wallet using mnemonic (electrum seed)
http_simple_client_template< blocked_mode_client > http_simple_client
unsigned int uint32_t
Definition stdint.h:126
unsigned __int64 uint64_t
Definition stdint.h:136
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
WalletManager - provides functions to manage wallets.
const char * address
Definition multisig.cpp:37