mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-08-29 10:47:50 +02:00
Prefer explicit uint160 conversion
This commit is contained in:
@@ -595,7 +595,7 @@ static UniValue decodescript(const JSONRPCRequest& request)
|
|||||||
if (which_type == TX_PUBKEY) {
|
if (which_type == TX_PUBKEY) {
|
||||||
segwitScr = GetScriptForDestination(WitnessV0KeyHash(Hash160(solutions_data[0].begin(), solutions_data[0].end())));
|
segwitScr = GetScriptForDestination(WitnessV0KeyHash(Hash160(solutions_data[0].begin(), solutions_data[0].end())));
|
||||||
} else if (which_type == TX_PUBKEYHASH) {
|
} else if (which_type == TX_PUBKEYHASH) {
|
||||||
segwitScr = GetScriptForDestination(WitnessV0KeyHash(solutions_data[0]));
|
segwitScr = GetScriptForDestination(WitnessV0KeyHash(uint160{solutions_data[0]}));
|
||||||
} else {
|
} else {
|
||||||
// Scripts that are not fit for P2WPKH are encoded as P2WSH.
|
// Scripts that are not fit for P2WPKH are encoded as P2WSH.
|
||||||
// Newer segwit program versions should be considered when then become available.
|
// Newer segwit program versions should be considered when then become available.
|
||||||
|
@@ -307,7 +307,7 @@ CScript GetScriptForWitness(const CScript& redeemscript)
|
|||||||
if (typ == TX_PUBKEY) {
|
if (typ == TX_PUBKEY) {
|
||||||
return GetScriptForDestination(WitnessV0KeyHash(Hash160(vSolutions[0].begin(), vSolutions[0].end())));
|
return GetScriptForDestination(WitnessV0KeyHash(Hash160(vSolutions[0].begin(), vSolutions[0].end())));
|
||||||
} else if (typ == TX_PUBKEYHASH) {
|
} else if (typ == TX_PUBKEYHASH) {
|
||||||
return GetScriptForDestination(WitnessV0KeyHash(vSolutions[0]));
|
return GetScriptForDestination(WitnessV0KeyHash(uint160{vSolutions[0]}));
|
||||||
}
|
}
|
||||||
return GetScriptForDestination(WitnessV0ScriptHash(redeemscript));
|
return GetScriptForDestination(WitnessV0ScriptHash(redeemscript));
|
||||||
}
|
}
|
||||||
|
@@ -78,7 +78,6 @@ struct PKHash : public uint160
|
|||||||
PKHash() : uint160() {}
|
PKHash() : uint160() {}
|
||||||
explicit PKHash(const uint160& hash) : uint160(hash) {}
|
explicit PKHash(const uint160& hash) : uint160(hash) {}
|
||||||
explicit PKHash(const CPubKey& pubkey);
|
explicit PKHash(const CPubKey& pubkey);
|
||||||
using uint160::uint160;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct WitnessV0KeyHash;
|
struct WitnessV0KeyHash;
|
||||||
@@ -91,7 +90,6 @@ struct ScriptHash : public uint160
|
|||||||
explicit ScriptHash(const PKHash& hash) = delete;
|
explicit ScriptHash(const PKHash& hash) = delete;
|
||||||
explicit ScriptHash(const uint160& hash) : uint160(hash) {}
|
explicit ScriptHash(const uint160& hash) : uint160(hash) {}
|
||||||
explicit ScriptHash(const CScript& script);
|
explicit ScriptHash(const CScript& script);
|
||||||
using uint160::uint160;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct WitnessV0ScriptHash : public uint256
|
struct WitnessV0ScriptHash : public uint256
|
||||||
@@ -99,14 +97,12 @@ struct WitnessV0ScriptHash : public uint256
|
|||||||
WitnessV0ScriptHash() : uint256() {}
|
WitnessV0ScriptHash() : uint256() {}
|
||||||
explicit WitnessV0ScriptHash(const uint256& hash) : uint256(hash) {}
|
explicit WitnessV0ScriptHash(const uint256& hash) : uint256(hash) {}
|
||||||
explicit WitnessV0ScriptHash(const CScript& script);
|
explicit WitnessV0ScriptHash(const CScript& script);
|
||||||
using uint256::uint256;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct WitnessV0KeyHash : public uint160
|
struct WitnessV0KeyHash : public uint160
|
||||||
{
|
{
|
||||||
WitnessV0KeyHash() : uint160() {}
|
WitnessV0KeyHash() : uint160() {}
|
||||||
explicit WitnessV0KeyHash(const uint160& hash) : uint160(hash) {}
|
explicit WitnessV0KeyHash(const uint160& hash) : uint160(hash) {}
|
||||||
using uint160::uint160;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//! CTxDestination subtype to encode any future Witness version
|
//! CTxDestination subtype to encode any future Witness version
|
||||||
|
Reference in New Issue
Block a user