diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index bbd7b7a3a..91cd9ed9b 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -431,7 +431,7 @@ ZcashdUnifiedSpendingKey CWallet::GenerateNewUnifiedSpendingKey() { } } -std::optional CWallet::GenerateUnifiedSpendingKeyForAccount(uint32_t accountId) { +std::optional CWallet::GenerateUnifiedSpendingKeyForAccount(libzcash::AccountId accountId) { auto seed = GetMnemonicSeed(); if (!seed.has_value()) { throw std::runtime_error(std::string(__func__) + ": Wallet has no mnemonic HD seed."); diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 35920fb8d..3bb5c55d1 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1097,7 +1097,7 @@ public: * Unified keys & addresses */ libzcash::ZcashdUnifiedSpendingKey GenerateNewUnifiedSpendingKey(); - std::optional GenerateUnifiedSpendingKeyForAccount(uint32_t accountId); + std::optional GenerateUnifiedSpendingKeyForAccount(libzcash::AccountId accountId); /** * Increment the next transaction order id diff --git a/src/zcash/address/zip32.cpp b/src/zcash/address/zip32.cpp index 82ae79ac1..f88311fde 100644 --- a/src/zcash/address/zip32.cpp +++ b/src/zcash/address/zip32.cpp @@ -85,7 +85,7 @@ std::optional diversifier_index_t::ToTransparentChildIndex() const // Transparent // -std::optional> DeriveBip44TransparentAccountKey(const MnemonicSeed& seed, uint32_t bip44CoinType, uint32_t accountId) { +std::optional> DeriveBip44TransparentAccountKey(const MnemonicSeed& seed, uint32_t bip44CoinType, libzcash::AccountId accountId) { auto rawSeed = seed.RawSeed(); auto m = CExtKey::Master(rawSeed.data(), rawSeed.size()); @@ -110,7 +110,7 @@ std::optional> DeriveBip44TransparentAccountKey(co std::optional Bip44AccountChains::ForAccount( const MnemonicSeed& seed, uint32_t bip44CoinType, - uint32_t accountId) { + libzcash::AccountId accountId) { auto accountKeyOpt = DeriveBip44TransparentAccountKey(seed, bip44CoinType, accountId); if (!accountKeyOpt.has_value()) return std::nullopt; @@ -251,7 +251,7 @@ SaplingExtendedSpendingKey SaplingExtendedSpendingKey::Derive(uint32_t i) const return xsk_i; } -std::pair SaplingExtendedSpendingKey::ForAccount(const MnemonicSeed& seed, uint32_t bip44CoinType, uint32_t accountId) { +std::pair SaplingExtendedSpendingKey::ForAccount(const MnemonicSeed& seed, uint32_t bip44CoinType, libzcash::AccountId accountId) { auto m = Master(seed); // We use a fixed keypath scheme of m/32'/coin_type'/account' @@ -313,7 +313,7 @@ SaplingExtendedFullViewingKey SaplingExtendedSpendingKey::ToXFVK() const // Unified // -std::optional> ZcashdUnifiedSpendingKey::ForAccount(const MnemonicSeed& seed, uint32_t bip44CoinType, uint32_t accountId) { +std::optional> ZcashdUnifiedSpendingKey::ForAccount(const MnemonicSeed& seed, uint32_t bip44CoinType, libzcash::AccountId accountId) { ZcashdUnifiedSpendingKey usk; usk.accountId = accountId; diff --git a/src/zcash/address/zip32.h b/src/zcash/address/zip32.h index 83bbc3443..9da16b71e 100644 --- a/src/zcash/address/zip32.h +++ b/src/zcash/address/zip32.h @@ -165,6 +165,8 @@ uint256 ovkForShieldingFromTaddr(HDSeed& seed); namespace libzcash { +typedef uint32_t AccountId; + /** * 88-bit diversifier index. This would ideally derive from base_uint * but those values must have bit widths that are multiples of 32. @@ -290,7 +292,7 @@ struct SaplingExtendedSpendingKey { } static SaplingExtendedSpendingKey Master(const HDSeed& seed); - static std::pair ForAccount(const MnemonicSeed& seed, uint32_t bip44CoinType, uint32_t accountId); + static std::pair ForAccount(const MnemonicSeed& seed, uint32_t bip44CoinType, libzcash::AccountId accountId); static std::pair Legacy(const MnemonicSeed& seed, uint32_t bip44CoinType, uint32_t addressIndex); @@ -363,7 +365,7 @@ public: class ZcashdUnifiedSpendingKey { private: - uint32_t accountId; + libzcash::AccountId accountId; std::optional transparentKey; std::optional saplingKey; @@ -372,7 +374,7 @@ public: static std::optional> ForAccount( const MnemonicSeed& mnemonic, uint32_t bip44CoinType, - uint32_t accountId); + libzcash::AccountId accountId); const std::optional& GetTransparentKey() const { return transparentKey; @@ -390,18 +392,18 @@ std::optional ParseHDKeypathAccount(uint32_t purpose, uint32_t co class Bip44AccountChains { private: uint256 seedFp; - uint32_t accountId; + libzcash::AccountId accountId; uint32_t bip44CoinType; CExtKey external; CExtKey internal; - Bip44AccountChains(uint256 seedFpIn, uint32_t bip44CoinTypeIn, uint32_t accountIdIn, CExtKey externalIn, CExtKey internalIn): + Bip44AccountChains(uint256 seedFpIn, uint32_t bip44CoinTypeIn, libzcash::AccountId accountIdIn, CExtKey externalIn, CExtKey internalIn): seedFp(seedFpIn), accountId(accountIdIn), bip44CoinType(bip44CoinTypeIn), external(externalIn), internal(internalIn) {} public: static std::optional ForAccount( const MnemonicSeed& mnemonic, uint32_t bip44CoinType, - uint32_t accountId); + libzcash::AccountId accountId); std::optional> DeriveExternal(uint32_t addrIndex); std::optional> DeriveInternal(uint32_t addrIndex);