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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user