ledger-core
WalletPoolApi.hpp
1 /*
2  *
3  * WalletPool
4  * ledger-core
5  *
6  * Created by Pierre Pollastri on 15/11/2016.
7  *
8  * The MIT License (MIT)
9  *
10  * Copyright (c) 2016 Ledger
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a copy
13  * of this software and associated documentation files (the "Software"), to deal
14  * in the Software without restriction, including without limitation the rights
15  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16  * copies of the Software, and to permit persons to whom the Software is
17  * furnished to do so, subject to the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be included in all
20  * copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28  * SOFTWARE.
29  *
30  */
31 #ifndef LEDGER_CORE_WALLETPOOL_API_HPP
32 #define LEDGER_CORE_WALLETPOOL_API_HPP
33 
34 #include <api/WalletPool.hpp>
35 #include <wallet/pool/WalletPool.hpp>
36 #include <api/WalletPoolCallback.hpp>
37 #include <api/ErrorCodeCallback.hpp>
38 #include <debug/LoggerApi.hpp>
39 
40 namespace ledger {
41  namespace core {
42 
43  class BitcoinLikeWalletFactory;
44 
45  class WalletPoolApi : public api::WalletPool, public std::enable_shared_from_this<WalletPoolApi> {
46  public:
47  WalletPoolApi(const std::shared_ptr<ledger::core::WalletPool>& pool);
48  std::shared_ptr<api::Logger> getLogger() override;
49  std::shared_ptr<api::Preferences> getPreferences() override;
50 
51  void getWalletCount(const std::shared_ptr<api::I32Callback> &callback) override;
52 
53  void getWallet(const std::string &name, const std::shared_ptr<api::WalletCallback> &callback) override;
54 
55  void updateWalletConfig(const std::string &name,
56  const std::shared_ptr<api::DynamicObject> &configuration,
57  const std::shared_ptr<api::ErrorCodeCallback> &callback) override;
58 
59  void getWallets(int32_t from, int32_t size, const std::shared_ptr<api::WalletListCallback> &callback) override;
60 
61  void createWallet(const std::string &name, const api::Currency &currency,
62  const std::shared_ptr<api::DynamicObject> &configuration,
63  const std::shared_ptr<api::WalletCallback> &callback) override;
64 
65  void getCurrencies(const std::shared_ptr <api::CurrencyListCallback> &callback) override;
66 
67  void getCurrency(const std::string &name, const std::shared_ptr<api::CurrencyCallback> &callback) override;
68 
69  std::string getName() override;
70 
71  std::shared_ptr<api::EventBus> getEventBus() override;
72 
73  void
74  getLastBlock(const std::string &currencyName, const std::shared_ptr<api::BlockCallback> &callback) override;
75 
76  void eraseDataSince(const std::chrono::system_clock::time_point & date, const std::shared_ptr<api::ErrorCodeCallback> & callback) override;
77 
78  void freshResetAll(const std::shared_ptr<api::ErrorCodeCallback>& callback) override;
79 
80  void changePassword(const std::string &oldPassword,
81  const std::string &newPassword,
82  const std::shared_ptr<api::ErrorCodeCallback> & callback) override;
83 
84  ~WalletPoolApi();
85 
86  private:
87  std::shared_ptr<ledger::core::WalletPool> _pool;
88  std::shared_ptr<LoggerApi> _logger;
89  std::shared_ptr<api::ExecutionContext> _mainContext;
90 
91  public:
92  static void open( const std::string &name,
93  const std::string &password,
94  const std::shared_ptr<api::HttpClient> &httpClient,
95  const std::shared_ptr<api::WebSocketClient> &webSocketClient,
96  const std::shared_ptr<api::PathResolver> &pathResolver,
97  const std::shared_ptr<api::LogPrinter> &logPrinter,
98  const std::shared_ptr<api::ThreadDispatcher> &dispatcher,
99  const std::shared_ptr<api::RandomNumberGenerator>& rng,
100  const std::shared_ptr<api::DatabaseBackend> &backend,
101  const std::shared_ptr<api::DynamicObject>& configuration,
102  const std::shared_ptr<api::WalletPoolCallback>& listener);
103  };
104  }
105 }
106 
107 
108 #endif //LEDGER_CORE_WALLETPOOL_API_HPP
std::shared_ptr< api::EventBus > getEventBus() override
Definition: WalletPoolApi.cpp:166
Definition: WalletPoolApi.hpp:45
std::shared_ptr< api::Preferences > getPreferences() override
Definition: WalletPoolApi.cpp:100
Definition: Currency.hpp:23
Definition: Account.cpp:8
std::string getName() override
Definition: WalletPoolApi.cpp:158
std::shared_ptr< api::Logger > getLogger() override
Definition: WalletPoolApi.cpp:96
Definition: WalletPool.hpp:42