1
// Copyright © 2017-2020 Trust Wallet.
2
//
3
// This file is part of Trust. The full Trust copyright notice, including
4
// terms governing use, modification, and redistribution, is contained in the
5
// file LICENSE at the root of the source code distribution tree.
6

7
#pragma once
8

9
#include "../Base58Address.h"
10
#include "../PublicKey.h"
11

12
#include <array>
13
#include <cstdint>
14
#include <string>
15

16
namespace TW::Zcash {
17

18
class TAddress : public TW::Base58Address<22> {
19
  public:
20
    static const byte staticPrefix = 0x1c;
21
    static const byte p2pkh = 0xB8; // p2pkhPrefix(TWCoinType::TWCoinTypeZcash);
22
    static const byte p2sh = 0xBD; // p2shPrefix(TWCoinType::TWCoinTypeZcash);
23

24
    /// Determines whether a string makes a valid ZCash address.
25 1
    static bool isValid(const std::string& string) {
26 1
        return TW::Base58Address<size>::isValid(string, {{staticPrefix, p2pkh}, {staticPrefix, p2sh}});
27
    }
28

29
    /// Determines whether a string makes a valid ZCash address, with possible prefixes.
30
    static bool isValid(const std::string& string, const std::vector<Data>& validPrefixes) {
31
        return TW::Base58Address<size>::isValid(string, validPrefixes);
32
    }
33

34
    /// Initializes a  address with a string representation.
35 1
    explicit TAddress(const std::string& string) : TW::Base58Address<size>(string) {}
36

37
    /// Initializes a  address with a collection of bytes.
38
    explicit TAddress(const Data& data) : TW::Base58Address<size>(data) {}
39

40
    /// Initializes a  address with a public key and a prefix (2nd byte).
41 1
    TAddress(const PublicKey& publicKey, uint8_t prefix = p2pkh) : TW::Base58Address<size>(publicKey, {staticPrefix, prefix}) {}
42

43
  private:
44
    TAddress() = default;
45
};
46

47
} // namespace TW::Zcash
48

49
/// Wrapper for C interface.
50
struct TWZcashTAddress {
51
    TW::Zcash::TAddress impl;
52
};

Read our documentation on viewing source code .

Loading