Introduce wrappers around CZCPaymentAddress

This patch removes the need for the intermediary Base58 type
CZCPaymentAddress, by providing {Encode,Decode}PaymentAddress
functions that directly operate on the conversion between strings
and libzcash::PaymentAddress.
This commit is contained in:
Jack Grigg
2018-04-24 15:01:45 +01:00
parent f146029b0a
commit 80ed13d545
15 changed files with 135 additions and 140 deletions

View File

@@ -363,3 +363,18 @@ template bool CZCEncoding<libzcash::SpendingKey,
template libzcash::SpendingKey CZCEncoding<libzcash::SpendingKey,
CChainParams::ZCSPENDING_KEY,
libzcash::SerializedSpendingKeySize>::Get() const;
std::string EncodePaymentAddress(const libzcash::PaymentAddress& zaddr)
{
return CZCPaymentAddress(zaddr).ToString();
}
boost::optional<libzcash::PaymentAddress> DecodePaymentAddress(const std::string& str)
{
CZCPaymentAddress addr(str);
try {
return addr.Get();
} catch (const std::runtime_error&) {
return boost::none;
}
}