diff options
author | Ben Woosley <ben.woosley@gmail.com> | 2020-01-15 14:03:57 -0800 |
---|---|---|
committer | Ben Woosley <ben.woosley@gmail.com> | 2020-06-19 12:14:08 -0700 |
commit | 4d7369125a82214ea42b808a32b71b315a5c3c72 (patch) | |
tree | 33bc116c982bb70914801d72b799aa9afca0f275 /src/script/standard.cpp | |
parent | fa9ef2cdbed32438bdb32623af6e06f13ecd35e4 (diff) | |
download | bitcoin-4d7369125a82214ea42b808a32b71b315a5c3c72.tar.xz |
Disallow automatic conversion between hash types
A templated BaseHash does not allow for automatic conversion, thus
conversions much be explicitly allowed / whitelisted, which will
reduce the risk of unintended conversions.
Diffstat (limited to 'src/script/standard.cpp')
-rw-r--r-- | src/script/standard.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/script/standard.cpp b/src/script/standard.cpp index f8bfc3b69c..2adf6ce56d 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -16,17 +16,17 @@ typedef std::vector<unsigned char> valtype; bool fAcceptDatacarrier = DEFAULT_ACCEPT_DATACARRIER; unsigned nMaxDatacarrierBytes = MAX_OP_RETURN_RELAY; -CScriptID::CScriptID(const CScript& in) : uint160(Hash160(in.begin(), in.end())) {} -CScriptID::CScriptID(const ScriptHash& in) : uint160(static_cast<uint160>(in)) {} +CScriptID::CScriptID(const CScript& in) : BaseHash(Hash160(in.begin(), in.end())) {} +CScriptID::CScriptID(const ScriptHash& in) : BaseHash(static_cast<uint160>(in)) {} -ScriptHash::ScriptHash(const CScript& in) : uint160(Hash160(in.begin(), in.end())) {} -ScriptHash::ScriptHash(const CScriptID& in) : uint160(static_cast<uint160>(in)) {} +ScriptHash::ScriptHash(const CScript& in) : BaseHash(Hash160(in.begin(), in.end())) {} +ScriptHash::ScriptHash(const CScriptID& in) : BaseHash(static_cast<uint160>(in)) {} -PKHash::PKHash(const CPubKey& pubkey) : uint160(pubkey.GetID()) {} -PKHash::PKHash(const CKeyID& pubkey_id) : uint160(pubkey_id) {} +PKHash::PKHash(const CPubKey& pubkey) : BaseHash(pubkey.GetID()) {} +PKHash::PKHash(const CKeyID& pubkey_id) : BaseHash(pubkey_id) {} -WitnessV0KeyHash::WitnessV0KeyHash(const CPubKey& pubkey) : uint160(pubkey.GetID()) {} -WitnessV0KeyHash::WitnessV0KeyHash(const PKHash& pubkey_hash) : uint160(static_cast<uint160>(pubkey_hash)) {} +WitnessV0KeyHash::WitnessV0KeyHash(const CPubKey& pubkey) : BaseHash(pubkey.GetID()) {} +WitnessV0KeyHash::WitnessV0KeyHash(const PKHash& pubkey_hash) : BaseHash(static_cast<uint160>(pubkey_hash)) {} CKeyID ToKeyID(const PKHash& key_hash) { |