mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-10 09:06:15 +01:00
Merge bitcoin/bitcoin#28284: refactor: Remove confusing static_cast in address types
fadf671fa5
Refactor: Remove confusing static_cast (MarcoFalke)faeea1ab58
refactor: Add missing includes (MarcoFalke) Pull request description: It seems confusing to use `static_cast<uint160>(bla)` to call the constructor of `uint160`. The normal and common way to call a constructor is by simply calling it. (`uint160{bla}`). Do this, and also drop the constructor completely where the existing `const&` reference is enough. Also, add missing includes while touching the file. ACKs for top commit: vincenzopalazzo: ACKfadf671fa5
TheCharlatan: ACKfadf671fa5
Tree-SHA512: 8fb9a72203a6461b1f4b38bb90943ca25a92b218fc87da2022b90802e7747350e3668a13db3189201ad30e2e39a51d6658fed4aad176fd52cecc1c7f972c3134
This commit is contained in:
commit
03a536f1ed
2 changed files with 13 additions and 9 deletions
|
@ -3,39 +3,42 @@
|
||||||
// file COPYING or https://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or https://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include <addresstype.h>
|
#include <addresstype.h>
|
||||||
#include <script/script.h>
|
|
||||||
#include <script/solver.h>
|
#include <crypto/sha256.h>
|
||||||
#include <hash.h>
|
#include <hash.h>
|
||||||
#include <pubkey.h>
|
#include <pubkey.h>
|
||||||
|
#include <script/script.h>
|
||||||
|
#include <script/solver.h>
|
||||||
#include <uint256.h>
|
#include <uint256.h>
|
||||||
#include <util/hash_type.h>
|
#include <util/hash_type.h>
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
typedef std::vector<unsigned char> valtype;
|
typedef std::vector<unsigned char> valtype;
|
||||||
|
|
||||||
ScriptHash::ScriptHash(const CScript& in) : BaseHash(Hash160(in)) {}
|
ScriptHash::ScriptHash(const CScript& in) : BaseHash(Hash160(in)) {}
|
||||||
ScriptHash::ScriptHash(const CScriptID& in) : BaseHash(static_cast<uint160>(in)) {}
|
ScriptHash::ScriptHash(const CScriptID& in) : BaseHash{in} {}
|
||||||
|
|
||||||
PKHash::PKHash(const CPubKey& pubkey) : BaseHash(pubkey.GetID()) {}
|
PKHash::PKHash(const CPubKey& pubkey) : BaseHash(pubkey.GetID()) {}
|
||||||
PKHash::PKHash(const CKeyID& pubkey_id) : BaseHash(pubkey_id) {}
|
PKHash::PKHash(const CKeyID& pubkey_id) : BaseHash(pubkey_id) {}
|
||||||
|
|
||||||
WitnessV0KeyHash::WitnessV0KeyHash(const CPubKey& pubkey) : BaseHash(pubkey.GetID()) {}
|
WitnessV0KeyHash::WitnessV0KeyHash(const CPubKey& pubkey) : BaseHash(pubkey.GetID()) {}
|
||||||
WitnessV0KeyHash::WitnessV0KeyHash(const PKHash& pubkey_hash) : BaseHash(static_cast<uint160>(pubkey_hash)) {}
|
WitnessV0KeyHash::WitnessV0KeyHash(const PKHash& pubkey_hash) : BaseHash{pubkey_hash} {}
|
||||||
|
|
||||||
CKeyID ToKeyID(const PKHash& key_hash)
|
CKeyID ToKeyID(const PKHash& key_hash)
|
||||||
{
|
{
|
||||||
return CKeyID{static_cast<uint160>(key_hash)};
|
return CKeyID{uint160{key_hash}};
|
||||||
}
|
}
|
||||||
|
|
||||||
CKeyID ToKeyID(const WitnessV0KeyHash& key_hash)
|
CKeyID ToKeyID(const WitnessV0KeyHash& key_hash)
|
||||||
{
|
{
|
||||||
return CKeyID{static_cast<uint160>(key_hash)};
|
return CKeyID{uint160{key_hash}};
|
||||||
}
|
}
|
||||||
|
|
||||||
CScriptID ToScriptID(const ScriptHash& script_hash)
|
CScriptID ToScriptID(const ScriptHash& script_hash)
|
||||||
{
|
{
|
||||||
return CScriptID{static_cast<uint160>(script_hash)};
|
return CScriptID{uint160{script_hash}};
|
||||||
}
|
}
|
||||||
|
|
||||||
WitnessV0ScriptHash::WitnessV0ScriptHash(const CScript& in)
|
WitnessV0ScriptHash::WitnessV0ScriptHash(const CScript& in)
|
||||||
|
|
|
@ -3,14 +3,15 @@
|
||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include <script/solver.h>
|
|
||||||
#include <pubkey.h>
|
#include <pubkey.h>
|
||||||
#include <script/interpreter.h>
|
#include <script/interpreter.h>
|
||||||
#include <script/script.h>
|
#include <script/script.h>
|
||||||
|
#include <script/solver.h>
|
||||||
#include <span.h>
|
#include <span.h>
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cassert>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
typedef std::vector<unsigned char> valtype;
|
typedef std::vector<unsigned char> valtype;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue