diff --git a/src/base58.cpp b/src/base58.cpp index efce9186f..a6152e692 100644 --- a/src/base58.cpp +++ b/src/base58.cpp @@ -313,21 +313,19 @@ bool CBitcoinSecret::SetString(const std::string& strSecret) return SetString(strSecret.c_str()); } -const size_t serializedPaymentAddressSize = 64; - bool CZCPaymentAddress::Set(const libzcash::PaymentAddress& addr) { CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); ss << addr; std::vector addrSerialized(ss.begin(), ss.end()); - assert(addrSerialized.size() == serializedPaymentAddressSize); - SetData(Params().Base58Prefix(CChainParams::ZCPAYMENT_ADDRRESS), &addrSerialized[0], serializedPaymentAddressSize); + assert(addrSerialized.size() == libzcash::SerializedPaymentAddressSize); + SetData(Params().Base58Prefix(CChainParams::ZCPAYMENT_ADDRRESS), &addrSerialized[0], libzcash::SerializedPaymentAddressSize); return true; } libzcash::PaymentAddress CZCPaymentAddress::Get() const { - if (vchData.size() != serializedPaymentAddressSize) { + if (vchData.size() != libzcash::SerializedPaymentAddressSize) { throw std::runtime_error( "payment address is invalid" ); @@ -347,21 +345,19 @@ libzcash::PaymentAddress CZCPaymentAddress::Get() const return ret; } -const size_t serializedSpendingKeySize = 32; - bool CZCSpendingKey::Set(const libzcash::SpendingKey& addr) { CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); ss << addr; std::vector addrSerialized(ss.begin(), ss.end()); - assert(addrSerialized.size() == serializedSpendingKeySize); - SetData(Params().Base58Prefix(CChainParams::ZCSPENDING_KEY), &addrSerialized[0], serializedSpendingKeySize); + assert(addrSerialized.size() == libzcash::SerializedSpendingKeySize); + SetData(Params().Base58Prefix(CChainParams::ZCSPENDING_KEY), &addrSerialized[0], libzcash::SerializedSpendingKeySize); return true; } libzcash::SpendingKey CZCSpendingKey::Get() const { - if (vchData.size() != serializedSpendingKeySize) { + if (vchData.size() != libzcash::SerializedSpendingKeySize) { throw std::runtime_error( "spending key is invalid" ); diff --git a/src/wallet/crypter.cpp b/src/wallet/crypter.cpp index 06753bf15..06ace79c6 100644 --- a/src/wallet/crypter.cpp +++ b/src/wallet/crypter.cpp @@ -145,7 +145,7 @@ static bool DecryptSpendingKey(const CKeyingMaterial& vMasterKey, if(!DecryptSecret(vMasterKey, vchCryptedSecret, address.GetHash(), vchSecret)) return false; - if (vchSecret.size() != 32) + if (vchSecret.size() != libzcash::SerializedSpendingKeySize) return false; // TODO does this undo the benefits of using CKeyingMaterial? diff --git a/src/zcash/Address.hpp b/src/zcash/Address.hpp index f259818af..efae2af22 100644 --- a/src/zcash/Address.hpp +++ b/src/zcash/Address.hpp @@ -7,6 +7,9 @@ namespace libzcash { +const size_t SerializedPaymentAddressSize = 64; +const size_t SerializedSpendingKeySize = 32; + class PaymentAddress { public: uint256 a_pk;