Remove ZcashdUnifiedAddress in favor of UnifiedAddress

This commit is contained in:
Kris Nuttycombe 2021-11-19 16:29:24 -07:00
parent a2f8e3b56c
commit 3bfb9d0c84
2 changed files with 15 additions and 33 deletions

View File

@ -39,8 +39,17 @@ ZcashdUnifiedFullViewingKey ZcashdUnifiedSpendingKey::ToFullViewingKey() const {
return ufvk;
}
std::optional<ZcashdUnifiedAddress> ZcashdUnifiedFullViewingKey::Address(diversifier_index_t j) const {
ZcashdUnifiedAddress ua;
std::optional<UnifiedAddress> ZcashdUnifiedFullViewingKey::Address(diversifier_index_t j) const {
UnifiedAddress ua;
if (saplingKey.has_value()) {
auto saplingAddress = saplingKey.value().Address(j);
if (saplingAddress.has_value()) {
ua.AddReceiver(saplingAddress.value());
} else {
return std::nullopt;
}
}
if (transparentKey.has_value()) {
auto childIndex = j.ToTransparentChildIndex();
@ -53,16 +62,7 @@ std::optional<ZcashdUnifiedAddress> ZcashdUnifiedFullViewingKey::Address(diversi
CExtPubKey childKey;
if (externalKey.Derive(childKey, childIndex.value())) {
ua.transparentAddress = childKey.pubkey.GetID();
} else {
return std::nullopt;
}
}
if (saplingKey.has_value()) {
auto saplingAddress = saplingKey.value().Address(j);
if (saplingAddress.has_value()) {
ua.saplingAddress = saplingAddress.value();
ua.AddReceiver(childKey.pubkey.GetID());
} else {
return std::nullopt;
}

View File

@ -7,31 +7,13 @@
#include "zip32.h"
#include "bip44.h"
#include "zcash/Address.hpp"
namespace libzcash {
class ZcashdUnifiedSpendingKey;
class ZcashdUnifiedFullViewingKey;
class ZcashdUnifiedAddress {
private:
diversifier_index_t diversifier_index;
std::optional<CKeyID> transparentAddress;
std::optional<SaplingPaymentAddress> saplingAddress;
friend class ZcashdUnifiedFullViewingKey;
ZcashdUnifiedAddress() {}
public:
const std::optional<CKeyID>& GetTransparentAddress() const {
return transparentAddress;
}
const std::optional<SaplingPaymentAddress>& GetSaplingPaymentAddress() const {
return saplingAddress;
}
};
class ZcashdUnifiedFullViewingKey {
private:
std::optional<CExtPubKey> transparentKey;
@ -49,9 +31,9 @@ public:
return saplingKey;
}
std::optional<ZcashdUnifiedAddress> Address(diversifier_index_t j) const;
std::optional<UnifiedAddress> Address(diversifier_index_t j) const;
std::pair<ZcashdUnifiedAddress, diversifier_index_t> FindAddress(diversifier_index_t j) const {
std::pair<UnifiedAddress, diversifier_index_t> FindAddress(diversifier_index_t j) const {
auto addr = Address(j);
while (!addr.has_value()) {
if (!j.increment())