Fix naming of unified spending & full viewing keys
This commit is contained in:
parent
cd01b2d9bf
commit
87f7e5fbba
|
@ -406,7 +406,7 @@ bool CWallet::AddCryptedSaplingSpendingKey(const libzcash::SaplingExtendedFullVi
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
UnifiedSpendingKey CWallet::GenerateNewUnifiedSpendingKey() {
|
ZcashdUnifiedSpendingKey CWallet::GenerateNewUnifiedSpendingKey() {
|
||||||
AssertLockHeld(cs_wallet);
|
AssertLockHeld(cs_wallet);
|
||||||
|
|
||||||
CHDChain& hdChain = mnemonicHDChain.value();
|
CHDChain& hdChain = mnemonicHDChain.value();
|
||||||
|
@ -426,13 +426,13 @@ UnifiedSpendingKey CWallet::GenerateNewUnifiedSpendingKey() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<libzcash::UnifiedSpendingKey> CWallet::GenerateUnifiedSpendingKeyForAccount(uint32_t accountId) {
|
std::optional<libzcash::ZcashdUnifiedSpendingKey> CWallet::GenerateUnifiedSpendingKeyForAccount(uint32_t accountId) {
|
||||||
auto seed = GetMnemonicSeed();
|
auto seed = GetMnemonicSeed();
|
||||||
if (!seed.has_value()) {
|
if (!seed.has_value()) {
|
||||||
throw std::runtime_error(std::string(__func__) + ": Wallet has no mnemonic HD seed. Please upgrade this wallet.");
|
throw std::runtime_error(std::string(__func__) + ": Wallet has no mnemonic HD seed. Please upgrade this wallet.");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto usk = UnifiedSpendingKey::ForAccount(seed.value(), BIP44CoinType(), accountId);
|
auto usk = ZcashdUnifiedSpendingKey::ForAccount(seed.value(), BIP44CoinType(), accountId);
|
||||||
if (usk.has_value()) {
|
if (usk.has_value()) {
|
||||||
// TODO: Save the unified full viewing key & metadata to the wallet
|
// TODO: Save the unified full viewing key & metadata to the wallet
|
||||||
|
|
||||||
|
|
|
@ -1096,8 +1096,8 @@ public:
|
||||||
/**
|
/**
|
||||||
* Unified keys & addresses
|
* Unified keys & addresses
|
||||||
*/
|
*/
|
||||||
libzcash::UnifiedSpendingKey GenerateNewUnifiedSpendingKey();
|
libzcash::ZcashdUnifiedSpendingKey GenerateNewUnifiedSpendingKey();
|
||||||
std::optional<libzcash::UnifiedSpendingKey> GenerateUnifiedSpendingKeyForAccount(uint32_t accountId);
|
std::optional<libzcash::ZcashdUnifiedSpendingKey> GenerateUnifiedSpendingKeyForAccount(uint32_t accountId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Increment the next transaction order id
|
* Increment the next transaction order id
|
||||||
|
|
|
@ -38,7 +38,7 @@ MnemonicSeed MnemonicSeed::Random(uint32_t bip44CoinType, Language language, siz
|
||||||
// account 0x7FFFFFFF because derivation via the legacy path can simply search
|
// account 0x7FFFFFFF because derivation via the legacy path can simply search
|
||||||
// for a valid diversifier; unlike in the unified spending key case, diversifier
|
// for a valid diversifier; unlike in the unified spending key case, diversifier
|
||||||
// indices don't need to line up with anything.
|
// indices don't need to line up with anything.
|
||||||
if (libzcash::UnifiedSpendingKey::ForAccount(seed, bip44CoinType, 0).has_value() &&
|
if (libzcash::ZcashdUnifiedSpendingKey::ForAccount(seed, bip44CoinType, 0).has_value() &&
|
||||||
libzcash::Bip44AccountChains::ForAccount(seed, bip44CoinType, ZCASH_LEGACY_ACCOUNT).has_value()) {
|
libzcash::Bip44AccountChains::ForAccount(seed, bip44CoinType, ZCASH_LEGACY_ACCOUNT).has_value()) {
|
||||||
return seed;
|
return seed;
|
||||||
}
|
}
|
||||||
|
@ -301,8 +301,8 @@ SaplingExtendedFullViewingKey SaplingExtendedSpendingKey::ToXFVK() const
|
||||||
// Unified
|
// Unified
|
||||||
//
|
//
|
||||||
|
|
||||||
std::optional<std::pair<UnifiedSpendingKey, HDKeyPath>> UnifiedSpendingKey::ForAccount(const HDSeed& seed, uint32_t bip44CoinType, uint32_t accountId) {
|
std::optional<std::pair<ZcashdUnifiedSpendingKey, HDKeyPath>> ZcashdUnifiedSpendingKey::ForAccount(const HDSeed& seed, uint32_t bip44CoinType, uint32_t accountId) {
|
||||||
UnifiedSpendingKey usk;
|
ZcashdUnifiedSpendingKey usk;
|
||||||
usk.accountId = accountId;
|
usk.accountId = accountId;
|
||||||
|
|
||||||
auto transparentKey = DeriveBip44TransparentAccountKey(seed, bip44CoinType, accountId);
|
auto transparentKey = DeriveBip44TransparentAccountKey(seed, bip44CoinType, accountId);
|
||||||
|
@ -315,8 +315,8 @@ std::optional<std::pair<UnifiedSpendingKey, HDKeyPath>> UnifiedSpendingKey::ForA
|
||||||
return std::make_pair(usk, saplingKey.second);
|
return std::make_pair(usk, saplingKey.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
UnifiedFullViewingKey UnifiedSpendingKey::ToFullViewingKey() const {
|
ZcashdUnifiedFullViewingKey ZcashdUnifiedSpendingKey::ToFullViewingKey() const {
|
||||||
UnifiedFullViewingKey ufvk;
|
ZcashdUnifiedFullViewingKey ufvk;
|
||||||
|
|
||||||
if (transparentKey.has_value()) {
|
if (transparentKey.has_value()) {
|
||||||
ufvk.transparentKey = transparentKey.value().Neuter();
|
ufvk.transparentKey = transparentKey.value().Neuter();
|
||||||
|
@ -329,7 +329,7 @@ UnifiedFullViewingKey UnifiedSpendingKey::ToFullViewingKey() const {
|
||||||
return ufvk;
|
return ufvk;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<ZcashdUnifiedAddress> UnifiedFullViewingKey::Address(diversifier_index_t j) const {
|
std::optional<ZcashdUnifiedAddress> ZcashdUnifiedFullViewingKey::Address(diversifier_index_t j) const {
|
||||||
ZcashdUnifiedAddress ua;
|
ZcashdUnifiedAddress ua;
|
||||||
|
|
||||||
if (transparentKey.has_value()) {
|
if (transparentKey.has_value()) {
|
||||||
|
|
|
@ -306,8 +306,8 @@ struct SaplingExtendedSpendingKey {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class UnifiedSpendingKey;
|
class ZcashdUnifiedSpendingKey;
|
||||||
class UnifiedFullViewingKey;
|
class ZcashdUnifiedFullViewingKey;
|
||||||
|
|
||||||
class ZcashdUnifiedAddress {
|
class ZcashdUnifiedAddress {
|
||||||
private:
|
private:
|
||||||
|
@ -315,7 +315,7 @@ private:
|
||||||
std::optional<CPubKey> transparentKey; //TODO: should this just be the public key hash?
|
std::optional<CPubKey> transparentKey; //TODO: should this just be the public key hash?
|
||||||
std::optional<SaplingPaymentAddress> saplingAddress;
|
std::optional<SaplingPaymentAddress> saplingAddress;
|
||||||
|
|
||||||
friend class UnifiedFullViewingKey;
|
friend class ZcashdUnifiedFullViewingKey;
|
||||||
|
|
||||||
ZcashdUnifiedAddress() {}
|
ZcashdUnifiedAddress() {}
|
||||||
public:
|
public:
|
||||||
|
@ -328,14 +328,14 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class UnifiedFullViewingKey {
|
class ZcashdUnifiedFullViewingKey {
|
||||||
private:
|
private:
|
||||||
std::optional<CExtPubKey> transparentKey;
|
std::optional<CExtPubKey> transparentKey;
|
||||||
std::optional<SaplingExtendedFullViewingKey> saplingKey;
|
std::optional<SaplingExtendedFullViewingKey> saplingKey;
|
||||||
|
|
||||||
UnifiedFullViewingKey() {}
|
ZcashdUnifiedFullViewingKey() {}
|
||||||
|
|
||||||
friend class UnifiedSpendingKey;
|
friend class ZcashdUnifiedSpendingKey;
|
||||||
public:
|
public:
|
||||||
const std::optional<CExtPubKey>& GetTransparentKey() const {
|
const std::optional<CExtPubKey>& GetTransparentKey() const {
|
||||||
return transparentKey;
|
return transparentKey;
|
||||||
|
@ -358,15 +358,15 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class UnifiedSpendingKey {
|
class ZcashdUnifiedSpendingKey {
|
||||||
private:
|
private:
|
||||||
uint32_t accountId;
|
uint32_t accountId;
|
||||||
std::optional<CExtKey> transparentKey;
|
std::optional<CExtKey> transparentKey;
|
||||||
std::optional<SaplingExtendedSpendingKey> saplingKey;
|
std::optional<SaplingExtendedSpendingKey> saplingKey;
|
||||||
|
|
||||||
UnifiedSpendingKey() {}
|
ZcashdUnifiedSpendingKey() {}
|
||||||
public:
|
public:
|
||||||
static std::optional<std::pair<UnifiedSpendingKey, HDKeyPath>> ForAccount(
|
static std::optional<std::pair<ZcashdUnifiedSpendingKey, HDKeyPath>> ForAccount(
|
||||||
const HDSeed& seed,
|
const HDSeed& seed,
|
||||||
uint32_t bip44CoinType,
|
uint32_t bip44CoinType,
|
||||||
uint32_t accountId);
|
uint32_t accountId);
|
||||||
|
@ -379,7 +379,7 @@ public:
|
||||||
return saplingKey;
|
return saplingKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
UnifiedFullViewingKey ToFullViewingKey() const;
|
ZcashdUnifiedFullViewingKey ToFullViewingKey() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::optional<unsigned long> ParseZip32KeypathAccount(const std::string& keyPath);
|
std::optional<unsigned long> ParseZip32KeypathAccount(const std::string& keyPath);
|
||||||
|
|
Loading…
Reference in New Issue