mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
Remove ScriptHash from CScriptID constructor
Replaces the constructor in CScriptID that converts a ScriptHash with a function ToScriptID that does the same. This prepares for a move of CScriptID to avoid a circular dependency.
This commit is contained in:
parent
cba69dda3d
commit
b81ebff0d9
5 changed files with 9 additions and 7 deletions
|
@ -205,7 +205,7 @@ CKeyID GetKeyForDestination(const SigningProvider& store, const CTxDestination&
|
|||
}
|
||||
if (auto script_hash = std::get_if<ScriptHash>(&dest)) {
|
||||
CScript script;
|
||||
CScriptID script_id(*script_hash);
|
||||
CScriptID script_id = ToScriptID(*script_hash);
|
||||
CTxDestination inner_dest;
|
||||
if (store.GetCScript(script_id, script) && ExtractDestination(script, inner_dest)) {
|
||||
if (auto inner_witness_id = std::get_if<WitnessV0KeyHash>(&inner_dest)) {
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
typedef std::vector<unsigned char> valtype;
|
||||
|
||||
CScriptID::CScriptID(const CScript& in) : BaseHash(Hash160(in)) {}
|
||||
CScriptID::CScriptID(const ScriptHash& in) : BaseHash(static_cast<uint160>(in)) {}
|
||||
|
||||
ScriptHash::ScriptHash(const CScript& in) : BaseHash(Hash160(in)) {}
|
||||
ScriptHash::ScriptHash(const CScriptID& in) : BaseHash(static_cast<uint160>(in)) {}
|
||||
|
@ -38,6 +37,11 @@ CKeyID ToKeyID(const WitnessV0KeyHash& key_hash)
|
|||
return CKeyID{static_cast<uint160>(key_hash)};
|
||||
}
|
||||
|
||||
CScriptID ToScriptID(const ScriptHash& script_hash)
|
||||
{
|
||||
return CScriptID{static_cast<uint160>(script_hash)};
|
||||
}
|
||||
|
||||
WitnessV0ScriptHash::WitnessV0ScriptHash(const CScript& in)
|
||||
{
|
||||
CSHA256().Write(in.data(), in.size()).Finalize(begin());
|
||||
|
|
|
@ -20,7 +20,6 @@ static const bool DEFAULT_ACCEPT_DATACARRIER = true;
|
|||
|
||||
class CKeyID;
|
||||
class CScript;
|
||||
struct ScriptHash;
|
||||
|
||||
/** A reference to a CScript: the Hash160 of its serialization (see script.h) */
|
||||
class CScriptID : public BaseHash<uint160>
|
||||
|
@ -29,7 +28,6 @@ public:
|
|||
CScriptID() : BaseHash() {}
|
||||
explicit CScriptID(const CScript& in);
|
||||
explicit CScriptID(const uint160& in) : BaseHash(in) {}
|
||||
explicit CScriptID(const ScriptHash& in);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -80,6 +78,7 @@ struct ScriptHash : public BaseHash<uint160>
|
|||
explicit ScriptHash(const CScript& script);
|
||||
explicit ScriptHash(const CScriptID& script);
|
||||
};
|
||||
CScriptID ToScriptID(const ScriptHash& script_hash);
|
||||
|
||||
struct WitnessV0ScriptHash : public BaseHash<uint256>
|
||||
{
|
||||
|
|
|
@ -440,10 +440,9 @@ public:
|
|||
|
||||
UniValue operator()(const ScriptHash& scripthash) const
|
||||
{
|
||||
CScriptID scriptID(scripthash);
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
CScript subscript;
|
||||
if (provider && provider->GetCScript(scriptID, subscript)) {
|
||||
if (provider && provider->GetCScript(ToScriptID(scripthash), subscript)) {
|
||||
ProcessSubScript(subscript, obj);
|
||||
}
|
||||
return obj;
|
||||
|
|
|
@ -672,7 +672,7 @@ RPCHelpMan listunspent()
|
|||
std::unique_ptr<SigningProvider> provider = pwallet->GetSolvingProvider(scriptPubKey);
|
||||
if (provider) {
|
||||
if (scriptPubKey.IsPayToScriptHash()) {
|
||||
const CScriptID& hash = CScriptID(std::get<ScriptHash>(address));
|
||||
const CScriptID hash = ToScriptID(std::get<ScriptHash>(address));
|
||||
CScript redeemScript;
|
||||
if (provider->GetCScript(hash, redeemScript)) {
|
||||
entry.pushKV("redeemScript", HexStr(redeemScript));
|
||||
|
|
Loading…
Add table
Reference in a new issue