2017-11-23 11:20:20 -08:00
|
|
|
#ifndef ZC_ADDRESS_H_
|
|
|
|
#define ZC_ADDRESS_H_
|
2016-05-04 17:25:42 -07:00
|
|
|
|
2020-02-18 07:28:04 -08:00
|
|
|
#include "zcash/address/sapling.hpp"
|
|
|
|
#include "zcash/address/sprout.hpp"
|
2020-02-18 07:48:13 -08:00
|
|
|
#include "zcash/address/zip32.h"
|
2016-05-04 17:25:42 -07:00
|
|
|
|
2020-10-20 17:05:00 -07:00
|
|
|
#include <variant>
|
2018-04-25 18:51:17 -07:00
|
|
|
|
2016-05-04 17:25:42 -07:00
|
|
|
namespace libzcash {
|
2018-04-25 18:51:17 -07:00
|
|
|
class InvalidEncoding {
|
|
|
|
public:
|
|
|
|
friend bool operator==(const InvalidEncoding &a, const InvalidEncoding &b) { return true; }
|
|
|
|
friend bool operator<(const InvalidEncoding &a, const InvalidEncoding &b) { return true; }
|
|
|
|
};
|
2016-05-04 17:25:42 -07:00
|
|
|
|
2020-10-20 17:07:14 -07:00
|
|
|
typedef std::variant<InvalidEncoding, SproutPaymentAddress, SaplingPaymentAddress> PaymentAddress;
|
|
|
|
typedef std::variant<InvalidEncoding, SproutViewingKey, SaplingExtendedFullViewingKey> ViewingKey;
|
|
|
|
typedef std::variant<InvalidEncoding, SproutSpendingKey, SaplingExtendedSpendingKey> SpendingKey;
|
2018-06-06 21:40:59 -07:00
|
|
|
|
2020-10-20 17:07:14 -07:00
|
|
|
class AddressInfoFromSpendingKey {
|
2019-11-11 15:49:11 -08:00
|
|
|
public:
|
|
|
|
std::pair<std::string, PaymentAddress> operator()(const SproutSpendingKey&) const;
|
|
|
|
std::pair<std::string, PaymentAddress> operator()(const struct SaplingExtendedSpendingKey&) const;
|
|
|
|
std::pair<std::string, PaymentAddress> operator()(const InvalidEncoding&) const;
|
|
|
|
};
|
|
|
|
|
2020-10-20 17:07:14 -07:00
|
|
|
class AddressInfoFromViewingKey {
|
2020-04-06 13:11:50 -07:00
|
|
|
public:
|
|
|
|
std::pair<std::string, PaymentAddress> operator()(const SproutViewingKey&) const;
|
|
|
|
std::pair<std::string, PaymentAddress> operator()(const struct SaplingExtendedFullViewingKey&) const;
|
|
|
|
std::pair<std::string, PaymentAddress> operator()(const InvalidEncoding&) const;
|
|
|
|
};
|
|
|
|
|
2016-05-04 17:25:42 -07:00
|
|
|
}
|
|
|
|
|
2018-04-25 18:51:17 -07:00
|
|
|
/** Check whether a PaymentAddress is not an InvalidEncoding. */
|
|
|
|
bool IsValidPaymentAddress(const libzcash::PaymentAddress& zaddr);
|
|
|
|
|
|
|
|
/** Check whether a ViewingKey is not an InvalidEncoding. */
|
|
|
|
bool IsValidViewingKey(const libzcash::ViewingKey& vk);
|
|
|
|
|
2020-02-18 07:48:13 -08:00
|
|
|
/** Check whether a SpendingKey is not an InvalidEncoding. */
|
|
|
|
bool IsValidSpendingKey(const libzcash::SpendingKey& zkey);
|
|
|
|
|
2017-11-23 11:20:20 -08:00
|
|
|
#endif // ZC_ADDRESS_H_
|