ledger-core
BCHBech32.h
1 /*
2  *
3  * BCHBech32
4  *
5  * Created by El Khalil Bellakrid on 18/02/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_BCHBECH32_H
33 #define LEDGER_CORE_BCHBECH32_H
34 
35 #include "Bech32.h"
36 #include "Bech32Parameters.h"
37 // Refecrence: https://github.com/bitcoincashjs/cashaddrjs
38 namespace ledger {
39  namespace core {
40  class BCHBech32 : public Bech32 {
41  public:
42  BCHBech32() {
43  _bech32Params = Bech32Parameters::getBech32Params("abc");
44  };
45 
46  uint64_t polymod(const std::vector<uint8_t>& values) override;
47 
48  std::vector<uint8_t> expandHrp(const std::string& hrp) override;
49 
50  std::string encode(const std::vector<uint8_t>& hash,
51  const std::vector<uint8_t>& version) override;
52 
53  std::pair<std::vector<uint8_t>, std::vector<uint8_t>>
54  decode(const std::string& str) override;
55  };
56  }
57 }
58 
59 
60 #endif //LEDGER_CORE_BCHBECH32_H
Definition: BCHBech32.h:40
Definition: Bech32.h:46
Definition: Account.cpp:8