ledger-core
RippleLikeAddress.h
1 /*
2  *
3  * RippleLikeAddress
4  *
5  * Created by El Khalil Bellakrid on 05/01/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_RIPPLELIKEADDRESS_H
33 #define LEDGER_CORE_RIPPLELIKEADDRESS_H
34 
35 
36 #include <api/RippleLikeAddress.hpp>
37 #include <api/RippleLikeNetworkParameters.hpp>
38 #include "../utils/optional.hpp"
39 #include <wallet/common/AbstractAddress.h>
40 
41 namespace ledger {
42  namespace core {
44  public:
46  const std::vector<uint8_t>& hash160,
47  const std::vector<uint8_t>& version,
48  const Option<std::string>& derivationPath = Option<std::string>());
49  std::vector<uint8_t> getVersion() override ;
50  std::vector<uint8_t> getHash160() override ;
52  std::string toBase58() override ;
53 
55  std::string toString() override ;
56 
57  static std::shared_ptr<AbstractAddress> parse(const std::string& address, const api::Currency& currency,
58  const Option<std::string>& derivationPath = Option<std::string>());
59  static std::shared_ptr<RippleLikeAddress> fromBase58(const std::string& address,
60  const api::Currency& currency,
61  const Option<std::string>& derivationPath = Option<std::string>());
62  private:
63  const std::vector<uint8_t> _version;
64  const std::vector<uint8_t> _hash160;
66  const Option<std::string> _derivationPath;
67  };
68  }
69 }
70 
71 
72 #endif //LEDGER_CORE_RIPPLELIKEADDRESS_H
std::string toString() override
Definition: RippleLikeAddress.cpp:79
Definition: RippleLikeNetworkParameters.hpp:15
Definition: RippleLikeAddress.h:43
optional< std::string > getDerivationPath() override
Definition: RippleLikeAddress.cpp:75
Definition: AbstractAddress.h:42
Definition: Currency.hpp:23
std::string toBase58() override
Definition: RippleLikeAddress.cpp:67
std::vector< uint8_t > getVersion() override
Definition: RippleLikeAddress.cpp:55
Definition: Account.cpp:8
api::RippleLikeNetworkParameters getNetworkParameters() override
Definition: RippleLikeAddress.cpp:63
Definition: optional.hpp:177
std::vector< uint8_t > getHash160() override
Definition: RippleLikeAddress.cpp:59
Definition: RippleLikeAddress.hpp:23