AddTransparentSecretKey does not need to take a CExtKey
This commit is contained in:
parent
b29ca10b8d
commit
290985ba48
|
@ -282,7 +282,7 @@ CPubKey CWallet::GenerateNewKey()
|
||||||
BIP44CoinType(),
|
BIP44CoinType(),
|
||||||
ZCASH_LEGACY_ACCOUNT).value();
|
ZCASH_LEGACY_ACCOUNT).value();
|
||||||
|
|
||||||
std::optional<std::pair<CExtKey, HDKeyPath>> extKey = std::nullopt;
|
std::optional<std::pair<CKey, HDKeyPath>> extKey = std::nullopt;
|
||||||
do {
|
do {
|
||||||
extKey = accountChains.DeriveExternal(hdChain.GetLegacyTKeyCounter());
|
extKey = accountChains.DeriveExternal(hdChain.GetLegacyTKeyCounter());
|
||||||
hdChain.IncrementLegacyTKeyCounter();
|
hdChain.IncrementLegacyTKeyCounter();
|
||||||
|
@ -301,10 +301,10 @@ CPubKey CWallet::GenerateNewKey()
|
||||||
|
|
||||||
CPubKey CWallet::AddTransparentSecretKey(
|
CPubKey CWallet::AddTransparentSecretKey(
|
||||||
const uint256& seedFingerprint,
|
const uint256& seedFingerprint,
|
||||||
const std::pair<CExtKey, HDKeyPath>& extSecret,
|
const std::pair<CKey, HDKeyPath>& extSecret,
|
||||||
const std::optional<libzcash::UFVKId>& ufvkId)
|
const std::optional<libzcash::UFVKId>& ufvkId)
|
||||||
{
|
{
|
||||||
CKey secret = extSecret.first.key;
|
CKey secret = extSecret.first;
|
||||||
CPubKey pubkey = secret.GetPubKey();
|
CPubKey pubkey = secret.GetPubKey();
|
||||||
assert(secret.VerifyPubKey(pubkey));
|
assert(secret.VerifyPubKey(pubkey));
|
||||||
|
|
||||||
|
@ -479,8 +479,10 @@ std::optional<std::pair<libzcash::ZcashdUnifiedSpendingKey, ZcashdUnifiedSpendin
|
||||||
// Add Transparent component to the wallet
|
// Add Transparent component to the wallet
|
||||||
if (sk.GetTransparentKey().has_value()) {
|
if (sk.GetTransparentKey().has_value()) {
|
||||||
auto keypath = libzcash::Bip44TransparentAccountKeyPath(BIP44CoinType(), accountId);
|
auto keypath = libzcash::Bip44TransparentAccountKeyPath(BIP44CoinType(), accountId);
|
||||||
AddTransparentSecretKey(skmeta.GetSeedFingerprint(),
|
AddTransparentSecretKey(
|
||||||
std::make_pair(sk.GetTransparentKey().value(), keypath));
|
skmeta.GetSeedFingerprint(),
|
||||||
|
std::make_pair(sk.GetTransparentKey().value().key, keypath)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add Sapling component to the wallet
|
// Add Sapling component to the wallet
|
||||||
|
@ -592,6 +594,9 @@ UAGenerationResult CWallet::GenerateUnifiedAddress(
|
||||||
// Persist the newly created address to the keystore
|
// Persist the newly created address to the keystore
|
||||||
AddUnifiedAddress(ufvkid, found.first);
|
AddUnifiedAddress(ufvkid, found.first);
|
||||||
|
|
||||||
|
// If we have the associated spending key, add this to the keystore as one
|
||||||
|
// of our own addresses with AddTransparentSecretKey,
|
||||||
|
|
||||||
// Save the metadata for the generated address so that we can re-derive
|
// Save the metadata for the generated address so that we can re-derive
|
||||||
// it in the future.
|
// it in the future.
|
||||||
ZcashdUnifiedAddressMetadata addrmeta(ufvkid, found.second, receiverTypes);
|
ZcashdUnifiedAddressMetadata addrmeta(ufvkid, found.second, receiverTypes);
|
||||||
|
|
|
@ -823,7 +823,7 @@ private:
|
||||||
/* Add an extended secret key to the wallet. Internal use only. */
|
/* Add an extended secret key to the wallet. Internal use only. */
|
||||||
CPubKey AddTransparentSecretKey(
|
CPubKey AddTransparentSecretKey(
|
||||||
const uint256& seedFingerprint,
|
const uint256& seedFingerprint,
|
||||||
const std::pair<CExtKey, HDKeyPath>& extSecret,
|
const std::pair<CKey, HDKeyPath>& extSecret,
|
||||||
const std::optional<libzcash::UFVKId>& ufvkId = std::nullopt);
|
const std::optional<libzcash::UFVKId>& ufvkId = std::nullopt);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -46,7 +46,7 @@ std::optional<libzcash::Bip44AccountChains> libzcash::Bip44AccountChains::ForAcc
|
||||||
return Bip44AccountChains(seed.Fingerprint(), bip44CoinType, accountId, external.value(), internal.value());
|
return Bip44AccountChains(seed.Fingerprint(), bip44CoinType, accountId, external.value(), internal.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::pair<CExtKey, HDKeyPath>> libzcash::Bip44AccountChains::DeriveExternal(uint32_t addrIndex) {
|
std::optional<std::pair<CKey, HDKeyPath>> libzcash::Bip44AccountChains::DeriveExternal(uint32_t addrIndex) {
|
||||||
auto childKey = external.Derive(addrIndex);
|
auto childKey = external.Derive(addrIndex);
|
||||||
if (!childKey.has_value()) return std::nullopt;
|
if (!childKey.has_value()) return std::nullopt;
|
||||||
|
|
||||||
|
@ -56,10 +56,10 @@ std::optional<std::pair<CExtKey, HDKeyPath>> libzcash::Bip44AccountChains::Deriv
|
||||||
+ "0/"
|
+ "0/"
|
||||||
+ std::to_string(addrIndex);
|
+ std::to_string(addrIndex);
|
||||||
|
|
||||||
return std::make_pair(childKey.value(), hdKeypath);
|
return std::make_pair(childKey.value().key, hdKeypath);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::pair<CExtKey, HDKeyPath>> libzcash::Bip44AccountChains::DeriveInternal(uint32_t addrIndex) {
|
std::optional<std::pair<CKey, HDKeyPath>> libzcash::Bip44AccountChains::DeriveInternal(uint32_t addrIndex) {
|
||||||
auto childKey = internal.Derive(addrIndex);
|
auto childKey = internal.Derive(addrIndex);
|
||||||
if (!childKey.has_value()) return std::nullopt;
|
if (!childKey.has_value()) return std::nullopt;
|
||||||
|
|
||||||
|
@ -69,6 +69,6 @@ std::optional<std::pair<CExtKey, HDKeyPath>> libzcash::Bip44AccountChains::Deriv
|
||||||
+ "1/"
|
+ "1/"
|
||||||
+ std::to_string(addrIndex);
|
+ std::to_string(addrIndex);
|
||||||
|
|
||||||
return std::make_pair(childKey.value(), hdKeypath);
|
return std::make_pair(childKey.value().key, hdKeypath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@ public:
|
||||||
uint32_t bip44CoinType,
|
uint32_t bip44CoinType,
|
||||||
libzcash::AccountId accountId);
|
libzcash::AccountId accountId);
|
||||||
|
|
||||||
std::optional<std::pair<CExtKey, HDKeyPath>> DeriveExternal(uint32_t addrIndex);
|
std::optional<std::pair<CKey, HDKeyPath>> DeriveExternal(uint32_t addrIndex);
|
||||||
std::optional<std::pair<CExtKey, HDKeyPath>> DeriveInternal(uint32_t addrIndex);
|
std::optional<std::pair<CKey, HDKeyPath>> DeriveInternal(uint32_t addrIndex);
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace libzcash
|
} //namespace libzcash
|
||||||
|
|
Loading…
Reference in New Issue