ledger-core
TezosLikeKeychain.h
1 /*
2  *
3  * TezosLikeKeychain
4  *
5  * Created by El Khalil Bellakrid on 27/04/2019.
6  *
7  * The MIT License (MIT)
8  *
9  * Copyright (c) 2019 Ledger
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining a copy
12  * of this software and associated documentation files (the "Software"), to deal
13  * in the Software without restriction, including without limitation the rights
14  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15  * copies of the Software, and to permit persons to whom the Software is
16  * furnished to do so, subject to the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be included in all
19  * copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27  * SOFTWARE.
28  *
29  */
30 
31 
32 #ifndef LEDGER_CORE_TEZOSLIKEKEYCHAIN_H
33 #define LEDGER_CORE_TEZOSLIKEKEYCHAIN_H
34 
35 #include <string>
36 #include <vector>
37 #include <utils/DerivationScheme.hpp>
38 #include <utils/Option.hpp>
39 #include <preferences/Preferences.hpp>
40 #include <api/Configuration.hpp>
41 #include <api/DynamicObject.hpp>
42 #include <api/Currency.hpp>
43 #include <api/AccountCreationInfo.hpp>
44 #include <api/ExtendedKeyAccountCreationInfo.hpp>
45 #include <api/TezosLikeExtendedPublicKey.hpp>
46 #include <tezos/TezosLikeAddress.h>
47 
48 namespace ledger {
49  namespace core {
51 
52  public:
53  using Address = std::shared_ptr<TezosLikeAddress>;
54 
55  TezosLikeKeychain(const std::shared_ptr<api::DynamicObject> &configuration,
56  const api::Currency &params,
57  const Option<std::vector<uint8_t>> &pubKey,
58  const std::shared_ptr<Preferences> &preferences);
59 
60  std::vector <Address> getAllObservableAddresses(uint32_t from, uint32_t to);
61 
62  Address getAddress() const;
63 
64  const api::TezosLikeNetworkParameters &getNetworkParameters() const;
65 
66  const api::Currency &getCurrency() const;
67 
68  Option <std::vector<uint8_t>> getPublicKey() const;
69 
70  std::shared_ptr <api::DynamicObject> getConfiguration() const;
71 
72  std::string getRestoreKey() const;
73 
74  bool contains(const std::string &address) const;
75 
76  protected:
77  std::shared_ptr <Preferences> getPreferences() const;
78 
79  private:
80  TezosLikeKeychain::Address getAddressFromPublicKey();
81 
82  const api::Currency _currency;
83  std::shared_ptr<Preferences> _preferences;
84  std::shared_ptr<api::DynamicObject> _configuration;
85  std::shared_ptr<TezosLikeAddress> _address;
86  Option<std::vector<uint8_t>> _publicKey;
87  };
88  }
89 }
90 #endif //LEDGER_CORE_TEZOSLIKEKEYCHAIN_H
Definition: Option.hpp:49
Definition: Currency.hpp:23
Definition: Account.cpp:8
Definition: TezosLikeKeychain.h:50
Definition: TezosLikeNetworkParameters.hpp:15